Dobrica Pavlinušić's random unstructured stuff
Blue Pill: Revision 15
{file: The-Generic-STM32F103-Pinout-Diagram.pdf}

{toc: }

stm32f103 board

^ arduino boot loader

* https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Flashing-Bootloader-for-BluePill-Boards

^ triple usb serial

^^ pill_serial

* https://satoshinm.github.io/blog/171223_stm32serial_triple_usb-to-serial_adapter_using_stm32_blue_pill.html
* https://github.com/satoshinm/pill_serial

| Function | Pin and Port |
| USART3 TX | PB10 |
| USART3 RX | PB11 |
| USART2 TX | PA2 |
| USART2 RX | PA3 |
| USART1 TX | PA9 |
| USART1 RX | PA10 |

| USART | TX pin | RX pin | special | speed | sensor | linux |
| 3 | PB10 | PB11 | | 9600 | [MH-Z19B] | /dev/ttyACM1 |
| 2 | PA2 | PA3 | | 9600 | | |
| 1 | PA9 | PA10 | BOOT=0 | 9600 | | |

.pre
dpavlin@nuc:/nuc/stm32/pill_serial$ cat flash.sh
sudo ../stlink/build/Release/st-flash write src/pill_serial.bin 0x08000000
.pre

lower serial speed to 9600 so we can use slow sensors on it: {file: serial-speed.diff}

^^ bluepill-serial-monster

https://github.com/r2axz/bluepill-serial-monster

^ openocd with raspberry pi

http://git.rot13.org/?p=openocd-rpi2-stm32;a=blob;f=openocd-rpi.txt

^ clones

https://github.com/thanks4opensource/buck50/issues/2

https://github.com/keirf/Greaseweazle/wiki/STM32-Fakes

.pre
dpavlin@nuc:/nuc/stm32/Greaseweazle$ wget https://github.com/keirf/Greaseweazle/releases/download/v0.22/Greaseweazle-v0.22.zip

dpavlin@nuc:/nuc/stm32/Greaseweazle$ unzip Greaseweazle-v0.22.zip Greaseweazle-v0.22/alt/Blinky_Test-v0.22.hex
Archive: Greaseweazle-v0.22.zip
inflating: Greaseweazle-v0.22/alt/Blinky_Test-v0.22.hex
.pre

write it to flash using openocd

.pre
> flash write_image erase /nuc/stm32/Greaseweazle/Greaseweazle-v0.22/alt/Blinky_Test-v0.22.hex 0 ihex
auto erase enabled
wrote 5120 bytes from file /nuc/stm32/Greaseweazle/Greaseweazle-v0.22/alt/Blinky_Test-v0.22.hex in 0.299529s (16.693 KiB/s)
.pre

serial output is on the programming interface at pins A9/TX and A10/RX: Not via the USB port!

.pre
pi@pihdmi:/nuc/stm32/buck50 $ microcom -p /dev/ttyUSB1
connected to /dev/ttyUSB1
Escape character: Ctrl-\
Type the escape character to get to the prompt.

** Blinky
** Blinky Test **
** Keir Fraser <keir.xen@gmail.com>
** https://github.com/keirf/Greaseweazle
Serial = ff48:0670:8967:5655:4740:6706
Flash Size = 128kB
Device ID = 0x0000
Revision = 0x0000
Testing I2C1... OK
Testing I2C2... OK
Testing SPI1... OK
Testing SPI2... OK
Testing TIM1... OK
Testing TIM2... OK
Testing TIM3... OK
Testing TIM4... OK
DMA Test #1... OK
DMA Test #2... OK
DMA Test #3... OK
DMA Test #4... OK
Testing 64kB Flash... OK
Enable TIM4 IRQ... .OK
Testing 20kB SRAM (endless loop)................................................................
.pre

After flashing this test, you will not be able to address blue pill using openocd.

To work-around this problem, I switched boot0 jumper, used stm32loader (after pressing reset button) to load alternative binary.