Implement bootloader in NCS SDK

Hello,

Until now I was working on an application based on the nRF5 SDK: it is this application that is used by my customers.
Now I would like to use the NCS SDK to continue to have the latest features and bug fixes.

Here I almost finished redeveloping my new application (based on NCS SDK) to work like my old one (based on nRF5 SDK) but I have a problem with the bootloader...

My board (contains an nrf 52840) has no buttons and no external memory (so I will have to overwrite existing code when I do an update) but does have a UART.
I need to be able to update the application but also the bootloader.

Here are my questions:

  • I think I have to go into recovery mode to be able to update in this situation? But how can I do it if I don't have a button?
  • The update files will be sent by another microcontroller on the board via the uart: can you tell me more about what I need so that the other microcontroller can communicate with the nrf 52840 to send the files to the bootloader? (files ? protocol ?)
  • Is it possible to update a device that would work with the nRF5 SDK (secure_bootloader_uart_mbr_pca10056) to keep the old bootloader but updating the softdevice+app with the new application (NCS SDK)?

THANKS

  • Thank you for your response but I'm sorry I still can't update the bootlaoder.

    I configured MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=y.

    I tried these commands:
    mcumgr -c my_config image upload Application\TA_Smart\zephyr\signed_by_mcuboot_and_b0_s1_image_update.bin -n 1 --> this writes the file to my application partition (mcuboot_primary)

    mcumgr -c my_config image upload Application\TA_Smart\zephyr\signed_by_mcuboot_and_b0_s1_image_update.bin -n 2 --> this writes the file to mcuboot_secondary (after reboot, nothing is copied to the s1 partition)

    mcumgr -c my_config image upload Application\TA_Smart\zephyr\signed_by_mcuboot_and_b0_s1_image_update.bin -n 3
    mcumgr -c my_config image upload Application\TA_Smart\zephyr\signed_by_mcuboot_and_b0_s1_image_update.bin -n 4
    --> I can't load the file because the bootloader returns <inf> mcuboot: RX: 0x3


    So how can I write to the s1 partition? Which partition do "-n 3" and "-n 4" correspond to?

  • Hi,

    Apologies for the longer response time since my previous reply 

    QuentinD said:

    I tried these commands:
    mcumgr -c my_config image upload Application\TA_Smart\zephyr\signed_by_mcuboot_and_b0_s1_image_update.bin -n 1 --> this writes the file to my application partition (mcuboot_primary)

    mcumgr -c my_config image upload Application\TA_Smart\zephyr\signed_by_mcuboot_and_b0_s1_image_update.bin -n 2 --> this writes the file to mcuboot_secondary (after reboot, nothing is copied to the s1 partition)

    This is as expected, as you've only uploaded the slots to primary and secondary mcuboot application slots. When uploading the new firmware to s1 with the upload command it only stores the image here and does not swap at restart. 

    You will first have to mark the image in s1 as "ready for DFU" by using testconfirm, or test & confirm using mcumgr <connection-options> image test <hash>

    From https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/services/device_mgmt/mcumgr.html it is stated

    This command should mark a test upgrade, which means that after the next reboot the bootloader will execute the upgrade and jump into the new image. If no other image operations are executed on the newly running image, it will revert back to the image that was previously running on the device on the subsequent reset. When a test is requested, flags will be updated with pending to inform that a new image will be run after a reset:

    After this you can use the "confirm" option when you see that the image in s1 has changed from " " to "confirmed" before performing a pin-reset which will swap the images in the new boot

    QuentinD said:
    mcumgr -c my_config image upload Application\TA_Smart\zephyr\signed_by_mcuboot_and_b0_s1_image_update.bin -n 3
    mcumgr -c my_config image upload Application\TA_Smart\zephyr\signed_by_mcuboot_and_b0_s1_image_update.bin -n 4
    --> I can't load the file because the bootloader returns <inf> mcuboot: RX: 0x3

    When uploading the bootloader you don't need the -n tag, as the image number is not relevant for the bootloader

    See this sample for how to use mcumgr to upload and update signed_by_mcuboot_and_b0_s1_image_update.bin https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples/updatable_bootloader/nsib_mcuboot_smp 

    Let me know if this answers your questions

    Kind regards,
    Andreas

  • Thank you for these explanations.

    The problem I have here is that I cannot execute the commands that you told me (test, confirm, ...) because I do not see the hash and even less the image that I have uploded.

    Here is my upload with the result:


    If I do the upload command without the "-n 2", it overwrites my application (mcuboot_primary). So that's why I put "-n 2" so that the application is not deleted and that it puts the bootloader file in the only partition that I have access to (mcuboot_secondary).

  • Hi, 

    This is just an update to let you know that I will return to you with an answer to your questions early next week. I'm waiting for some internal feedback to verify the answer your question

    I'll check in again on Monday

    Kind regards,
    Andreas

  • Hi,

    Thank you for your follow-up.

    Haven't received a response yet?

Related