title: Problem in flashing and running STM32 bluepill in linux environment
body: <p>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 &quot;Beginning STM32 developing with freeRTOS libopencm3 and GCC&quot; for the same.
  As per the book
  I have downloaded the book software using git clone <a href="https://github.com/ve3wwg/stm32f103c8t6.git" rel="nofollow noreferrer">https://github.com/ve3wwg/stm32f103c8t6.git</a>
  I have downloaded the libopencm3 in stm32f103c8t6 folder using git clone <a href="https://github.com/libopencm3/libopencm3.git" rel="nofollow noreferrer">https://github.com/libopencm3/libopencm3.git</a>
  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 &quot;FREERTOS        ?= FreeRTOSv10.2.1&quot;
  I have installed ARM cross compiler using sudo apt install gcc-arm-none-eabi
  I have build the software using following command &quot;$ cd ~/stm32f103c8t6&quot; and &quot;$ make&quot;
  Then i have installed st-flash tool</p>
  <p>There is pre written code named as miniblink.c in miniblink folder
  code is as follows:</p>
  <pre><code>#include &lt;libopencm3/stm32/rcc.h&gt;
  #include &lt;libopencm3/stm32/gpio.h&gt;
  
  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 &lt; 1500000; i++)   /* Wait a bit. */
              __asm__(&quot;nop&quot;);
  
          gpio_set(GPIOC,GPIO13);     /* LED off */
          for (i = 0; i &lt; 500000; i++)    /* Wait a bit. */
              __asm__(&quot;nop&quot;);
      }
  
      return 0;
  }
  </code></pre>
  <p>I have connected my bluepill using st-link v2 to my computer.</p>
  <p>I have used following commands in terminal from miniblink folder &quot;$ make clobber&quot; followed by &quot;$ make&quot; followed by &quot;$ make flash&quot; as given in textbook.</p>
  <p>it shows following output in terminal:</p>
  <pre><code> /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!
  </code></pre>
  <p>Also the book doesn't mention about whether BOOT0 is HIGH or LOW during flashing.</p>
  <p>I tried flashing bluepill with both settings BOOT0 HIGH and BOOT0 LOW</p>
  <p>But in either case I don't see PC13 green LED blink in the bluepill after flashing.</p>
  <p>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?</p>