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?
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)
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 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
@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:
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.
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!
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:
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:
@JojoS Ah-hah! That did the trick! 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+.