Skip to content

Serial flashing method

AI LIFE edited this page Mar 21, 2024 · 8 revisions

Caution

Warning! Using serial flashing requires doing micro soldering to the pin(s) of gd32, please use the SWD flashing method if you are not comfortable doing it!)

Usage

In the following cases, you might want to use serial for flashing your board:

  • The SWD GPIO (PA13 PA14) is used as a GPIO, thus SWD is disabled
  • You do not have a STlink V2 or any compatible SWD debug probe
  • You want to use STM32 Cube Programmer
  • Flash unlock fails

Wiring

T1he gd32/stm32/mm32 bootloader is activated by pulling BOOT0 HIGH and BOOT1 LOW

The Serial pin in bootloader mode is different from the normal ones (pa9 TX pa10 RX)

GPIO Description wiring
BOOT0 -- connect to 3.3V
PB2 BOOT1 connect to GND with 1K resistor
PA9 TX RX
PA10 RX TX
VCC 3.3V
GND GND

serial flash

  • On most board, the BOOT0 is directly soldered to GND pad, so you will have to lift the pin up with a sharp tool while heating it
  • BOOT0 can be directly connected to 3.3v afterwards, just make sure there is no short circuit to GND from the pad it originally connect to
  • BOOT1 must be pulled LOW through a 1K resistor, because it is used as a normal GPIO, if you hard pull it to GND it can cause a short circuit in the micro controller and destroy it, and if you use too high value it can get dragged by the load to HIGH
  • TX and RX is PA9 PA10 which is always used by the motor blue and green phase, so you can solder the line to the gate driver ic they will not interfere with the signal and makes a larger solder pad to work with
  • It is important never connect the battery when serial line is connected, because you can create a short circuit with the mosfets, power the board from CP2102 internal 3.3v source is enough (100ma)
  • Make sure the usb to serial adapter is 3.3v not 5v(and also not +-15v!), or at least have a series resistor, otherwise it will not work I tried

video toturial of soldering: https://youtu.be/rUMzHYvKoW4

Example

The example soldering job is definitely not the best but it did work

IMG_20240129_2220292

IMG_20240130_011527

Flashing

  1. Download STM32 Cube Programmer from official website or fileCR
  2. Select UART

image

  1. Plug in your board with usb to serial adapter
  2. Select your com port, 115200 baud, Even parity

image

  1. Click connect
  2. The flash should be read and if lock it will be unlocked automatically

image

  1. Click open file and choose the hex file, then press download

  2. After a while it should say download complete

image

Aftermath

After flashing, BOOT0 need to be connected to GND to boot normally again, or it will always boot to bootloader