Hi,
I'm developing on the current setup:
- nRF52833 DK, emulating an nRF52820.
- Soft Device 113 version 7.2.0
- SDK 17.1.0, with updated MDK (see link)
- IAR EW ARM 9.30
I'm having issues with the debugger on my project. The issues seem to arise from including the secure bootloader based on example "\examples\dfu\secure_bootloader\pca10100e_s112_ble".
The linker configuration for the bootloader project is:
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x38000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x38000;
define symbol __ICFEDIT_region_ROM_end__ = 0x3dfff;
define symbol __ICFEDIT_region_RAM_start__ = 0x200022c8;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007fff;
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;
And the application linker configuration is:
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x1C000;
/*-Memory Regions-*/
// FLASH
define symbol __ICFEDIT_region_ROM_start__ = 0x1C000;
define symbol __ICFEDIT_region_ROM_end__ = 0x37fff;
// RAM
define symbol __ICFEDIT_region_RAM_start__ = 0x20003DA8;
define symbol __ICFEDIT_region_RAM_end__ = 0x20007fff;
export symbol __ICFEDIT_region_RAM_start__;
export symbol __ICFEDIT_region_RAM_end__;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 3072;
define symbol __ICFEDIT_size_heap__ = 0;
I generate the dfu settings with the following command (note I'm using everything as if it were the nRF52820, whereas I'm actually flashing on a nRF52833 DK)
nrfutil settings generate --family NRF52QFAB --application app.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 dfu_settings.hex
After that, I merge all hex files (bootloader, dfu_settings, app and softdevice) using the mergehex utility. Because IAR's J-Link driver can't flash the UICR addresses, I'm flashing the fully merged image using jprog with this command:
nrfjprog.exe --program Fullimage.hex --family NRF52 --verify --recover --log
Then I start a debugging session with IAR, which flashes the App and SoftDevice on top of that again and runs to main. This appears to work fine: the app executes and I can connect and communicate. The DFU fails when I run it for some reason, nRF Connect Desktop crashes and the Android version gets stuck in a loop of starting, connecting, etc. but I guess that's an issue for another post (here)
The issue at hand here is that if I reset the debugger hitting the "Reset" button in IAR or if I add the "--reset" flag to the nrfjprog, When our app calls "nrf_sdh_enable_request" to enable the SoftDevice, sd_softdevice_enable returns with code NRF_ERROR_INVALID_STATE. Apparently this means that the SoftDevice has already been initialized, but this doens't seem to be the case (not by the app at least, there's no call to enable it before).
Calling NVIC_SystemReset doesn't trigger this error. Without including the bootloader (just flashing SoftDevice and app from IAR when debugging starts on a blank chip), it works just fine, the IAR Debugger reset doesn't generate the error.
This post seems like a very similar problem, but I can't figure out if it's the same thing. For one, I haven't modified the bootloader example an I'm on a much newer SDK.
Thanks for the help!
Thank you!