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

Modify bootloader address

Hi Sir,

As check below link, we know how to re-write the bootloader address.

https://devzone.nordicsemi.com/f/nordic-q-a/26300/how-to-use-nrfjprog-to-write-uicr-bootloaderaddr 

1. But could we re-write the bootloader address in Application layer?

2. If we program two application image in the flash (example,like one in 0x26000, another in 0x46000)

   Could we jump to difference application address from bootloader?

Thank you.

BRs, Han

Parents
  • Hello,

    When you compile an application and generate a packet using nrfutil the start address of the application is not stored in that packet. It is the bootloader that deals with placing the application in the correct place.

    What SDK version do you use?

    Best regards,

    Edvin

  • Hi Edvin,

    The project use SDK 15.0.0

    BRs, Han

  • Hello,

    Sorry. I thought forced dual banking was included in the later SDK versions, but it seems like it isn't.

    So the answer is that currently, we don't support this. It is probably possible to implement this by adjusting some registers from the application, such as storing the address of where to start next in the UICR registers, and use this register in the bootloader. 

    The place where the bootloader starts the application is:

    main() -> nrf_bootloader_init -> nrf_bootloader_app_start -> nrf_bootloader_app_start_final(start_addr);

    So if you read the start_addr from the UICR, it may be possible. You would also have to change the bootloader to store the applications in the places that you want to store them when performing the DFU.

    Best regards,

    Edvin

  • Hi Edvin,

    I tried to assign the address "0x26000" to "start_addr" directly, but system cannot boot up well (no response).

    Cannot I assign the address directly?

    BRs, Han

  • Hello Han,

    What other than changing start_addr have you done?

    I assume you have programmed these applications with your IDE or nrfjprog or something similar? Or did you do it over DFU?

    If you programmed them directly, did you also program the bootloader settings page?

    BR,

    Edvin

  • Hi Edvin,

    1. we tried to assign the "start_addr" to 0x26000 (or 0x46000), but boot fail.

    2. Change the flash start address setting from Keil C (0x26000 -. 0x46000), but fail.

    3. Add  below code jump to 0x46000 in the main () function, but fail.

    4. The "bootloader settings page" is from IDE? or main() function of bootloader?

    ------------ 

    typedef  void ( *pFunction ) ( void );

    int main(void)

    {

        uint8_t op_mode = 0U;

        pFunction jump2app;

        uint32_t jump_addr;

           

        jump_addr = * ( __IO uint32_t * ) ( 0x46000UL + 4UL );

        jump2app = ( pFunction ) jump_addr;

        /* Initialize user application's Stack Pointer */

        __set_MSP ( * ( __IO uint32_t * ) ( 0x46000UL ) );

        jump2app();

    ....

    }

    -------------

    Thank you.

    BRs, Han

Reply
  • Hi Edvin,

    1. we tried to assign the "start_addr" to 0x26000 (or 0x46000), but boot fail.

    2. Change the flash start address setting from Keil C (0x26000 -. 0x46000), but fail.

    3. Add  below code jump to 0x46000 in the main () function, but fail.

    4. The "bootloader settings page" is from IDE? or main() function of bootloader?

    ------------ 

    typedef  void ( *pFunction ) ( void );

    int main(void)

    {

        uint8_t op_mode = 0U;

        pFunction jump2app;

        uint32_t jump_addr;

           

        jump_addr = * ( __IO uint32_t * ) ( 0x46000UL + 4UL );

        jump2app = ( pFunction ) jump_addr;

        /* Initialize user application's Stack Pointer */

        __set_MSP ( * ( __IO uint32_t * ) ( 0x46000UL ) );

        jump2app();

    ....

    }

    -------------

    Thank you.

    BRs, Han

Children
  • Hello Han,

    Does your implementation from your last reply work if you don't change the application start_addr to 0x46000?

  • Hi Edvin,

    1. From item 1, If we don't change the "start_addr" and keep the original code, it works ( start addr is 0x26000). (bootloader's main())

    2. From item 3, if we common the code as below, it works because it will go through the original part that start w/ 0x26000.

    ======

        //jump_addr = * ( __IO uint32_t * ) ( 0x46000UL + 4UL );

        //jump2app = ( pFunction ) jump_addr;

        /* Initialize user application's Stack Pointer */

        //__set_MSP ( * ( __IO uint32_t * ) ( 0x46000UL ) );

        //jump2app();

    ======

    Thank you,

    BRs, Han

  • I am not able to follow the logic from your main() function.

    If you try:

    typedef  void ( *pFunction ) ( void );
    
    int main(void)
    
    {
    
        uint8_t op_mode = 0U;
    
        pFunction jump2app;
    
        uint32_t jump_addr;
    
           
    
        jump_addr = * ( __IO uint32_t * ) ( 0x26000UL);
    
        jump2app = ( pFunction ) jump_addr;
    
        /* Initialize user application's Stack Pointer */
    
        __set_MSP ( * ( __IO uint32_t * ) ( 0x26000UL ) );
    
        jump2app();
    
    ....
    
    }

    What happens then? 

    Is it possible to send your project, so that I can try to understand how your implementation is working? Right now, I know only that it isn't working. Not what the part that isn't working looks like.

    BR,

    Edvin

Related