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

FAILS to erase the bootloader in app

HI,

I want to upgrade the BL in APP directly. I encouter a wierd problem. When APP erase a specific page of the BL(the address is 0x74000), the system halts. If ignoring this page, the progress can be done without any problem. The flash space for BL is from 0x6E000 to 0x7DFFF. 

And if the APP runs without BL, the operation can be also done.

I have tried to delete the nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE, false) in the bootloader, but it seems no help.

I have tried it in two boards, this issue is found.

And the code is now like this

#define BL_CODE_START 0x6E000

#define BL_CODE_END 0x7E000

bool cpy_bootloader()
{
uint32_t write_addr = BL_CODE_START;
uint32_t retry = 0;

uint8_t test = 0xA1;

while(write_addr < BL_CODE_END)
{
uint8_t write_buffer[12];
memset(write_buffer, test++, sizeof(write_buffer));

NRF_LOG_DEBUG("erase bl %x, retry = %d", write_addr, retry);


//if(write_addr != 0x74000)
{
nrf_fstorage_erase(&fstorage, write_addr, 1, NULL);
while(nrf_fstorage_is_busy(&fstorage)) {nrf_delay_us(100);wdt_feed();}

NRF_LOG_DEBUG("cpy bl %x -> %x", read_addr, write_addr);
nrf_fstorage_write(&fstorage, write_addr, (void*)write_buffer, sizeof(write_buffer), NULL);
while(nrf_fstorage_is_busy(&fstorage)) {nrf_delay_us(100);wdt_feed();}
}


//if(!memcmp((void*)write_addr, (void*)write_buffer, sizeof(write_buffer)))
{
write_addr += FLASH_PAGE_SIZE;
read_addr += FLASH_PAGE_SIZE;
retry = 0;
}
}

return retry == 0;

}

Parents
  • And, is it safe to update the BL like this? I can not use DFU to update BL as the devices are installed in the trucks, and the NRF52832 connects to its host via UART, by which a new BL image can be transferred to the NRF, now the only job is how to copy the new BL to its desired address.

    I have tried executing the sd_mbr_command with a parameter of SD_MBR_COMMAND_COPY_BL, however, the APP is deleted as soon as this command is executed.

Reply
  • And, is it safe to update the BL like this? I can not use DFU to update BL as the devices are installed in the trucks, and the NRF52832 connects to its host via UART, by which a new BL image can be transferred to the NRF, now the only job is how to copy the new BL to its desired address.

    I have tried executing the sd_mbr_command with a parameter of SD_MBR_COMMAND_COPY_BL, however, the APP is deleted as soon as this command is executed.

Children
No Data
Related