Custom bootloader with softdevice with jump to a specific address of app

Hi!

I try to explain quickly my setup that is working, I am on nrf52805 and I have SD112 ( 7.2.0 ) onboard. I am ok with placing bootloader at specific address using linker file, working correctly and also jump to the app is working correctly. My bootloader is custom ( not using softdevice - application needs sd instead), i just receive data from uart, erase app flash and rewrite with it with new app. All working if fw is above SD.

My issue is that I have a firmware now with a custom header needed for signature verification, which introduces an offsett on starting address of my app ( 0x800 + BASEADDRR ), I am quite sure that I can instruct MBR+SD to jump there reading this post , but i can't get it working. My understanding is that:

When I reset from bootloader i have to:

  • use SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET with my address plus the offset ( no more jump to 0x1000 default address )
  • Reset and jump there

But seems not working, I can't understand if I need also to use in some way this mbr command NRF_MBR_COMMANDS_SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, but it's not clear to me ( and in this case it seems that I have to allocate a page for Settings right? ).

Thanks in advance!

  • It looks like everything is working correctly up until the point where you try to make the "jump" to the application. Are you able to step through the app's start function with a debugger to see what happens?

    Will try and see if I can use debug with Rust, for the jump i am using this implementation  let me know if it seems correct...

    Another thing you can try is to call 'nrfjprog --readregs' after the jump to the main app to read out the core registers. This may provide us with some clues as to what the problem is.

    Will try tonite at home

    Anyway looking to different posts like this i am bit confused if i need also to call the isr forward of mbr command like I see in this post.

    And also this post seems indicating that both approach can be used:

            SD_MBR_COMMAND_INIT_SD and then sd_softdevice_vector_table_base_set 

            or

            SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET and then jump always to 0x1000

    Anyway thanks for support, i will continue my investigation...

  • marklander said:
    SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET and then jump always to 0x1000

    This approach only works when the application starts at the default address (default start address is hardcoded within the Sotdevice). 

    The SD_MBR_COMMAND_INIT_SD is needed to initialize the Softdevice and make the MBR start forwarding interrupts to it.  After the Softdevice has been invoked with this command, the bootloader can instruct the Softdevice to relay application interrupts to the application's vector table with the sd_softdevice_vector_table_base_set() function. The bootloader must then branch directly to your application's reset handler. 

Related