Utilizing SDK 15.2 and Softdevice S132, when debugging with Segger Ozone and starting from main or after triggering a reset to restart at main an ERROR 8 [NRF_ERROR_INVALID_STATE] is produced when nrf_sdh_enable_request is called. I have reproduced this on mulitiple boards, and utilizing multiple j-link debug probes including the Nordic NRF52-DK. Can be reproduced simply by trying to debug one of the example applications (such as ble_app_hrcs) directly on the NRF52-DK board utilizing Ozone. Without utilizing the soft device debugging works normally. Also if I set a watchdog timer and allow it to reset while debugging the nrf_sdh_enable_request works normally.
Root issue is that ozone is starting execution at the reset_handler of the app rather than the looking to the vector table at the base of flash and running whatever it points to (i.e. reset code for sd…
Root issue is that ozone is starting execution at the reset_handler of the app rather than the looking to the vector table at the base of flash and running whatever it points to (i.e. reset code for sd). Simplest fix is to change the line VectorTableAddr = Elf.GetBaseAddr() to VectorTableAddr = 0 in both AfterTargetReset and AfterTargetLoad.
It is great to hear the root cause is found.
Thanks for that answer.. solved the problem for me.
I am using FreeRTOS and it hardfaulted shortly into the SVC handler triggered by FreeRTOS function vPortStartFirstTask() during RTOS startup. Until i applied this solution.
Just for those not fluent in Ozone (like me who had to research where and what the line "VectorTableAddr = Elf.GetBaseAddr()" is about), its the ozone project .jdebug file. It contains a C like script program, it is a bunch of functions that is run on different events in Ozone.
Search replace "VectorTableAddr = Elf.GetBaseAddr();" to "VectorTableAddr = 0;" - restart Ozone and you should be good to go.
I found that I also needed to adjust PC = Elf.GetEntryPointPC(); to PC = Target.ReadU32(VectorTableAddr + 4);
This thread plus this wiki entry on Segger site helped solved the problem properly for me.