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

nRF52840 Hardfault on call to sd_mbr_command

Currently we are integrating the serial and BLE DFU into a single binary executable. The project enables the logging (NRF_LOG_ENABLED = 1) and we use RTT as backend. 

When the software starts, when ble_stack_init is called which in turn calls nrf_dfu_mbr_init_sd, we run into hardfault when sd_mbr_command is executed.

The linker file for the bootloader project is below. We had to change the start addresses when we enabled the logging. Any idea what could possibly be wrong?

/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0xe4000;
/*-Memory Regions-*/
define exported symbol __ICFEDIT_region_ROM_start__ = 0xe4000;
define exported symbol __ICFEDIT_region_ROM_end__ = 0xfdfff;
define symbol __ICFEDIT_region_RAM_start__ = 0x200057b8;
define symbol __ICFEDIT_region_RAM_end__ = 0x2003ffff;
export symbol __ICFEDIT_region_RAM_start__;
export symbol __ICFEDIT_region_RAM_end__;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 2048;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];

define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
define block RO_END with alignment = 8, size = 0 { };

initialize by copy { readwrite };
do not initialize { section .noinit };

keep { section .intvec };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly,
block RO_END };
place in RAM_region { readwrite,
block CSTACK,
block HEAP };

Parents
  • Hello,

    I have not tried this using IAR before, but have you tried editing the start address using the IDE's options interface?

    At least when I use this, I get a different .icf file than what you pasted above, which still includes the MBR params page. Try it out. 

    I assume you still remembered to flash the softdevice (which includes the actual MBR file). 

    I didn't manage to test this, because of the wchar size issue in the later IAR versions. It has a fix, but it has been years since I looked into that, and it doesn't look like that was the issue in your case. 

    Best regards,

    Edvin

Reply
  • Hello,

    I have not tried this using IAR before, but have you tried editing the start address using the IDE's options interface?

    At least when I use this, I get a different .icf file than what you pasted above, which still includes the MBR params page. Try it out. 

    I assume you still remembered to flash the softdevice (which includes the actual MBR file). 

    I didn't manage to test this, because of the wchar size issue in the later IAR versions. It has a fix, but it has been years since I looked into that, and it doesn't look like that was the issue in your case. 

    Best regards,

    Edvin

Children
  • Thanks, This information helped. We were using some custom symbols for ROM START and ROM END and for us to use custom symbols we had to modify the generated icf file. Looks like IAR does not like custom modifications to the icf file and hence the ROM STart and End text boxes in the above picture were always empty even if I entered a non-zero value. Once I removed the custom modifications, it worked. The custom changes were lines related to exporting the symbols __ICFEDIT_region_ROM_start__ and __ICFEDIT_region_ROM_end__

Related