Skip to content

boards/any silabs: Allow selecting OpenOCD #10475

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

Merged
merged 5 commits into from
Feb 24, 2020

Conversation

chrysn
Copy link
Member

@chrysn chrysn commented Nov 26, 2018

Contribution description

This adds support for flashing and debugging an STK3700 board using the OpenOCD debugger.

OpenOCD support for those chips and board is good in 0.10, all it needs is the hint that it's possible. I've used the seemingly common PROGRAMMER=... idiom to allow picking one's tools.

Testing procedure

In any example (I'm using saul), run make BOARD=stk3700 PROGRAMMER=openocd flash term

PR scope

I've only changed the behavior I could test. If someone can confirm that OpenOCD works with Leopard Gecko boards (STK3600) as well, I can apply the same changes there as well.

In principle, the same works also for sltb001a, but that requires an OpenOCD git master version (actually only 1y old, but they haven't had a release since then) -- if requiring an unreleased OpenOCD version (for the non-default programmer) is OK, I'd add that there as well.

(Those changes would well go in one commit as their Makefile.include files are virtually identical.)

@@ -0,0 +1 @@
source [find board/efm32.cfg]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I think this change should work with all stk boards. I can try on slstk4201a.

@miri64 miri64 added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: tools Area: Supplementary tools Area: boards Area: Board ports labels Nov 30, 2018
@stale
Copy link

stale bot commented Aug 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
@chrysn
Copy link
Member Author

chrysn commented Aug 10, 2019

From my point of view this issue is still in the shape to proceed, and just needs someone to OK it to continue. @aabadie, you mentioned you could test it, would you mind?

@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
@stale
Copy link

stale bot commented Feb 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Feb 11, 2020
@chrysn
Copy link
Member Author

chrysn commented Feb 11, 2020

This is just lacking reviews. @aabadie, could you still review, or should I rather ping other EFM32 maintainers?

@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Feb 11, 2020
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 13, 2020
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is just a simple switch, you might just put that into boards/common/silabs/Makefile.include.

You can also move the openocd.cfg there, just add a OPENOCD_CONFIG ?= $(RIOTBOARD)/common/silabs/dist/openocd.cfg and you should be good.


ifeq ($(PROGRAMMER),jlink)
# setup JLink for flashing
export JLINK_DEVICE := $(CPU_MODEL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be set unconditionally.

@benemorius
Copy link
Member

I tested this on stk3700 and it works great with openocd master. I get strange errors with the 0.10.0 tagged release but of course that's not because of this pr.

openocd master
$ BOARD=stk3700 PROGRAMMER=openocd make flash-only
/home/stilwellt/projects/RIOT-kw41z/dist/tools/openocd/openocd.sh flash /home/stilwellt/projects/RIOT-kw41z/examples/default/bin/stk3700/default.elf
### Flashing Target ###
Open On-Chip Debugger 0.10.0+dev-01060-g0a11537b (2020-02-13-21:25)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
cortex_m reset_config sysresetreq
                                                                                
Info : Energy Micro EFM32 compiled Apr 20 2016 12:17:23                          
Info : Hardware version: 1.00                                                     
Info : VTarget = 3.280 V                                                           
Info : clock speed 1000 kHz                                                         
Info : SWD DPIDR 0x2ba01477                                                           
Info : efm32.cpu: hardware has 6 breakpoints, 4 watchpoints                             
Info : Listening on port 42639 for gdb connections                                       
    TargetName         Type       Endian TapName            State                          
--  ------------------ ---------- ------ ------------------ ------------                     
 0* efm32.cpu          cortex_m   little efm32.cpu          running                           
                                                                                                
target halted due to debug-request, current mode: Thread                                         
xPSR: 0x01000000 pc: 0x00000444 msp: 0x20000200                                                    
Info : detected part: EFM32GG Giant Gecko, rev 18                                                    
Info : flash size = 1024kbytes                                                                        
Info : flash page size = 4096bytes
auto erase enabled
wrote 28672 bytes from file /home/stilwellt/projects/RIOT-kw41z/examples/default/bin/stk3700/default.elf in 1.025120s (27.314 KiB/s)

verified 27108 bytes in 0.298932s (88.557 KiB/s)

shutdown command invoked
Done flashing
openocd v0.10.0
$ BOARD=stk3700 PROGRAMMER=openocd make flash-only
/home/stilwellt/projects/RIOT-kw41z/dist/tools/openocd/openocd.sh flash /home/stilwellt/projects/RIOT-kw41z/examples/default/bin/stk3700/default.elf
### Flashing Target ###
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
adapter speed: 1000 kHz
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : Energy Micro EFM32 compiled Apr 20 2016 12:17:23
Info : Hardware version: 1.00
Info : VTarget = 3.279 V
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : efm32.cpu: hardware has 6 breakpoints, 4 watchpoints
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* efm32.cpu          cortex_m   little efm32.cpu          running
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000444 msp: 0x20000200
auto erase enabled
Info : detected part: EFM32 Giant Gecko - Rev: 18
Info : flash size = 1024kbytes
Info : flash page size = 4096bytes
Error: jaylink_swd_io() failed: JAYLINK_ERR_DEV_NO_MEMORY.
Warn : Sending data to device timed out, retrying.
Warn : Sending data to device timed out, retrying.
Error: Sending data to device timed out.
Error: transport_write() failed: timeout occurred.
Error: jaylink_swd_io() failed: JAYLINK_ERR_TIMEOUT.
Warn : Last read operation left 16 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Error: flash write algorithm aborted by target
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 16 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Error: efm32.cpu -- clearing lockup after double fault
Warn : Last read operation left 34 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 9 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 15 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 9 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 33 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 9 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 33 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 22 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 16 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 33 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Error: efm32.cpu -- clearing lockup after double fault
Warn : Last read operation left 33 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 9 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Error: error waiting for target flash write algorithm
Warn : Last read operation left 15 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 34 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Warn : Last read operation left 16 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_swd_io() failed: JAYLINK_ERR.
Error: error writing to flash at address 0x00000000 at offset 0x00000000

Warn : Last read operation left 16 bytes.
Error: Failed to send data to device: LIBUSB_ERROR_PIPE.
Error: transport_write() failed: unspecified error.
Error: jaylink_unregister() failed: JAYLINK_ERR.
/home/stilwellt/projects/RIOT-kw41z/examples/default/../../Makefile.include:671: recipe for target 'flash-only' failed
make: *** [flash-only] Error 1

@chrysn
Copy link
Member Author

chrysn commented Feb 14, 2020

Moving things to silabs/Makefile.include is tempting though of larger scope. It'd mean removing the jlink includes from the boards that use common, set a PROGRAMMER ?= there and switch.

I'll give it a try localy -- @benemorius, would you also have this in here, or rather in a follow-up PR?

(One reason I originally had this stk3700-only was that sltb001a requried OpenOCD master. Given that 0.10.0 ostensibly causes trouble with stk3700 as well, might just as well go all the way.)

@aabadie
Copy link
Contributor

aabadie commented Feb 14, 2020

I've applied the same changes to the slstk3402a and it's working. I'm using fairly recent and manually built version of openocd.
I remember I was not able to make it work with openocd 0.10.0. So I think it's worth moving the openocd configuration in a common location (boards/common/silabs seems to be the good candidate) and deduplicate the JLink configuration. This can be done in a follow-up PR if you want to move faster with this one @chrysn.

OpenOCD works well with those devices; the OpenOCD config is provided at
the default location and only needs to refer to the setup that OpenOCD
ships.
OpenOCD already ships config files for the EFM32 and EFR32 family, no
need to duplicate them in RIOT; this removes the "file exists" check for
files that are clearly OpenOCD-shipped board configurations, as the
script can't (and shouldn't) know OpenOCD's include paths.
This removes duplication for the jlink case (keeping only any
non-default values in the board makefiles), and opens up STK3700's
OpenOCD programmability for generic boards.
@chrysn
Copy link
Member Author

chrysn commented Feb 14, 2020

Not too much point in having the STK3700 as a test balloon then; I've generalized this to all silabs boards. (Force push as the original commit is rebased onto master; it's become a bit hard to handle otherwise. The first commit is still the same, though).

The changes to the OpenOCD build script were added to avoid having a single-line openocd.cfg for each and every board (or one in the common area): The goal of the check that is conditionally disabled is to have errors fly out of of make rather than of openocd, but the single-line config would just be a band-aid over that check, because if the included file is actually not present, openocd would just err again.

(By the way, I do get the error with OpenOCD 0.10.0 occasionally as well, but pressing the reset button does wonders there.)

@chrysn chrysn force-pushed the openocd-for-stk3700 branch from 2b02a99 to 1dbf07f Compare February 14, 2020 08:48
@chrysn chrysn changed the title boards/stk3700: Allow selecting OpenOCD boards/any silabs: Allow selecting OpenOCD Feb 14, 2020
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice clean up and @benemorius and @aabadie confirmed it's still working.
We don't have to test this for every board.

@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs labels Feb 21, 2020
@miri64
Copy link
Member

miri64 commented Feb 21, 2020

Is it a good idea to skip build tests for a change to the build system? Even if it doesn't effect building, one syntax error in the Makefile can introduce a regression.

@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs labels Feb 21, 2020
@benpicco benpicco merged commit 4671fd2 into RIOT-OS:master Feb 24, 2020
@leandrolanzieri leandrolanzieri added this to the Release 2020.04 milestone Mar 13, 2020
@chrysn chrysn deleted the openocd-for-stk3700 branch July 2, 2020 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports 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: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants