IMSProg and other Linux utilities for CH341A

 Posted by:   Posted on:   Updated on:  2023-10-28T19:42:04Z

About the available programming utilities for CH341A programmers on Linux platform

It was July 2017 when I ordered an EEPROM programmer I found on AliExpress for only 2.13 USD with free shipping. It wasn't a surprise it came without any kind of documentation. So I began searching for information since I didn't knew how to use it or what PC software I need to read a memory chip. In fact, I didn't even know how to place a chip in the programming socket. I gathered all information about the programmer hardware in this post. At that time I wasn't expecting this programmer to become so popular, still being used today.

The CH341A MiniProgrammer and other programmers based on this controller are affordable USB programmers used for reading and writing EEPROM chips and flash memory. They are widely used by hobbyists and technicians for tasks like flashing BIOS chips, recovering data from bricked devices, and working with various types of EEPROM and SPI flash memory chips. Yet, with all this popularity, the only (probably) official software for this programmer is Windows-only, hard to get and some of the alternatives come from not very trustful sites. Let's see what is available for Linux (Ubuntu).

Reading SPI Flash with IMSProg
Reading SPI Flash with IMSProg

IMSProg

IMSProg is a new tool developed by Mikhail Medvedev and it is currently the only existing programming utility for Linux with graphical interface. The software is based on Qt (in theory it may also be built on Windows) and it is open source. Source code and builds are available on GitHub (in release folder), for Linux (universal AppImage, DEB and RPM packages).

I recommend you install the distribution specific package (DEB on Ubuntu and Debian based, RPM on RedHat, openSuSE and others). This is because the package automatically sets udev rules which are required to have access to USB devices (in this case the CH341A).

If you want to use the AppImage you have to copy udev rules file 99-ch341a-prog.rules to /etc/udev/rules.d. Note that you need to perform the copy with administrator rights. For example, here are all terminal commands required for Ubuntu users:

sudo apt update
sudo apt install git
git clone https://github.com/bigbigmdm/IMSProg.git
cd IMSProg/IMSProg_programmer
sudo cp 99-ch341a-prog.rules /etc/udev/rules.d
sudo udevadm control --reload-rules

The above will download IMSProg repository and set udev rules. However, keep in mind that you need these rules to access CH341A, no matter what programmer you intend to use. So here is another way to get only the rules (and not the entire repository):

wget https://raw.githubusercontent.com/bigbigmdm/IMSProg/main/IMSProg_programmer/99-ch341a-prog.rules
sudo cp 99-ch341a-prog.rules /etc/udev/rules.d
sudo udevadm control --reload-rules

After you are done with this, plug the programmer in the USB port and launch IMSProg. If using the AppImage, right click the file, select Properties and tick Executable as Program. It should then open when you double click on it.

If you are in the same terminal you used to download the Git repository, you can do the following:

cd ../release/build
chmod +x IMSProg.appimage
chmod +x IMSProg_editor.appimage
./IMSProg.appimage

However, if you installed the package (choose the latest version available) everything is set and you can find IMSProg in the applications menu.

I tested IMSProg with the W25Q128 flash memory and it had no problems detecting and reading it. Note that there is also an editor with IMSProg which allows you to add other chips to the database. If you used the portable AppImage, the chip database file (IMSProg.dat) is in the same folder with the executable files and you will have no problems opening it in editor. However, if you installed the distribution package, the database is also with the executable program, but in a system folder you can't write to as a regular user. This is just a bad choice of paths which hopefully will be fixed in a future release.

Command line utilities

I already talked about SNANDer usage on Windows. Here is how to get it on Linux (Ubuntu):

sudo apt update
sudo apt install git
git clone https://github.com/McMCCRU/SNANDer.git
cd SNANDer/Linux
sudo cp SNANDer /usr/local/bin
sudo cp 40-persistent-ch341a.rules /etc/udev/rules.d
sudo udevadm control --reload-rules

The first two commands are required to install Git client. Skip them if you have it installed. The last two commands set udev rules. Also skip them if you previously did that. After this, you can open any terminal and run SNANDer. For example, to auto detect chip and read use:

SNANDer -r flash.bin

Another command line utility is flashrom. This should be available in the package manager and you can install it with sudo apt install flashrom. Its downside is that it only supports SPI. Usage is straightforward:

flashrom -p ch341a_spi -r flash.bin

I can confirm both utilities read correctly the big W25Q128 flash I used for tests. And for I2C there is ch341eeprom utility from Collin Allen. You have to get the source and build it yourself:

sudo apt update
sudo apt install git clang libusb-dev
git clone https://github.com/command-tab/ch341eeprom.git
cd ch341eeprom
make -j4
sudo cp ch341eeprom /usr/local/bin
sudo cp 99-ch341a-prog.rules /etc/udev/rules.d
sudo udevadm control --reload-rules

After this you can invoke ch341eeprom from any terminal. I didn't test it because I couldn't find an out-of-circuit EEPROM.

Overview

CH341A serial programmers became popular in last years, being very cheap and reliable. It is great to know that programming utilities have been developed for Linux too. I recommend IMSProg and SNANDer for being open source and the most complete (I2C, SPI and Microwire support).

If regularly using CH341A to program chips, you may want to buy a programmer with voltage level switch between 3.3V and 5V. There are also adapters to 1.8V. It’s important to know that the black MiniProgrammer supplies 3.3V to memory chips placed in the ZIF socket and 5V to CH341A. I2C and SPI bus I/O voltage levels are set to 5V! A fix that requires soldering already exists.

1 comment :

  1. You can be install the IMSProg in Debian / Ubuntu / Mint / MX use this commands:

    sudo add-apt-repository ppa:bigmdm/imsprog
    sudo apt update
    sudo apt install imsprog

    ReplyDelete

Please read the comments policy before publishing your comment.