Arm Mbed OS support forum

Mbed Studio Generates Incompatible Binaries for nRF52810

This is the scenario :

I have the nRF52-DK with nRF52832 on board. I tried creating Mbed Studio (1.1.0) projects with Mbed OS 6 (6.2.0) for the DK. Mbed Studio detects the board, configures it, compiles the code and flashes it on to the MCU through DAP-Link. Everything including the debugging works fine.

Now I have the Laird Connectivity’s BL651 series BLE module 453-00005 which uses nRF52810. I want the Mbed OS project to be compiled for nRF52810 and flash it. Since I know that there are no dedicated development kits from either Nordic or Laird to evaluate the SoC, but the nRF52-DK provides a way of emulating nRF52810 on it, I thought I could change the build target CPU on Mbed Studio and compile the project.

So I did this,

image

I created a custom target by renaming it and choosing the right SoC. The project compiles fine and the binary file is generated as shown below.

image

Now the problem : I am able to flash this binary file to my external BL651 moulde over SWD using the Debug-Out port (J-Link OB firmware on interface MCU). But when run, the CPU on the BL651 module (nRF52810) halts with a hard fault. I found this was happening from the Ozone debugging interface.

The cause of the fault is the NOCP exception which is described as,

NOCP - Indicates that a Cortex-M coprocessor instruction was issued but the coprocessor was disabled or not present. One common case where this fault happens is when code is compiled to use the Floating Point extension ( -mfloat-abi=hard -mfpu=fpv4-sp-d16 ) but the coprocessor was not enabled on boot.

This clearly shows that Mbed Studio did not compile the source files for the configured target CPU nRF52810, because the nRF52810 is a stripped down version of nRF52832, without an FPU. I did a clean build and there was no difference. I could verify this by flashing the binary to the nRF52823 on the DK which runs fine over there.

If somebody could tell me how to tell Mbed Studio to compile for the selected target CPU, that would me save a lot of time.

I’m replying, not because I have a solution but because I am rather interested in what you’ve tried as I am hoping to do something similar with the nRF52811 (a stripped down version of the nRF52840). I too posted the forum waiting for an answer.

My hunch, as yet to try, is to look at the MBED OS library target folder. There you will find all the config settings for the nRF52832. As to what is the best approach to make a modification, who knows…

I was just reading your thread and about that README.md file you found. Thanks for that. As suggested by it, I tried adding a new target inheriting the already defined nRF52832 as below,

Then I opened the Mbed Studio and could see the new target,

But the Flash and RAM size were not showing up in the tooltip as it would for other entries!

Anyway, I proceeded with a clean build of my project and Mbed Studio threw me an error,

This strongly makes me assume that the mbed-os path doesn’t have definitions for the sub-family SoCs.

Wow, good effort. Curious, did you add or copy the nRF52832 PinNames. h file to your project as maybe that is not inherited.

Yeah, missing pin definitions was the problem. Since pinouts for nRF52810 and 832 are same, I copied the files from 832’s folder to my new target’s folder and it compiled. The output binary was different from the previous one for the same project. That gave me hope. But after flashing the binary to my BLE module, I got the same hard fault.

Inspecting the new definitions I added, I found an obvious mistake : the nRF52832 is a Cortex-M4F and nRF52810 is just Cortex-M because it is missing that FPU. That flag has to be changed when inheriting the nRF52832.

So I changed it and tried to compile it. Then Mbed Studio complained about missing linker script. But I found the existing linker script for the 832. I need to fork that to make a version for 810.

I can only do that on Monday. I think you will have to do something like what I’ve done.

1 Like

Thanks for the feedback. This is really encouraging.

Since nRF52810 (even though subset of nRF52832) and nRF52811 (subset of nRF52840) are not Mbed enabled MCUs, we have to do a porting as explained here : https://os.mbed.com/docs/mbed-os/v6.2/porting/index.html

1 Like

Did you ever come across/read through the “README.md” file found in the TARGET_NORDIC/TARGET_NRF5x folder.

It’s titled ## Adding New Targets Based On Nordic NRF52832 And NRF52840 MCUs

Seems to give an explanation on what to change etc.

Yes I did. But the term target here refers to a development board or module, based on the mentioned MCUs. It doesn’t say anything about other variant of MCUs. I tried modifying so many source files in the mbed OS repo by trial and error method, and I was able to compile to 93%. But since Mbed Studio compiles and checks for dependencies of every existing libraries, regardless of you use it not, I finally hit the bottom with errors I could not fix. I gave up at that point.

The best help we could get is from the mbed OS developers which I don’t think happening anytime soon.

Meanwhile I’m switching to another module for now, BL652 based on nRF52832. Fortunately it is pin and form-factor compatible with the current BL651 I have.

Anyway, if you make any progress in this, kindly post it in this thread, and I will do the same if I find anything.

1 Like