Python based flash/verify tool for the CH55x MCUs
This script is based on work done by:
- Aaron Christophel: https://github.com/atc1441/chflasher
- Guys at mikrokontroller.net forum (reverse engineering the bootloader)
- And my own research on flashing procedures used by the original WCH programing software.
2.2 Fixed flash/erase block ranges, bargraph, added udev install script.
2.1 Added serial port option for bootloader v.2.31 + hardware reboot into bootloader.
2.0 Fixed flashing algorithm for bootloader v.2.31
1.0 Initial version
Succesfull tests:
- CH552 using bootloader v. 2.4, USB only
Succesfull tests:
- CH559, CH554 using bootloader v. 2.31, both USB and UART
- CH551 using bootloader v. 1.1, USB only
- Implement programming via UART - done for bootloader v. 2.31
- Test more MCUs.
- Test version 1 of the bootloader.
Logging and Serial port option is not implemented for Bootloader v.1.1.
- python3 installed and in PATH
- pyusb and pyserial libraries, install it via:
python3 -m pip install --user pyusb pyserial
- For Windows, use zadig tool (https://zadig.akeo.ie/) to change the driver for the CH55x board to libusb-win32. Linux does not need that step.
python3 chflasher.py [-h] [--version] [-p PORT] [-f FILE] [-w | -v | -d | -e]
[-s] [--log LOG]
optional arguments:
-h, --help show this help message and exit
--version Show version.
-p PORT, --port PORT serial port
-f FILE, --file FILE The target file to be flashed.
-w, --write Write file to flash, verify and exit the bootloader
-v, --verify Verify flash against the provided file.
-d, --detect Detect chip and bootloader version.
-e, --erase Erase flash.
-s, --start_app Reset and start application.
--log LOG Log opeations to file.
On Linux if you make the script executable:
chmod +x chflasher.py
you can omit the python3 command and run the srcipt directly.
write, verify the blink.bin file and exit the bootloader:
python3 chflasher.py -w -f blink.bin -s
write, verify the blink bin file and exit the bootloader, log operations in the write.log file:
python3 chflasher.py -w -f blink.bin -s --log write.log
verify the flash against the blink.bin file:
python3 chflasher.py -v -f blink.bin
erase the flash:
python3 chflasher.py -e
detect chip and bootloader version:
python3 chflasher.py -d
show help/usage:
python3 chflasher.py -h
To make use of a serial port instead of USB provide the additional parameter:
-p PORT
ie on Linux:
python3 chflasher.py -p /dev/ttyUSB0 -w -f blink.bin
or in Windows:
python3 chflasher.py -p COM5 -w -f blink.bin
Copyright 07.2021 by Piotr Zapart
www.hexefx.com