Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Must re-flash SoftDevice every time I debug

I am using the PCA10056 development board, running a custom application merging the MESH stack (2.0.1) with an IAR-based SDK v15 template, sd 140 v6.  Whenever I go to debug with my I-Jet Trace, the program only runs if I erase the chip and re-program the softDevice with nRFgo Studio.  If I go to debug or download and debug my call stack shows a few hundred app_error_handler instances and the debugger breaks in app_error_weak, so I'm assuming the stack is getting blown somewhere, or something of the like.  Why would this happen?

  • I did my normal thing and erased the board, programmed the SoftDevice, and debugged with IAR.  I then used nrfjprog to pull off the image.  I compared it to the .hex file generated by IAR and the contents are identical.  But if I go to debug again it always fails while initializing the softDevice.  It fails if I download again and if I just debug without downloading.

    The code does appear to run if I reset the chip and I'm not debugging.

  • Did anyone resolve this issue? I'm having the same issue where I need to re-flash my board before I can download and debug my application from IAR.

    I am using SDK 17, S112 v7.0.1, a custom board with nrf52810, IAR Embedded Workbench 8.50.1, and Segger JLink.

  • For programming there are a few IAR posts, such as iar-flash-loader-error-nrf52810.

    To debug in IAR using a Softdevice the J-Link Monitor is required:

            <group>
                <name>JLink-Monitor</name>
                <excluded>
                    <configuration>nrf52832_xxaa</configuration>
                </excluded>
                <file>
                    <name>$PROJ_DIR$\..\..\..\..\..\..\JLink-Monitor\JLINK_Monitor.c</name>
                </file>
                <file>
                    <name>$PROJ_DIR$\..\..\..\..\..\..\JLink-Monitor\JLINK_MONITOR.h</name>
                </file>
                <file>
                    <name>$PROJ_DIR$\..\..\..\..\..\..\JLink-Monitor\JLINK_Monitor_ISR_IAR.s</name>
                </file>
            </group>

    This requires the companion enable in main():

       // This allows all interrupts higher than _PRIO_SD_LOW (ie 4, BLE SD stuff) to continue execution even during a break
       // note Two J-Link commands are required in command file:
       // SetMonModeDebug = 1
       // SetMonModeVTableAddr = ADDR, typically 0x2600
       //  where ADDR is the application's vector table located in FLASH, ie the start address for the
       // application, probably either 0x1B000 or 0x1C000 or 0x26000 depending on SoftDevice
       // See https://github.com/NordicPlayground/j-link-monitoring-mode-debugging
       NVIC_SetPriority(DebugMonitor_IRQn, _PRIO_SD_LOW);

Related