#embedded-bootloader #ch32 #risc-v #bootloader

sys no-std tinyboot-ch32-hal

Hardware abstraction layer for tinyboot on CH32 microcontrollers

4 releases (2 breaking)

Uses new Rust 2024

new 0.3.0 Apr 15, 2026
0.2.1 Mar 25, 2026
0.2.0 Mar 21, 2026
0.1.0 Mar 20, 2026

#2231 in Embedded development


Used in 2 crates

MIT/Apache

41KB
831 lines

tinyboot-ch32-hal

Part of the tinyboot project — see the main README to get started.

Minimal hardware abstraction layer for tinyboot on CH32 microcontrollers. This is not a general-purpose HAL — it provides only what the bootloader needs, optimized for code size.

Modules

Module Description
flash Flash page erase/write, boot metadata address
gpio Pin configuration (input, output, alternate function)
usart UART transmit/receive with embedded-io traits
rcc Clock configuration and peripheral reset
afio Alternate function I/O and pin remapping
pfic Interrupt controller and system reset
iwdg Independent watchdog timer feed
boot_request Boot request signaling (reg/ram/gpio, auto-selected)

Code generation

build.rs reads chip metadata from ch32-metapac and generates:

  • Pin enum — all GPIO pins with bit-packed discriminants for table-free port/pin extraction
  • UsartMapping enum — all USART remap configurations with TX/RX pin and register accessors

This keeps the source chip-agnostic while producing zero-overhead accessors.

Features

Feature Description
ch32v003f4p6 CH32V003F4P6 chip variant (default, for rust-analyzer; CI uses explicit chip)
ch32v103c8t6 CH32V103C8T6 chip variant
system-flash Bootloader runs from system flash (boot request scheme auto-selected by chip)

Notes

  • All modules use PAC register access directly for minimal code size.
  • The default feature (ch32v003f4p6) exists so rust-analyzer can analyze the ch32 workspace without explicit feature flags. Downstream crates use default-features = false.

Dependencies

~8.5MB
~243K SLoC