Hi all,
I hope to tap the knowledge of the community, since I am hitting a brick wall. I want to set up a custom board for a generic STM32G031G8U6. So far, I setup the board file (generic_stm32g031g8u6.json) according to what I could find on the internet:
{
"build": {
"core": "stm32",
"cpu": "cortex-m0plus",
"extra_flags": "-DSTM32G0 -DSTM32G0xx -DSTM32G031xx",
"f_cpu": "64000000L",
"framework_extra_flags": {
"arduino": "-D__CORTEX_SC=0"
},
"mcu": "stm32g031g8",
"product_line": "STM32G031xx",
"variant": "STM32G0xx/G031K(4-6-8)(T-U)_G041K(6-8)(T-U)"
},
"debug": {
"default_tools": [
"stlink"
],
"jlink_device": "STM32G031G8",
"onboard_tools": [
"stlink"
],
"openocd_target": "stm32g0x",
"svd_path": "STM32G031.svd"
},
"frameworks": [
"arduino",
"cmsis",
"stm32cube"
],
"name": "ST NUCLEO-G031G8",
"upload": {
"maximum_ram_size": 8192,
"maximum_size": 65536,
"protocol": "stlink",
"protocols": [
"blackmagic",
"cmsis-dap",
"dfu",
"jlink",
"serial",
"stlink",
"mbed"
]
},
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32g031g8.html",
"vendor": "FB"
}
This is basically a copy of the nucleo_g031k8.json.
My platformio.ini for a project with this board looks as expected:
[env]
boards_dir = ./boards
[env:custom_stm32g031g8u6]
platform = ststm32
board = generic_stm32g031g8u6
; board_build.ldscript = ./boards/ldscript.ld
framework = arduino
upload_protocol = stlink
upload_port = stlink
When I try to build a blank project, it compiles all the necessary files, as far as I can see, but then the linker throws a lot of errors:
/Users/fb/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: warning: .pio/build/custom_stm32g031g8u6/firmware.elf has a LOAD segment with RWX permissions
/Users/fb/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/custom_stm32g031g8u6/SrcWrapper/src/stm32/hw_config.c.o: in function `hw_config_init':
hw_config.c:(.text.hw_config_init+0xe): undefined reference to `SystemClock_Config'
/Users/fb/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/custom_stm32g031g8u6/libFrameworkArduino.a(HardwareSerial.cpp.o): in function `HardwareSerial::setRx(unsigned long)':
HardwareSerial.cpp:(.text._ZN14HardwareSerial5setRxEm+0x4c): undefined reference to `digitalPin'
/Users/fb/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: HardwareSerial.cpp:(.text._ZN14HardwareSerial5setRxEm+0x50): undefined reference to `analogInputPin'
/Users/fb/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/custom_stm32g031g8u6/libFrameworkArduino.a(HardwareSerial.cpp.o): in function `HardwareSerial::setTx(unsigned long)':
HardwareSerial.cpp:(.text._ZN14HardwareSerial5setTxEm+0x4c): undefined reference to `digitalPin'
/Users/fb/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: HardwareSerial.cpp:(.text._ZN14HardwareSerial5setTxEm+0x50): undefined reference to `analogInputPin'
/Users/fb/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/custom_stm32g031g8u6/libFrameworkArduino.a(HardwareSerial.cpp.o): in function `HardwareSerial::HardwareSerial(void*, HalfDuplexMode_t)':
HardwareSerial.cpp:(.text._ZN14HardwareSerialC2EPv16HalfDuplexMode_t+0x90): undefined reference to `analogInputPin'
/Users/fb/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld: HardwareSerial.cpp:(.text._ZN14HardwareSerialC2EPv16HalfDuplexMode_t+0x98): undefined reference to `digitalPin'
collect2: error: ld returned 1 exit status
*** [.pio/build/custom_stm32g031g8u6/firmware.elf] Error 1
I tried adding a linker script from CubeIDE, therefore the commented boards_build.ldscript definition in the platformio.ini, but with this, the result is the same.
I think I am missing something obvious here, but I can’t see it. Any help would be greatly appreciated.
Cheers