Use custom target (blackpill) with CLI2

I’m new in MbedOs programming and have a problem with creating cmake project for custom target.
What i did:
Created new project with

mbed-tools new test


then I imported custom target from and copy it to project root folder.

after this i tryed to compile:
mbed-tools compile -m BLACKPILL_F411CE -t GCC_ARM

project configuration goes ok, but when compiling starts i have errors like theese:

/home/me/projects/mbed/test/mbed-os/cmsis/device/rtos/include/mbed_rtx_conf.h:26:10: fatal error: mbed_rtx.h: No such file or directory
   26 | #include "mbed_rtx.h"
      |          ^~~~~~~~~~~~
compilation terminated.

what is wrong in my way?)

Hello Pavel,

I’m sorry but neither the BLACKPILL_F401CC nor the BLACKPILL_F411CE custom targets support CLI2. However, CLI1 should work.

Edit1: Try to add a CMakeLists.txt file with the following content to the root directory of your program:



then I imported custom target from BLACKPILL_Custom_Target and copy it to project root folder. After this i tried to compile.

That’s just the first step before compilation!

  • Open the BLACKPILL_Custom_Target folder and according to you board drag&drop the TARGET_BLACKPILL_F401CC or the TARGET_BLACKPILL_F411CE folder and the custom_targets.json file one by one to the root folder of your program

  • Delete the BLACKPILL_Custom_Target folder from your project.

(As described at

I resolved this issue. Soon I’ll try to make an article how to use CLI2 with custom targets, for example you blackpill targets.
Also i found a problem in TARGET_BLACKPILL_F411CE. If you check end of flash_data.h, you can find:

/* Base address of the Flash sectors Bank 1 */
#define ADDR_FLASH_SECTOR_0     ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */
#define ADDR_FLASH_SECTOR_1     ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */
#define ADDR_FLASH_SECTOR_2     ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */
#define ADDR_FLASH_SECTOR_3     ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */
#define ADDR_FLASH_SECTOR_4     ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */
#define ADDR_FLASH_SECTOR_5     ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */
#define ADDR_FLASH_SECTOR_5     ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */
#define ADDR_FLASH_SECTOR_5     ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */

ADDR_FLASH_SECTOR_5 is defined for 3 times and there are error messages while compiling project.

I fixed it to

#define ADDR_FLASH_SECTOR_5     ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */
#define ADDR_FLASH_SECTOR_6     ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */
#define ADDR_FLASH_SECTOR_7     ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */

and everything goes ok!)


I appreciate your valuable feedback!

  • A repository of STM32 custom targets is available at GitHub - ARMmbed/stm32customtargets: Enable the support of your custom boards in mbed-os 6. Majority of them already support CLI2/CMake. But to be honest with you I’m not a big fan of the CMake. However, I’m certain that a guide “How to add a CLI2 support for custom targets” will be a big help for the Mbed community.

  • What concerns the flash_data.h you are right. The file distributed by STMicroelectronics for the TARGET_STM32F411xE is correct and I have no idea when and why I changed that :frowning: