A reconstructed version of Samsung's Odin4 firmware flashing tool, based on:
- Decompiled binary analysis (Ghidra)
- Heimdall open-source reference (MIT License)
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.
- 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.
brew install libusb lz4 openssl
# Optional for better crypto support:
brew install cryptopp pkg-configsudo apt install libusb-1.0-0-dev liblz4-dev zlib1g-dev libcrypto++-devsudo dnf install libusb1-devel lz4-devel zlib-devel cryptopp-develEnsure you have the required dependencies installed (see Requirements above).
makeObject 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.
make cleansudo make installPREFIX (default /usr/local) and DESTDIR are both honoured:
make install PREFIX=/usr DESTDIR=/tmp/stagingOr manually copy the odin4 binary to your PATH.
# 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| 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.
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- Ensure device is in Download Mode
- Check USB connection
- Verify udev rules are installed
Run with sudo or set up udev rules (see above).
Ensure all dependencies are installed. Run make deps to check.
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.
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.
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
Reconstructed by MhAhmadAli
- GitHub: https://github.com/MhAhmadAli