Stm32 g030f6 board config

Hi,

I would like to use the stm32 G030F6 for developing power saving application,

which board config should I use

thanks!

PlatformIO does currently not have the board definition for a G030F6 (boards), but it can be created.

I’ve created a test project at GitHub - maxgerhardt/pio-g030f6-test, can you test it?

1 Like

Sure, I could test and report the result here, could you help to create another test project for STM32F031F6P7?

thanks

Sure, I’ve added the board definition for the F031 board too (not G031). The platformio.ini now has two environments, genericSTM32G030F6 and genericSTM32F031F6, you can chose between them as normal through the project environment switcher.

Hello @maxgerhardt I’ve test it successfully. and thanks

may I change the framework to stm32?

What framework is called “STM32”? You mean STM32Cube with the STM32HAL?

Yes @maxgerhardt I mean the STM32cube framework

The board files already declared stm32cube compatibility, so you could have created the example yourself by duplicating the environments and changing framework = arduino to framework = stm32cube.

I’ve updated the project again to have both Arduino and STM32Cube examples in the same project.

Hi
I’ve tried to replicate this solution for my stm32-g030f6 board, I created the stm32g030f6p6.json file in the “%Users%.platformio\platforms\ststm32\boards” directory and made the following edit

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m0plus",
    "extra_flags": "-DSTM32G0xx -DSTM32G030xx -DVARIANT_H=\\\"variant_generic.h\\\"",
    "f_cpu": "64000000L",
    "framework_extra_flags": {
      "arduino": "-D__CORTEX_SC=0"
    },
    "mcu": "stm32g030f6p6",
    "product_line": "STM32G030xx",
    "variant": "STM32G0xx/G030F6P"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32G030F6",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32g0x",
    "svd_path": "STM32G030.svd"
  },
  "frameworks": [
    "arduino",
    "cmsis",
    "stm32cube"
  ],
  "name": "Generic STM32G030F6",
  "upload": {
    "maximum_ram_size": 8192,
    "maximum_size": 32768,
    "protocol": "stlink",
    "protocols": [
      "blackmagic",
      "cmsis-dap",
      "dfu",
      "jlink",
      "serial",
      "stlink",
      "mbed"
    ]
  },
  "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32g030f6.html",
  "vendor": "ST"
}

however when I create the new project with the Arduino framework, the main.c default code could not compile due to a reference error
the error is located in the “%USER%.platformio\packages\framework-arduinoststm32\cores\arduino\variant.h” path
it can not find any file with the name of #include "variant_STM32G030F6P6.h"
I followed the GitHub solution in this link
and change it to #include "variant_generic.h"

however, when I compile the code, it throws considerable errors to the definition of Arduino’s basic function

Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\LL\stm32yyxx_ll_utils.c.o
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\new.cpp.o
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\PortNames.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\analog.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\bootloader.c.o
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\clock.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\core_callback.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\dwt.c.o
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\hw_config.c.o
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\interrupt.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\otp.c.o
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\pinmap.c.o
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\stm32_def.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\system_stm32yyxx.c.o
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\timer.c.o
<command-line>: warning: "VARIANT_H" redefined
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\stm32\uart.c.o
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\SrcWrapper\src\syscalls.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\src\main.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\Print.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\RingBuffer.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\Tone.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\USBSerial.cpp.o
<command-line>: warning: "VARIANT_H" redefined
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\VirtIOSerial.cpp.o
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\WInterrupts.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\WMath.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\WSerial.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\WString.cpp.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\abi.cpp.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\avr\dtostrf.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\board.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\core_debug.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\hooks.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\itoa.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\main.cpp.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\pins_arduino.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\device.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\generic\condition.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\generic\cortexm\sys.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\generic\generic_device.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\generic\generic_init.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\generic\generic_io.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\generic\generic_shmem.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\generic\time.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\init.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\io.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\log.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\libmetal\shmem.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\mbox_ipcc.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\open-amp\remoteproc\remoteproc_virtio.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\open-amp\rpmsg\rpmsg.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\open-amp\rpmsg\rpmsg_virtio.c.o
<command-line>: warning: "VARIANT_H" redefined
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\openamp.c.o
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\rsc_table.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\virt_uart.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\virtio\virtio.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\virtio\virtqueue.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\virtio_buffer.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\OpenAMP\virtio_log.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\startup_stm32yyxx.S.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\cdc\cdc_queue.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\cdc\usbd_cdc.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\cdc\usbd_cdc_if.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\hid\usbd_hid_composite.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\hid\usbd_hid_composite_if.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\usb_device_core.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\usb_device_ctlreq.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\usb_device_ioreq.c.o
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\usbd_conf.c.o
<command-line>: warning: "VARIANT_H" redefined
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\usbd_desc.c.o
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\usbd_ep_conf.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\stm32\usb\usbd_if.c.o
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\wiring_analog.c.o
<command-line>: warning: "VARIANT_H" redefined
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\wiring_digital.c.o
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\wiring_pulse.cpp.o
<command-line>: warning: "VARIANT_H" redefined
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\wiring_shift.c.o
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Compiling .pio\build\stm32g030f6p6\FrameworkArduino\wiring_time.c.o
<command-line>: warning: "VARIANT_H" redefined
<command-line>: note: this is the location of the previous definition
Linking .pio\build\stm32g030f6p6\firmware.elf
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/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'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(HardwareSerial.cpp.o): in function `HardwareSerial::setRx(unsigned long)':
HardwareSerial.cpp:(.text._ZN14HardwareSerial5setRxEm+0x48): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: HardwareSerial.cpp:(.text._ZN14HardwareSerial5setRxEm+0x4c): undefined reference to `analogInputPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(HardwareSerial.cpp.o): in function `HardwareSerial::setTx(unsigned long)':
HardwareSerial.cpp:(.text._ZN14HardwareSerial5setTxEm+0x48): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: HardwareSerial.cpp:(.text._ZN14HardwareSerial5setTxEm+0x4c): undefined reference to `analogInputPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(HardwareSerial.cpp.o): in function `HardwareSerial::HardwareSerial(void*, HalfDuplexMode_t)':
HardwareSerial.cpp:(.text._ZN14HardwareSerialC2EPv16HalfDuplexMode_t+0x90): undefined reference to `analogInputPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: HardwareSerial.cpp:(.text._ZN14HardwareSerialC2EPv16HalfDuplexMode_t+0x98): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(wiring_digital.c.o): in function `pinMode':
wiring_digital.c:(.text.pinMode+0x9c): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: wiring_digital.c:(.text.pinMode+0xa8): undefined reference to `analogInputPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(wiring_digital.c.o): in function `digitalWrite':
wiring_digital.c:(.text.digitalWrite+0x68): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: wiring_digital.c:(.text.digitalWrite+0x74): undefined reference to `analogInputPin'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\stm32g030f6p6\firmware.elf] Error 1
========================================================================================== [FAILED] Took 95.77 seconds ==========================================================================================

 *  The terminal process "C:\Users\lkeyn\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 


Don’t put the VARIANT_H definition in extra flags like this, if you look at newer board definitions you’ll see

I did add & remove VARIANT_H in JSON file, but it makes no difference and don’t know why make the following error

Compiling .pio\build\stm32g030f6p6\FrameworkArduino\wiring_time.c.o
Linking .pio\build\stm32g030f6p6\firmware.elf
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/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'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(HardwareSerial.cpp.o): in function `HardwareSerial::setRx(unsigned long)':
HardwareSerial.cpp:(.text._ZN14HardwareSerial5setRxEm+0x48): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: HardwareSerial.cpp:(.text._ZN14HardwareSerial5setRxEm+0x4c): undefined reference to `analogInputPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(HardwareSerial.cpp.o): in function `HardwareSerial::setTx(unsigned long)':
HardwareSerial.cpp:(.text._ZN14HardwareSerial5setTxEm+0x48): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: HardwareSerial.cpp:(.text._ZN14HardwareSerial5setTxEm+0x4c): undefined reference to `analogInputPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(HardwareSerial.cpp.o): in function `HardwareSerial::HardwareSerial(void*, HalfDuplexMode_t)':
HardwareSerial.cpp:(.text._ZN14HardwareSerialC2EPv16HalfDuplexMode_t+0x90): undefined reference to `analogInputPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: HardwareSerial.cpp:(.text._ZN14HardwareSerialC2EPv16HalfDuplexMode_t+0x98): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(wiring_digital.c.o): in function `pinMode':
wiring_digital.c:(.text.pinMode+0x9c): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: wiring_digital.c:(.text.pinMode+0xa8): undefined reference to `analogInputPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/stm32g030f6p6/libFrameworkArduino.a(wiring_digital.c.o): in function `digitalWrite':
wiring_digital.c:(.text.digitalWrite+0x68): undefined reference to `digitalPin'
c:/users/lkeyn/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: wiring_digital.c:(.text.digitalWrite+0x74): undefined reference to `analogInputPin'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\stm32g030f6p6\firmware.elf] Error 1

It’s not hitting the

definition because ARDUINO_GENERIC_G030F6PX is not defined because the board file has an unexpected name: It should be genericSTM32G030F6.json. There’s python logic that looks at the name / id of the board and generates identifications macros that would generate this ARDUINO_<board id> macro here.

If you do that, the variant_h definition is also reduant.

boards/genericSTM32G030F6P6.json:

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m0plus",
    "extra_flags": "-DSTM32G0xx -DSTM32G030xx",
    "f_cpu": "64000000L",
    "framework_extra_flags": {
      "arduino": "-D__CORTEX_SC=0"
    },
    "mcu": "stm32g030f6p6",
    "product_line": "STM32G030xx",
    "variant": "STM32G0xx/G030F6P"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32G030F6",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32g0x",
    "svd_path": "STM32G030.svd"
  },
  "frameworks": [
    "arduino",
    "cmsis",
    "stm32cube"
  ],
  "name": "Generic STM32G030F6",
  "upload": {
    "maximum_ram_size": 8192,
    "maximum_size": 32768,
    "protocol": "stlink",
    "protocols": [
      "blackmagic",
      "cmsis-dap",
      "dfu",
      "jlink",
      "serial",
      "stlink",
      "mbed"
    ]
  },
  "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32g030f6.html",
  "vendor": "ST"
}

Alternatively, keep your current board JSON file name and add -DARDUINO_GENERIC_G030F6PX to the extra_flags.

{
  "build": {
    "core": "stm32",
    "arduino": {
      "variant_h": "variant_generic.h"
    },
    "cpu": "cortex-m0plus",
    "extra_flags": "-DSTM32G0xx -DSTM32G030xx -DARDUINO_GENERIC_G030F6PX",
    "f_cpu": "64000000L",
    "framework_extra_flags": {
      "arduino": "-D__CORTEX_SC=0"
    },
    "mcu": "stm32g030f6p6",
    "product_line": "STM32G030xx",
    "variant": "STM32G0xx/G030F6P"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32G030F6",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32g0x",
    "svd_path": "STM32G030.svd"
  },
  "frameworks": [
    "arduino",
    "cmsis",
    "stm32cube"
  ],
  "name": "Generic STM32G030F6",
  "upload": {
    "maximum_ram_size": 8192,
    "maximum_size": 32768,
    "protocol": "stlink",
    "protocols": [
      "blackmagic",
      "cmsis-dap",
      "dfu",
      "jlink",
      "serial",
      "stlink",
      "mbed"
    ]
  },
  "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32g030f6.html",
  "vendor": "ST"
}
1 Like

Hi @maxgerhardt,

I’m trying to do the same thing for a custom board based on STM32G031F8P3, so I cloned your repository and from your boards JSON files I created this one:

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m0plus",
    "extra_flags": "-DSTM32G0xx -DSTM32G031xx -DARDUINO_GENERIC_G031F8P",
    "f_cpu": "64000000L",
    "framework_extra_flags": {
      "arduino": "-D__CORTEX_SC=0"
    },
    "mcu": "stm32g031f8p3",
    "product_line": "STM32G031xx",
    "variant": "STM32G0xx/G031F(4-6-8)P_G031Y8Y_G041F(6-8)P_G041Y8Y"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32G031F8",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32g0x",
    "svd_path": "STM32G031.svd"
  },
  "frameworks": [
    "arduino",
    "cmsis",
    "stm32cube"
  ],
  "name": "FloppoBoard rev3.1 64k STM32G031F8P3",
  "upload": {
    "maximum_ram_size": 8192,
    "maximum_size": 65536,
    "protocol": "serial",
    "protocols": [
      "blackmagic",
      "cmsis-dap",
      "dfu",
      "jlink",
      "serial",
      "stlink",
      "mbed"
    ]
  },
  "url": "https://github.com/FloppyO1/Floppy_Boards",
  "vendor": "FloppyLab"
}

and for platformio.ini I used this env:

[env:genericSTM32G031F8P3_arduino]
platform = ststm32
board = genericSTM32G031F8P3
framework = arduino
board_build.ldscript = ldscript_g0.ld
build_src_filter = +<*> -<main_stm32cube.c>

After some failed tries, I try to compile with yours envs and the errors are the same:

Processing genericSTM32G030F6_arduino (platform: ststm32; board: genericSTM32G030F6; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32G030F6.html
PLATFORM: ST STM32 (6.1.1) > Generic STM32G030F6
HARDWARE: STM32G030F6P6 64MHz, 8KB RAM, 32KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduinoststm32 @ 4.10800.200207 (1.8.0)
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 10 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\genericSTM32G030F6_arduino\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\genericSTM32G030F6_arduino\FrameworkArduino\HardwareTimer.cpp.o
Compiling .pio\build\genericSTM32G030F6_arduino\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\genericSTM32G030F6_arduino\FrameworkArduino\Print.cpp.o
Compiling .pio\build\genericSTM32G030F6_arduino\FrameworkArduino\Stream.cpp.o
Compiling .pio\build\genericSTM32G030F6_arduino\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\genericSTM32G030F6_arduino\FrameworkArduino\WInterrupts.cpp.o
Compiling .pio\build\genericSTM32G030F6_arduino\FrameworkArduino\WMath.cpp.o
In file included from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32G0xx_HAL_Driver\Inc/stm32g0xx_hal.h:30,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32G0xx\Include/stm32g0xx.h:171,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/clock.h:43,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring_time.h:23,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\Arduino.h:32,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\HardwareSerial.cpp:26:
C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\STM32G0xx/stm32g0xx_hal_conf.h:4:10: fatal error: variant.h: No such file or directory

*****************************************************************
* Looking for variant.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:variant.h"
* Web  > https://registry.platformio.org/search?q=header:variant.h
*
*****************************************************************

    4 | #include "variant.h"
      |          ^~~~~~~~~~~
In file included from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32G0xx_HAL_Driver\Inc/stm32g0xx_hal.h:30,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32G0xx\Include/stm32g0xx.h:171,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/clock.h:43,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring_time.h:23,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\Arduino.h:32,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\HardwareTimer.cpp:26:
C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\STM32G0xx/stm32g0xx_hal_conf.h:4:10: fatal error: variant.h: No such file or directory

*****************************************************************
* Looking for variant.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:variant.h"
* Web  > https://registry.platformio.org/search?q=header:variant.h
*
*****************************************************************

    4 | #include "variant.h"
      |          ^~~~~~~~~~~
compilation terminated.
In file included from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32G0xx_HAL_Driver\Inc/stm32g0xx_hal.h:30,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32G0xx\Include/stm32g0xx.h:171,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/clock.h:43,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring_time.h:23,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\Arduino.h:32,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\Stream.cpp:25:
C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\STM32G0xx/stm32g0xx_hal_conf.h:4:10: fatal error: variant.h: No such file or directory

*****************************************************************
* Looking for variant.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:variant.h"
* Web  > https://registry.platformio.org/search?q=header:variant.h
*
*****************************************************************

    4 | #include "variant.h"
      |          ^~~~~~~~~~~
compilation terminated.
compilation terminated.
In file included from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32G0xx_HAL_Driver\Inc/stm32g0xx_hal.h:30,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32G0xx\Include/stm32g0xx.h:171,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/clock.h:43,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino/wiring_time.h:23,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino/wiring.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino/Arduino.h:32,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\IPAddress.cpp:20:
C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\STM32G0xx/stm32g0xx_hal_conf.h:4:10: fatal error: variant.h: No such file or directory

*****************************************************************
* Looking for variant.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:variant.h"
* Web  > https://registry.platformio.org/search?q=header:variant.h
*
*****************************************************************

    4 | #include "variant.h"
      |          ^~~~~~~~~~~
compilation terminated.
In file included from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32G0xx_HAL_Driver\Inc/stm32g0xx_hal.h:30,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32G0xx\Include/stm32g0xx.h:171,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/clock.h:43,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring_time.h:23,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\Arduino.h:32,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\Print.cpp:27:
C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\STM32G0xx/stm32g0xx_hal_conf.h:4:10: fatal error: variant.h: No such file or directory

*****************************************************************
* Looking for variant.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:variant.h"
* Web  > https://registry.platformio.org/search?q=header:variant.h
*
*****************************************************************

    4 | #include "variant.h"
      |          ^~~~~~~~~~~
compilation terminated.
In file included from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32G0xx_HAL_Driver\Inc/stm32g0xx_hal.h:30,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32G0xx\Include/stm32g0xx.h:171,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/clock.h:43,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring_time.h:23,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\Arduino.h:32,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\Tone.cpp:22:
C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\STM32G0xx/stm32g0xx_hal_conf.h:4:10: fatal error: variant.h: No such file or directory

*****************************************************************
* Looking for variant.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:variant.h"
* Web  > https://registry.platformio.org/search?q=header:variant.h
*
*****************************************************************

    4 | #include "variant.h"
      |          ^~~~~~~~~~~
compilation terminated.
*** [.pio\build\genericSTM32G030F6_arduino\FrameworkArduino\Stream.cpp.o] Error 1
*** [.pio\build\genericSTM32G030F6_arduino\FrameworkArduino\HardwareSerial.cpp.o] Error 1
*** [.pio\build\genericSTM32G030F6_arduino\FrameworkArduino\HardwareTimer.cpp.o] Error 1
*** [.pio\build\genericSTM32G030F6_arduino\FrameworkArduino\IPAddress.cpp.o] Error 1
*** [.pio\build\genericSTM32G030F6_arduino\FrameworkArduino\Print.cpp.o] Error 1
*** [.pio\build\genericSTM32G030F6_arduino\FrameworkArduino\Tone.cpp.o] Error 1
In file included from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32G0xx_HAL_Driver\Inc/stm32g0xx_hal.h:30,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32G0xx\Include/stm32g0xx.h:171,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/clock.h:43,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring_time.h:23,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\wiring.h:38,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\Arduino.h:32,
                 from C:\Users\alanm\.platformio\packages\framework-arduinoststm32\cores\arduino\WInterrupts.cpp:20:
C:\Users\alanm\.platformio\packages\framework-arduinoststm32\system\STM32G0xx/stm32g0xx_hal_conf.h:4:10: fatal error: variant.h: No such file or directory

*****************************************************************
* Looking for variant.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:variant.h"
* Web  > https://registry.platformio.org/search?q=header:variant.h
*
*****************************************************************

    4 | #include "variant.h"
      |          ^~~~~~~~~~~
compilation terminated.
*** [.pio\build\genericSTM32G030F6_arduino\FrameworkArduino\WInterrupts.cpp.o] Error 1
====================================================================================== [FAILED] Took 4.94 seconds ======================================================================================

Environment                 Status    Duration
--------------------------  --------  ------------
genericSTM32G030F6_arduino  FAILED    00:00:04.942
================================================================================= 1 failed, 0 succeeded in 00:00:04.942 =================================================================================

For Arduino Framework, and:

Processing genericSTM32G030F6_stm32cube (platform: ststm32; board: genericSTM32G030F6; framework: stm32cube)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32G030F6.html
PLATFORM: ST STM32 (6.1.1) > Generic STM32G030F6
HARDWARE: STM32G030F6P6 64MHz, 8KB RAM, 32KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-stm32cube @ 2.0.200813
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Error: Cannot find template file to configure framework!
========================================================================= [FAILED] Took 1.03 seconds =========================================================================

Environment                   Status    Duration
----------------------------  --------  ------------
genericSTM32G030F6_stm32cube  FAILED    00:00:01.027
==================================================================== 1 failed, 0 succeeded in 00:00:01.027 ====================================================================

for the STMCube Framework

Can you help me fixing those errors??
Another question is about the upload protocol: stm32 platform allows serial programming, eg. a CH340 chip based programmer like the Arduino IDE does?

Alan

This macro name should be ARDUINO_GENERIC_G041F8PX because that’s what it’s looking for

This file name is not correct. You must correct the board definition to tell it to use the existing variant_generic.h by adding

to the build object.

Hi and thanks for your reply, but now I got a new error that is more difficult to understand that the previous one:

Processing genericSTM32G031F8P3_arduino (board: genericSTM32G031F8P3; platform: ststm32; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32G031F8P3.html
PLATFORM: ST STM32 (15.4.1) > FloppoBoard rev3.1 64k STM32G031F8P3
HARDWARE: STM32G031F8P3 64MHz, 8KB RAM, 64KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduinoststm32 @ 4.20200.221104 (2.2.0)
 - framework-cmsis @ 2.50700.210515 (5.7.0)
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 11 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\genericSTM32G031F8P3_arduino\FrameworkArduinoVariant\PeripheralPins.c.o
Compiling .pio\build\genericSTM32G031F8P3_arduino\FrameworkArduinoVariant\generic_clock.c.o
Compiling .pio\build\genericSTM32G031F8P3_arduino\FrameworkArduinoVariant\variant_generic.cpp.o
Compiling .pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal.c.o
<command-line>: error: missing '(' after predicate
<command-line>: error: missing '(' after predicate
Compiling .pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal_adc.c.o
<command-line>: error: missing '(' after predicate
Compiling .pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal_adc_ex.c.o
<command-line>: error: missing '(' after predicate
Compiling .pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal_can.c.o
Compiling .pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal_cec.c.o
<command-line>: error: missing '(' after predicate
<command-line>: error: missing '(' after predicate
C:\Users\alanm\.platformio\packages\framework-arduinoststm32\variants\STM32G0xx\G031F(4-6-8)P_G031Y8Y_G041F(6-8)P_G041Y8Y\generic_clock.c: In function 'SystemClock_Config':
C:\Users\alanm\.platformio\packages\framework-arduinoststm32\variants\STM32G0xx\G031F(4-6-8)P_G031Y8Y_G041F(6-8)P_G041Y8Y\generic_clock.c:27:2: warning: #warning "SystemClock_Config() is empty. Default clock at reset is used." [-Wcpp]
   27 | #warning "SystemClock_Config() is empty. Default clock at reset is used."
      |  ^~~~~~~
<command-line>: error: missing '(' after predicate
<command-line>: error: missing '(' after predicate
*** [.pio\build\genericSTM32G031F8P3_arduino\FrameworkArduinoVariant\generic_clock.c.o] Error 1
*** [.pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal_can.c.o] Error 1
*** [.pio\build\genericSTM32G031F8P3_arduino\FrameworkArduinoVariant\PeripheralPins.c.o] Error 1
*** [.pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal_adc.c.o] Error 1
*** [.pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal.c.o] Error 1
*** [.pio\build\genericSTM32G031F8P3_arduino\FrameworkArduinoVariant\variant_generic.cpp.o] Error 1
*** [.pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal_adc_ex.c.o] Error 1
*** [.pio\build\genericSTM32G031F8P3_arduino\SrcWrapper\src\HAL\stm32yyxx_hal_cec.c.o] Error 1
=================================================== [FAILED] Took 2.98 seconds ===================================================

Environment                   Status    Duration
----------------------------  --------  ------------
genericSTM32G031F8P3_arduino  FAILED    00:00:02.976
============================================== 1 failed, 0 succeeded in 00:00:02.976 ==============================================

For the CH340 support you have some information about???

[EDIT]: in my case I would like to compile for an STM32G031F8P3 so, if I understood well the mechanism, I should define the ARDUINO_GENERIC_G031F8PX macro, correct??

Alan

I don’t see the problem with Arduino – this board definition as genericSTM32G031F8P3.json works just fine

{
  "build": {
    "arduino": {
      "variant_h": "variant_generic.h"
    },
    "core": "stm32",
    "cpu": "cortex-m0plus",
    "extra_flags": "-DSTM32G0xx -DSTM32G031xx -DARDUINO_GENERIC_G031F8PX",
    "f_cpu": "64000000L",
    "framework_extra_flags": {
      "arduino": "-D__CORTEX_SC=0"
    },
    "mcu": "stm32g031f8p3",
    "product_line": "STM32G031xx",
    "variant": "STM32G0xx/G031F(4-6-8)P_G031Y8Y_G041F(6-8)P_G041Y8Y"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32G031F8",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32g0x",
    "svd_path": "STM32G031.svd"
  },
  "frameworks": [
    "arduino",
    "cmsis",
    "stm32cube"
  ],
  "name": "FloppoBoard rev3.1 64k STM32G031F8P3",
  "upload": {
    "maximum_ram_size": 8192,
    "maximum_size": 65536,
    "protocol": "serial",
    "protocols": [
      "blackmagic",
      "cmsis-dap",
      "dfu",
      "jlink",
      "serial",
      "stlink",
      "mbed"
    ]
  },
  "url": "https://github.com/FloppyO1/Floppy_Boards",
  "vendor": "FloppyLab"
}

and that’s with no board_build.ldscript modifications, just

[env:genericSTM32G031F8P3]
platform = ststm32
board = genericSTM32G031F8P3
framework = arduino

In the same way,

[env:genericSTM32G031F8P3]
platform = ststm32
board = genericSTM32G031F8P3
framework = stm32cube

works with that, too.

Yes, that’s why there’s serial in the board json’s upload protocol array. If your chip has a built in serial bootloader and you boot into it (BOOT0 / BOOT1 pins pulled to GND/VCC in some manner) and you connect any working serial adapter to the specified UART bootloader pins (STM has documentation on it), you can upload to it.

Thanks,
I wrote ARDUINO_GENERIC_G031F8PX instead of -DARDUINO_GENERIC_G031F8PX in extra_flags and so this error!

About serial protocolo I’m getting this error, and I don’t know how to fix it:

Linking .pio\build\genericSTM32G031F8P3_arduino\firmware.elf
Checking size .pio\build\genericSTM32G031F8P3_arduino\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.1% (used 912 bytes from 8192 bytes)
Flash: [==        ]  25.0% (used 16352 bytes from 65536 bytes)
Building .pio\build\genericSTM32G031F8P3_arduino\firmware.bin
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, mbed, serial, stlink
CURRENT: upload_protocol = serial
Looking for upload port...
Auto-detected: COM25
Uploading .pio\build\genericSTM32G031F8P3_arduino\firmware.bin
stm32flash 0.4
Unknown/unsupported device (Device ID: 0x466)

http://stm32flash.googlecode.com/

Using Parser : Raw BINARY
Interface serial_w32: 115200 8E1

*** [upload] Error 1
=================================================== [FAILED] Took 47.23 seconds ===================================================
Environment                   Status    Duration
----------------------------  --------  ------------
genericSTM32G031F8P3_arduino  FAILED    00:00:47.234
============================================== 1 failed, 0 succeeded in 00:00:47.234 ==============================================

maybe I need to specify the VID and PID of the CH340 in the board JSON file??

Alan

PS:
I’m thinking about using an RP2040 programmed as PicoProbe to program STM32 using CMSIS-DAP Protocol, I’m not an expert on Debug Probes/protocols but I’m interested on.
In your opinion is possible to do that in some ways? What I need to do or configure for using this device as programmer?

I would like to get some information about embedded debug tools, so if you have some advice about articles, reading, books or whatever you think, I’ll be grateful!!

Alan

Looks like that version is so outdated it doesn’t know about STM32G0 series chips. The latest stable version is 0.7 from https://sourceforge.net/p/stm32flash/code/ci/master/tree/. The current version definitely knows about that device ID and recognizes it as STM32G03xxx/04xxx per code.

You could compile the latest version yourself and then replace the binary within C:\Users\<user>\.platformio\packages\tool-stm32duino yourself. This is also tracked in https://github.com/platformio/platform-ststm32/issues/640.

You can flash a Raspberry Pi Pico with the debugprobe firmware (https://github.com/raspberrypi/debugprobe/releases) and use upload_protocol = cmsis-dap as well as debug_tool = cmsis-dap for uploading and debugging. If you flash the debugprobe_on_pico.uf2 file on the Pico, the pinout for SWDIO, SWCLK is as described in https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf chapter “Debug with a second Pico”.

Yes but I got some errors also with this protocol!!

Linking .pio\build\genericSTM32G031F8P3_arduino\firmware.elf
Checking size .pio\build\genericSTM32G031F8P3_arduino\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.1% (used 912 bytes from 8192 bytes)
Flash: [==        ]  25.0% (used 16352 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, dfu, jlink, mbed, serial, stlink
CURRENT: upload_protocol = cmsis-dap
Uploading .pio\build\genericSTM32G031F8P3_arduino\firmware.elf
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-10-16-21:19)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

swd
*** [upload] Error 3221225477
=================================================== [FAILED] Took 27.05 seconds ===================================================
Environment                   Status    Duration
----------------------------  --------  ------------
genericSTM32G031F8P3_arduino  FAILED    00:00:27.048
============================================== 1 failed, 0 succeeded in 00:00:27.048 ==============================================

I don’t know the meaning of Error 3221225477…

Alan