Disclaimer: sorry for the long reply… I’m really excited with the principles behind platformIO
. It seems to be extremely fitted to be used in classrooms to expose the toolchain quite a bit more for my students without all the incidental complexity of setting up the toolchain themselves (which is a really pain in the **s for novices).
I confirm debugging does not work either, probably for all MSP430 boards. I’m still trying to fiddle to see if I can figure out a solution but I got stuck…
-
To upload, as described above, the msp430.dylib for dslite is broken. It can be solved by taking the binary file from Texas instruments open source tools as described above.
-
Default compiler flags are buggy. Can be easily solved by adding debug_build_flags = -O0 -g3 -ggdb3
to the platformio.ini file. Would be nice to have those as default…
$ pio debug -v
Processing lpmsp430f5529 (platform: timsp430; board: lpmsp430f5529)
--------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/timsp430/lpmsp430f5529.html
PLATFORM: TI MSP430 (2.2.0) > TI LaunchPad MSP-EXP430F5529LP
HARDWARE: MSP430F5529 25MHz, 8KB RAM, 47KB Flash
DEBUG: Current (mspdebug) On-board (mspdebug)
PACKAGES:
- toolchain-timsp430 1.40603.190926 (4.6.3)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
msp430-g++ -o .pio/build/lpmsp430f5529/src/main.o -c -fno-exceptions -fno-threadsafe-statics -ffunction-sections -fdata-sections -mmcu=msp430f5529 -Og -g2 -ggdb2 -DF_CPU=25000000L -DPLATFORMIO=50003 -DENERGIA_ARCH_MSP430 -DENERGIA_MSP_EXP430F5529LP -D__PLATFORMIO_BUILD_DEBUG__ -Iinclude -Isrc src/main.cpp
cc1plus: error: argument to '-O' should be a non-negative integer
*** [.pio/build/lpmsp430f5529/src/main.o] Error 1
- The debugger, however is based on
mspdebug
and it is being requested to use the dslite driver by default which it does not understand.
$ piodebuggdb -v
Preparing firmware for debugging...
Processing lpmsp430f5529 (platform: timsp430; board: lpmsp430f5529; debug_build_flags: -O0 -g3 -ggdb3)
--------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/timsp430/lpmsp430f5529.html
PLATFORM: TI MSP430 (2.2.0) > TI LaunchPad MSP-EXP430F5529LP
HARDWARE: MSP430F5529 25MHz, 8KB RAM, 47KB Flash
DEBUG: Current (mspdebug) On-board (mspdebug)
PACKAGES:
- toolchain-timsp430 1.40603.190926 (4.6.3)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
MethodWrapper(["checkprogsize"], [".pio/build/lpmsp430f5529/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 0.0% (used 2 bytes from 8192 bytes)
Flash: [ ] 0.7% (used 330 bytes from 48128 bytes)
.pio/build/lpmsp430f5529/firmware.elf :
section size addr
.text 202 17408
.noinit 2 9216
.vectors 128 65408
.debug_aranges 144 0
.debug_info 882 0
.debug_abbrev 277 0
.debug_line 812 0
.debug_frame 60 0
.debug_str 206 0
.debug_loc 64 0
.debug_macinfo 75105 0
.debug_ranges 12 0
Total 77894
========================= [SUCCESS] Took 0.37 seconds =========================
MSPDebug version 0.24 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2016 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.3.1.4 Copyright (C) 2013 TI, Inc.
Unknown driver: dslite. Try --help for a list.
Reading symbols from /Users/jose.edil/2-development/ti/pio-workspace/Blink/.pio/build/lpmsp430f5529/firmware.elf...done.
(gdb)
I’m quite familiar with mspdebug
and even tough the command line does not show in the log, it is probably trying to call it with mspdebug dslite
which yields
MSPDebug version 0.24 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2016 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.3.1.4 Copyright (C) 2013 TI, Inc.
Unknown driver: dslite. Try --help for a list.
In my experience, mspdebug
works best with the Launchpad boards using the tilib
driver (which is based on the same lib I pointed before in the dslite solution). Unfortunately the pio version yields:
❯ ./mspdebug tilib
MSPDebug version 0.24 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2016 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.3.1.4 Copyright (C) 2013 TI, Inc.
tilib_api: can't find libmsp430.so: dlopen(libmsp430.so, 1): image not found
which is quite weird as in OSX the dynamic libraries use the .dylib suffix. Anyhow, I copied the same libmsp430.dylib to the ~/.platformio/packages/tool-mspdebug
folder and renamed accordingly and it connects to the board when called from within the ~/.platformio/packages/tool-mspdebug
folder:
❯ ls
builtin_tools_versions.txt mspdebug
libmsp430.so package.json
jose.edil in .platformio/packages/tool-mspdebug
❯ ./mspdebug tilib
MSPDebug version 0.24 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2016 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.3.1.4 Copyright (C) 2013 TI, Inc.
Using new (SLAC460L+) API
MSP430_GetNumberOfUsbIfs
MSP430_GetNameOfUsbIf
Found FET: usbmodem141201
MSP430_Initialize: usbmodem141201
Firmware version is 31501001
…
This does not work in VS Code, however, it complains about not finding the library file. The default folder mspdebug
looks for the library is /usr/local/lib
(I inspected the source code a long time ago…) so the libmsp430.dylib
should be renamed and copied there. This breaks the nice sandbox of platformIO
but I could not advance without it…
By adding
debug_tool = mspdebug
upload_protocol = tilib
to the project .ini file pio
now tries do do everything with mspdebug
. It uploads the binary on the CLI and in VS Code, but the debugger in VS Code seems to start and then halt. In the command line it is able to start everything but:
❯ piodebuggdb -v
Preparing firmware for debugging...
Processing lpmsp430f5529 (platform: timsp430; board: lpmsp430f5529; upload_protocol: tilib; debug_tool: mspdebug; debug_build_flags: -O0 -g3 -ggdb3)
--------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/timsp430/lpmsp430f5529.html
PLATFORM: TI MSP430 (2.2.0) > TI LaunchPad MSP-EXP430F5529LP
HARDWARE: MSP430F5529 25MHz, 8KB RAM, 47KB Flash
DEBUG: Current (mspdebug) On-board (mspdebug)
PACKAGES:
- toolchain-timsp430 1.40603.190926 (4.6.3)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
MethodWrapper(["checkprogsize"], [".pio/build/lpmsp430f5529/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 0.0% (used 2 bytes from 8192 bytes)
Flash: [ ] 0.7% (used 330 bytes from 48128 bytes)
.pio/build/lpmsp430f5529/firmware.elf :
section size addr
.text 202 17408
.noinit 2 9216
.vectors 128 65408
.debug_aranges 144 0
.debug_info 882 0
.debug_abbrev 277 0
.debug_line 812 0
.debug_frame 60 0
.debug_str 206 0
.debug_loc 64 0
.debug_macinfo 75105 0
.debug_ranges 12 0
Total 77894
========================= [SUCCESS] Took 0.40 seconds =========================
MSPDebug version 0.24 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2016 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chip info database from MSP430.dll v3.3.1.4 Copyright (C) 2013 TI, Inc.
Using new (SLAC460L+) API
MSP430_GetNumberOfUsbIfs
MSP430_GetNameOfUsbIf
Found FET: usbmodem141201
MSP430_Initialize: usbmodem141201
Firmware version is 31501001
MSP430_VCC: 3000 mV
Reading symbols from /Users/jose.edil/2-development/ti/pio-workspace/Blink/.pio/build/lpmsp430f5529/firmware.elf...done.
(gdb) MSP430_OpenDevice
MSP430_GetFoundDevice
Device: MSP430F5529 (id = 0x002f)
8 breakpoints available
MSP430_EEM_Init
Chip ID data:
ver_id: 2955
ver_sub_id: 0000
revision: 19
fab: 55
self: 5555
config: 12
Device: MSP430F5529
Bound to port 2000. Now waiting for connection...
it freezes waiting for some input after the mspdebug
initialization which might be what is causing VS Code to abandon the debugging process. Pressing enter gives me the (gdb)
command line. I had to manually connect to the server, which from the platformIO
source code it should be able to automatically do it (if I correctly understood it):
(gdb) target remote :2000
Client connected from 127.0.0.1:51154
Clearing all breakpoints...
Reading 2 bytes from 0x4400
Remote debugging using :2000
_reset_vector__ () at ../../../gcc/gcc/config/msp430/crt0.S:105
in ../../../gcc/gcc/config/msp430/crt0.S
105 ../../../gcc/gcc/config/msp430/crt0.S: No such file or directory.
continue
starts the program on the board as supposed to be, but everytime I try to stop to execution with ctrl-c
gdb breaks and I can’t debug properly…
(gdb) c
Reading 2 bytes from 0x43fa
Reading 2 bytes from 0x43fc
Reading 2 bytes from 0x43fe
Continuing.
Running
^CMSP430_Run
Program received signal SIGTRAP, Trace/breakpoint trap.
../../../gdb/gdb/thread.c:79: internal-error: inferior_thread: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) [answered Y; input not from terminal]
../../../gdb/gdb/thread.c:79: internal-error: inferior_thread: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) [answered Y; input not from terminal]
Remote connection closed
@maxgerhardt isn’t probably better to take this into some issue tracker?