This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FOTA when nRF Connect SDK is updated on nRF9160

Hi,

What do I need to be able to FOTA when nRF Connect SDK is updated?

For example, when the SDK version is 1.6.0, can I use the changes I made to the new SDK version using a code like "nrf\samples\nrf9160\http_update\application_update" example? Will providing the pm_static.yml file fix this problem? What should I do for .yml file if the partition names change in the new SDK?

Is there anything I should do other than that using a pm_static.yml file?

I surmise that maybe something is mismatched between the 1.5.0 SDK MCUBoot and the 1.6.0 one, but I'm not sure what it could be. Do I need an updateable bootloader and also immutable bootloader to? If the answer is yes;

If I am not mistaken, the key algorithms used in these two documents are different. Which one makes sense to use for MCUboot: ECDSA or RSA? Does it matter?

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/nrf/samples/bootloader/README.html#building-with-ses

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.5.0/mcuboot/readme-zephyr.html#managing-signing-keys

I used ECDSA_P256. I changed  C:/X/Y/bootloader/mcuboot/boot/zephyr/Kconfig file as follows.

config BOOT_SIGNATURE_KEY_FILE
    string "PEM key file"
#    default "root-ec-p256.pem" if BOOT_SIGNATURE_TYPE_ECDSA_P256
    default "C:/X/Y/bootloader/mcuboot/mcuboot_priv_ec_p256.pem" if BOOT_SIGNATURE_TYPE_ECDSA_P256

Also, I added CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y  and CONFIG_BOOT_UPGRADE_ONLY=y   to C:/X/Y/bootloader/mcuboot/boot/zephyr/prj.conf file.

In my main project, I added to prj.conf.
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_BUILD_S1_VARIANT=y
CONFIG_SECURE_BOOT=y
CONFIG_SB_SIGNING_KEY_FILE="C:/my_prj/configuration/b0_private.pem"

These b0_private.pem and mcuboot_priv_ec_p256.pem files were generated using this command:

openssl ecparam -name prime256v1 -genkey -noout -out priv.pem

Also, I added these lines to main project CMakeList.txt file:

if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/configuration/b0_prj_minimal.conf")
  set(b0_OVERLAY_CONFIG
    ${CMAKE_CURRENT_SOURCE_DIR}/configuration/b0_prj_minimal.conf
  )
endif()

This b0_prj_minimal.conf file is a copy of SDK\nrf\samples\bootloader\prj_minimal.conf file.

I guess that's all the changes I've made.

On Segger Debug screen

*** Booting Zephyr OS build v2.4.99-ncs1  ***
I: Starting bootloader
I: Swap type: none
I: Swap type: none
I: Bootloader chainload address offset: 0x28000
I: Jumping to the first image slot

Meanwhile, using the Fota download library, I gave the paths of the .bin files required for s0 and s1. I triggered the FOTA update to the upgradable bootloader.

On JlinkRTT Viewer screen

00> [00:00:21.201,141]<inf> fota_download: B1 update, selected file:
00> mcuboot/s1.bin
00> [00:01:15.952,941] <inf> download_client: Setting up TLS credentials, tag 42
00> [00:01:15.953,033] <inf> download_client: Configuring socket timeout (30 s)
00> [00:01:15.953,033] <inf> download_client: Connecting to awsfota.s3.eu-central-1.amazonaws.com
00> [00:01:22.158,538] <inf> download_client: Downloading: m_b/s1.bin [0]
00> [00:01:25.296,447] <inf> download_client: Downloaded 2048/45779 bytes (4%)
00> [00:01:27.535,583] <inf> download_client: Downloaded 4096/45779 bytes (8%)
...
00> [00:02:06.256,713] <inf> download_client: Downloaded 43008/45779 bytes (93%)
00> [00:02:10.481,903] <inf> download_client: Downloaded 45056/45779 bytes (98%)
00> [00:02:11.808,349] <inf> download_client: Downloaded 45779/45779 bytes (100%)
00> [00:02:11.900,054] <inf> download_client: Download complete
00> [00:02:11.988,861] <inf> dfu_target_mcuboot: MCUBoot image upgrade scheduled. Reset device to apply
00> FINISHED fota_download
I pressed the "Restart" and "Continue Execution"command on the Segger Debug screen and saw the following result.
On Segger Debug screen

*** Booting Zephyr OS build v2.4.99-ncs1  ***
I: Starting bootloader
I: Swap type: perm
I: Image upgrade secondary slot -> primary slot
I: Erasing the primary slot
I: Copying the secondary slot to the primary slot: 0xb2d4 bytes
I: Bootloader chainload address offset: 0x28000
I: Jumping to the first image slot

What should I do after seeing them on the Segger Debug screen. After waiting for a while, I pressed the "Restart" and "Continue Execution"command on the Segger Debug screen and saw the following result.

On Segger Debug screen

*** Booting Zephyr OS build v2.4.99-ncs1  ***
I: Starting bootloader
I: Swap type: none
I: Swap type: none
I: Bootloader chainload address offset: 0x28000
I: Jumping to the first image slot

What should I do for the new mcuboot in slot s1 to work? How can I tell if it's working?

Thanks,

Have a nice day

  • Hi!

    Just to make sure I understand what you're asking: you are running nrf/samples/nrf9160/http_update/application_update with the modifications you've specified in your case, yes?

    Which NCS version are you using (NCS 1.6.0 does not exist, so I'm assuming either NCS 1.5.0 or the master branch)?

    And then you're seeing this:

    *** Booting Zephyr OS build v2.4.99-ncs1  ***
    I: Starting bootloader
    I: Swap type: perm
    I: Image upgrade secondary slot -> primary slot
    I: Erasing the primary slot
    I: Copying the secondary slot to the primary slot: 0xb2d4 bytes
    I: Bootloader chainload address offset: 0x28000
    I: Jumping to the first image slot

    and you're wondering how to run the new application image that's just been put in S1?

    If this is your question, then the answer is that a device reset is necessary to use the new image.

    If you clear up my questions first, I can help you figure out why the device isn't resetting after the update.

    Best regards,

    Heidi

  • Hi,

    +Just to make sure I understand what you're asking: you are running nrf/samples/nrf9160/http_update/application_update with the modifications you've specified in your case, yes?

    -Yes

    +Which NCS version are you using?

    -I am using NCS 1.5.0. "What should I do if NCS 1.6.0 is released in the future?" I asked to say. Whenever a new NCS is released, all I need to update my code using FOTA is the using a pm_static.yml file?


    Thanks,

    Have a nice day

  • Thanks for clearing that up! I don't have an answer for you immediately but I will get back to you as soon as possible. 

  • Hi again and apologies for the delay in my response.

    So it looks like the downloaded image needs to be signed using imgtool for the MCUboot to be able to use it. Could you confirm that you've done this?

Related