stm32stm32f1

How to compile StdPeriph Library examples for BluePill?


I am trying to compile the example with GNU arm eabi gcc: and I got this from the compiler:

#error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"

I have then added -DSTM32F10X_MD to the command line because I believe, maybe incorrectly that's what the BluePill is and then I got this:

#error "Please select first the STM32 EVAL board to be used (in stm32_eval.h)"

It took me a while of search to realize that EVAL means one of the evaluation boards ST sells to test their products, but I of course do not have one, I have a cheap bluepill from Aliexpress. So what is my choice now? How do I compile the examples?

Update: here is my complete command line

arm-none-eabi-gcc -DSTM32F10X_MD main.c -I/home/me/st/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x -I/home/me/st/Libraries/CMSIS/CM3/CoreSupport  -I/home/me/st/Utilities/STM32_EVAL -Wfatal-errors

Solution

  • First: don't use the STDPeriph, it's deprecated. Use the HAL.

    Second: it's asking you to define in the library itself what platform it is compiling for so it can include the correct dependencies. (Such as peripheral placements in memory)

    The solution is to read the STM chip's model number (something like STM32F103C8T6) then look inside the stm32f10x.h file and select your MCU, which probably involves uncommenting a define line. If you can't figure out what types of options there are, try reading the datasheet for the MCU you have as it specifies everything about it.

    For the EVAL board you can select any of them as they only alias (define) simple names such as LED1. You just can't use them then.

    BUT AGAIN DON'T USE STDPeriph use the HAL! Just use CubeMX to generate a project with libraries for you. It probably also better supports the BluePill than some old STDPeriph eval board header.