Skip to content
Llucs edited this page May 4, 2026 · 5 revisions

odin4 Wiki

Overview

odin4 is a modern, open-source Samsung firmware flashing tool specifically designed for Linux environments. It provides a clean, correct, and robust implementation of the Thor USB protocol, offering a reliable alternative for Samsung device maintenance and development workflows on Linux.

The project emphasizes:

  • Correct Protocol Behavior: Adherence to the Thor USB protocol specifications for reliable communication.
  • Strong Validation: Comprehensive checks before flashing to prevent device bricking or data corruption.
  • Structured Logging: Detailed and organized logging for easier debugging and operational oversight.
  • Deterministic and Safe Flashing Logic: Ensuring predictable and secure flashing operations.
  • Clean and Maintainable C++ Code: A well-structured codebase that is easy to understand, extend, and maintain.

Why odin4?

  • Works natively on Linux (no Wine needed)
  • Open-source and auditable
  • Safer validation system
  • Better logging and debugging tools

Core Features

odin4 offers a comprehensive set of features for flashing Samsung devices:

  • Samsung Download Mode Detection: Automatic detection of devices in Download Mode via libusb.
  • Native Thor Protocol Implementation: A custom, native implementation of the Thor protocol for efficient and accurate flashing.
  • Automatic PIT Retrieval and Parsing: Automatically retrieves and parses Partition Information Table (PIT) data from devices.
  • Strict Partition Validation: Ensures that firmware partitions match the device's PIT, preventing mismatches.
  • Support for Standard Samsung Firmware Packages: Compatible with common firmware components:
    • BL (Bootloader)
    • AP (Application Processor)
    • CP (Modem/Phone)
    • CSC (Consumer Software Customization)
    • UMS (USB Mass Storage - less common in modern devices)
  • .tar.md5 Integrity Verification: Verifies the integrity of .tar.md5 firmware archives using Crypto++.
  • Streaming Flash Support: Efficient flashing for various image types:
    • Raw images
    • LZ4-compressed images (for faster transfers)
  • Per-file Flashing Progress Reporting: Provides detailed progress for each file being flashed.
  • Transfer Statistics: Displays real-time statistics including size, elapsed time, and average speed.
  • Persistent Log File: Generates an odin4.log file for post-operation analysis and debugging.
  • Sequential Multi-device Flashing: Supports flashing multiple devices sequentially when no specific device is targeted with -d.
  • Safe Dry-run Mode: The --check-only option allows validation of PIT and archives without performing any actual flashing, ensuring safety.

Safety and Validation

odin4 prioritizes device safety by enforcing strict checks before any write operations:

  • Firmware Integrity Verification: Ensures the firmware is not corrupted or tampered with.
  • Partition Name Validation against PIT: Prevents flashing incorrect partitions to the wrong locations.
  • Device Model Compatibility Check: Verifies that the firmware is compatible with the connected device model.
  • Explicit Flashing Control Flow: Requires clear commands for flashing, reducing accidental operations.
  • Optional Dry-run Execution: Allows users to simulate the flashing process for validation without risk.

The tool is designed to be non-destructive and explicitly avoids high-risk operations such as NAND erase or forced repartitioning, which could lead to irreversible device damage.

Getting Started

To use odin4, you can either download a pre-compiled binary or build it from source on your Linux system.

Dependencies

Ensure you have the following packages installed on your system:

sudo apt-get update
sudo apt-get install -y cmake ninja-build zip make pkg-config g++ libusb-1.0-0-dev libcrypto++-dev

Building from Source (Alternative)

  1. Clone the repository:

    git clone https://github.com/Llucs/odin4.git
    cd odin4
  2. Compile the project:

    cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
    cmake --build build --parallel $(nproc)

Upon successful compilation, the odin4 executable will be located in the build/ directory.

Using Pre-compiled Binaries

For users who prefer not to compile from source, pre-compiled binaries are available in the releases section of the GitHub repository.

  1. Download the latest release: Visit the releases page and download the appropriate executable file for your system (e.g., odin4-linux-x86_64).
  2. Make the binary executable: Ensure the downloaded file has execute permissions.
    chmod +x odin4-linux-x86_64
  3. Run odin4: You can now run the tool directly.
    ./odin4-linux-x86_64 -h

Usage

The odin4 tool is operated via the command line. Here are the available options and common usage examples.

Command-Line Options

Usage: odin4 [options]
Samsung firmware flashing tool for Linux. Version: x.x.x-abcdefg

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 (e.g. /dev/bus/usb/001/002)
  -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 (disabled by default)
  --reboot             Reboot device after flashing
  --redownload         Reboot into download mode if supported

Logging:
  --quiet              Only print errors
  --verbose            More detailed logs
  --debug              Debug logs (includes USB packet hexdumps)

USB selection overrides (optional):
  --vid <hex>          Override USB vendor ID (hex, e.g. 04e8)
  --pid <hex>          Override USB product ID (hex)
  --usb-interface <n>  Force a specific USB interface number

Examples

  • List devices in Download Mode:

    ./build/odin4 -l
  • Flash firmware (all components):

    ./build/odin4 \ 
      -b BL_XXXX.tar.md5 \ 
      -a AP_XXXX.tar.md5 \ 
      -c CP_XXXX.tar.md5 \ 
      -s CSC_XXXX.tar.md5
  • Flash a specific device with selected components:

    ./build/odin4 -d /dev/bus/usb/001/002 \ 
      -b BL_XXXX.tar.md5 \ 
      -a AP_XXXX.tar.md5
  • Perform a dry-run (validation only):

    ./build/odin4 --check-only \ 
      -b BL_XXXX.tar.md5 \ 
      -a AP_XXXX.tar.md5
  • Reboot device after flashing:

    ./build/odin4 --reboot \ 
      -b BL_XXXX.tar.md5 \ 
      -a AP_XXXX.tar.md5

Linux USB Permissions

If odin4 reports LIBUSB_ERROR_ACCESS during operation, it indicates a permission issue with accessing USB devices. To resolve this, you need to install the udev rule provided with this repository:

  1. Copy the udev rule: Copy udev/60-odin4.rules to /etc/udev/rules.d/60-odin4.rules.

    sudo cp udev/60-odin4.rules /etc/udev/rules.d/60-odin4.rules
  2. Reload udev rules: Inform the system about the new rule.

    sudo udevadm control --reload-rules
    sudo udevadm trigger
  3. Reconnect your device: Unplug and then re-plug your Samsung device (in Download Mode) to apply the new permissions.

This rule specifically targets known Samsung Download Mode USB Vendor IDs (04e8) and Product IDs (6601, 685d, 68c3) to grant the necessary permissions.