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

Enabling Monitor Mode Debugging in IAR for nRF52 when using SDK 17.0.2 and S132 soft device

I have run into the issue where the soft device is not being processed when I debug so it throws the assertion failed error. After a lot of searching on the forum I came across the Monitor Mode Debugging blog post which is out of date and now redirects to the Github repo. But Github doesnt reference IAR any more, and the last comments I found on the forum are 2 years old.

Would it be possible to either update the Github repo with IAR support or provide step by step details so I (and others) can get monitor mode debuggin up an running?

Thanks in advance

Mat

Parents
  • Hello Mat,

    Remember that Monitor Mode Debugging is a product from Segger, and not Nordic, so we don't provide the IAR project. 

    What we do have is a guide on how to perform MMD:

    https://github.com/NordicPlayground/j-link-monitoring-mode-debugging/#monitor-mode-debugging-in-keil-%C2%B5vision5-and-segger-embedded-studio

    Does the assert only occur when you enable Monitor Mode Debugging, or is it possible that the assert is coming from the application that you are trying to debug?

    Although Monitor Mode Debugging is an option, and it is working, I have never tried it. Are you trying this only because being able to step in the code is a Nice To Have feature? Did you run into any issues that caused you to want to try this?

    In case you need MMD, have you tried to follow the guide in the link above? We don't have any IAR specific, but you can try with SES (which is free of charge).

    BR,

    Edvin

  • I think you might have missed my point. Your SDK provides examples in SES, IAR and Keil, yet that Github project only gives me an example for SES and Keil. Just pointing out whats missing.

    We use IAR here and our previous nRF52 projects have been simple - basically porting from nRF51 to nRF52. So the application layer is basically the same. I am now porting over code from a legacy Silabs MCU+nRF8001 project over to the nRF52 so can you can imagine there is a LOT of debugging to go on. Stepping through the code with the radio is an absolute necessity. If I send my device a BLE command then I need to be able to break and step though what that command does.

    I did try and follow the steps in the Github project. Had it building and linking, but just not running - gave me the exception and I didnt get the JLink popup. This is why I am asking for a simple example project for IAR. For someone who has never used MMD before, it would help me (and everyone else searching the forums) as lot.

Reply
  • I think you might have missed my point. Your SDK provides examples in SES, IAR and Keil, yet that Github project only gives me an example for SES and Keil. Just pointing out whats missing.

    We use IAR here and our previous nRF52 projects have been simple - basically porting from nRF51 to nRF52. So the application layer is basically the same. I am now porting over code from a legacy Silabs MCU+nRF8001 project over to the nRF52 so can you can imagine there is a LOT of debugging to go on. Stepping through the code with the radio is an absolute necessity. If I send my device a BLE command then I need to be able to break and step though what that command does.

    I did try and follow the steps in the Github project. Had it building and linking, but just not running - gave me the exception and I didnt get the JLink popup. This is why I am asking for a simple example project for IAR. For someone who has never used MMD before, it would help me (and everyone else searching the forums) as lot.

Children
  • It might well be a Segger product (which I didnt know) but I (and everyone else) need to use it on IAR silicon.

  • Hello,

    I got this folder from a colleague:

    200506_MonitorMode.zip

    He said that it probably is a bit random whether the IAR version works or not, because IAR is quite version sensitive. 

    If it doesn't work, then you need to contact Segger to get the correct one (as they are the ones who implemented Monitor Mode Debugging (also for IAR)).

    The approach should be the same as with Segger and Keil from the github repository/guide that I linked in the previous reply.

    Best regards,

    Edvin

  • As a reference for everyone, I got in touch with Segger, and the only differences between what they provided and what Edvin attached above are a number change in the .S files.

    Cant link the new ZIP as Segger requested I didnt.

    The only change is below. This is the same change in all 3 .S files

    -#define _NUM_BYTES_EXTENDED_STACKFRAME  72

    +#define _NUM_BYTES_EXTENDED_STACKFRAME  104        // Values for stackframes are explained at location where they are used

  • And as a follow on, I appear to have working Monitor Mode Debugging in IAR v8.50.9

    So for everyone else viewing this, this is how I got it working.

    Made a MonitorModeDebugging directory and copied in the files from 200506_MonitorMode.zip linked above. Made the change(s) to the .S file(s) above - I only needed the  JLINK_MONITOR_ISR_IAR.s file obviously.

    Added this directory to the Project Options -> C/C++ Compiler -> Preprocessor -> Additional Include Directories

    Added JLINK_MONITOR_ISR_IAR.s and JLINK_MONITOR.c to my IAR project

    Copied over the EnableMonMode.mac file listed in the original blog post (https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/monitor-mode-debugging---revolutionize-the-way-you-debug-ble-applications) from the 4382.EnableMonMode.zip folder. I have pasted this below just in case that link goes away in future

    /*********************************************************************
    * *
    execUserSetup()
    * *
    Function description
    * Called once after the target application is downloaded.
    * Implement this macro to set up the memory map, breakpoints,
    * interrupts, register macro files, etc.
    */
    execUserSetup() {
    __message "Macro-execUserSetup(): Enabling monitor mode";
    __jlinkExecCommand("SetMonModeDebug=1");
    __jlinkExecCommand("SetMonModeVTableAddr=0x26000");
    }

    In Project Options -> Debugger -Setup -> Setup Macros I have selected this .MAC file and ticked the User Macro(s) file checkbox.

    Added the below to the start of main.c

    NVIC_SetPriority(DebugMonitor_IRQn, 7ul);

    Build the code and run. The original blog post and the Github project both talk about seeing a popup with the title of "Monitor Mode missing license". I have NOT seen this however. I am using the uBlox BMD-350 Eval Board so maybe that matters...who knows.

    I am now able to put a breakpoint in Bluetooth write handlers and debug. The radio stays connected to my Android device and at the end of the debugging I can "run" without hitting the app_error_fault_handler

  • That is great news! Thank you for sharing! As you say, this may be useful for other IAR users.

    Best regards,

    Edvin

Related