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

DFU without rebooting nRF

Is there a supported way of doing an unsecure flash (the nRF is hardwired via UART to a secure processor) without rebooting? 

The HW design the nRF is integrated with uses the nRF as as the main CPU power sequencer and thus cannot be rebooted to allow DFU update from that CPU.

Parents
  • Hi Honsch, 

    Could you clarify what exactly you need ? How do you receive the image ?
    I assume you receive the new image in your application and want to switch to the new image without trigger a reset ? 

    It's actually possible, but you need to change the vector table forwarding of the softdevice to point to the new image. You can do that by calling sd_softdevice_vector_table_base_set() but your application need to run as it's in bootloader mode (MBR forward interrupt to the bootloader/application instead of the softdevice) 

    Please refere to ble_stack_init() in nrf_dfu_ble.c in our bootloader

  • Hung,

    I've finally gotten back to this task.

    I modified my original project to use only the first 256K of flash and 48K of RAM.

    I've created a new peripheral uart example based app that does not use the softdevice. It gets flashed to 0x40000 and runs when I branch to the .init start address.

    The problem I have is interrupts.  I don't get any even after calling sd_softdevice_vector_table_base_set()

    Even if I did it wouldn't solve the problem of flashing a new softdevice with the firmware updater.

    What I need to do is fully disable the softdevice, unprotect the entire system, set SCB->VTOR to my vector table so I can erase and reflash whatever I need to.  The only peripherals I need access to are UART0, a timer, PWM, GPIO, and the CPU registers to erase and program the flash memory.  Bluetooth is not used at all during the update procedure.

    Is this even possible?  The final HW design uses the nRF as a power sequencer for the main CPU and rebooting it resets the main CPU so I cannot ever reset the CPU during a flash update.  After the flash update is complete I can reboot, but not before.

    Thanks for any advice,

    Eric

  • Hi Eric, 

    One thing we need to clarify is that if you run your application as the bootloader or not. Your application is treated as the bootloader (so that the softdevice wouldn't initialize before your application ) when the MBR forwarding the PC and vector table to you. This is done by writing the address of the bootloader to UICR (in SDK v15.2 and earlier) or to the MBR setting page (SDK v15.3) .

    Which SDK are you using ? 

    If your device is running as a bootloader, there shouldn't be a problem to update the softdevice (the same way as our current bootloader). However, if the softdevice is already initialized (if you start to use BLE) I don't see any easy way to replace the softdevice without a reboot. 

  • Hug,

    We're not using a bootloader, our app was originally based on the ble peripheral uart example. 

    The SDK is 15.0.0 a53641a with softdevice 132 v6.0.0.

    The DFU  happens after the softdevice is enabled via a command over a hardwired serial connection.  The nRF's main job is reading a bunch of sensors and acting as a BT conduit to the main CPU. 

    Thanks,

    Eric

  • Hi Eric,

    I understand that you are not using the bootloader.

    But as your requirement we need to run your application as a bootloader (so that you can replace the softdevice, change the vectortable location etc). 

    To run your application as a bootloader you need to follow what we do in our bootloader and implement that in your application. 

    In SDK v15.0 to tell the MBR that you have a bootloader (at address 0x40000 for example) you need to write to UICR 

    Please have a look at the attribute commands inside nrf_bootloader_info.c , this is where we write to UICR to tell the MBR where the bootloader (your application ) is. 

Reply
  • Hi Eric,

    I understand that you are not using the bootloader.

    But as your requirement we need to run your application as a bootloader (so that you can replace the softdevice, change the vectortable location etc). 

    To run your application as a bootloader you need to follow what we do in our bootloader and implement that in your application. 

    In SDK v15.0 to tell the MBR that you have a bootloader (at address 0x40000 for example) you need to write to UICR 

    Please have a look at the attribute commands inside nrf_bootloader_info.c , this is where we write to UICR to tell the MBR where the bootloader (your application ) is. 

Children
Related