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

Bootloader usage for multiple applications switch

Hi,

I have read that bootloader can switch between two applications if programmed at different locations in flash by user. So how exactly bootloader knows to which application it should jump. 

I am asking this question by taking reference from http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/lib_bootloader_modules.html?cp=4_0_0_3_5 second paragraph.

Is my understanding correct? If yes please reply an answer.

Thanks,

Sridhar

Parents
  • Hi Jonnavittula, 

    jumping between multiple applications is not something we support out of the box, but it is possible to modify the bootlaoder to do so. 

    The bootloader jumps to the location passed in the nrf_bootloader_app_start_final() call in nrf_bootloader_app_start() in nrf_bootloader_app_start.c. You can modify this address  so that the bootlaoder jumps to another location, i.e. another app. Note: you will also have to  modify nrf_dfu_mbr_irq_forward_address_set() so that the interrupts are forwarded to the correct location. 

    void nrf_bootloader_app_start(void)
    {
        uint32_t start_addr = MBR_SIZE; // Always boot from end of MBR. If a SoftDevice is present, it will boot the app.
        NRF_LOG_DEBUG("Running nrf_bootloader_app_start with address: 0x%08x", start_addr);
        uint32_t err_code;
    
        // Disable and clear interrupts
        // Notice that this disables only 'external' interrupts (positive IRQn).
        NRF_LOG_DEBUG("Disabling interrupts. NVIC->ICER[0]: 0x%x", NVIC->ICER[0]);
    
        NVIC->ICER[0]=0xFFFFFFFF;
        NVIC->ICPR[0]=0xFFFFFFFF;
    #if defined(__NRF_NVIC_ISER_COUNT) && __NRF_NVIC_ISER_COUNT == 2
        NVIC->ICER[1]=0xFFFFFFFF;
        NVIC->ICPR[1]=0xFFFFFFFF;
    #endif
    
        err_code = nrf_dfu_mbr_irq_forward_address_set();
        if (err_code != NRF_SUCCESS)
        {
            NRF_LOG_ERROR("Failed running nrf_dfu_mbr_irq_forward_address_set()");
        }
    
        NRF_LOG_FLUSH();
        nrf_bootloader_app_start_final(start_addr);
    }

    Best regards

    Bjørn 

Reply
  • Hi Jonnavittula, 

    jumping between multiple applications is not something we support out of the box, but it is possible to modify the bootlaoder to do so. 

    The bootloader jumps to the location passed in the nrf_bootloader_app_start_final() call in nrf_bootloader_app_start() in nrf_bootloader_app_start.c. You can modify this address  so that the bootlaoder jumps to another location, i.e. another app. Note: you will also have to  modify nrf_dfu_mbr_irq_forward_address_set() so that the interrupts are forwarded to the correct location. 

    void nrf_bootloader_app_start(void)
    {
        uint32_t start_addr = MBR_SIZE; // Always boot from end of MBR. If a SoftDevice is present, it will boot the app.
        NRF_LOG_DEBUG("Running nrf_bootloader_app_start with address: 0x%08x", start_addr);
        uint32_t err_code;
    
        // Disable and clear interrupts
        // Notice that this disables only 'external' interrupts (positive IRQn).
        NRF_LOG_DEBUG("Disabling interrupts. NVIC->ICER[0]: 0x%x", NVIC->ICER[0]);
    
        NVIC->ICER[0]=0xFFFFFFFF;
        NVIC->ICPR[0]=0xFFFFFFFF;
    #if defined(__NRF_NVIC_ISER_COUNT) && __NRF_NVIC_ISER_COUNT == 2
        NVIC->ICER[1]=0xFFFFFFFF;
        NVIC->ICPR[1]=0xFFFFFFFF;
    #endif
    
        err_code = nrf_dfu_mbr_irq_forward_address_set();
        if (err_code != NRF_SUCCESS)
        {
            NRF_LOG_ERROR("Failed running nrf_dfu_mbr_irq_forward_address_set()");
        }
    
        NRF_LOG_FLUSH();
        nrf_bootloader_app_start_final(start_addr);
    }

    Best regards

    Bjørn 

Children
No Data
Related