Unable to add custom board (STM32F030 Discovery ) with OpenCM3

Hello,

Let me first start by saying what a fantastic job you guys have done. PlatformIO literally replaced every other IDE I have been using so far.

I am having a peculiar problem while trying to add a custom board in platformIO.
I am using OSX to develop.
I am trying to add the STM32F030 discovery board and use the libopenCM3 framework to develop on.
As I understand from the documentation, it should be as simple as creating a boards folder under the “.platformio” folder and creating a custom json file with the necessary parameters.

I have created my custom json file and used another “disco” board as a template and replaced the appropriate parameters from the “ST nucleo F030” file. (Just the processor, protocols). The custom board is successfully added and is showing up in the list of boards but PlatformIO is unable to initialize a new project based on the custom board.

Can you guys point what am I doing wrong??

Here is the custom json file.
disco_f030r8.json

{"disco_f030r8": {
        "build": {
            "f_cpu": "48000000L",
            "cpu": "cortex-m0",
            "mcu": "stm32f030r8t6"
        },
        "frameworks": ["libopencm3","mbed","cmsis","spl"],
        "name": "disco_f030r8",
        "platform": "ststm32",
        "upload": {
            "maximum_ram_size": 8192,
            "maximum_size": 65536,
            "protocol": "stlink"
        },
        "vendor": "ST"
    }
}

And this is the error I am seeing while trying to initialize a new project or build with the same settings.
Error Screenshot

I apologize for pasting a screenshot. I tried copying the terminal output but it simple was not copying it!

Hi @krishna_chaitanya!
Actually, you should have something like that:

  "build": {
    "core": "stm32",
    "cpu": "cortex-m0", 
    "f_cpu": "48000000L", 
    "mcu": "stm32f030r8t6",
    "variant": "stm32f030r8t6",
    "ldscript": "stm32f03xz6.ld"
  }, 
  "frameworks": ["libopencm3","mbed","cmsis","spl"], 
  "name": "ST STM32F0DISCOVERY", 
  "upload": {
    "maximum_ram_size": 8192, 
    "maximum_size": 65536, 
    "protocol": "stlink"
  }, 
  "vendor": "ST"
}

Thank you for the prompt reply!! :slight_smile:

This solved the issue to a certain stage
The project initializes, but does not build. The build process throws up “undeclared” errors. about first use in this function. I am attaching the associated screenshot, my resent board.json and my platformio.ini

Sorry, if it feels like I am wanting to be spoonfed. I am just starting out in ARM and really liked platformio from my previous experience using it in AVR and MSP430.

Platformio.ini

#
# PlatformIO Project Configuration File
#
# Please make sure to read documentation with examples first
# http://docs.platformio.org/en/stable/projectconf.html
#
[env:disco_f030r8]
platform = ststm32
framework = libOpenCM3
board = disco_f030r8

board.json

{"disco_f030r8"	:
			{
		  "build": {
		  	"core":	"stm32",
		    "cpu": "cortex-m0", 
		    "f_cpu": "48000000L", 
		    "mcu": "stm32f030r8t6",
		    "variant": "stm32f030r8t6",
		    "ldscript": "stm32f03xz6.ld"
		  }, 
		  "frameworks": ["libopencm3","mbed","cmsis","spl"],
		  "platform":"ststm32",
		  "name": "ST STM32F030DISCOVERY",
		  "upload": {
		    "maximum_ram_size": 8192, 
		    "maximum_size": 65536, 
		    "protocol": "stlink"
		  }, 
  		  "vendor": "ST"
		   }
}

Error Screenshot

Now, in the board.json fil you have specified the linker file as “stm32f03xz6.ld”, I have checked the directory under .platformio to see if it exists. It does not. I have used a custom linker “stm32f030x8.ld” and copied it into the ldscripts folder and replaced the same name in the board.json.

Still the same error shows up. Any advice on what actually might be the root cause?
I am thinking it is because of an incorrect library/linker script.

Again, thank you so much for your time and help!!

What project do you compile? Could you try to specify MCU family in platformio.ini:

[disco_f030r8]
platform = ststm32
framework = libOpenCM3
board = disco_f030r8
build_flags = -DSTM32F0

Thank you @valeros
the “build_flags” did the trick!!

I was just trying to compile the example program in the libopencm3 STM32F0

Again, thank you !! You have just saved a LOT of running around in circles for me!!

Edit: Just for the sake of completeness, I tried the exercise again with my “stm32f030x8.ld” linker file and the build process failed. Running the build with the suggested “stm32f03xz6.ld” works just fine.
I guess I have the wrong file…