Skip to content

openocd-adapters: select transport based on adapter#14480

Merged
benpicco merged 5 commits intoRIOT-OS:masterfrom
benpicco:openocd-adapters_swd
Aug 4, 2020
Merged

openocd-adapters: select transport based on adapter#14480
benpicco merged 5 commits intoRIOT-OS:masterfrom
benpicco:openocd-adapters_swd

Conversation

@benpicco
Copy link
Copy Markdown
Contributor

@benpicco benpicco commented Jul 9, 2020

Contribution description

Things were a bit muddled since some boards come with a debug adapter while other boards have to use an external one.

This allows for more flexibility in external debug adapter use. The Adapter will select it's default transport, but boards can overwrite them if they need something special (this can only be JTAG instead of SWD since hla_swd is an implementation detail of the adpater and should not be selected by the board.

There are some boards that don't use the DEBUG_ADAPTER property at all and define everything in their private openocd.cfg.

Those can of course still select their own transport, but ideally they should be transferred to openocd-adapters/ so the adapters can be shared with other boards.

Testing procedure

Flashing should still work.
I tried

  • flashing a Kinetis board with OpenOCD
  • flashing a nRF52 board with OpenOCD
  • flashing a board that uses iotlab.inc.mk
  • flashing a board that uses JLink with OpenOCD (all the nrf52xxxdk boards come with an on-board JLink)
  • flashing a mulle board with OpenOCD

Issues/PRs references

alternative to #13858

@benpicco benpicco requested review from aabadie and gschorcht July 9, 2020 15:55
@benpicco benpicco requested a review from haukepetersen as a code owner July 9, 2020 15:55
@benpicco benpicco force-pushed the openocd-adapters_swd branch from ed1fcc5 to 7164c88 Compare July 9, 2020 15:56
@benpicco benpicco added Area: tools Area: Supplementary tools Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Jul 9, 2020
@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jul 9, 2020

Flashing should still work.

Can you provide a list of board/adapter to test (stlink, nrf, kinetis, etc) ? This will simplify the tracking of what needs to be tested.

alternative to #13858

I also prefer this approach over #13858 as it's more generic and covers all openocd adapters.

@benpicco
Copy link
Copy Markdown
Contributor Author

benpicco commented Jul 9, 2020

Can you provide a list of board/adapter to test (stlink, nrf, kinetis, etc) ? This will simplify the tracking of what needs to be tested.

Sure! Well for most adapters, this basically just shuffles around the location of -c 'transport select swd' inside OPENOCD_ADAPTER_INIT so I don't think we need to test them all.

What should be tested is

  • flashing a Kinetis board with OpenOCD
  • flashing a nRF52 board with OpenOCD
  • flashing a board that uses iotlab.inc.mk
  • flashing a board that uses JLink with OpenOCD (all the nrf52xxxdk boards come with an on-board JLink)
  • flashing a mulle board with OpenOCD

And ideally, the Waveshare nRF52840 Eval Kit should now be flashable with ST-Link.
I tried with a nRF52810 board and one of the common ST-Link v2 dongles and wasn't successful, but OpenOCD got called with the right parameters so (hla_swd), it might well be that OpenOCD does not support this device yet.

@gschorcht
Copy link
Copy Markdown
Contributor

I tried with a nRF52810 board and one of the common ST-Link v2 dongles and wasn't successful, but OpenOCD got called with the right parameters so (hla_swd), it might well be that OpenOCD does not support this device yet.

It should work because all Nucleo boards are flashed with OpenOCD, ST-LINKV2 and hla_swd as transport protocol.
I have tested it with the Waveshare nRF52840 Eval Kit and it also works with the following flashing command 👍

PROGRAMMER=openocd DEBUG_ADAPTER=stlink make BOARD=waveshare-nrf52840-eval-kit -C tests/shell flash

@gschorcht
Copy link
Copy Markdown
Contributor

@benpicco Since this PR also solves the problem addressed in PR #13858, I will close PR #13858. However, I would like at least the documentation to be expanded, as suggested in the PR #13858. This could be done piggybacked with this PR.

@gschorcht
Copy link
Copy Markdown
Contributor

Looks good to me and makes sense. Unfortunately I can't support the test because I don't have the boards mentioned in the test list 😟

@benpicco
Copy link
Copy Markdown
Contributor Author

Flashing the openlabs-kw41z-mini with OpenOCD also still works.

@benpicco benpicco force-pushed the openocd-adapters_swd branch from 1e4799a to b6c144d Compare August 2, 2020 19:52
@benpicco benpicco requested review from fjmolinas and maribu August 2, 2020 19:53
Copy link
Copy Markdown
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

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

See inline comment

@benpicco benpicco force-pushed the openocd-adapters_swd branch from cb4a343 to d09e952 Compare August 3, 2020 17:49
@fjmolinas
Copy link
Copy Markdown
Contributor

Test results on IoT-LAB flashing still works, we can skip mulle IMO, not widely available, can't be bought, I think there is one in FU-BERLIN, but that is it AFAIK.

IOTLAB_NODE=m3-9.saclay.iot-lab.info BOARD=iotlab-m3 make -C examples/default/ flash term
iotlab-node --jmespath='keys(@)[0]' --format='int'  --list saclay,m3,9 --update /home/francisco/workspace/RIOT3/examples/default/bin/iotlab-m3/default.elf | grep 0
0
ssh -t [email protected] 'socat - tcp:m3-9.saclay.iot-lab.info:20000'
help
help
Command              Description
---------------------------------------
reboot               Reboot the node
version              Prints current RIOT_VERSION
pm                   interact with layered PM subsystem
ps                   Prints information about running threads.
random_init          initializes the PRNG
random_get           returns 32 bit of pseudo randomness
rtc                  control RTC peripheral interface
ifconfig             Configure network interfaces
txtsnd               Sends a custom string as is over the link layer
saul                 interact with sensors and actuators using SAUL
>

@fjmolinas fjmolinas added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Aug 4, 2020
Copy link
Copy Markdown
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

ACK, please squash @benpicco

@benpicco benpicco force-pushed the openocd-adapters_swd branch from d09e952 to 8f1d32b Compare August 4, 2020 08:37
@benpicco benpicco merged commit 52bf309 into RIOT-OS:master Aug 4, 2020
@benpicco benpicco deleted the openocd-adapters_swd branch August 4, 2020 09:37
@leandrolanzieri
Copy link
Copy Markdown
Contributor

Test results on IoT-LAB flashing still works

I'm not sure testing like this is correct in this case. On current master I'm getting the following error when trying to flash the iotlab-m3:

Info : FTDI SWD mode enabled
swd
Warn : Interface already configured, ignoring
trst_and_srst separate srst_nogate trst_push_pull srst_open_drain connect_assert_srst

Error: SWD mode is active but SWD_EN signal is not defined

There seems to be no definition of SWD_EN in the configuration file.

@fjmolinas
Copy link
Copy Markdown
Contributor

I'm not sure testing like this is correct in this case. On current master I'm getting the following error when trying to flash the iotlab-m3:

You are absolutely right, iot-lab uses its own flashing scheme. Sorry for letting this slip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation 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