Can't use custom board with mbed framework

I am doing some work with custom boards and working with the WaveShare Open407Z-C devkit (STM32F407 processor) ahead of boards arriving. If I create simple test program with just a while(1) loop in main() it builds with both the libopencm3 and mbed frameworks if I select the disco_f407vg board, that has the same processor as my board.

If I create a boards directory and copy the disco_f407vg.json file there with the new name open407z-c.json and change the platformio.ini to use that board it builds fine with the libopencm3 framework but fails with the mbed framework. The error reported is:
Cannot find configuration file for your board! Please read instructions here /home/david/.platformio/packages/framework-mbed/platformio/README.txt

Does anyone have any pointers as to what I need to do to resolve this problem?

Thanks in advance

If you look under /home/david/.platformio/packages/framework-mbed/platformio/variants, you will see that there is a folder for each of the supported boards. These folders are generated by platformio.

If you follow the instructions in the README.txt, you should be able to regenerate all of these folders (haven’t tried it myself). It seems that you will first need to enter details of your board into /home/david/.platformio/packages/framework-mbed/targets.json. I think that this file lists all the boards officially supported by mbed.

Assuming that this approach works, be aware that your manual changes may get overwritten when platformio updates its mbed package. Is there any reason why you don’t want to just specify the disco_f407vg if that works fine?

Another possibility is that you need to add your board here:

mbed framework depends on own TARGETs. Sometime PIO Board ID is equal to mbed’s board TARGET. You have 2 options here:

  1. See answer by @DavidPowell Can't use custom board with mbed framework - #3 by DavidPowell . The source file of a script for mbed framework is located under /home/david/.platformio/platforms/ststm32/builder/frameworks/mbed
  2. You can make PR to GitHub - platformio/platform-ststm32: ST STM32: development platform for PlatformIO with your custom board.

Hi guys, thanks for the information. I had seen boards added with libopencm3 so when I had problems with non-ST-Link uploaders I had assume creating a new board may help. Having dug deeper into that problem I see it would not have helped so David Powell’s advise to just stick with the disco_f407vg is the path I will follow for now. I think I have found a work around for the uploader problem.

I was going suggest changes to the documentation but looking at it again I realise the problem was I was extrapolating ideas from the documentation that weren’t actual supported. I was generalising on the assumption that PlatformIO was more generic/flexible than it actually is. Once I get a bit more time under my belt with PlatformIO I may be able to make and submit some inprovements.

Here is located docs repository:


I was also struggling with the issue of adding a unsupported variant of processor to platformio + mbed. In my case I created a simple board which used ATSAMD21J16 which is same as SAMD21J18 used in Atmel Xplained Pro board but has only 64KB ROM and 8KB RAM.

It took me some time to learn how to do it but now i created a readme on GitHub. It may be useful for future work.

@ivankravets, if you want, I can write a docu page on that.

Thanks a lot for your “readme”. We are so close to release new mbed builder with a supprot for mbed OS/SDK. The build script has been changed and variants declaration is located in framework directory, not in build file.

Could you try development version? GitHub - platformio/platform-atmelsam: Atmel SAM: development platform for PlatformIO

I updated to platformio 0.5.1 and switched atmelsam platform to development version. From what I can tell the procedure of getting a new uC to work is still the same.

I still had to manually create a folder in targets/TARGET_SAM_CortexM0P and create a customize a load script. I haven’t seen the option to declare memory map in other files.
My problem is not creating a variant of already declared board but adding a variant of a microcontroller.