When it comes to debugging programs, the first tool in my toolbox for compiled languages like C or C++ is usually 'print'. I don't tend to bust out a debugger unless I'm in an IDE such as IntelliJ.
This can pose problems for me in a relatively print-challenged environment, such as msp430 on Linux. Last night I had found myself in just this situation when I found myself musing on why the msp430 upload tool was called mspdebug. A quick search found a nice manual and a few minutes later I was debugging away.
Here's a sample transcript:
With the sketch already uploaded to the board, this script shows how to:
This can pose problems for me in a relatively print-challenged environment, such as msp430 on Linux. Last night I had found myself in just this situation when I found myself musing on why the msp430 upload tool was called mspdebug. A quick search found a nice manual and a few minutes later I was debugging away.
Here's a sample transcript:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msp430fr5739$ /usr/local/energia/hardware/tools/msp430/bin/msp430-nm Blink.elf > Blink.out | |
msp430fr5739$ mspdebug -q rf2500 | |
Trying to open interface 1 on 056 | |
rf2500: warning: can't detach kernel driver: No data available | |
Device: MSP430FR5739 | |
fet: FET returned NAK | |
warning: device does not support power profiling | |
(mspdebug) sym import Blink.out | |
(mspdebug) setbreak setup | |
Set breakpoint 0 | |
(mspdebug) run | |
Running. Press Ctrl+C to interrupt... | |
( PC: 0c2c0) ( R4: 08fbf) ( R8: 00091) (R12: 08ffc) | |
( SP: 01ffe) ( R5: 05a0c) ( R9: 00000) (R13: 00001) | |
( SR: 0000a) ( R6: 07dd3) (R10: 0c276) (R14: 00000) | |
( R3: 00000) ( R7: 03f4b) (R11: 0c276) (R15: 00000) | |
setup: | |
0c2c0: b0 12 fc c3 CALL #_ZN5Tasks4initEv (Tasks::init) | |
0c2c4: 3f 40 00 1c MOV #blink, R15 | |
0c2c8: 1e 42 00 1c MOV &blink, R14 | |
0c2cc: ae 12 CALL @R14 | |
0c2ce: 3e 40 | |
(mspdebug) step | |
( PC: 0c3fc) ( R4: 08fbf) ( R8: 00091) (R12: 08ffc) | |
( SP: 01ffc) ( R5: 05a0c) ( R9: 00000) (R13: 00001) | |
( SR: 0000a) ( R6: 07dd3) (R10: 0c276) (R14: 00000) | |
( R3: 00000) ( R7: 03f4b) (R11: 0c276) (R15: 00000) | |
_ZN5Tasks4initEv (Tasks::init): | |
0c3fc: c2 93 ae 1c TST.B &_ZGVZN5Tasks4initEvE4main | |
0c400: 05 20 JNZ 0xc40c | |
0c402: b2 40 20 c7 b6 1c MOV #0xc720, &_ZZN5Tasks4initEvE4main | |
0c408: d2 43 ae 1c MOV.B #0x0001, &_ZGVZN5Tasks4initEvE4main |
With the sketch already uploaded to the board, this script shows how to:
- Generate a name-list from the sketch's Elf file
- Import these symbols into the debugger
- Set a breakpoint by name in the program
- Run the sketch up to the breakpoint
- Single-step the program once the breakpoint has been reached.
If you're interested, the sketch is a rather convoluted version of Blink.
No comments:
Post a Comment