Firmware upgrade over BLE using nrfconnect SDK 2.1.0 for nRF52840

HI,

I have couple of questions here.

1.Is there any sample application that upgrade firmware over BLE using zephyr/NCS 2.1.0 for nRF52840

2.If so our requirement is as below.

 nRF52840 connected over SPI to another module(which has its own firmware). We need to download the nRF52840 and the other module firmware over BLE and upgrade both

How this can done?

3.How we can secure the BLE firmware upgrade to avoid unkonwn firmware upgrade

Parents
  • Hello,

    Device firmware upgrade over the BLE is well documented in this blog. You can also refer to our FOTA upgrade page of nRF connect SDK.

    How we can secure the BLE firmware upgrade to avoid unkonwn firmware upgrade

    This security is  by default provided,when you add MCU boot to your application. Refer MCUboot in nRF connect SDK. It's clearly mentioned here.

    Kind Regards,

    Abhijith

  • Hi , With the sample application we are able to flash the new firmware over BLE and verify it.

    We have couple of questions on it

    1.How the flash is partitioned to accomidate the old image and new image(where we can modify the parition tabele)

    2.Once the upgrade is done the reset is initiated automatically right where this is handled in the code so that we will reser ourself

    3.Once the firmware is downloaded or before downloaded is there any method to verify version of the binary. and  based on that how we can stop the upgrade

    4.once the upgrade is done still both the firmwares are on flashe or old will be erased and newer one replaces the old

Reply
  • Hi , With the sample application we are able to flash the new firmware over BLE and verify it.

    We have couple of questions on it

    1.How the flash is partitioned to accomidate the old image and new image(where we can modify the parition tabele)

    2.Once the upgrade is done the reset is initiated automatically right where this is handled in the code so that we will reser ourself

    3.Once the firmware is downloaded or before downloaded is there any method to verify version of the binary. and  based on that how we can stop the upgrade

    4.once the upgrade is done still both the firmwares are on flashe or old will be erased and newer one replaces the old

Children
  • 1.How the flash is partitioned to accomidate the old image and new image(where we can modify the parition tabele)

    Read more about the image slots in the MCUboot documentation to know more on this.

    2.Once the upgrade is done the reset is initiated automatically right where this is handled in the code so that we will reser ourself

    please search for sys_reboot() in the mcuboot code to find the soft resets that are applied in the code. In my search it looks something like this.

    3.Once the firmware is downloaded or before downloaded is there any method to verify version of the binary. and  based on that how we can stop the upgrade

    MCUboot always validates your image before it can mark the upgrade is finished. The application does not have to do anything as this is part of MCUboot internals.

    4.once the upgrade is done still both the firmwares are on flashe or old will be erased and newer one replaces the old

    This is the info given in the documentation of MCUboot, 
    "The algorithm does two erase cycles on the primary slot and one on the secondary slot during each swap. Assuming that receiving a new image by the DFU application requires 1 erase cycle on the secondary slot, this should result in leveling the flash wear between the slots."

    It looks like it erases the secondary slot after update.

  • Hi 

    Thank you for the information.

    I have couple of questions after testing the upgrade of the firmware over BLE(followed : devzone.nordicsemi.com/.../ncs-dfu).

    1.How data is communicated over BLE (data read and write) to nRF. Means based on this article :  Building a Bluetooth application on nRF Connect SDK- Comparing and contrasting to SoftDevice based applications - Part 1 it should be either UART/SPI/OPENAMP) .

    The reason for this is in the dts file when we removed

            zephyr,bt-mon-uart = &uart0;
            zephyr,bt-c2h-uart = &uart0;

    this also BLE works. What is the purpose of this. because we want to use uart0 for some other functionality like logging etc.

    2.When we are updating and the updation completed with Test and confirmation , I see the firmware updated but both old and new applications are still existing in the Memory. Is this expected?

    3. Let us say if an application existing in the device and later when we do DFU new application is updated and both are in the two slots. But unfortunately the newly updated application has some issue/crash then how to fall back to the old application.

    4. How to define the size of the flash for Slot 0 and slot1

    5. As you mentioned in the previous answer there will be erase cycles but as I mentioned both the applications are there in the memory slot 0 will be new one at any time and if crash happens how it is handled.

    6. when Firmware is sent over BLE , which part of the code is involved in keeping in falsh and loding. because we want to understand and based on that we want to add one file which we need to use later for sending it over SPI to other module. can you please pint out the code which is handling this stuff.

    7.Does MCU boot is secure boot loader or to make it secure do we need to enable any config

  • Hi team,

    can some one help in getting all the answers

  • Hello,

    Srikara said:

    How data is communicated over BLE (data read and write) to nRF. Means based on this article :  Building a Bluetooth application on nRF Connect SDK- Comparing and contrasting to SoftDevice based applications - Part 1 it should be either UART/SPI/OPENAMP) .

    The reason for this is in the dts file when we removed

            zephyr,bt-mon-uart = &uart0;
            zephyr,bt-c2h-uart = &uart0;

    this also BLE works. What is the purpose of this. because we want to use uart0 for some other functionality like logging etc.

    In the nrf52 series board since both host and controller are on same chip it's the RPMsg protocol used. I contacted the author of the blog and he accidently missed  to include. This is the reason you can still see the BLE working.
    AFAIK, zephyr bt-mon-uart is used for enabling the Debug monitor and zephyr,bt-c2h-uart is used only with hci_uart examples. Yes you can use uart0 for logging.

    Srikara said:
    When we are updating and the updation completed with Test and confirmation , I see the firmware updated but both old and new applications are still existing in the Memory. Is this expected?

    Yes that is an expected behavior. Original application is kept when receiving the image. The reason is that we need original application to talk on BLE to receive the image.

    Srikara said:
    Let us say if an application existing in the device and later when we do DFU new application is updated and both are in the two slots. But unfortunately the newly updated application has some issue/crash then how to fall back to the old application

    For this you need to tag your image with TEST. Take a look at this repo created by one of my colleague. You can refer this for image swapping.

    Srikara said:
    How to define the size of the flash for Slot 0 and slot1

    Generally slot0 and slot1 is autogenerated in the partition yml file, You can can define this using the pm_static.yml. Take a look at data partition on a device.

    Srikara said:
    Does MCU boot is secure boot loader or to make it secure do we need to enable any config

    Usually building projects will generate signed files. Take a look at the Secure boot page for knowing more on this. The signing operation of the MCU boot is explained here.

    I need to confirm few things with my colleague for answering questions 5, 6 and will try to reply soon. Thank you for understanding.

    Kind Regards,

    Abhijith

  • Hi Abhijith,

    Thank you for the inforamtion

    regarding Q1:In the nrf52 series board since both host and controller are on same chip it's the RPMsg protocol used. I contacted the author of the blog and he accidently missed  to include. This is the reason you can still see the BLE working.
    AFAIK, zephyr bt-mon-uart is used for enabling the Debug monitor and zephyr,bt-c2h-uart is used only with hci_uart examples. Yes you can use uart0 for logging.

    We want the code base if any where the BLE data handled and kept in flash. Also how to use the Uart logging. As we are not using any Devkits.

    Regarding Q2:Yes that is an expected behavior. Original application is kept when receiving the image. The reason is that we need original application to talk on BLE to receive the image.

    My actual question was after upgradation and swap also old image still exists. why after upgradation both the slots are having images.

    Other questions i will look into it for further understanding and will check with you if any query.

Related