Mbed custom board

custom target mbed

Please make instructions on how to add custom boards.

I assume you have built a custom board with an ARM micro controller and now would like to use PlatformIO to program it.

If you tell us what micro controller you are using and what interfaces (UART, USB, SWD, JTAG etc.) are available on your board, it would be much easier to provide you specific and helpful instructions.

https://docs.platformio.org/en/latest/frameworks/mbed.html

I want to add this controller
STM32F401CCU6

But my knowledge is not enough to do it.

Your STM32F401CC is close to the DISCO_F401VC target, so copy this as a new custom_target.json and just rename STM32F401VC to STM32F401CC (same for device name).

Then the documentation tells you the rest

" Secondly, you need to add code specific to your target to the src folder of your project. Usually, it’s a good idea to isolate this code in a separate folder and add еру path to this folder to build_flagsof “platformio.ini” (Project Configuration File): "

Where to get this specific code?

This is just the code in src/ a.k.a. your firmware. Try blinky as your first code?

https://github.com/platformio/platform-ststm32/tree/develop/examples/mbed-custom-target/src

Where does the TARGET_STM32L452xE folder come from?

Files regarding the implementation mbed-APIs and a description of the device are placed here. See reference folders at mbed-os/targets/TARGET_STM/TARGET_STM32F4 at master · ARMmbed/mbed-os · GitHub. Note that there already is the mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F401xC at master · ARMmbed/mbed-os · GitHub folder which fits your device. You’d need add a new TARGET_XXX folder there for your device. This specific folder just contains pin-mapping and clock initialization.

Thank you very much!
I will try.

Alright. Oh and, one last note. The needed PeripheralPins.c file is also available in a not 100% identical but nearly identical format at this very good repo: https://github.com/stm32duino/Arduino_Tools/tree/master/src/genpinmap/Arduino. Difference is that at this repo they use WEAK instead of MBED_WEAK, surround pin definitions by compile-time macros (HAL_ADC_MODULE_ENABLED etc) and use different naming (ADC1 instead of ADC_1). So it’s nearly the same so that you can port them over easily.

Your device is STM32F401CCU6 so your folder is https://github.com/stm32duino/Arduino_Tools/blob/master/src/genpinmap/Arduino/STM32F401C(B-C)Ux/PeripheralPins.c.

Thanks for the help! I hope to succeed.

Hm… How to add the DFU upload option fro this board?

From what I understand - this board supports DFU mode, while DISCO_F401VC doesn’t.

First step would be to add dfu to the array of upload protocols, e.g., platform-ststm32/disco_f401vc.json at a69b7909b9d9381d7d4b9006a79abd80df28eccd · platformio/platform-ststm32 · GitHub, then see what it does and how the DFU loader is invoked, to see if it needs correction.

With this I’m getting error about space in username (Windows 10, x64). (((