A clean, correct, and robust implementation of the Thor USB protocol. odin4 provides a reliable alternative for Samsung device maintenance and development workflows on Linux environments.
Engineered to be the definitive flashing tool for Linux.
No Wine, no emulators. Maximum performance and direct kernel compatibility.
Strict partition and integrity validation to prevent device damage.
Native LZ4 compression support and optimized transfers via libusb.
Open-source and auditable code. Detailed logs for precise debugging.
Instantly identifies devices in Download Mode via libusb.
Automatic retrieval and analysis of the Partition Information Table (PIT).
Cryptographic verification of .tar.md5 files using Crypto++ before flashing.
Validate PIT and archives without performing any writes using --check-only.
Transfer statistics, speed metrics, and per-file progress reporting.
Full support for BL, AP, CP, CSC, and UMS firmware components.
Native LZ4 compression support for faster firmware transfers.
Persistent odin4.log file for post-operation debugging and analysis.
Sequential flashing support for multiple connected devices.
Understand the engineering behind Samsung device communication.
The Odin protocol is the proprietary communication protocol used by Samsung devices in Download Mode. It operates over USB bulk transfers and handles session management, partition table delivery, and firmware writing.
Before any data transfer, the host sends the ASCII string ODIN (4 bytes) over USB bulk transfer. The device bootloader responds with LOKE (4 bytes) to confirm readiness.
The Partition Information Table (PIT) defines the device's storage layout. odin4 requests this table to validate firmware compatibility using the Odin command protocol (command type 0x65).
The PIT is retrieved in 500-byte blocks: first the device reports the total PIT size, then individual blocks are fetched, and finally the dump is terminated.
0x12349876) followed by 132-byte partition entries. Each entry includes partition name, flash filename, binary type, device type, identifier, and block geometry.
Flashing uses the Odin command type 0x66 and proceeds in sequences, each divided into packets of the negotiated size (128 KiB or 1 MiB depending on protocol version).
| Phase | Command | Name | Description |
|---|---|---|---|
| Init | 0x66/0x00 |
REQUEST_FILE_FLASH | Start file transfer session |
| Begin | 0x66/0x02 |
BEGIN_SEQUENCE | Start a sequence with aligned size |
| Data | Bulk write | FILE_PART | Raw data chunk at packet size |
| End | 0x66/0x03 |
END_SEQUENCE | Complete sequence with partition metadata |
| Init (LZ4) | 0x66/0x05 |
REQUEST_COMPRESSED | Start compressed file transfer |
| Begin (LZ4) | 0x66/0x06 |
BEGIN_COMPRESSED_SEQUENCE | Start a compressed sequence |
| End (LZ4) | 0x66/0x07 |
END_COMPRESSED_SEQUENCE | Complete compressed sequence |
The device type is queried using command 0x64 with subcommand 0x01. The device responds with a model code which the host formats as SM-<code>.
Device control uses command type 0x67 with the following subcommands:
| Command | Value | Description |
|---|---|---|
| END_SESSION | 0x00 |
Terminate session gracefully |
| REBOOT | 0x01 |
Reboot device normally |
| REDOWNLOAD | 0x02 |
Reboot into Download Mode |
Follow the steps below to set up odin4 on your system.
Install the required libraries via terminal:
sudo apt-get update
sudo apt-get install -y cmake ninja-build zip make pkg-config g++ libusb-1.0-0-dev libcrypto++-dev
Clone and compile the project using CMake:
git clone https://github.com/Llucs/odin4.git
cd odin4
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel $(nproc)
Configure udev rules for non-root access:
sudo cp udev/60-odin4.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger
Usage: odin4 [options]
Samsung firmware flashing tool for Linux.
Options:
-h Show this help message
-v Show version
-w Show license
-l List detected Download Mode devices
-d <path> Select a specific USB device path
-b <file> Bootloader archive (.tar or .tar.md5)
-a <file> AP archive (.tar or .tar.md5)
-c <file> CP archive (.tar or .tar.md5)
-s <file> CSC archive (.tar or .tar.md5)
-u <file> UMS archive (.tar or .tar.md5)
--check-only Validate PIT + archives and exit without flashing
--allow-unknown Allow archive entries without a PIT match
--reboot Reboot device after flashing
--redownload Reboot into download mode if supported
--efs-clear Clear EFS partition during flash
--bl-update Signal bootloader update to device
Logging:
--quiet Only print errors
--verbose More detailed logs
--debug Debug logs (includes USB packet hexdumps)
USB selection overrides:
--vid <hex> Override USB vendor ID
--pid <hex> Override USB product ID
--usb-interface <n> Force a specific USB interface number
./odin4 -b BL.tar.md5 -a AP.tar.md5 -c CP.tar.md5 -s CSC.tar.md5 -u UMS.tar.md5 --reboot
./odin4 -d /dev/bus/usb/001/002 -a AP.tar.md5 --check-only
./odin4 -a AP.tar.md5 --reboot --redownload