Shop OBEX P1 Docs P2 Docs Learn Events
Propeller 2 Debug system — Parallax Forums

Propeller 2 Debug system

Hi All

Here's my Propeller 2 Debugger.
It's Python based and makes use of P2's debug interrupt mechanism.
It currently only supports debugging one cog a a time.

The cog ubnder test can be single stepped and monitored with a variety of commands
such as disassembly,wathlist,flag modification,stack manipulation and memory related
functions.

The code requires Python 3 and pyserial (see pyserial site).

The debuggers command line options can be found by
 python p2debug7_5.py -?

To load the sample denug code.
 python p2debug7_5.py sample1

The debugger will search for a P2 on all available com ports.
If a P2 is detected the object file will be loaded into the P2.
If available a .lst file is scanned for symbol information.
The debugger recognizes pnut , fastspin and p2asm format list files.

When you are presented with the debug prompt ">" type "help" or "help1" for a list
of commands and examples.
For an interactive demo type "intro". A log of the 'intro' session can be found in the 'oz.txt' file.

For pnut users make sure you use "Ctrl-M" "Ctrl-S" to generate a .lst file.
For p2asm users use the -o option to generate a .bin object file.

See the sample1.spin2 source file to see how the debugger attaches to your code.

This is still a work in progress, code needs tidying up. I need to expand on the documentation and build
some more interactive demos first!

:)


Comments

  • cgraceycgracey Posts: 14,133
    Ozpropdev, would it be possible to make a little video of it operating. That would convey the idea pretty well.
  • Thanks for posting this Brian! I haven't had a chance to really use it yet, but did get the sample to work on my Linux machine. A few notes for Linux users:

    (1) If your machine has both python2 and python3 installed, make sure to use python3 to run P2Debug7_5.py.

    (2) I had to increase the timeouts in find_p2() from "sleep(0.01)" to "sleep(0.1)" (with 0.01 the P2 wasn't being detected).

    (3) Running the sample1 program worked fine, but when I tried to load my own program (compiled with fastspin) I got a "Loading failed!,no response from P2" message. My program is a bit larger than sample1.obj (6528 bytes), I'm not sure if that's the problem or not.

  • ersmithersmith Posts: 5,913
    edited 2019-08-20 11:02
    ersmith wrote: »
    (3) Running the sample1 program worked fine, but when I tried to load my own program (compiled with fastspin) I got a "Loading failed!,no response from P2" message. My program is a bit larger than sample1.obj (6528 bytes), I'm not sure if that's the problem or not.

    Never mind, I see the problem now, I don't have the debug code linked in to my program.
  • I just wanted to try it out but python forces me to install >1GB windows updates, first. I'll be back tomorrow when the download has finished... (slow internet here in the black forest) :neutral:
  • Wow, I have managed to install python, install pyserial and P2debug is running
    G:\Projekte\Speedcube3\Source\Propeller\Debug>python P2Debug7_5.py sample1
    spin2.ref loaded.
    Scanning ports....
    COM1 =  no P2 found.
    COM3 = Prop_Ver G
    Port = COM3
    Baud rate = 1000000
    Debug port is COM3
    File: sample1.obj : P2-ES Silicon
    HUBSET #1 Ok
    HUBSET #2 Ok
    loader baud = 3000000
    Loading complete
    32 symbols loaded from pnut format 'sample1' file
    [running](step) >
    
    :smile: At least it loads the code and gives a prompt. Now I have to learn the commands...
  • Hmm, when I try "step" it says "not available while running". When I try to "stop" I get a "*** timeout" and the shell window closes. :neutral:

    I think I have to wait for the new version.
  • ManAtWork wrote: »
    Hmm, when I try "step" it says "not available while running". When I try to "stop" I get a "*** timeout" and the shell window closes. :neutral:

    I think I have to wait for the new version.

    It's the same for me.
  • evanhevanh Posts: 15,187
    edited 2021-02-14 02:32

    Lol, I've just discovered this doesn't always load a program in stopped debug state. My first attempt to use p2debug7_5.py has resulted in the target program always taking over and running as normal. Said program is Chip's interrupt driven NTSC_256_x_192_interrupt.spin2. What I'm wanting is the disassembled machine code. In fact, only the first three (six including AUGDs) instructions:

    9dd680ff 003064fd 860180ff 1f8066fd 9dd680ff 003664fd
    

    PS: I know they'll be HUBSET, WAITX, HUBSET, in that order.

Sign In or Register to comment.