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