Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dist/tools/mspdebug: build from source #20345

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

maribu
Copy link
Member

@maribu maribu commented Feb 6, 2024

Contribution description

This adds mspdebug as package, similar to EDBG, so that the programmer/debugger is build from source.

This has the advantage that we can indeed provide patches of our own. The first patch fixes a bug with the CPU detection of mspdebug in combination with the Olimex MSP430-JTAG-TINY-V2. The second adds the --expect-id <CPU_NAME> argument.

The RIOT integration is updated to directly make use of the --expect-id parameter. No more spending time debugging why firmware the firmware for the olimex-msp430-h2618 doesn't run when flashed on the olimex-msp430h1611 hardware :D

Testing procedure

Connect an MSP430 board to the Olimex MSP430-JTAG-TINY-V2, subsequently named CORRECT_MSP430_BOARD. DO NOT connect WRONG_MSP430_BOARD (any other MSP430 board but the one connected).

The following should now fail with this PR, while it won't fail on master:

make BOARD=<WRONG_MSP430_BOARD> -C examples/default flash
make BOARD=<WRONG_MSP430_BOARD> -C examples/default debug-server
make BOARD=<WRONG_MSP430_BOARD> -C examples/default debug

The following should still work (did also work on master):

make BOARD=<CORRECT_MSP430_BOARD> -C examples/default flash
make BOARD=<CORRECT_MSP430_BOARD> -C examples/default debug-server
make BOARD=<CORRECT_MSP430_BOARD> -C examples/default debug

Finally, flashing and debugging should work even without mspdebug installed locally.

Issues/PRs references

None

This adds mspdebug as package, similar to EDBG, so that the
programmer/debugger is build from source.

This has the advantage that we can indeed provide patches of our own.
The first patch fixes a bug with the CPU detection of `mspdebug` in
combination with the Olimex MSP430-JTAG-TINY-V2. The second adds the
`--expect-id <CPU_NAME>` argument.

The RIOT integration is updated to directly make use of the
`--expect-id` parameter. No more spending time debugging why firmware
the firmware for the `olimex-msp430-h2618` doesn't run when flashed on
the `olimex-msp430h1611` hardware :D
@maribu maribu added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: tools Area: Supplementary tools labels Feb 6, 2024
@maribu maribu requested a review from OlegHahm February 6, 2024 14:32
@github-actions github-actions bot added the Area: build system Area: Build system label Feb 6, 2024
@maribu
Copy link
Member Author

maribu commented Feb 6, 2024

With the olimex-msp430-h1611 connected, flashing/debugging the wrong board:

make BOARD=olimex-msp430-h2618 -C examples/hello-world flash
make: Entering directory '/home/maribu/Repos/software/RIOT/master/examples/hello-world'
Building application "hello-world" for "olimex-msp430-h2618" with MCU "msp430".

"make" -C /home/maribu/Repos/software/RIOT/master/boards/common/init
"make" -C /home/maribu/Repos/software/RIOT/master/boards/olimex-msp430-h2618
"make" -C /home/maribu/Repos/software/RIOT/master/core
"make" -C /home/maribu/Repos/software/RIOT/master/core/lib
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/msp430
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/msp430/periph
"make" -C /home/maribu/Repos/software/RIOT/master/drivers
"make" -C /home/maribu/Repos/software/RIOT/master/drivers/periph_common
"make" -C /home/maribu/Repos/software/RIOT/master/sys
"make" -C /home/maribu/Repos/software/RIOT/master/sys/auto_init
"make" -C /home/maribu/Repos/software/RIOT/master/sys/div
"make" -C /home/maribu/Repos/software/RIOT/master/sys/libc
"make" -C /home/maribu/Repos/software/RIOT/master/sys/malloc_thread_safe
"make" -C /home/maribu/Repos/software/RIOT/master/sys/newlib_syscalls_default
"make" -C /home/maribu/Repos/software/RIOT/master/sys/preprocessor
"make" -C /home/maribu/Repos/software/RIOT/master/sys/stdio_uart
/usr/lib/gcc/msp430-elf/13.2.0/../../../../msp430-elf/bin/ld: warning: /home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h2618/hello-world.elf has a LOAD segment with RWX permissions
   text	  data	   bss	   dec	   hex	filename
   6789	   156	  1066	  8011	  1f4b	/home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h2618/hello-world.elf
/home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/mspdebug -j --expect-id "MSP430F2618" olimex "prog /home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h2618/hello-world.hex"
MSPDebug version 0.25 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2017 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.15.0.1 Copyright (C) 2013 TI, Inc.

Resetting Olimex command processor...
Initializing FET...
FET protocol version is 20000007
Set Vcc: 3000 mV
Configured for JTAG (2)
Sending reset...
Using Olimex identification procedure
Device ID: 0xf16c
  Code start address: 0x4000
  Code size         : 49152 byte = 48 kb
  RAM  start address: 0x200
  RAM  end   address: 0x9ff
  RAM  size         : 2048 byte = 2 kb
Device: MSP430F1611
Number of breakpoints: 8
fet: FET returned error code 34 (Not supported by selected interface or interface is not initialized)
fet: warning: message C_IDENT3 failed
fet: FET returned NAK
warning: device does not support power profiling
Device: MSP430F1611
Detected MSP430F1611, but MSP430F2618 was expected
make: *** [/home/maribu/Repos/software/RIOT/master/examples/hello-world/../../Makefile.include:861: flash] Error 255
make: Leaving directory '/home/maribu/Repos/software/RIOT/master/examples/hello-world'
make BOARD=olimex-msp430-h2618 -C examples/hello-world debug-server
make: Entering directory '/home/maribu/Repos/software/RIOT/master/examples/hello-world'
/home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/debug_srv.sh /home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/mspdebug olimex JTAG "" "" "MSP430F2618" 2000
MSPDebug version 0.25 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2017 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.15.0.1 Copyright (C) 2013 TI, Inc.

Resetting Olimex command processor...
Initializing FET...
FET protocol version is 20000007
Set Vcc: 3000 mV
Configured for JTAG (2)
Sending reset...
Using Olimex identification procedure
Device ID: 0xf16c
  Code start address: 0x4000
  Code size         : 49152 byte = 48 kb
  RAM  start address: 0x200
  RAM  end   address: 0x9ff
  RAM  size         : 2048 byte = 2 kb
Device: MSP430F1611
Number of breakpoints: 8
fet: FET returned error code 34 (Not supported by selected interface or interface is not initialized)
fet: warning: message C_IDENT3 failed
fet: FET returned NAK
warning: device does not support power profiling
Device: MSP430F1611
Detected MSP430F1611, but MSP430F2618 was expected
make: *** [/home/maribu/Repos/software/RIOT/master/examples/hello-world/../../Makefile.include:910: debug-server] Error 255
make: Leaving directory '/home/maribu/Repos/software/RIOT/master/examples/hello-world'
make BOARD=olimex-msp430-h2618 -C examples/hello-world debug       
make: Entering directory '/home/maribu/Repos/software/RIOT/master/examples/hello-world'
/home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/debug.sh /home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/mspdebug olimex JTAG "" "" "MSP430F2618" 2000 /home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h2618/hello-world.elf msp430-elf- /home/maribu/Repos/software/RIOT/master
Please wait...
GNU gdb (GDB) 14.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h2618/hello-world.elf...
localhost:2000: Operation timed out.
"monitor" command not supported by this target.
(gdb) 

(OK, Operation timed out. is not the best error message here. But I supposed it is better than silently working already and most of the time one will flash first anyway.)

@maribu
Copy link
Member Author

maribu commented Feb 6, 2024

With the olimex-msp430-h1611 connected flashing/debugging the correct board:

make BOARD=olimex-msp430-h1611 -C examples/hello-world flash 
make: Entering directory '/home/maribu/Repos/software/RIOT/master/examples/hello-world'
Building application "hello-world" for "olimex-msp430-h1611" with MCU "msp430".

"make" -C /home/maribu/Repos/software/RIOT/master/boards/common/init
"make" -C /home/maribu/Repos/software/RIOT/master/boards/olimex-msp430-h1611
"make" -C /home/maribu/Repos/software/RIOT/master/core
"make" -C /home/maribu/Repos/software/RIOT/master/core/lib
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/msp430
"make" -C /home/maribu/Repos/software/RIOT/master/cpu/msp430/periph
"make" -C /home/maribu/Repos/software/RIOT/master/drivers
"make" -C /home/maribu/Repos/software/RIOT/master/drivers/periph_common
"make" -C /home/maribu/Repos/software/RIOT/master/sys
"make" -C /home/maribu/Repos/software/RIOT/master/sys/auto_init
"make" -C /home/maribu/Repos/software/RIOT/master/sys/div
"make" -C /home/maribu/Repos/software/RIOT/master/sys/libc
"make" -C /home/maribu/Repos/software/RIOT/master/sys/malloc_thread_safe
"make" -C /home/maribu/Repos/software/RIOT/master/sys/newlib_syscalls_default
"make" -C /home/maribu/Repos/software/RIOT/master/sys/preprocessor
"make" -C /home/maribu/Repos/software/RIOT/master/sys/stdio_uart
/usr/lib/gcc/msp430-elf/13.2.0/../../../../msp430-elf/bin/ld: warning: /home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h1611/hello-world.elf has a LOAD segment with RWX permissions
   text	  data	   bss	   dec	   hex	filename
   7869	   168	  1078	  9115	  239b	/home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h1611/hello-world.elf
/home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/mspdebug -j --expect-id "MSP430F1611" olimex "prog /home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h1611/hello-world.hex"
MSPDebug version 0.25 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2017 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.15.0.1 Copyright (C) 2013 TI, Inc.

Resetting Olimex command processor...
Initializing FET...
FET protocol version is 20000007
Set Vcc: 3000 mV
Configured for JTAG (2)
Sending reset...
Using Olimex identification procedure
Device ID: 0xf16c
  Code start address: 0x4000
  Code size         : 49152 byte = 48 kb
  RAM  start address: 0x200
  RAM  end   address: 0x9ff
  RAM  size         : 2048 byte = 2 kb
Device: MSP430F1611
Number of breakpoints: 8
fet: FET returned error code 34 (Not supported by selected interface or interface is not initialized)
fet: warning: message C_IDENT3 failed
fet: FET returned NAK
warning: device does not support power profiling
Device: MSP430F1611
Erasing...
Programming...
Writing  483 bytes at 4000...
Writing 4096 bytes at 41e4...
Writing 3454 bytes at 51e4...
Writing    2 bytes at ffe6...
Writing    2 bytes at fffe...
Done, 8037 bytes total
make: Leaving directory '/home/maribu/Repos/software/RIOT/master/examples/hello-world'
make BOARD=olimex-msp430-h1611 -C examples/hello-world debug-server
make: Entering directory '/home/maribu/Repos/software/RIOT/master/examples/hello-world'
/home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/debug_srv.sh /home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/mspdebug olimex JTAG "" "" "MSP430F1611" 2000
MSPDebug version 0.25 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2017 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.15.0.1 Copyright (C) 2013 TI, Inc.

Resetting Olimex command processor...
Initializing FET...
FET protocol version is 20000007
Set Vcc: 3000 mV
Configured for JTAG (2)
Sending reset...
Using Olimex identification procedure
Device ID: 0xf16c
  Code start address: 0x4000
  Code size         : 49152 byte = 48 kb
  RAM  start address: 0x200
  RAM  end   address: 0x9ff
  RAM  size         : 2048 byte = 2 kb
Device: MSP430F1611
Number of breakpoints: 8
fet: FET returned error code 34 (Not supported by selected interface or interface is not initialized)
fet: warning: message C_IDENT3 failed
fet: FET returned NAK
warning: device does not support power profiling
Device: MSP430F1611
Bound to port 2000. Now waiting for connection...
make BOARD=olimex-msp430-h1611 -C examples/hello-world debug       
make: Entering directory '/home/maribu/Repos/software/RIOT/master/examples/hello-world'
/home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/debug.sh /home/maribu/Repos/software/RIOT/master/dist/tools/mspdebug/mspdebug olimex JTAG "" "" "MSP430F1611" 2000 /home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h1611/hello-world.elf msp430-elf- /home/maribu/Repos/software/RIOT/master
Please wait...
GNU gdb (GDB) 14.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/maribu/Repos/software/RIOT/master/examples/hello-world/bin/olimex-msp430-h1611/hello-world.elf...
Remote debugging using localhost:2000
__crt0_start () at /home/buildozer/aports/community/newlib/src/newlib-4.3.0.20230120/libgloss/msp430/crt0.S:56
warning: 56	/home/buildozer/aports/community/newlib/src/newlib-4.3.0.20230120/libgloss/msp430/crt0.S: No such file or directory
(gdb) break main
Breakpoint 1 at 0x42ea: file /home/maribu/Repos/software/RIOT/master/examples/hello-world/main.c, line 26.
(gdb) monitor reset
(gdb) cont
Continuing.

Breakpoint 1, main () at /home/maribu/Repos/software/RIOT/master/examples/hello-world/main.c:26
26	   puts("Hello World!");
(gdb) 

@riot-ci
Copy link

riot-ci commented Feb 6, 2024

Murdock results

✔️ PASSED

aafc099 dist/tools/mspdebug: build from source

Success Failures Total Runtime
10016 0 10016 09m:37s

Artifacts

@maribu maribu added this pull request to the merge queue Feb 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 6, 2024
@maribu maribu added this pull request to the merge queue Feb 6, 2024
Merged via the queue into RIOT-OS:master with commit 80cdde4 Feb 6, 2024
29 checks passed
@maribu maribu deleted the dist/tools/mspdebug branch February 6, 2024 18:16
@maribu
Copy link
Member Author

maribu commented Feb 6, 2024

Thx :)

@MrKevinWeiss MrKevinWeiss added this to the Release 2024.04 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants