I am new to STM32 programming. I have bluepill hardware with me. My goal is to flash a simple program (such as blink an led in bluepill) using opensource tools and ubuntu OS. I am currently following the book "Beginning STM32 developing with freeRTOS libopencm3 and GCC" for the same. As per the book I have downloaded the book software using git clone https://github.com/ve3wwg/stm32f103c8t6.git I have downloaded the libopencm3 in stm32f103c8t6 folder using git clone https://github.com/libopencm3/libopencm3.git I have downloaded freertos (version FreeRTOSv10.2.1.zip) from sourceforge and unzip in location /stm32f103c8t62/rtos/ I have made required changes in /stm32f103c8t6/rtos/Project.mk file "FREERTOS ?= FreeRTOSv10.2.1" I have installed ARM cross compiler using sudo apt install gcc-arm-none-eabi I have build the software using following command "$ cd ~/stm32f103c8t6" and "$ make" Then i have installed st-flash tool
There is pre written code named as miniblink.c in miniblink folder code is as follows:
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
static void
gpio_setup(void) {
/* Enable GPIOC clock. */
rcc_periph_clock_enable(RCC_GPIOC);
/* Set GPIO8 (in GPIO port C) to 'output push-pull'. */
gpio_set_mode(GPIOC,GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL,GPIO13);
}
int
main(void) {
int i;
gpio_setup();
for (;;) {
gpio_clear(GPIOC,GPIO13); /* LED on */
for (i = 0; i < 1500000; i++) /* Wait a bit. */
__asm__("nop");
gpio_set(GPIOC,GPIO13); /* LED off */
for (i = 0; i < 500000; i++) /* Wait a bit. */
__asm__("nop");
}
return 0;
}
I have connected my bluepill using st-link v2 to my computer.
I have used following commands in terminal from miniblink folder "$ make clobber" followed by "$ make" followed by "$ make flash" as given in textbook.
it shows following output in terminal:
/usr/bin/st-flash write miniblink.bin 0x8000000
st-flash 1.6.0
2022-04-07T21:44:50 INFO common.c: Loading device parameters....
2022-04-07T21:44:50 INFO common.c: Device connected is: F1 Low-density device, id 0x10006412
2022-04-07T21:44:50 INFO common.c: SRAM size: 0x2800 bytes (10 KiB), Flash: 0x8000 bytes (32 KiB) in pages of 1024 bytes
2022-04-07T21:44:50 INFO common.c: Attempting to write 688 (0x2b0) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000000 erased
2022-04-07T21:44:50 INFO common.c: Finished erasing 1 pages of 1024 (0x400) bytes
2022-04-07T21:44:50 INFO common.c: Starting Flash write for VL/F0/F3/F1_XL core id
2022-04-07T21:44:50 INFO flash_loader.c: Successfully loaded flash loader in sram
1/1 pages written
2022-04-07T21:44:50 INFO common.c: Starting verification of write complete
2022-04-07T21:44:50 INFO common.c: Flash written and verified! jolly good!
Also the book doesn't mention about whether BOOT0 is HIGH or LOW during flashing.
I tried flashing bluepill with both settings BOOT0 HIGH and BOOT0 LOW
But in either case I don't see PC13 green LED blink in the bluepill after flashing.
Where am I going wrong. How to check whether the code is getting flashed to the bluepill? What should I do to get the green led blink in the bluepill?