Skip to content
MhAhmadAliPublic

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

Odin4 - Samsung Firmware Flashing Tool

A reconstructed version of Samsung's Odin4 firmware flashing tool, based on:

  • Decompiled binary analysis (Ghidra)
  • Heimdall open-source reference (MIT License)

Version

1.2.1-dc05e3ea

Warning

UNDER DEVELOPMENT - EDUCATIONAL PURPOSE ONLY

This tool is a reconstruction intended for EDUCATIONAL PURPOSES ONLY. It is NOT FULLY TESTED and is not intended for production using. Use at your own risk. Incorrect usage or bugs could potentially BRICK your device. Always verify partition tables and firmware files before flashing.

Features

  • Flash firmware to Samsung devices in Download Mode
  • Support for multiple file types:
    • .tar.md5 - TAR archives with MD5 checksum
    • .lz4 - LZ4 compressed files
    • .gz - GZIP compressed files
    • .bin - Raw binary files
  • Multi-device flashing support (parallel)
  • PIT (Partition Information Table) handling
  • MD5/SHA256 verification

For .tar.md5 files the checksum appended by Samsung is checked against the archive contents, and a mismatch aborts the flash.

Requirements

macOS

brew install libusb lz4 openssl
# Optional for better crypto support:
brew install cryptopp pkg-config

Linux (Debian/Ubuntu)

sudo apt install libusb-1.0-0-dev liblz4-dev zlib1g-dev libcrypto++-dev

Linux (Fedora)

sudo dnf install libusb1-devel lz4-devel zlib-devel cryptopp-devel

Building

Prerequisites

Ensure you have the required dependencies installed (see Requirements above).

Compile

make

Object files land in build/. liblz4 and crypto++ are optional: the build detects them with pkg-config and falls back to OpenSSL for hashing when crypto++ is absent.

Clean

make clean

Installation

sudo make install

PREFIX (default /usr/local) and DESTDIR are both honoured:

make install PREFIX=/usr DESTDIR=/tmp/staging

Or manually copy the odin4 binary to your PATH.

Usage

# Show help
odin4 -h

# Show version
odin4 -v

# List available devices
odin4 -l

# Flash firmware
odin4 -b BL_XXXX.tar.md5 -a AP_XXXX.tar.md5 -c CP_XXXX.tar.md5 -s CSC_XXXX.tar.md5

# Flash to specific device
odin4 -b BL.tar.md5 -a AP.tar.md5 -d /dev/bus/usb/001/002

# Enable NAND erase
odin4 -e -b BL.tar.md5 -a AP.tar.md5

# Flash with PIT file
odin4 -V partition.pit -b BL.tar.md5 -a AP.tar.md5

Options

Option Description
-h Show help
-v Show version
-w Show licenses
-l List downloadable devices
-b FILE Add Bootloader file
-a FILE Add AP (Android) image file
-c FILE Add CP (Modem) image file
-s FILE Add CSC file
-u FILE Add UMS file
-V FILE Write the given PIT (partition table) to the device
-e Enable NAND erase
-d PATH Specify device path (repeat for multi-device flashing)
--reboot Reboot to normal mode after flash
--redownload Reboot to download mode

Caution

-V repartitions the device. Only pass a PIT that matches the exact model you are flashing.

At least one of -b, -a, -c, -s, -u, -V, --reboot or --redownload must be given; the tool will not open a session with nothing to do.

udev Rules (Linux)

To access Samsung devices without root, create /etc/udev/rules.d/51-samsung.rules:

SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"

Then reload udev:

sudo udevadm control --reload-rules
sudo udevadm trigger

Troubleshooting

Device not detected

  1. Ensure device is in Download Mode
  2. Check USB connection
  3. Verify udev rules are installed

Permission denied

Run with sudo or set up udev rules (see above).

Build errors

Ensure all dependencies are installed. Run make deps to check.

License

Odin4's own source code is released under the MIT License — see LICENSE.

It links against third-party libraries under their own terms, including libusb (LGPL-2.1-or-later) and, depending on build configuration, OpenSSL (Apache-2.0) or Crypto++ (BSL-1.0). The required notices and full license texts are in THIRD-PARTY-NOTICES.md; odin4 -w prints a condensed version at runtime.

Disclaimer

This tool is provided for EDUCATIONAL PURPOSES ONLY. It is a reconstruction enabling study of the Samsung Odin protocol. It is not affiliated with or endorsed by Samsung.

Use at your own risk. The authors are not responsible for any damage caused by using this software. Always backup your data before flashing firmware.

The MIT License covers this project's own code only. It grants no rights in Samsung's original software, and reverse engineering or redistributing work derived from a proprietary binary may be restricted in your jurisdiction independently of that license.

Samsung and Odin are trademarks of Samsung Electronics Co., Ltd.

Project Structure

odin4/
├── Makefile                # Build system
├── README.md               # This file
├── LICENSE                 # MIT License for this project
├── THIRD-PARTY-NOTICES.md  # Notices for bundled/linked components
├── include/
│   ├── DownloadEngine.h    # Core protocol class
│   ├── FirmwareData.h      # Firmware parsing
│   ├── FirmwareInfo.h      # Firmware file info struct
│   ├── Log.h               # Logging utility
│   ├── Manifest.h          # Hash verification
│   ├── OdinException.h     # Exception classes
│   ├── PIT.h               # Partition table parsing
│   ├── Tar.h               # TAR archive handling
│   └── UsbDevice.h         # USB device interface
└── src/
    ├── DownloadEngine.cpp  # Protocol implementation
    ├── FirmwareData.cpp    # Firmware parsing
    ├── Log.cpp             # Logging
    ├── main.cpp            # Entry point
    ├── Manifest.cpp        # Hash calculation
    ├── PIT.cpp             # PIT handling
    ├── showLicenses.cpp    # License display
    ├── Tar.cpp             # TAR handling
    └── UsbDeviceImpl.cpp   # USB implementation

Developer

Reconstructed by MhAhmadAli

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages