7 years, 10 months ago.

Adding a new CPU to mbed

Hi,

I am trying to add a new CPU variant to mbed OS 5.0 called NEWCPU. For SDK porting it is mentioned that we should add the Target CPU to the file /mbed-os/targets/targets.json.

I added the following to the targets.json file.

"NEWMCU": { "inherits": ["Target"], "core": "Cortex-M4", "default_toolchain": "GCC_ARM", "supported_toolchains": ["GCC_ARM"], "extra_labels": ["Companyname", "Newcpu"], "macros": [], "public": true "device_has": ["PORTIN", "PORTINOUT", "PORTOUT"] },

But when I compile the code by calling mbed compile -m NEWCPU, it gives me an error saying Unsupported CPU type and lists the available list of MCU's but my CPU name does not show in that list

I see mbed compile calls on the make.py, but at which point will make.py use the NEWCPU from the targets.json file.

Thank you for reading this and providing some solution.

1 Answer

7 years, 10 months ago.

Hey Royston,

You seem to have followed the guide exactly, except for one thing: you need a `release_versions` key which would contain `["5"]`. Let me know if that's not in the guide.

Could you give that a try?

-Jimmy

Thank your reply, No the release_versions key is not mentioned in the porting guide. I tried adding it the json file, but it still doesn't work. Apparently make.py is using the json file inside .temp/tools If I add the newmcu to that json file the make.py is able to find the mcu and compiles. If I add the same CPU definition to json file in mbed-os/targets it doesnt work.

"NEWMCU": { "inherits": ["Target"], "core": "Cortex-M4", "default_toolchain": "GCC_ARM", "supported_toolchains": ["GCC_ARM"], "extra_labels": ["CompanyName", "McuName"], "macros": [], "public": true, "device_has": ["PORTIN", "PORTINOUT", "PORTOUT"], "device_name": "McuName", "release_versions": ["5"] },

posted by Royston Dsouza 03 Feb 2017

Ah. I take it that you are using mbed-dev then.

If you are looking to add new targets, I recommend that you use the mbed-os repo here: https://github.com/ARMmbed/mbed-os as mbed-cli will not add a hidden folder containing the tools and the tools will use the target.json from that repo by default.

posted by the other jimmy 03 Feb 2017

Thank you Jimmy. Yes, I am using mbed-cli. I don't want to add the target inside the hidden folder, I want to add the new target using the method recommended by mbed i.e. by adding the definition to mbed-os/targets/ targets.json. Is there a reason mbed compile (make.py) is not picking up the new target from there? Is there a potential fix to this?

Thank you

posted by Royston Dsouza 03 Feb 2017

So, supposing that you are using the mbed-os that I recommended, as mbed-os.lib, mbed-cli should be using `make.py` from `mbed-os/tools/make.py` (you can check with `-v` appended to your mbed-cli command). That version of `make.py` should be using `mbed-os/targets/targets.json` as it's source of targets.

If this is not the case, then we really should start looking at the files in your workspace. -Jimmy

posted by the other jimmy 03 Feb 2017