Hello everyone, I have a question. I want to write a program for the STM32F103C8T6 chip. The framework I use is not the STM32CUBE library but a standard library, but I have not found the standard library in PlatFormIO. I don’t know how to do it.
Do you mean just the bare-metal the C standard library (
newlib-nano) or the STM32 standard peripheral library (SPL)?
嗯嗯，YES，Is ST’s standard peripheral library，I saw that PlatFormIO supports STM32CUBE, but I don’t see the standard peripheral library. I want to ask if PlatFormIO can use the standard peripheral library.
I see some ST chips support SPL, but STM32F103C8T6 does not seem to support
We have SPL examples (platform-ststm32/examples/spl-blink at develop · platformio/platform-ststm32 · GitHub) but the
bluepill_f103c8 target (here) is not including
spl in the
frameworks . I’ll look into it why it’s not activated later the day.
Pull-Request is on its way, see Add SPL support for bluepill board by maxgerhardt · Pull Request #226 · platformio/platform-ststm32 · GitHub. Will be available after merging and release.
OK~Thank you for your answer.
Hello, I am very grateful for your reply. I changed my local “bluepill_f103c8.json” file according to the link you gave. When compiling, I was prompted with the missing “stm32f10x.h”. I feel that the SPL of STM32F1 is not downloaded.
Do I need to download the SPL library from the ST official website and add it to these directories?
Sorry, I didn’t read the text on GITHUB seriously. Now I have added the file, but I still have a question: Why is the STM32F1 series chip used so much, and PlatFormIO does not support the SPL library of the STM32F1 series chip?
I can upload my
framework-spl files in the evening.
SPL is deprecated by STM (see here) and they recommend to use LL (low-level) or STM32Cube libraries.
framework-spl can be downloaded from https://drive.google.com/open?id=1HTh7bK_5nY7-EjgIgb7_S584TIrOQ_cj.
Thank you very much for your answer, I have copied the file to the correct place and compiled it correctly. In this case, can I use the SPL library of the entire STM32F1 series?
Not directly, you have to enable the board JSON for it. If you take a look at the diff for the
bluepill_f103c8.json file (here), then you will see that it
- adds the macro
The first change will cause PlatformIO to allow writing
framework = spl without aborting. The second macro is needed for the SPL framework to identifiy the device class. If you look into
framework-spl\stm32\cmsis\variants\stm32f1\system_stm32f10x.c you’ll see there are macros which control the target CPU frequency (for STM32F103C8: 72MHz after PLL from 8MHz quartz crystal) and other stuff.
#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL) /* #define STM32F10X_LD */ /*!< STM32F10X_LD: STM32 Low density devices */ /* #define STM32F10X_LD_VL */ /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */ /* #define STM32F10X_MD */ /*!< STM32F10X_MD: STM32 Medium density devices */ /* #define STM32F10X_MD_VL */ /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */ /* #define STM32F10X_HD */ /*!< STM32F10X_HD: STM32 High density devices */ /* #define STM32F10X_HD_VL */ /*!< STM32F10X_HD_VL: STM32 High density value line devices */ /* #define STM32F10X_XL */ /*!< STM32F10X_XL: STM32 XL-density devices */ /* #define STM32F10X_CL */ /*!< STM32F10X_CL: STM32 Connectivity line devices */ #endif /* Tip: To avoid modifying this file each time you need to switch between these devices, you can define the device in your toolchain compiler preprocessor. - Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes. - Low-density value line devices are STM32F100xx microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes. - Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes. - Medium-density value line devices are STM32F100xx microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes. - High-density devices are STM32F101xx and STM32F103xx microcontrollers where the Flash memory density ranges between 256 and 512 Kbytes. - High-density value line devices are STM32F100xx microcontrollers where the Flash memory density ranges between 256 and 512 Kbytes. - XL-density devices are STM32F101xx and STM32F103xx microcontrollers where the Flash memory density ranges between 512 and 1024 Kbytes. - Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers. */
So for the STM32F103C8 it says “Mainstream Performance line” and "medium-density ", so we conclude that we need the
The other thing is the startup assembler code located
framework-spl\stm32\cmsis\variants\stm32f1\startup_stm32f10x_md.s. I copied the startup file for the MD device class because I know it was the correct one for the bluepill. Other boards require other startup files. These files come from the SPL download
I haven’t looked into how the builder script here finds out which
.s file to use so I just assumed it would try to assemble all of them; that’s why there should be only one
.s file in there. You can do the same (only place the correct startup file in the folder) or we’d need to adapt the builder script to only select the correct startup file. For that the script would have to know which device class we have.
The other STM32 F0/3/4 and L1 don’t have this problem, they all have nice unified startup files. I wonder why that’s so for the F1 class.
Thank you for your answer~（膜拜大佬:grinning:）
第一步：将framework-spl的库下载下来放到C:\Users\Administrator.platformio\packages这个路径下， maxgerhardt把这个文件放到谷歌云盘去了，我们中国是不能访问外网的 ，我待会 给你 发个链接。然后更改这个文件bluepill_f103c8.json，这个文件在C:\Users\Administrator.platformio\platforms\ststm32\boards这个文件下，Stm32 Standard Library - #15 by maxgerhardt
第一步：把framework-spl解压放到C:\Users\Administrator.platformio\packages这个文件下。百度网盘地址：链接: 百度网盘-链接不存在 提取码: vrq6 复制这段内容后打开百度网盘手机App，操作更方便哦
第二步: 把ststm32解压放到C:\Users\Administrator.platformio\platforms这个文件下，如果有这个文件，则替换掉它。百度网盘地址：链接: 百度网盘-链接不存在 提取码: gkq3 复制这段内容后打开百度网盘手机App，操作更方便哦