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

[CLOSED][nrf52832][S132 4.0.2] application can not start normally in merged hex (SD+APP+BL)

I am beginner of 52832. Current software is based S132 4.0.2 and SDK 13.0.0. Test platform is based on PCA10040.0

My problem is application can not start normally in merged hex. Merged hex means softdevice(S132 4.0.2 size:0x1F000), bootloader(start from 0x77000, size: 32KB) , bootloader setting( starts at 0x7F000 with 4KB size) and application (start from 0x1F000). Here is detailed flash map: image description

Firstly, application has no problem. If I program softdevice + application (no bootloader), application can start normally.

Secondly, I have experience of 51822 merged hex. It can run normally. In my opinion, the main difference between 51822 and 52832 is flash map. After change key starting address and size, i generate merged hex in similar way. 52832 fails to start application. Is there any important change I missed?

Finally, after I program 52832 merged hex, bootloader can start normally and find valid application (expected image size and CRC). The result is restart of bootloader, and application does not start normally. Here is log of bootloader:

image description

Log confirms application starts expected 0x1F000. Why application does not start with correct starting address 0x1F000 and correct application.

Here is more information that should help analysis:

(1) bootloader settting hex I used :

:10F0000001000000FF0000006C780100000000001B :0CF01000000000000000000000000000F4

where 6C7801 is size of application.

(2) code for function "nrf_bootloader_app_start" (in "nrf_bootloader_app_start.c") and its calling function (in "nrf_bootloader_app_start_asm.c"), I copy from SDK 13.0.0 bootloader:

nrf_bootloader_app_start.c

nrf_bootloader_app_start_asm.c

nrf_bootloader_app_start.h

void nrf_bootloader_app_start(uint32_t start_addr) { BTL_RTT_LOG("Running nrf_bootloader_app_start with address: 0x%08x\r\n", start_addr); uint32_t err_code;

err_code = nrf_dfu_mbr_init_sd();
if(err_code != NRF_SUCCESS)
{
    BTL_RTT_LOG("Failed running nrf_dfu_mbr_init_sd\r\n");
    return;
}

// Disable interrupts
BTL_RTT_LOG("Disabling interrupts\r\n");

NVIC->ICER[0]=0xFFFFFFFF;
NVIC->ICER[1]=0xFFFFFFFF;

// Set the sd softdevice vector table base address
BTL_RTT_LOG("Setting SD vector table base: 0x%08x\r\n", start_addr);
err_code = sd_softdevice_vector_table_base_set(start_addr);
if(err_code != NRF_SUCCESS)
{
    BTL_RTT_LOG("Failed running sd_softdevice_vector_table_base_set\r\n");
    return;
}

// Run application


nrf_bootloader_app_start_impl(start_addr);

}

(3) I also attached packages I use and final merged hex (softdevice + application + bootloader + bootloader setting):

softdevice: s132_nrf52_4.0.2_softdevice.hex

application: btl-qfac-rev3.hex

bootloader: bootloader.hex

final merged hex: btl-all-070A04-4.0.2-2.0.0-0.1.2.hex

With correct starting address 0x1F000 and correct appplication (can run with only softdevice), why application does not start? Please help check it. Thanks a lot.

update on 31,5,2017 @Jørgen Kvalvaag From my understanding, bootloader setting is only used in bootloader. It can be in old version. I use old bootloader struct for 51822 S110. Its struct is below: typedef struct { bootloader_bank_code_t bank_0; /< Variable to store if bank 0 contains a valid application. */ uint16_t
bank_0_crc; /
< If bank is valid, this field will contain a valid CRC of the total image. */

bootloader_bank_code_t bank_1;          /**< Variable to store if bank 1 has been erased/prepared for new image. Bank 1 is only used in Banked Update scenario. */

uint32_t               bank_0_size;     /**< Size of active image in bank0 if present, otherwise 0. */
uint32_t               sd_image_size;   /**< Size of SoftDevice image in bank0 if bank_0 code is BANK_VALID_SD. */

uint32_t               bl_image_size;   /**< Size of Bootloader image in bank0 if bank_0 code is BANK_VALID_SD. */

uint32_t               app_image_size;  /**< Size of Application image in bank0 if bank_0 code is BANK_VALID_SD. */

uint32_t               sd_image_start;  /**< Location in flash where SoftDevice image is stored for SoftDevice update. */

} bootloader_settings_t;

Although CRC is missing, bootloader I wrote will ignore it and it finally calls nrf_bootloader_app_start(0x1F000). Do you have any comment on why application does not start? Thanks.

Related