tillitis-key/hw/usb_interface/ch552_fw
Jonas Thörnblad 46ef63ee2d
ch552: Misc. fixes and cleanup
- Move copying of TKEYCTRL data from UartRxBuf to TkeyCtrlRxBuf to align
  with previous code.

- Remove obsolete UartRxBufOverflow variable.

- Add missing Endpoint4 handling for USB bus reset.

- Fix more robust uart_byte_count() calculation.

- Fix baudrate fast mode calculation to get rid of compiler warning.

- Fix assignment of bUD_PD_DIS to UDEV_CTRL.

- Cleanup comments.
2025-02-25 14:40:26 +01:00
..
include ch552: Misc. fixes and cleanup 2025-02-25 14:40:26 +01:00
.gitignore USB: move firmware for usb-to-serial MCU (CH552) 2024-06-25 15:47:22 +02:00
baud rate calculator.ods USB: move firmware for usb-to-serial MCU (CH552) 2024-06-25 15:47:22 +02:00
encode_usb_strings.py ch552: Add USB HID and protocol support over UART 2025-02-06 16:20:34 +01:00
inject_serial_number.py USB: move firmware for usb-to-serial MCU (CH552) 2024-06-25 15:47:22 +02:00
LICENSE doc: Update copyright notice on CH552 fw 2025-02-13 13:49:29 +01:00
main.c ch552: Misc. fixes and cleanup 2025-02-25 14:40:26 +01:00
Makefile ch552: Add USB HID and protocol support over UART 2025-02-06 16:20:34 +01:00
Makefile.include ch552: Add USB HID and protocol support over UART 2025-02-06 16:20:34 +01:00
README.md doc: Note in CH552 fw where to find CH55x Reset Controller 2025-02-12 14:09:20 +01:00

CH552 USB-to-Serial firmware

Toolchain setup

SDCC:

sudo apt install build-essential sdcc

chprog (for flashing the firmware to a device):

cd ~
sudo apt install libusb-1.0-0-dev
git clone https://github.com/ole00/chprog.git
cd chprog
./build_linux.sh
sudo cp chprog /usr/local/bin

Usage

Build the firmware using a default serial number:

make

Flash the firmware to a device:

make flash_patched

Re-programming the firmware

By design, once the USB to serial firmware is loaded onto the chip, there isn't an intended way to reflash it using only software. However, if 3.3V is applied to the D+ line through a 10K resistor during power-up, then the CH552 will enter bootloader mode, and a new firmware can be programmed onto the chip.

The Blinkinlabs CH55x Reset Controller can help you do this:

https://shop-nl.blinkinlabs.com/products/ch55x-reset-controller

https://github.com/Blinkinlabs/ch55x_programmer

Note that the CH552 flash is only guaranteed for a few hundred flash cycles.