Arm Mbed OS support forum

LPC812 support?

Hi folks. I’m getting ready to design my first custom board. I want to use the NXP LPC812 but I’m having trouble telling how much support there is for it. I see a number of forum posts that suggest that people have gotten a custom board working with this chip, but when I try to compile the default blinky-baremetal project in Mbed Studio 1.0.0, I get a build failure:

argument -m/–mcu: LPC812 is not a supported MCU. Supported MCUs are:
[… long list of all supported MCUs here…]

I have selected the “NXP LPC800-MAX” target in my project, as it’s the only one that made sense when I filtered the target list for “LPC812.”

Any ideas how to get code to compile for the LPC81x family?

Thanks!

hi @pion

Note the LPC812 was removed in Mbed OS 6, hence the error you’re seeing.
You can either switch to the 5.15 branch or create a custom board based on Mbed OS 6.

For the latter, you can follow the guidelines in the docs and blog.

In summary:

  • Create custom_targets.json based on the LPC812 in targets.json from 5.15 (see here)
  • Create TARGET_LPC812 folder and hierarchy based on LPC812 from 5.15 (see here)
  • Add mbed-os.lib and main.cpp (see details about baremetal in the docs here and here)

Have a look to other good examples of custom boards such as the Bluepill.
You should be able to compile with either Mbed CLI or Mbed Studio (1.0)

Kind regards,
Marcelo

2 Likes

Thanks, @MarceloSalazar! That was a very helpful post and I’ve started digging through the links you mentioned. While I’m tempted to try the 5.15 option since it sounds a lot easier, my instinct is to go through the laborious process of (what I suspect requires) doing a full port to Mbed OS 6, as I don’t want to start a brand new project by depending on a deprecated OS. (Unless you can offer a reason why 5.15 is the smarter option long-term?) I’m curious: Do you know why LPC812 support was removed in 6?

Note Mbed OS 5 isn’t deprecated. There are new patch releases on the 5.15 branch from time to time.
Unless you really want to use a new feature that may land on Mbed OS 6, you should be able to use the 5.15 branch without problems.

@MarceloSalazar Ok, you’ve convinced me :slight_smile: I’ll start off with 5.15 to save some time. I created a new baremetal-blinky example and targeted Mbed OS 5.15 with the NXP LPC800-MAX target, but now I see a different error:

Could not compile for LPC812: Target LPC812 is not supported by toolchain ARMC6

What am I doing wrong?

That seems correct, the target hasn’t been enabled with Arm Compiler 6.

I think you can try one of these options:

  • Use GCC with Mbed CLI
  • Use AC5 with Mbed CLI (toolchain from Keil MDK free 32K version)
  • Enable support for AC6 (as an example, look at the Arm linker script for LPC1114)

Remember to follow instructions to migrate to Mbed OS 5 as shown here:
https://os.mbed.com/docs/mbed-os/v5.15/tutorials/migrating-to-mbed-os-5.html

@MarceloSalazar I installed Mbed CLI and imported the mbed-os-example-blinky example. I made sure to check out the Mbed OS 5.15.0 tag. I set the target to LPC812 and tried toolchains set to ARM, ARMC5, and GCC_ARM. But I’m still getting an unsupported target error. Here’s the log for GCC:

(mbed CLI) $ pwd
[...]/mbed-os-example-blinky

(mbed CLI) $ ls
BUILD  CONTRIBUTING.md  README.md  main.cpp  mbed-os  mbed-os.lib  mbed_settings.py  mbed_settings.pyc  resources

(mbed CLI) $ git branch
* (HEAD detached at mbed-os-5.15.0)
  master

(mbed CLI) $ mbed target
[mbed] "[...]/mbed-os-example-blinky" (program)
[mbed] LPC812

(mbed CLI) $ mbed toolchain
[mbed] "[...]/mbed-os-example-blinky" (program)
[mbed] GCC_ARM

$ mbed compile
[mbed] "[...]/mbed-os-example-blinky" (program)
argument -m/--mcu: LPC812 is not a supported MCU. Supported MCUs are:
[...]
[...]
[...]
[mbed] ERROR: "/Applications/MBEDCLI.app/Contents/Resources/miniconda/bin/python" returned error.
       Code: 2
       Path: "[...]/mbed-os-example-blinky"
       Command: "/Applications/MBEDCLI.app/Contents/Resources/miniconda/bin/python -u [...]/mbed-os-example-blinky/mbed-os/tools/make.py -t GCC_ARM -m LPC812 --source . --build ./BUILD/LPC812/GCC_ARM"

Sorry for the noob questions… I’m not sure what I’m doing wrong though. Can you help?

Did you use the bare-metal setting in your mbed_app.json?

@JojoS I’ve added an mbed_app.json now and tried again. Same result:

(mbed CLI) $ pwd
[...]/mbed-os-example-blinky

(mbed CLI) $ ls
BUILD  CONTRIBUTING.md  README.md  main.cpp  mbed-os  mbed-os.lib  mbed_app.json  mbed_settings.py  mbed_settings.pyc  resources

(mbed CLI) $ cat mbed_app.json
{
    "requires": ["bare-metal"],
    "target_overrides": {
        "*": {
            "target.c_lib": "small"
        }
    }
}

(mbed CLI) $ mbed compile
[mbed] Working path "[...]/mbed-os-example-blinky" (program)
argument -m/--mcu: LPC812 is not a supported MCU. Supported MCUs are:
[...]
[mbed] ERROR: "/Applications/MBEDCLI.app/Contents/Resources/miniconda/bin/python" returned error.
       Code: 2
       Path: "[...]/mbed-os-example-blinky"
       Command: "/Applications/MBEDCLI.app/Contents/Resources/miniconda/bin/python -u [...]/mbed-os-example-blinky/mbed-os/tools/make.py -t GCC_ARM -m LPC812 --source . --build ./BUILD/LPC812/GCC_ARM"
       Tip: You could retry the last command with "-v" flag for verbose output
---

can you check if your mbed-os/targets/targets.json contains the LPC812 MCU?

I can compile successfully for the LPC812, but you have to lower the BOOT_STACK_SIZE, otherwise you’ll get a linker error.

{
    "requires": ["bare-metal", "rtos-api"],
    "target_overrides": {
        "*": {
            "platform.stdio-baud-rate": 115200,
            "platform.stdio-convert-newlines": true
        },
        "LPC812": {
            "target.tickless-from-us-ticker": true,
            "target.boot-stack-size": "0x400"
        },
        "LPC824": {
            "target.tickless-from-us-ticker": true
        }      
    }
}

I will also try to add the LPC812/824 to a custom target, it is annoying to maintain several OS versions.

1 Like

was this executed in mbed-os directory? The blinky example has also a mbed-os-5.15 branch.

1 Like

I have add the LPC812 and LPC824 to my custom_targets collection. With this repo added to your project, you can compile for these targets with current mbed-os-6.1
But the code size has increased significantly for a simple blinky from 9028 to 11992 Bytes with mbed6.

Stats for Mbed-os-6.1.0 and LPC812:

| Module                                                |         .text |     .data |      .bss |
|-------------------------------------------------------|---------------|-----------|-----------|
| [fill]                                                |       22(+22) |     0(+0) |   19(+19) |
| [lib]\c_nano.a\lib_a-closer.o                         |       36(+36) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-errno.o                          |       12(+12) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-fflush.o                         |     408(+408) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-findfp.o                         |     452(+452) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-fputc.o                          |     136(+136) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-fstatr.o                         |       36(+36) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-fwalk.o                          |       64(+64) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-impure.o                         |         0(+0) | 100(+100) |     0(+0) |
| [lib]\c_nano.a\lib_a-init.o                           |       72(+72) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-isattyr.o                        |       36(+36) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-lock.o                           |         6(+6) |     0(+0) |     9(+9) |
| [lib]\c_nano.a\lib_a-lseekr.o                         |       40(+40) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-makebuf.o                        |     216(+216) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-malloc.o                         |       20(+20) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-memcpy-stub.o                    |       18(+18) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-memset.o                         |       16(+16) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-nano-freer.o                     |     148(+148) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-nano-mallocr.o                   |     188(+188) |     0(+0) |     8(+8) |
| [lib]\c_nano.a\lib_a-putc.o                           |     148(+148) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-readr.o                          |       40(+40) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-reent.o                          |         0(+0) |     0(+0) |     4(+4) |
| [lib]\c_nano.a\lib_a-sbrkr.o                          |       36(+36) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-stdio.o                          |     152(+152) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-wbuf.o                           |     172(+172) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-writer.o                         |       40(+40) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-wsetup.o                         |     240(+240) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_aeabi_uldivmod.o                         |       64(+64) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_ashldi3.o                                |       24(+24) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_clzdi2.o                                 |       24(+24) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_clzsi2.o                                 |       60(+60) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_dvmd_tls.o                               |         4(+4) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_lshrdi3.o                                |       24(+24) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_muldi3.o                                 |       80(+80) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_udivmoddi4.o                             |     408(+408) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_udivsi3.o                                |     276(+276) |     0(+0) |     0(+0) |
| [lib]\misc\crt0.o                                     |     120(+120) |     0(+0) |     0(+0) |
| [lib]\misc\crtbegin.o                                 |       72(+72) |     4(+4) |   28(+28) |
| [lib]\misc\crtend.o                                   |         0(+0) |     0(+0) |     0(+0) |
| [lib]\misc\crti.o                                     |         0(+0) |     0(+0) |     0(+0) |
| [lib]\misc\crtn.o                                     |         0(+0) |     0(+0) |     0(+0) |
| custom_targets\TARGET_NXP\TARGET_LPC81X\TARGET_LPC812 |       84(+84) |     8(+8) |     0(+0) |
| custom_targets\TARGET_NXP\TARGET_LPC81X\device        |     256(+256) |     0(+0) |     0(+0) |
| custom_targets\TARGET_NXP\TARGET_LPC81X\gpio_api.o    |     176(+176) |     0(+0) |     4(+4) |
| custom_targets\TARGET_NXP\TARGET_LPC81X\pinmap.o      |       96(+96) |   72(+72) |     0(+0) |
| custom_targets\TARGET_NXP\TARGET_LPC81X\serial_api.o  |     518(+518) |     0(+0) |   17(+17) |
| custom_targets\TARGET_NXP\TARGET_LPC81X\sleep.o       |     104(+104) |     0(+0) |     0(+0) |
| custom_targets\TARGET_NXP\TARGET_LPC81X\us_ticker.o   |     366(+366) |     0(+0) |   20(+20) |
| main.o                                                |       64(+64) |     0(+0) |   24(+24) |
| mbed-os\drivers\source\BufferedSerial.o               |       34(+34) |     0(+0) |     0(+0) |
| mbed-os\drivers\source\TimerEvent.o                   |       84(+84) |     0(+0) |     0(+0) |
| mbed-os\drivers\source\UnbufferedSerial.o             |       42(+42) |     0(+0) |     0(+0) |
| mbed-os\hal\mbed_critical_section_api.o               |       64(+64) |     0(+0) |     2(+2) |
| mbed-os\hal\mbed_gpio.o                               |       76(+76) |     0(+0) |     0(+0) |
| mbed-os\hal\mbed_ticker_api.o                         |   1068(+1068) |     0(+0) |     0(+0) |
| mbed-os\hal\mbed_us_ticker_api.o                      |       72(+72) |     4(+4) |   65(+65) |
| mbed-os\hal\static_pinmap.o                           |       16(+16) |     0(+0) |     0(+0) |
| mbed-os\platform\source\CriticalSectionLock.o         |       24(+24) |     0(+0) |     0(+0) |
| mbed-os\platform\source\SysTimer.o                    |     554(+554) |     0(+0) |     0(+0) |
| mbed-os\platform\source\TARGET_CORTEX_M               |     412(+412) |     0(+0) |   84(+84) |
| mbed-os\platform\source\mbed_alloc_wrappers.o         |       16(+16) |     0(+0) |     0(+0) |
| mbed-os\platform\source\mbed_atomic_impl.o            |     126(+126) |     0(+0) |     0(+0) |
| mbed-os\platform\source\mbed_board.o                  |     246(+246) |     0(+0) |     0(+0) |
| mbed-os\platform\source\mbed_critical.o               |       70(+70) |     0(+0) |     4(+4) |
| mbed-os\platform\source\mbed_error.o                  |     306(+306) |     0(+0) | 114(+114) |
| mbed-os\platform\source\mbed_os_timer.o               |     284(+284) |     0(+0) |   68(+68) |
| mbed-os\platform\source\mbed_power_mgmt.o             |     138(+138) |     0(+0) |     2(+2) |
| mbed-os\platform\source\mbed_retarget.o               |   1138(+1138) | 260(+260) | 144(+144) |
| mbed-os\platform\source\mbed_sdk_boot.o               |     150(+150) |     0(+0) |     8(+8) |
| mbed-os\platform\source\mbed_thread.o                 |       12(+12) |     0(+0) |     0(+0) |
| mbed-os\platform\source\mbed_wait_api_no_rtos.o       |       30(+30) |     0(+0) |     0(+0) |
| mbed-os\platform\source\minimal-printf                |   1000(+1000) |     0(+0) |     0(+0) |
| mbed-os\rtos\source\ThisThread.o                      |         8(+8) |     0(+0) |     0(+0) |
| Subtotals                                             | 11544(+11544) | 448(+448) | 624(+624) |
Total Static RAM memory (data + bss): 1072(+1072) bytes
Total Flash memory (text + data): 11992(+11992) bytes

Image: ../../BUILD/blinky/Release\blinky.bin


Stats for Mbed-os-5.15.0 and LPC812:

| Module                                          |       .text |     .data |      .bss |
|-------------------------------------------------|-------------|-----------|-----------|
| [fill]                                          |     12(+12) |     4(+4) |   13(+13) |
| [lib]\c_nano.a\lib_a-errno.o                    |     12(+12) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-findfp.o                   |       0(+0) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-impure.o                   |       0(+0) | 100(+100) |     0(+0) |
| [lib]\c_nano.a\lib_a-init.o                     |     72(+72) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-malloc.o                   |     20(+20) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-memchr-stub.o              |     22(+22) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-memcpy-stub.o              |     18(+18) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-memmove.o                  |     38(+38) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-memset.o                   |     16(+16) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-nano-freer.o               |   148(+148) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-nano-mallocr.o             |   188(+188) |     0(+0) |     8(+8) |
| [lib]\c_nano.a\lib_a-nano-msizer.o              |     16(+16) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-nano-reallocr.o            |     76(+76) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-nano-svfprintf.o           |   708(+708) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-nano-vfprintf_i.o          |   770(+770) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-reent.o                    |       0(+0) |     0(+0) |     4(+4) |
| [lib]\c_nano.a\lib_a-sbrkr.o                    |     36(+36) |     0(+0) |     0(+0) |
| [lib]\c_nano.a\lib_a-vsnprintf.o                |   110(+110) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_aeabi_uldivmod.o                   |     64(+64) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_ashldi3.o                          |     24(+24) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_clzdi2.o                           |     24(+24) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_clzsi2.o                           |     60(+60) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_dvmd_tls.o                         |       4(+4) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_lshrdi3.o                          |     24(+24) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_muldi3.o                           |     80(+80) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_thumb1_case_shi.o                  |     20(+20) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_udivmoddi4.o                       |   408(+408) |     0(+0) |     0(+0) |
| [lib]\gcc.a\_udivsi3.o                          |   276(+276) |     0(+0) |     0(+0) |
| [lib]\misc\crt0.o                               |   120(+120) |     0(+0) |     0(+0) |
| [lib]\misc\crtbegin.o                           |     72(+72) |     4(+4) |   28(+28) |
| [lib]\misc\crtend.o                             |       0(+0) |     0(+0) |     0(+0) |
| [lib]\misc\crti.o                               |       0(+0) |     0(+0) |     0(+0) |
| [lib]\misc\crtn.o                               |       0(+0) |     0(+0) |     0(+0) |
| main.o                                          |     64(+64) |     0(+0) |   24(+24) |
| mbed-os\drivers\source\Serial.o                 |     64(+64) |     0(+0) |     0(+0) |
| mbed-os\drivers\source\TimerEvent.o             |     30(+30) |     0(+0) |     0(+0) |
| mbed-os\drivers\source\UARTSerial.o             |     28(+28) |     0(+0) |     0(+0) |
| mbed-os\hal\mbed_critical_section_api.o         |     64(+64) |     0(+0) |     2(+2) |
| mbed-os\hal\mbed_gpio.o                         |     76(+76) |     0(+0) |     0(+0) |
| mbed-os\hal\mbed_ticker_api.o                   |   930(+930) |     0(+0) |     0(+0) |
| mbed-os\hal\static_pinmap.o                     |     16(+16) |     0(+0) |     0(+0) |
| mbed-os\platform\source\CriticalSectionLock.o   |     24(+24) |     0(+0) |     0(+0) |
| mbed-os\platform\source\FileHandle.o            |       4(+4) |     0(+0) |     0(+0) |
| mbed-os\platform\source\SysTimer.o              |   278(+278) |     0(+0) |     0(+0) |
| mbed-os\platform\source\TARGET_CORTEX_M         |   528(+528) |     0(+0) |   84(+84) |
| mbed-os\platform\source\mbed_alloc_wrappers.o   |     24(+24) |     0(+0) |     0(+0) |
| mbed-os\platform\source\mbed_atomic_impl.o      |   104(+104) |     0(+0) |     0(+0) |
| mbed-os\platform\source\mbed_board.o            |   246(+246) |     0(+0) |     0(+0) |
| mbed-os\platform\source\mbed_critical.o         |     70(+70) |     0(+0) |     4(+4) |
| mbed-os\platform\source\mbed_error.o            |   296(+296) |     0(+0) | 114(+114) |
| mbed-os\platform\source\mbed_os_timer.o         |   212(+212) |     0(+0) |     4(+4) |
| mbed-os\platform\source\mbed_power_mgmt.o       |   138(+138) |     0(+0) |     2(+2) |
| mbed-os\platform\source\mbed_retarget.o         |   522(+522) | 260(+260) |     8(+8) |
| mbed-os\platform\source\mbed_sdk_boot.o         |     78(+78) |     0(+0) |     0(+0) |
| mbed-os\platform\source\mbed_thread.o           |     12(+12) |     0(+0) |     0(+0) |
| mbed-os\platform\source\mbed_wait_api_no_rtos.o |     96(+96) |     0(+0) |     0(+0) |
| mbed-os\rtos\source\ThisThread.o                |       8(+8) |     0(+0) |     0(+0) |
| mbed-os\targets\TARGET_NXP\TARGET_LPC81X        | 1230(+1230) |   80(+80) |   21(+21) |
| Subtotals                                       | 8580(+8580) | 448(+448) | 316(+316) |
Total Static RAM memory (data + bss): 764(+764) bytes
Total Flash memory (text + data): 9028(+9028) bytes

Image: ../../BUILD/blinky/Release\blinky.bin
1 Like

Thank you so much @JojoS! That was silly of me and you’re totally right: I didn’t check out the correct tag of mbed-os itself. After doing so and applying your stack size fix, I’m able to compile for Mbed OS 5.14.4 using Mbed CLI! :partying_face:

It’s also very cool and generous of you to have created and updated your custom-targets project. I would be totally happy to get Mbed OS 6.1.0 working on LPC812 with your additions even if there is extra code bloat right now. I cloned your repo, but, as someone new to the Mbed environment, I wasn’t sure how to get Mbed Studio to recognize it. I’ve been searching the web for the past hour and I see instructions on using custom_targets.json, but no clear instructions on file locations and getting Mbed Studio to pick up the new targets. I created symbolic links to your custom_targets.json, TARGET_LPC81X, and TARGET_LPC82X and placed the links in the root of my source tree:

% cd ~/Mbed\ Programs/mbed-os-example-blinky-baremetal
% ls -l
total 48
drwxr-xr-x   4 pion  staff   128 Jul 13 13:54 BUILD
-rw-r--r--   1 pion  staff  6320 Jul 13 13:16 README.md
lrwxr-xr-x   1 pion  staff    58 Jul 13 13:47 TARGET_NXP -> /Users/pion/Documents/GitHub/mbed-custom-targets/TARGET_NXP
lrwxr-xr-x   1 pion  staff    58 Jul 13 13:47 TARGET_STM -> /Users/pion/Documents/GitHub/mbed-custom-targets/TARGET_STM
lrwxr-xr-x   1 pion  staff    67 Jul 13 13:46 custom_targets.json -> /Users/pion/Documents/GitHub/mbed-custom-targets/custom_targets.json
-rw-r--r--   1 pion  staff   430 Jun 29 14:49 main.cpp
drwxr-xr-x  37 pion  staff  1184 Jul 13 13:54 mbed-os
-rw-r--r--   1 pion  staff    76 Jul 13 13:54 mbed-os.lib
-rw-r--r--   1 pion  staff   285 Jun 29 14:49 mbed_app.json
drwxr-xr-x   3 pion  staff    96 Jun 29 14:49 resources
drwxr-xr-x   4 pion  staff   128 Jun 29 14:49 tests

However, after quitting and relaunching Mbed Studio, and making sure I updated my Mbed OS library to 6.1.0, I don’t see your new targets showing up in the Target drop-down menu. Do you have any suggestions on how to get Mbed Studio to recognize them?

You’welcome, I’m happy that it is working for you also.
My dev env is still VSCode + some configured tasks that call the mbed-cli like ‘mbed compile’. There, I copy the whole custom_target dir into the project dir. Or rather, I use the ‘–source dir’ to add some common libs to the project, instead of using links. The build system will find them and the new custom targets can be used by their names.
I’ve just checked the custom_target documentation, this has been updated also and a few things can be improved further. Mbed-Studio uses the ARM compiler, that is interesting because gcc was lazy in optimizing Cortex-M0 code.
https://os.mbed.com/docs/mbed-studio/current/mbed-os/custom-targets.html

Edit:
I’ve got it working with Mbed-Studio and ARM compiler, but I have to cleanup my repo.
There are a few caveats:

  • the custom_targets.json must reside in the project root. This behaviour is different to mbed-cli build rules where it can be located also in a subdirectory (or --source path). The effect is that ‘target not found’ error is thrown when building. But targets are still listed when in selection.
  • Mbed-Studio has an own list of targets, api-targets.json in the install dir. There is already a LPC812 and prevents this from beeing displayed in the target selection. My other targets where shown, so renaming to custom_LPC812 will make it visible
  • uARM is no longer supported, so this has to be changed to ARM_STD
  • I get a ‘legacy warning’ from the linker, but don’t know how to fix it
  • the target linting tool does not work with custom_targets.json, so for testing the json settings it need to be temporarily added to targets.json

@arekzaluski is it really neccessary that custom_targets.json needs to be in the project root?

Edit2:
I have updated my github repo, this custom target compiles now for the LPC8xx. Please note that I had to rename the targets and you need also to change the name in mbed_app.json. The boot-stack-size is now in the custom definition and is not needed in mbed_app.json, only when you want to adjust it in your application.
To add your own target, you can copy the section the custom_target.json and copy and rename the dir in TARGET_NXP.

@JojoS I just pulled in your latest repo changes from a few minutes ago (including the target renames to the “Node” varieties) but Mbed Studio still doesn’t show any of your targets in the Targets menu. Can you share a log / screenshot of your project setup? I’m still using the same three symlinks into your repo at the root of my project dir:

% cd /Users/pion/Mbed\ Programs/mbed-os-example-blinky-baremetal  
% ls -l
total 40
drwxr-xr-x   4 pion  staff   128 Jul 13 13:54 BUILD
-rw-r--r--   1 pion  staff  6320 Jul 13 13:16 README.md
lrwxr-xr-x   1 pion  staff    58 Jul 13 13:47 TARGET_NXP -> /Users/pion/Documents/GitHub/mbed-custom-targets/TARGET_NXP
lrwxr-xr-x   1 pion  staff    58 Jul 13 13:47 TARGET_STM -> /Users/pion/Documents/GitHub/mbed-custom-targets/TARGET_STM
lrwxr-xr-x   1 pion  staff    67 Jul 13 13:46 custom_targets.json -> /Users/pion/Documents/GitHub/mbed-custom-targets/custom_targets.json
-rw-r--r--   1 pion  staff   430 Jun 29 14:49 main.cpp
drwxr-xr-x  37 pion  staff  1184 Jul 13 13:54 mbed-os
-rw-r--r--   1 pion  staff    76 Jul 13 13:54 mbed-os.lib
-rw-r--r--   1 pion  staff   285 Jun 29 14:49 mbed_app.json
drwxr-xr-x   3 pion  staff    96 Jun 29 14:49 resources
drwxr-xr-x   4 pion  staff   128 Jun 29 14:49 tests

I’m using windows, the repo is added by the library management, and I moved the custom_targets.json to the root.

2 Likes

@JojoS Ah-hah! That did the trick! :+1: I don’t know why, but adding your repo using the Mbed Studio library manager, rather than cloning manually and managing it outside of the project tree, allowed Mbed Studio to recognize it. I then symlinked your custom_targets.json from inside your repo into the root of my tree and was able to compile. Beautiful. Thank you so much for your help! I am very excited to be able to develop with Studio and Mbed OS 6.1+.

1 Like

great!
MbedStudio should have the same behaviour as the mbed-cli and find the targets from libraries, otherwise a clean versioning is more difficult.