Implementation of jumping from bootloader to application

Hello. We recently started working with the new nrf connect sdk and we need to implement a very simple bootloader that would only jump to the main application at a specific address. In this regard, there are several questions:


1) the bootloader should start from address 0, right? how to set the exact address?


2) implementation of our very simple bootloader:

#include <zephyr/kernel.h>

#define APP_ADDR 0x0000C200

int main(void)
{
printk("BOOT\n");
void *start;
irq_lock();
__set_MSP(APP_ADDR);
start = (void *)(APP_ADDR + 4);
((void (*)(void))start)();
while(1);
return 0;
}

how to transfer a vector table? Should this be done in the bootloader or in the application?


3) how to set the offset for the firmware image in the application (to which you need to jump) for nrf connect sdk based on zephyr? (in other projects and mcu this was done in the linker script).


4) is there any additional configuration needed in the main application?

The bootloader and main application are based on nrf connect sdk v2.5.0. MCU nrf52840. The assembly is carried out in Windows 11 and VS Code with the nrf connect sdk plugin.

thanks in advance for the answers

Parents
  • Hello, I think I can answer some questions.

    1. The bootloader typically starts from address 0, which is the reset vector address. To set the exact address, you need to modify the linker script used for the bootloader application. The linker script specifies the memory layout and sections of the application. By adjusting the memory region definitions in the linker script, you can set the bootloader's start address. Locate the linker script for your bootloader project and modify the memory region corresponding to the bootloader's start address.

    2. The implementation of your simple bootloader code snippet looks correct for jumping to the main application. However, you also need to ensure that the vector table is set correctly. In the nRF Connect SDK, the vector table is typically defined in the linker script for the application. The application's linker script should include a vector table section that specifies the address of the interrupt vector table. The bootloader should not modify the vector table but should rely on the one defined in the application's linker script.

    3.To set the offset for the firmware image in the application, you can modify the linker script of the application. Locate the application's linker script and adjust the memory region definitions to set the desired offset for the firmware image. This offset should match the address where the bootloader expects the main application to be located.

Reply
  • Hello, I think I can answer some questions.

    1. The bootloader typically starts from address 0, which is the reset vector address. To set the exact address, you need to modify the linker script used for the bootloader application. The linker script specifies the memory layout and sections of the application. By adjusting the memory region definitions in the linker script, you can set the bootloader's start address. Locate the linker script for your bootloader project and modify the memory region corresponding to the bootloader's start address.

    2. The implementation of your simple bootloader code snippet looks correct for jumping to the main application. However, you also need to ensure that the vector table is set correctly. In the nRF Connect SDK, the vector table is typically defined in the linker script for the application. The application's linker script should include a vector table section that specifies the address of the interrupt vector table. The bootloader should not modify the vector table but should rely on the one defined in the application's linker script.

    3.To set the offset for the firmware image in the application, you can modify the linker script of the application. Locate the application's linker script and adjust the memory region definitions to set the desired offset for the firmware image. This offset should match the address where the bootloader expects the main application to be located.

Children
No Data
Related