Hot!Is there any way to debug without writing any memories at all?

Author
Noble_Techno
Starting Member
  • Total Posts : 38
  • Reward points : 0
  • Joined: 2017/06/07 05:50:56
  • Location: 0
  • Status: offline
2017/12/07 01:55:50 (permalink)
0

Is there any way to debug without writing any memories at all?

Hi folks,
 
As I'm stuck on a currently un-debuggable issue with startup code ( http://www.microchip.com/forums/m1028297.aspx for reference) I would like to know if there is any way to start the debugger without writing to any of the chip's memories at all? The condition I need to set up in order to see what's going on relies on a particular state of the boot flash, program flash and configuration bits so hitting debug in MPLAB destroys that state.
 
If this were gdb I would know exactly what to do. Is there any way to override the tools to prevent loading? Can be command-line only if you like. I just need to have it come up at the reset vector, and give me the ability to single-step and view special function register values.
 
Any help greatly appreciated!
#1

7 Replies Related Threads

    mbrowning
    Just a Member
    • Total Posts : 611
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: Is there any way to debug without writing any memories at all? 2017/12/07 06:22:07 (permalink)
    0
    Which part?  Why can't you just set a breakpoint at the reset vector? I've done that before. For 8 bit parts at least, the debugger doesn't change any memory so I'm not sure what your concern is.

    Can't remember. I've slept since then - Mark
    #2
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: Is there any way to debug without writing any memories at all? 2017/12/07 06:29:19 (permalink)
    0
    mbrowning
    Which part?



    Whoops, sorry. PIC32MZ1024EFG100. Also I have a Real ICE and an ICD4 if that makes any difference.
     
    I'm trying to figure out what's going on with the boot sequences and the resulting BFSWAP bit in NVMCON, and in order to get it into the state where BFSWAP should be 1 (and it is not) I have to have my startup code in both boot flash partitions, and the sequences set so that the upper region will be mapped at reset. I don't see any way of achieving this with MPLAB because boot flash memory is always programmed when running in debug mode (it says so on the project options where you can choose which memories are programmed).
     
    I just want to execute without loading, and break at the reset vector.
    #3
    KTrenholm
    Super Member
    • Total Posts : 274
    • Reward points : 0
    • Joined: 2012/08/08 14:04:23
    • Location: Connecticut, USA
    • Status: offline
    Re: Is there any way to debug without writing any memories at all? 2017/12/07 08:47:10 (permalink)
    +1 (1)
    Would the MPLAB Settings do what you're looking for as far as breaking at the reset vector?
    Tools>Options>Embedded
    Debug Reset @: Reset Vector
    Debug Startup: Halt at Reset Vector
     
    There's also a "Live Connect Debug Main Project" that could possibly be what you're looking for but I don't know the rules/tools needed to get that working.  It's always greyed out for me.
    post edited by KTrenholm - 2017/12/07 08:53:51
    #4
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: Is there any way to debug without writing any memories at all? 2017/12/07 09:03:16 (permalink)
    0
    KTrenholm
    Would the MPLAB Settings do what you're looking for as far as breaking at the reset vector?
    Tools>Options>Embedded
    Debug Reset @: Reset Vector
    Debug Startup: Halt at Reset Vector



    Setting it up like that does allow me to single-step through my crt0.s, but since starting the debug session erases the upper boot segment it destroys the condition I'm trying to debug  :(
    #5
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: Is there any way to debug without writing any memories at all? 2017/12/07 09:08:14 (permalink)
    0
    Is it even possible to debug PICs without replacing the contents of boot flash? Does the debugger rely on putting some kind of special sauce in that area of memory?
     
    #6
    aschen0866
    Super Member
    • Total Posts : 4184
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: Is there any way to debug without writing any memories at all? 2017/12/07 11:04:55 (permalink)
    +2 (2)
    Noble_Techno
    Does the debugger rely on putting some kind of special sauce in that area of memory?

    Yes. For the PIC32MZ family, the debug executive resides in a reserved BFM area. It is the debugger that injects this piece of code while it is downloading the debug version of the firmware. Also, for the debug to run, #pragma config DEBUG needs to be set to ON, which is done by the debugger as well. There is a small amount of data memory that needs to be reserved at the very beginning of the data.
     
    I read your previous thread but hesitated to comment. I am not using Harmony so perhaps people using Harmony Live Update can comment on this.  The first thing I don't understand is why you need a custom startup code. The compiler already provides two functions, namely _on_reset () and _on_bootstrap(). _on_reset() is where you can put your own code at the earliest possible point. _on_bootstrap() is where you can do something before main() is reached. Although I have never tested, I would guess _on_reset() is where you should check the BFSWAP bit and set up PFSWAP accordingly.
     
    post edited by aschen0866 - 2017/12/07 11:10:42
    #7
    Noble_Techno
    Starting Member
    • Total Posts : 38
    • Reward points : 0
    • Joined: 2017/06/07 05:50:56
    • Location: 0
    • Status: offline
    Re: Is there any way to debug without writing any memories at all? 2017/12/11 01:57:28 (permalink)
    0
    aschen0866
    Yes. For the PIC32MZ family, the debug executive resides in a reserved BFM area.

     
    Ah. Thanks for confirming. I wonder if there's some way I can set the debug session up to have the debug BFM in both boot partitions, with different sequences, so that at least I can step through and see what's going on?
     
    aschen0866
    The first thing I don't understand is why you need a custom startup code.

     
    I'm sure it's not the only way to do it - to be honest I didn't know about _on_reset() so I'll try that and see how I get on.
     
    Thanks for your response!
    #8
    Jump to:
    © 2017 APG vNext Commercial Version 4.5