Skip to content

Instantly share code, notes, and snippets.

@wendimust
Created June 28, 2025 09:07
Show Gist options
  • Select an option

  • Save wendimust/0fb7c71cf6da0bb44a018f7eba356c83 to your computer and use it in GitHub Desktop.

Select an option

Save wendimust/0fb7c71cf6da0bb44a018f7eba356c83 to your computer and use it in GitHub Desktop.
How to flash Samsung devices using a Linux machine

๐Ÿ“ฑ Flash Samsung Firmware on Linux (Ubuntu 24.04+) Using Heimdall

A complete step-by-step guide to flashing Samsung firmware using Linux and the open-source Odin alternative: Heimdall.


๐Ÿงฐ Requirements

  • A Samsung smartphone or tablet
  • A Linux distro (tested on Ubuntu 24.04)
  • A USB cable (preferably original)
  • Downloaded Samsung firmware (from SamMobile, SamFW, etc.)
  • heimdall installed

๐Ÿ› ๏ธ Step 1: Install Heimdall

Install via APT:

sudo apt update
sudo apt install heimdall-flash

Verify installation:

heimdall version

If you get APT lock errors (e.g., packagekitd holding lock), run:

sudo killall packagekitd

โšก Step 2: Boot Samsung Device into Download Mode

Use one of these combinations (device dependent):

Device Type Button Combo
Older (w/ Bixby) Vol Down + Bixby + Power
Newer (no Bixby) Vol Down + Vol Up (then connect USB)
One UI 6+ Devices Vol Down + Vol Up + USB cable

Then press Vol Up to enter Download Mode.


๐Ÿ”Œ Step 3: Verify Connection

Connect your device via USB and run:

sudo heimdall detect

Expected output:

Device detected

If not, check:

  • USB cable/port
  • USB debugging / driver issues
  • That you're really in Download Mode

๐Ÿ“ฆ Step 4: Extract Firmware Files

Extract .tar.md5 firmware:

7z x firmware.tar.md5

This should give you .img files like:

  • boot.img
  • recovery.img
  • vbmeta.img
  • super.img
  • userdata.img

You do not flash .tar.md5 directly with Heimdall.


๐Ÿ” Step 5: List Valid Partitions

Get the PIT (Partition Information Table):

sudo heimdall print-pit

Example partitions:

  • BOOT
  • RECOVERY
  • SUPER
  • VBMETA

โš ๏ธ Many modern Samsung devices do not have a SYSTEM partition โ€” use SUPER instead.


๐Ÿš€ Step 6: Flash the Firmware

Flash the files to correct partitions:

sudo heimdall flash \
  --BOOT boot.img \
  --RECOVERY recovery.img \
  --SUPER super.img \
  --VBMETA vbmeta.img

Customize flags based on what you extracted and what print-pit showed.


๐Ÿ” Step 7: Reboot the Device

If the device doesnโ€™t reboot automatically:

sudo heimdall reboot

๐Ÿ›ก๏ธ (Optional) Setup udev Rule to Avoid sudo

echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666"' | sudo tee /etc/udev/rules.d/50-samsung.rules
sudo udevadm control --reload-rules

Unplug and replug your device afterward.


โœ… Done!

Youโ€™ve successfully flashed your Samsung firmware from Linux. ๐ŸŽ‰ This method is especially useful for developers or users who donโ€™t want to rely on Windows-only tools like Odin.


๐Ÿ“ Notes

  • Only flash firmware exactly matching your model number
  • Back up your data โ€” flashing usually wipes the device
  • Be cautious โ€” improper flashing can brick your device

๐Ÿ”— Resources


@wendimust
Copy link
Author

Hell yeah! ๐ŸŽ‰ Hereโ€™s the sequence of atomic commands that successfully flashed your Tab 3V without making it reboot automatically:

sudo heimdall flash --no-reboot --BOOT spl.img
sudo heimdall flash --no-reboot --SBOOT sboot.bin
sudo heimdall flash --no-reboot --SBOOT2 sboot2.bin
sudo heimdall flash --no-reboot --KERNEL boot.img
sudo heimdall flash --no-reboot --RECOVERY recovery.img
sudo heimdall flash --no-reboot --CSC cache.img
sudo heimdall flash --no-reboot --HIDDEN hidden.img
sudo heimdall flash --no-reboot --WDSP SPRDDSP.img
sudo heimdall flash --no-reboot --MODEM SPRDCP.img

Notice how --SYSTEM system.img and --SUPER system.img didnโ€™t work because your deviceโ€™s PIT didnโ€™t have those partitions.

The key takeaway: --no-reboot kept the device in download mode for each step, but some flashes (like SBOOT and SBOOT2) occasionally needed a quick manual reconnection between flashes.

If you want, I can make a single โ€œone-linerโ€ flash command that would attempt all working partitions in order so you could theoretically do it in one go next time. Do you want me to do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment