This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Remove Softdevice over USB DFU update

I have a number of devices that currently have an S132 softdevice, USB enabled DFU bootloader and application.

I am intending on updating the application, which removes bluetooth functionality, and as result I no longer require the softdevice to be on the device any more. Is it possible to remove this over a sequence of DFUs?

I'm expecting to be updating the Bootloader and Application at the same time as this, to ensure they are compatible without the softdevice present.


Rough flow of what I'm hoping to do:

Update Bootloader and erase softdevice + application

Update Application 

Parents
  • Hi Chris,

    The way the bootloader detect if there is a softdevice or not in the chip is to check the magic hex at the beginning of the softdevice area (right after MBR) , this is snipped from nrf_bootloader_info.h 

    So what you need to do is to make a new bootloader version that has SD_PRESENT forced to 0 . You will need first to update this bootloader. After that it's most likely the bootloader will stay in DFU mode because the softdevice will be recognized as invalid application and you can now update your application into the space of the softdevice. Please make sure your application is compiled with start address = 0x1000 which is the start address of the softdevice (right after the MBR). 


    I haven't tested this myself but as far as I can see it should work. 

  • Hi Hung,

    This appears to work - thanks! 

    Only slight problem is that after updating the bootloader, it doesn't stay in DFU mode. I'm guessing it goes into the start address at 0x1000, which at that point in time (before updating the application to this memory location) is still a valid softdevice? 

    My other, separate question is am I likely to run into any issues with the MBR?
    As these devices have previously used a softdevice with the included MBR, and now I'm removing the softdevice, I'm effectively using an MBR standalone, when it was designed for working with the softdevice. Could this cause me any problems?

Reply
  • Hi Hung,

    This appears to work - thanks! 

    Only slight problem is that after updating the bootloader, it doesn't stay in DFU mode. I'm guessing it goes into the start address at 0x1000, which at that point in time (before updating the application to this memory location) is still a valid softdevice? 

    My other, separate question is am I likely to run into any issues with the MBR?
    As these devices have previously used a softdevice with the included MBR, and now I'm removing the softdevice, I'm effectively using an MBR standalone, when it was designed for working with the softdevice. Could this cause me any problems?

Children
  • Hi Chris, 
    Do you enable CRC check on booting ? 
    I would assume the following check will fail when you set SD_PRESENT = 0. The function should return false hence the bootloader will stay in DFU mode: 

    The MBR included in the softdevice and the MBR that you supposed to flash when doing DFU without softdevice are the same. So there shouldn't be a problem with that. I would assume the softdevice you have include a v2.x MBR (Please check the release note of the softdevice you used)

  • Thanks Hung,

    I've investigated and found that 

    NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET and
    NRF_BL_APP_CRC_CHECK_SKIPPED_ON_GPREGRET2

    Were both set to 1. So I have set both to 0 now, so the CRC check should (to my knowledge) be run in all situations now. 

    However I get the same behaviour as before - it attempts to start a non existent application.

    Debugging the bootloader and getting some debug output reveals some interesting behaviour: 

    <info> app: ***** NEW BOOTLOADER *****
    <info> app: SD_PRESENT: 0
    <info> app: Inside main
    <debug> app: In nrf_bootloader_init
    <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    <debug> nrf_dfu_settings: Using settings page.
    <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    <debug> app: Enter nrf_bootloader_fw_activate
    <info> app: No firmware to activate.
    <info> app: crc_on_valid_app_required returning: 1
    <info> nrf_dfu_validation: nrf_dfu_validation_boot_validate() NO_VALIDATION. address: 0x00001000
    <info> nrf_dfu_validation: nrf_dfu_validation_boot_validate() VALIDATE_CRC. address: 0x00026000
    <debug> app: App is valid
    <warning> nrf_dfu_settings: No additional data erased
    <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    <debug> app: Running nrf_bootloader_app_start with address: 0x00001000
    <debug> app: Disabling interrupts. NVIC->ICER[0]: 0x0


    app_is_valid() appears to think that the softdevice (which has not yet been overwritten) is a valid application and attempts to start it.  

    It appears that setting SD_PRESENT to 0 isn't quite enough to stop it trying to validate the softdevice. 

  • Hi Chris,

    From what I can see in the log it seems that SD_PRESENT was not 0 in you test. 
    You can find this two lines: 

    <info> nrf_dfu_validation: nrf_dfu_validation_boot_validate() NO_VALIDATION. address: 0x00001000
    <info> nrf_dfu_validation: nrf_dfu_validation_boot_validate() VALIDATE_CRC. address: 0x00026000

    Were most likely the result of these code: 

        else if (SD_PRESENT && !boot_validate(&s_dfu_settings.boot_validation_softdevice, MBR_SIZE, s_dfu_settings.sd_size, do_crc))
        {
            NRF_LOG_WARNING("Boot validation failed. SoftDevice is present but invalid.");
            return false;
        }
        else if (!boot_validate(&s_dfu_settings.boot_validation_app, nrf_dfu_bank0_start_addr(), s_dfu_settings.bank_0.image_size, do_crc))
        {
            NRF_LOG_WARNING("Boot validation failed. App is invalid.");
            return false;
        }

    softdevice validation was "NO_VALIDATION" and application validation was VALIDATE_CRC. And you can see that the address used for application was 0x26000 meaning it still thinking that there is a softdevice (start address of application is at the end of the softdevice). 


    Please use a log and print out the value of SD_PRESENT. You may want to remove SOFTDEVICE_PRESENT and add MBR_PRESENT in the preprocessor symbol in the bootloader project's setting. 

Related