Coder Social home page Coder Social logo

j-link-monitoring-mode-debugging's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

j-link-monitoring-mode-debugging's Issues

Bug when using FP code (repros in all SDK exampless here): addresses are offset by 32 bytes

I had an issue where in the debugger, all local variables in a function were offset by 32 bytes. It didn't happen on all functions, and not on global variables. And it happens only with a specific program, cannot reproduce it with simpler code. Unfortunately the app I can reproduce with contains company-specific IP, so cannot provide the steps to reproduce it. I'm writing for a nRF52832, in case it makes a difference (I don't think it does)

In examining the JLINK_MONITOR files, I noticed that the code has a special case for the extended stack frame, and I tried changing the offset. It turns out that my problem can be fixed with a single change in JLINK_MONITOR_ISR_SES.s:

#define _NUM_BYTES_BASIC_STACKFRAME 32
#define _NUM_BYTES_EXTENDED_STACKFRAME 104 // was 72

I double checked and in all my code only one function seems to use the extended stack frame.

When reading the ARM documentation (https://developer.arm.com/docs/dui0553/a/the-cortex-m4-processor/exception-model/exception-entry-and-return) it's clear that the extended frame is 18 32-bit words longer than the basic one, so it's 18*4=72 bytes longer. And the total offset for extended is 104 instead of the basic 32

I'm really out of my league here, but I think that the following code

    LSRS     R1,LR,#+5 
    ITE      CS
    ADDCS    R0,R0,#+_NUM_BYTES_BASIC_STACKFRAME
    ADDCC    R0,R0,#+_NUM_BYTES_EXTENDED_STACKFRAME

Adds either the basic offset or the extended offset, depending on the carry. But the extended stack is 72 bytes more than the basic stack, so needs to add basic+extended (or add _NUM_BYTES_BASIC_STACKFRAME in any case and then add 72 if CS is true). As it is, the code is not working properly for the functions with an extended stack frame

The simplest fix is to change 72 to 104. And I think it would apply to all M4-based nRF5 cores. Incidentally the code is the same in the Keil version of JLINK_MONITOR_ISR_ARM.s, so the fix applies to both

EDIT: Adding link to the same issue in the Segger forums https://forum.segger.com/index.php/Thread/7292-Potential-bug-in-Monitor-Mode-Debug-example/

I think that these issues are related
https://forum.segger.com/index.php/Thread/5904-SOLVED-Jlink-Monitor-Mode-nRF52-SDK-debug-issues/ (by making the variable static instead of local, the local stack is not used)
https://devzone.nordicsemi.com/f/nordic-q-a/42248/monitor-mode-nrf52-sdk-debug-issues (FPU code triggers usage of the extended stack)

J-link settings documentation for SES

Include a paragraph on how to set SetMonModeDebug = 1 and SetMonModeVTableAddr = 0x23000 for SES.

"The application's vector table is at the start of the application's starting address in flash. In a SES project you'll find it in:
Option for project -> Common -> Linker -> Section Placement Macros -> FLASH_START. "

"Open up the example project from the SDK14.2 branch.
Right-click 'Project ble_app_blinky...' and choose 'Edit Options'.
Select 'Debug' from the drop-down menu. (Common, Debug, Release).
Go to Debug -> J-Link -> Additional J-Link Options. Double click to view or edit."

Support for mbn52832DK?

Is MBN52832DK compatible with MMD?. I can't get it work with it, nRF5_SDK16.0 and SES v5.44.

Support for GDB?

Could you also add instructions for using gdb with JLink Monitor Mode ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.