NUCLEO-F411RE and Mbed Bootloader in Pelion

Hello colleagues!

I move step by step into the world of Mbed OS.
I mastered esp8266 support and decided to move on to more complex things, for which I decided to master Mbed - remote firmware download (FOTA, IAP).

I downloaded and compiled the projects mbed-os-example-pelion-5 and mbed-os-example-pelion under Mbed OS versions 5.xx and 6.xx.
When I download the program to the NUCLEO-F411RE board, I see only one message in the serial terminal window: Mbed Bootloader.
From my point of view, Bootloader does not transfer control to the main program. Perhaps Bootloader is waiting for some kind of external influence (command, button)?

I tried to compile the project under Mbed IDE and Keil Studio - the result is the same.
I can’t compile the project under Keil uVision5, more than 100 errors.

Someone successfully made a project with Mbed Bootloader in Pelion for NUCLEO-F411RE or any NUCLEO board and what could be the reason?
I know there is a separate forum for Pelion, but Pelion doesn’t seem to have anything to do with it yet!

Why is …/mbed-os-example-pelion-5.NUCLEO_F411RE_header.hex file and not * .bin file? .

Here’s a post from Keil Studio:
Using ROM regions bootloader, header, application in this build.
Region bootloader: size 0x8000, offset 0x8000000
Region header: size 0x70, offset 0x8008000
Region application: size 0x77c00, offset 0x8008400
link mbed-os-example-pelion-5.NUCLEO_F411RE
L3912W: Option ‘legacyalign’ is deprecated.
elf2bin mbed-os-example-pelion-5.NUCLEO_F411RE
Merging regions
Filling region bootloader with /tmp/chroots/ch-cc4ac89c-cbf1-48d5-852a-daecd5f7cc5f/src/bootloader/mbed-bootloader-nucleo_f411re-block_device-kvstore-v4.1.0.bin
Filling region header with /tmp/chroots/ch-cc4ac89c-cbf1-48d5-852a-daecd5f7cc5f/build/mbed-os-example-pelion-5.NUCLEO_F411RE_header.hex
Filling region application with /tmp/chroots/ch-cc4ac89c-cbf1-48d5-852a-daecd5f7cc5f/build/mbed-os-example-pelion-5.NUCLEO_F411RE_application.bin
Space used after regions merged: 0x609e0
Merging regions
Filling region application with /tmp/chroots/ch-cc4ac89c-cbf1-48d5-852a-daecd5f7cc5f/build/mbed-os-example-pelion-5.NUCLEO_F411RE_application.bin
Space used after regions merged: 0x585e0
Build succeeded

BR, Vadim

Hi,

WRT target configuration, you need to connect external SD-card module for the F411RE board to store secure credentials.

Pin assignment is found here:

Hello,
English is not my native language, so do not pay attention if suddenly I do not quite correctly express my thoughts or emotions.
I’ll ask right away what is “WRT target configuration” or where to read about it?
I would agree about the SD card, but the post confused me:

I would be glad to see similar messages, especially since I see them in the bootloader *.bin file:
“Mbed Bootloader
booting …
Failed to jump to application!
@ t [DBG] Active firmware slot is empty
[DBG] Failed to boot active application
[DBG] Active firmware integrity check failed
[DBG] Update active firmware
Update image too large
Update image integrity check failed
Update image is older
No Update image
[DBG] New active firmware is valid
[DBG] Firmware update failed
[DBG] Active firmware up-to-date
[ERR] Active firmware invalid”

But I only see “Mbed Bootloader” in the serial port monitor window … :frowning:

I added these lines for SPI2, I think which pins and which interface to use is not important? I checked the work with esp8266 over two wires on a separate example, everything works fine.
{

“sd.SPI_MOSI”: “PB_15”,
“sd.SPI_MISO”: “PB_14”,
“sd.SPI_CLK”: “PB_13”,
“sd.SPI_CS”: “PB_12”,
“esp8266.tx”: “PA_9”,
“esp8266.rx”: “PA_10”,
“esp8266.provide-default”: true
},
I connected such a module and an 8 GB SD card, I could not find less: Adding ethernet connectivity to a STM32-Nucleo /
it looks like some kind of hardware problem
The module itself is functional, the example on this link works with the network.
And I remember that the signals for select SPI for SD and Ethernet are different on different pins.

I haven’t been able to get the map to work yet using this example:

if compiled with
#include “HeapBlockDevice.h”
BlockDevice * bd = new HeapBlockDevice (4096, 1, 1, 512);
then the example works fine on the heap.
I’ll try to figure out where the problem is with the SD card, but it will be very disappointing if the problem is not in its absence … :slight_smile:

I read the firmware with the programmer and I see three blocks there at the addresses that are specified in the configuration file.
To be honest, I have no idea what I’m doing wrong.
Maybe try to buy NUCLEO-F737ZI with Internal Flash, but it’s not very fast.
Perhaps the matter is in Build-only and the example is not working?
ST NUCLEO_F411RE Wi-Fi ESP8266 SD card Build-only

As I expected, the problem was in hardware.
There was not enough pull-up on the SS signal for the second device on the SPI.
For verification, I used this version of the program:

As I assumed, the SD card now work, but Pelion did not.
What else could be the problem? What do the experts think?

Hello,
I thought about your post again.
The specified pin assignment for the SPI is the only possible one, is it specified inside the * .bin bootloader file and cannot be changed?
“sd.SPI_MOSI” : “PC_3”,
“sd.SPI_MISO” : “PC_2”,
“sd.SPI_CLK” : “PC_7”,
“sd.SPI_CS” : “PB_9”,
Or can other pins and any SPI port be used, if I correctly set their pin assignment in mbed_app.json?
Is the algorithm of the bootloader mbed-bootloader-nucleo_f411re-block_device-kvstore-v4.1.0.bin and the like described anywhere?

Perhaps a stupid question, but is it possible to connect a small HeapBlockDevice of 4 … 16 kb in RAM during debugging in order to completely exclude the influence of external equipment (SD, etc.)? As soon as I manage to revive Pelion in the complex, I can think further, going step by step.

I would be grateful for any information if it helps to get off the ground.

BR, Vadim

Hi Vadim,

I have tested the mbed-os-example-pelion example with default setting and worked fine.

Boot log is below:

Mbed Bootloader
No Update image
[DBG ] Active firmware up-to-date
booting...

Application ready
Connect to network
Network initialized, connected with IP 172.16.80.xxx

Start developer flow
Create resources
Register Pelion Device Management Client

Counter 1
Counter 2
Counter 3
Client registered.
Account ID: 0xxxxxxxxxx8be206ae5ecf600000000
Endpoint name: 0xxxxxxxxxxea2dceaa1bd0d00000000
Device ID: 0xxxxxxxxxxea2dceaa1bd0d00000000

Counter 4
Counter 5
Counter 6
Counter 7

I have changed the mbed_app.json file in the example.

  • Changed nsapi.default-wifi-ssid and nsapi.default-wifi-password

  • Removed esp8266.rts and esp8266.cts as my ESP8266 module doesn’t support hardware flow control

The specified pin assignment for the SPI is the only possible one, is it specified inside the * .bin bootloader file and cannot be changed?

You can use different pin assignment for the SPI, but you also need to rebuild bootloader with same pin assignment.

The bootloader code is here: GitHub - PelionIoT/mbed-bootloader: Generic bootloader to be used in conjunction with Pelion Device Management Client

And app_config file for the F411RE is here: https://github.com/PelionIoT/mbed-bootloader/blob/master/configs/internal_kvstore_with_sd.json

To do this:

  • Modify the configs/internal_kvstore_with_sd.json file for your specific pin assignment
  • Build the bootloader, e.g. mbed compile -m nucleo_f411re -t gcc_arm --app-config configs/internal_kvstore_with_sd.json --profile release (you may need to change from STDIO_UART_TX to CONSOLE_TX in bootloader_common.cpp, if you got compile error)
  • Copy mbed-bootloader.bin file to mbed-bootloader-nucleo_f411re-block_device-kvstore-v4.1.0.bin in the mbed-os-example-pelion
  • Then, change pin assignment of the mbed_app.json of mbed-os-example-pelion as same as mbed-bootloader and build mbed-os-example-pelion example

I hope this helps.

Toyo

Hello, Toyomasa Watarai

Thanks for your support!

After a number of unsuccessful experiments, I still bought NUCLEO-F767ZI and ran the Pelion example on it.
At least that way I’ll understand how it all should work correctly. Then I will repeat on F411RE with a SD card.
I see similar messages in the terminal and see my device on Izuma Device Management.
I decided to try updating the software, for which, in fact, it was started.
I uploaded a .bin image but I don’t understand where can I get the Manifest?
I am using Windows 10 and Keil online/Mbed Compiler online. The command line is a different civilization for me.
And the second, less important question: is it possible to give the device a more readable name than 017e58d31c07d66e8889b73…?
The same question applies to other fields of the view:
Vendor ID 6465765f6d616e756661…
Class ID 6465765f6d6f64656c5f6e…

If there is a specialized forum for Pelion on another resource or FAQ, please tell me.

Hi,

I decided to try updating the software, for which, in fact, it was started.
I uploaded a .bin image but I don’t understand where can I get the Manifest?

You can find how to create manifest file Here:

This step is a bit complicated. If you are using Mbed online IDE, the manifest file can be generated automatically for you (Note that Keil Studio Cloud does not support Pelion Device Management integration).

  1. Open Mbed Online IDE
  2. Import mbed-os-example-pelion example from GitHub
  3. From [Pelion Device Management] menu…
    3-1. Manage Connect Certificates
    3-2. Apply Update Certificate
  4. Build the example and download .bin file to target board, make sure your board connected to Pelion DM service from portal
  5. Modify the program for update (e.g. adding new message by printf)
  6. From [Pelion Device Management] menu, select Publish Firmware Update. This will eventually navigate to portal site
  7. In portal site, create update campaign, select your device ID and finish
  8. From Update campaign menu, select the campaign and start

And the second, less important question: is it possible to give the device a more readable name than 017e58d31c07d66e8889b73…?

  • From Pelion DM portal, select device directory and click your device
  • Edit (pencil icon on top right) and change the name

Thanks,
Toyo

Hello Toyo.
Thank you for your answer.
It was somewhat helpful, but I never got anywhere and couldn’t update the test firmware.
I can’t describe all this with another word than “devil’s machinations”! :slight_smile:
And I still hoped to revive all this for the “constructor” on NUCLEO-F411RE with SD and WiFi! :slight_smile:

When I tried to follow your instruction in Mbed Online IDE.
For the mbed-os-example-pelion project I was working with, I couldn’t publish the manifest because I got a version compatibility error about the Pelion client:

I created another pelion-example-common project and was able to publish an update to the server, but this version does not connect to the pelion server and has a different set of messages:

Storage mounting failed.
Formatting the storage…
ERROR: Failed to reformat the storage (-5005).
Connecting to the network using the default network interface…
Connected to the network successfully. IP address: 192.168.1.8
Initializing Pelion Device Management Client…
Pelion Client initialization failed (1)

Now I understand what a manifest is and how it all should work as a whole.
It remains to conduct an experiment with a successful result. I feel that success is close, but I can not catch luck by the tail… :frowning:
Please tell me which example is guaranteed to work for NUCLEO-F767ZI in full and step-by-step instructions on how to do it?
To be honest, constantly “stepping on a rake” does not really help faith in the success of the event. :frowning:

And after that, one more question, as far as I understand, Pelion technology was originally developed for IoT.
Where can I look at examples of how to display discrete inputs, variables of different types and control the outputs and peripherals of the microcontroller through the Pelion server interface or similar?

BR, Vadim

Hi Vadim,

I created another pelion-example-common project and was able to publish an update to the server,
but this version does not connect to the pelion server and has a different set of messages:

Storage mounting failed.
Formatting the storage…
ERROR: Failed to reformat the storage (-5005).

As you can see this page, the pelion-example-common code is deprecated and not recommended to use.
This example program requires external SD card storage even for F767ZI, so you got storage error (-5005).

The mbed-os-example-pelion doesn’t use SD card for F767ZI, it use internal flash to store credential data etc.

Please tell me which example is guaranteed to work for NUCLEO-F767ZI in full and step-by-step instructions on how to do it?

Complete instruction is below:

  1. Login Pelion Device Management portal site: https://portal.mbedcloud.com/
  2. Create API key with Admin group
  3. Copy the API key and save it in secure place
  4. Open Mbed Online IDE: Compiler Deprecation | Mbed
  5. Import mbed-os-example-pelion example from GitHub
    5-1. From menu, click [Import]
    5-2. Click “Click here” link
    5-3. Set Source URL: GitHub - ARMmbed/mbed-os-example-pelion: Mbed OS example for Pelion Device Management
    5-4. Click [Import] button (it will take while…)
  6. Select the NUCLEO-F767ZI platform from top right
  7. From [Pelion Device Management] menu…
    7-1. Select “Manage Connect Certificates”
    7-2 Paste your API key and press OK button
    7-3. Select your developer certificate (or create new certificate and select it) and press OK button
    7-4. Press OK button to confirm overwrite dev credential file
  8. From [Pelion Device Management] menu…
    8-1. Select “Apply Update Certificate”
    8-2. Press “Create” to download private key
    8-3. Press “Create” to confirm update files
    8-4. Press “Download Private Key” button
  9. Build the example by clicking [Compile] button
  10. Download mbed-os-example-pelion.NUCLEO_F767ZI.bin file
  11. Connect serial terminal software (e.g. TeraTerm) with 115200 bauds
  12. Copy the mbed-os-example-pelion.NUCLEO_F767ZI.bin file to target board
  13. See serial console output and make sure your board connected to Pelion DM service from portal
  14. Modify the program for update (e.g. adding new message by printf)
    14-1. in line 269: printf(“Register Pelion Device Management Client *** UPDATED ***\n\n”);
  15. From [Pelion Device Management] menu, select Publish Firmware Update
    15-1. Put any name in the Name field (e.g. test123)
    15-2. Press “Publish” button
    15-3. Press “OK” button for API key dialog
    15-4. Press “Choose File” button and select your private key (downloaded by step 8-4)
    15-5. Press “OK"
    15-6. Press “Open Device Management Portal” button
  16. Login to the Pelion DM portal
    16-1. Press “Next” button in the Detail step
    16-2. Press “Next” button in Manifest step
    16-3. Select your device to update (normally top of the list)
    16-4. Press “Next” button in the Device step
    16-5. Press “Finish” button in the Review step
    16-6. Press “Start’ to start update campaign
    16-7. Select “Now” and press “Start campaign now” button
  17. Navigate to console output, you will see firmware update process in a while
  18. After the download new firmware, the device will reboot automatically
  19. The device firmware will be updated. You new see “Register Pelion Device Management Client *** UPDATED ***” message in the console

Where can I look at examples of how to display discrete inputs, variables of different types and control the outputs and peripherals of the microcontroller through the Pelion server interface or similar?

You can find some examples here:

I hope this helps.

Thanks,
Toyo