Flashing Blue Pill (STM32F103) bootloader

From Tom's notes
Jump to navigation Jump to search

Started off using following guide: https://medium.com/@paramaggarwal/programming-an-stm32f103-board-using-usb-port-blue-pill-953cec0dbc86

However, still didn't seem to work, always got following errors in dmesg:

usb 3-1: new full-speed USB device number 122 using xhci_hcd
usb 3-1: device descriptor read/64, error -71
usb 3-1: device descriptor read/64, error -71
usb 3-1: new full-speed USB device number 123 using xhci_hcd
usb 3-1: device descriptor read/64, error -71
usb 3-1: device descriptor read/64, error -71
usb 3-1: new full-speed USB device number 124 using xhci_hcd
usb 3-1: Device not responding to setup address.
usb 3-1: Device not responding to setup address.
usb 3-1: device not accepting address 124, error -71
usb 3-1: new full-speed USB device number 125 using xhci_hcd
usb 3-1: Device not responding to setup address.
usb 3-1: Device not responding to setup address.
usb 3-1: device not accepting address 125, error -71
usb usb3-port1: unable to enumerate USB device

Workaround was to first perform an erase step and follow it up with a verify just for good measure:

python ./stm32loader -p /dev/tty.SLAB_USBtoUART -e ./generic_boot20_pc13.bin
python ./stm32loader -p /dev/tty.SLAB_USBtoUART -w ./generic_boot20_pc13.bin
python ./stm32loader -p /dev/tty.SLAB_USBtoUART -v ./generic_boot20_pc13.bin

Keep BOOT0=1 and BOOT1=0. Reset between each step just in case.

Using 5V power seems to be working better on the Maple board (BluePill seems to work with 3.3V as well). Connect rx to PA9, tx to PA10.

When resetting bot jumpers to 0 and resetting the fast/slow flashing worked and the device was seen on USB.

Direct links:

Make sure to verify the bootloader was downloaded and not just some HTML page.

When creating the udev rules (/etc/udev/rules.d/45-maple.rules), make sure the group is valid and your user belongs to that group:

ATTRS{idProduct}=="1001", ATTRS{idVendor}=="0110", MODE="664", GROUP="uucp"
ATTRS{idProduct}=="1002", ATTRS{idVendor}=="0110", MODE="664", GROUP="uucp"
ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="uucp" SYMLINK+="maple", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="uucp" SYMLINK+="maple", ENV{ID_MM_DEVICE_IGNORE}="1"