Friday, May 14, 2021

Program Blue Pill with CKS32F103C8T6 using UART

 I needed a Blue Pill for a project. Got a few on ebay, but I couldn't find genuine STM32 ones in Europe. So I got ones with the compatible CKS32F103C8T6 chip.

I have never programmed a Blue Pill of any kind, so I don't really know how it is supposed to work. Programming with ST's UART tool didn't work for me, it didn't like the identity of the board. I instead got success using stm32flash, which can be found here .

I used  some generic USB-to-UART cable, which identifies as being "Prolific USB-to-Serial". Make sure that the UART dongle works by doing a loop test.

To program the chip on the Blue Pill, follow these steps:

  1. On Blue Pill set jumper for"boot 0" to 1.
  2. Connect UART GND (black) to G on Blue Pill
    UART 5V (red) to 5V on Blue Pill
    UART RX (white) to A9 on Blue Pill
    UART TX (green) to A10 on Blue Pill
  3. From command line, run:
    stm32flash -g 0x8000000 -b 115200 -w gd32f1_generic_boot20_pc13.bin COM4
    where COM4 is whatever com-port the UART has attached to, and the bin-file is whatever bin-file you want to upload.
    There seems to be some problem with paths and stm32flash, so I run everything from the same folder.
  4. On Blue Pill set jumper for"boot 0" to 0.
  5. Push reset button on Blue Pill.
  6. Done!