Coder Social home page Coder Social logo

ch55x_python_flasher's Introduction

CH55x_python_flasher

Python based flash/verify tool for the CH55x MCUs

This script is based on work done by:

  1. Aaron Christophel: https://github.com/atc1441/chflasher
  2. Guys at mikrokontroller.net forum (reverse engineering the bootloader)
  3. And my own research on flashing procedures used by the original WCH programing software.

Changelog:

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


10.2020 UPDATE:

Succesfull tests:

  • CH552 using bootloader v. 2.4, USB only

03.2020 UPDATE:

Succesfull tests:

  • CH559, CH554 using bootloader v. 2.31, both USB and UART
  • CH551 using bootloader v. 1.1, USB only

TODO:

  1. Implement programming via UART - done for bootloader v. 2.31
  2. Test more MCUs.
  3. Test version 1 of the bootloader.

Logging and Serial port option is not implemented for Bootloader v.1.1.


Requirements:

  1. python3 installed and in PATH
  2. pyusb and pyserial libraries, install it via:
    python3 -m pip install --user pyusb pyserial
  3. 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.

Usage:

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.


Examples:

Using USB (default method if port parameter is not provided)

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

Using serial port

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.