DEV Community

alexjune1206-maker
alexjune1206-maker

Posted on Edited on AI-assisted

I built a Linux tool to force my Samsung Phone with dead buttons into Download Mode

I have a Samsung Galaxy Core LTE with broken power and volume buttons. Entering Download Mode requires the Volume Down + Home + Power, which is impossible having the buttons broken. The original tool is Windows only, and because I didn't want to switch between PCs(my main pc is a kali linux one), I wrote a small tool in C to do the job natively on Linux.

This post is about what I learned from building it, not just the announcement about it.

The problem:

Samsung phones expose a diagnostic serial interface over USB (/dev/ttyACM*). You can send AT commands to force the device into Download Mode (Odin). The tricky part is doing this reliably from a Linux CLI, across different models and firmware versions, without accidentally sending commands to the wrong device.

How It Works

The tool does three things:

  1. Detects the device by reading the USB vendor ID from /sys. Samsung VID is 04e8. This check prevents the tool from accidentaly sending AT commands to a 3G modem or an Arduino plugged in the computer lets say.

  2. Sends a sequence of AT commands over the serial port. The exact command that triggers the reboot varies by model. On my Galaxy Core LTE the reboot command is AT+FUS?. On a Galaxy S8 I tested, the reboot command is AT+REBOOT=4

  3. Confirms Download Mode by polling sysfs for known Samsung PIDs: 685d, 685e, 6860.

What I Learned

Port names are useless for identification. /dev/ttyACM0 vs /dev/ttyACM1 depends on kernel enumeration order. I added serial identification so that you can tell the devices apart(in a scenario where you have multiple Samsung devices plugged in.)

The port can disappear mid-sequence. On the Core LTE, the phone reboots after AT+FUS?. The next command fails with EIO. Initially I treated this as an error. Now I treat it as a success signal and poll for the Download Mode PID.

Quick Start

git clone https://github.com/alexjune1206-maker/samsung-300k-tool-4-linux.git
cd samsung-300k-tool-4-linux
mkdir build && cd build
cmake ..
cmake --build .
sudo ./samsung-300k-tool --help
Enter fullscreen mode Exit fullscreen mode

Repo: https://github.com/alexjune1206-maker/samsung-300k-tool-4-linux.git

Any contributions are welcome! Thank you!

Top comments (0)