This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

Interrupt Vectors Bootloader & Main Application

How can I relocate or manage the transition between the bootloaders interrupt vector map and the applications interrupt vector map which will be at different addresses in FLASH. On the M3/M4, you can remap this but presumably on the M0, you cant. Is there a method I could use on the NRF51822?

Edit: We are not using soft devices (we are using proprietary software and protocols).

Ive written the bootloader software running on the NRF51822 which accepts and programs an image sent from a C++ application, and then using some assembler, loads the main image @ 0x8000. The only issue is how to tackle the problem of a non-relocatable vector table (unless I am mistaken) of the Cortex M0.

NXP and ST's Cortex M0 dont have a VTOR (vector table offset register) but they do have a remap register to set the vector table in SRAM. The vector table could then jump to the correct bootloader vector table (@ 0) or main application vector table (@ 0x8000).

If you could investigate if the NRF51822 offers any features/registers to enable relocation of the vector table I would be grateful, thanks.

Parents
  • I think the most straight forward thing to do, is add small, simple handlers for all interrupts in the default vector table at 0x0, which simply branches to the same address, offset by the position of your other image, e.g. 0x8000. This will add a few clock cycles to the interrupt latency, but that might be acceptable depending on the application.

    Example implementation for the Reset handler (pointed to by the vector table at 0x0):

    Reset_Handler
        MOVS  R0, #4       ;The offset for the Reset handler
        MOVS  R1, #0x8000  ;The address of the main image
        LDR   R1, [R1, R0] ;Load the address of the reset handler from the main image
        BX    R1           ;Branch there
    

    This could be changed to e.g. use macros or function calls to simplify the implementation of all handlers, and you could also change it to read the address of the main image from somewhere instead of being hardcoded, to be able to configure it.

  • Your MOVS R1, #0x8000 gives following error: error: A1492E: Immediate 0x00008000 out of range for this operation. Permitted values are 0x00000000 to 0x000000FF can you show me a working example with LDR?

Reply Children
No Data
Related