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!

Parents
  • Hi,

    Yes, this is possible. However, rather than using SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, you can use the SD_MBR_COMMAND_INIT_SD command. This will allow you to use the sd_softdevice_vector_table_base_set() function in your bootlaoder and change to a non-default interrupt forwarding address for the Softdevice. The application start sequence in the bootloader should be something like this:

    1. Issue the SD_MBR_COMMAND_INIT_SD command through the sd_mbr_command() API. This will cause the reset handler of the Softdevice to be executed.

    3. Disable interrupts globally

    2. Now with the SD initialized, you can use sd_softdevice_vector_table_base_set() to set the Softdevice vector forwarding address to your application's vector table address.

    3. Forward execution to main application. 

    Best regards,

    Vidar

  • Thanks! I will try the exact sequnce you are suggesting.

    One thing i forgot...i am on rust. But i have all bindings to nrf mbr so i can emulate all the sequence.

    Two questions:

    What does the sofdevice SD_MBR_COMMAND_INIT_SD do exactly?

    I have used sd_softdevice_vector_table_base_set function and seems that calling this a reset is issued immedeately ( while irq fuction does not reset ) am i right?

    And do i need to reserve a flash page for settings for that command?

  • Ups! I got now that I am confusing sd_mbr_command_vector_table_base_set_t with sd_softdevice_vector_table_base_set!

    So sd_softdevice_vector_table_base_set will take the starting address of application with offset...and then I have to jump there

Reply Children
No Data
Related