Hi, all!
I’m working with a stm32l010c6t6. I’d like to understand some build variables inclusion.
I had a lot of problems doing platformio work with stm32l010c6t6 and arduino framework, mainly in “variant.h” and “PeripheralPins.h” inclusion. In my old platformio.ini, I used the board_build.core = stm32l0
and this results in this inclusion errors. After changing to the following platformio.ini, some problems vanish.
platformio.ini
[env:stm32l0]
platform = ststm32
framework = arduino
board = stm32l010c6
upload_protocol = serial
build_flags =
-DPIO_FRAMEWORK_ARDUINO_ENABLE_MASS_STORAGE
-DARDUINO_GENERIC_L010C6TX
The build don’t work if remove the “ARDUINO_GENERIC_L010C6TX” from the platformio.ini
I had to create this board json file in the project folder
stm32l010c6.json
{
"build": {
"cpu": "cortex-m0plus",
"extra_flags": "-DSTM32L0xx -DSTM32L010x6",
"f_cpu": "32000000L",
"framework_extra_flags": {
"arduino": "-D__CORTEX_SC=0"
},
"mcu": "stm32l010c6t6",
"product_line": "STM32L010x6",
"variant": "STM32L0xx/L010C6T"
},
"debug": {
"default_tools": [
"stlink"
],
"jlink_device": "STM32L010C6",
"onboard_tools": [
"stlink"
],
"openocd_target": "stm32l0",
"svd_path": "STM32L0x0.svd"
},
"frameworks": [
"arduino",
"stm32cube"
],
"name": "STM32L010C6 (8k RAM. 32k Flash)",
"upload": {
"maximum_ram_size": 8192,
"maximum_size": 32768,
"protocol": "serial",
"protocols": [
"blackmagic",
"cmsis-dap",
"dfu",
"jlink",
"serial",
"stlink"
]
},
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l010c6.html",
"vendor": "ST"
}
When I built it, I had this following error:
Processing stm32l0 (platform: ststm32; framework: arduino; board: stm32l010c6)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/stm32l010c6.html
PLATFORM: ST STM32 (17.3.0) > STM32L010C6 (8k RAM. 32k Flash)
HARDWARE: STM32L010C6T6 32MHz, 8KB RAM, 32KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
- framework-arduinoststm32 @ 4.20701.0 (2.7.1)
- framework-cmsis @ 2.50900.0 (5.9.0)
- toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/stm32l0/FrameworkArduinoVariant/PeripheralPins.c.o
Compiling .pio/build/stm32l0/FrameworkArduinoVariant/generic_clock.c.o
Compiling .pio/build/stm32l0/FrameworkArduinoVariant/variant_generic.cpp.o
<command-line>: fatal error: variant_STM32L010C6.h: No such file or directory
*****************************************************************************
* Looking for variant_STM32L010C6.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:variant_STM32L010C6.h"
* Web > https://registry.platformio.org/search?q=header:variant_STM32L010C6.h
*
*****************************************************************************
compilation terminated.
Compiling .pio/build/stm32l0/SrcWrapper/src/HAL/stm32yyxx_hal.c.o
<command-line>: fatal error: variant_STM32L010C6.h: No such file or directory
*****************************************************************************
* Looking for variant_STM32L010C6.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:variant_STM32L010C6.h"
* Web > https://registry.platformio.org/search?q=header:variant_STM32L010C6.h
*
*****************************************************************************
compilation terminated.
Compiling .pio/build/stm32l0/SrcWrapper/src/HAL/stm32yyxx_hal_adc.c.o
*** [.pio/build/stm32l0/FrameworkArduinoVariant/PeripheralPins.c.o] Error 1
*** [.pio/build/stm32l0/FrameworkArduinoVariant/generic_clock.c.o] Error 1
<command-line>: fatal error: variant_STM32L010C6.h: No such file or directory
The default contents of this stm32 variant are:
and do not have a file “~/.platformio/packages/framework-arduinoststm32/variants/STM32L0xx/L010C6T/variant_STM32L010C6.h” as default. I create an empty file with this name and the error vanishes. If I rename “variant_generic.h” to “variant_STM32L010C6.h”, I have an error too.
With a verbose build routine, I have the following output
... .pio/build/stm32l0/FrameworkArduino/USBSerial.cpp.o -c -std=gnu++17 -fno-threadsafe-statics -fno-rtti -fno-exceptions -fno-use-cxa-atexit -mcpu=cortex-m0plus -mthumb -Os -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DPLATFORMIO=60115 -DSTM32L0xx -DSTM32L010x6 -DPIO_FRAMEWORK_ARDUINO_ENABLE_MASS_STORAGE -DARDUINO_GENERIC_L010C6TX -DSTM32L0xx -DARDUINO=10808 -DARDUINO_ARCH_STM32 -DNDEBUG -DARDUINO_STM32L010C6 -DBOARD_NAME=\"STM32L010C6\" -DHAL_UART_MODULE_ENABLED -DUSE_FULL_LL_DRIVER **-DVARIANT_H=\"variant_STM32L010C6.h\"** -D__CORTEX_SC=0 -DVECT_TAB_OFFSET=0x0 ...
and “VARIANT_H” have the same name as my board. If I change the board name, the VARIANT_H changes to.
What is the “right” way to configure this mcu? I think that creating an empty file only to vanish errors is not the best way. I believe I left something in the configuration file. I didn’t find documentation in Platformio or other sources that helped me.
Thank you for your time!
Mario