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

tools/openocd: only export OPENOCD_CONFIG to required targets #13452

Merged
merged 4 commits into from
Feb 25, 2020

Conversation

aabadie
Copy link
Contributor

@aabadie aabadie commented Feb 24, 2020

Contribution description

This PR updates how the OPENOCD_CONFIG variable is exported to the openocd.sh script:

  • it makes use of the target-export-variables in order to export the variable only with flash/reset/debug targets
  • it removes all use of export in boards configuration (which is the primary goal of this PR)
  • the default value $(BOARDSDIR)/$(BOARD)/dist/openocd.cfg is set in openocd.inc.mk and not in openocd.sh
  • a static-test is added in order to prevent futur global export of this variable

Testing procedure

Test that flashing still works with openocd for flash/reset/debug targets on several affected boards: nucleos, samr21-xpro, nrf (using PROGRAMMER=openocd from the command line for the last 2):

$ make BOARD=<board> --no-print-directory -C examples/hello-world flash
$ make BOARD=<board> --no-print-directory -C examples/hello-world reset
$ make BOARD=<board> --no-print-directory -C examples/hello-world debug
nucleo-l073rz

flash

$ make BOARD=nucleo-l073rz --no-print-directory -C examples/hello-world/ flash
Building application "hello-world" for "nucleo-l073rz" with MCU "stm32l0".

"make" -C /work/riot/RIOT/boards/nucleo-l073rz
"make" -C /work/riot/RIOT/boards/common/nucleo
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/stm32l0
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/stm32_common
"make" -C /work/riot/RIOT/cpu/stm32_common/periph
"make" -C /work/riot/RIOT/cpu/stm32l0/periph
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/pm_layered
"make" -C /work/riot/RIOT/sys/stdio_uart
   text	   data	    bss	    dec	    hex	filename
   8404	    112	   2568	  11084	   2b4c	/work/riot/RIOT/examples/hello-world/bin/nucleo-l073rz/hello-world.elf
/work/riot/RIOT/dist/tools/openocd/openocd.sh flash /work/riot/RIOT/examples/hello-world/bin/nucleo-l073rz/hello-world.elf
### Flashing Target ###
Open On-Chip Debugger 0.10.0+dev-01047-g09ac9ab1 (2020-02-05-08:53)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
WARNING: interface/stlink-v2-1.cfg is deprecated, please switch to interface/stlink.cfg
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_assert_srst

Info : clock speed 300 kHz
Info : STLINK V2J28M17 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.239293
Info : stm32l0.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : Listening on port 36045 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32l0.cpu        hla_target little stm32l0.cpu        reset

Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : Unable to match requested speed 300 kHz, using 240 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0xf1000000 pc: 0x08000414 msp: 0x20000200
Info : Device: STM32L0xx (Cat.5)
Info : STM32L flash has dual banks. Bank (0) size is 96kb, base address is 0x8000000
auto erase enabled
wrote 12288 bytes from file /work/riot/RIOT/examples/hello-world/bin/nucleo-l073rz/hello-world.elf in 2.811576s (4.268 KiB/s)

verified 8516 bytes in 0.443522s (18.751 KiB/s)

Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : Unable to match requested speed 300 kHz, using 240 kHz
shutdown command invoked
Done flashing

reset

$ make BOARD=nucleo-l073rz --no-print-directory -C examples/hello-world/ reset
/work/riot/RIOT/dist/tools/openocd/openocd.sh reset
### Resetting Target ###
Open On-Chip Debugger 0.10.0+dev-01047-g09ac9ab1 (2020-02-05-08:53)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
WARNING: interface/stlink-v2-1.cfg is deprecated, please switch to interface/stlink.cfg
hla_swd
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_assert_srst

Info : clock speed 300 kHz
Info : STLINK V2J28M17 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.245580
Info : stm32l0.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : Listening on port 38395 for gdb connections
Info : Unable to match requested speed 300 kHz, using 240 kHz
Info : Unable to match requested speed 300 kHz, using 240 kHz
shutdown command invoked

debug

$ make BOARD=nucleo-l073rz --no-print-directory -C examples/hello-world/ debug
/work/riot/RIOT/dist/tools/openocd/openocd.sh debug /work/riot/RIOT/examples/hello-world/bin/nucleo-l073rz/hello-world.elf
### Starting Debugging ###
Open On-Chip Debugger 0.10.0+dev-01047-g09ac9ab1 (2020-02-05-08:53)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Reading symbols from /work/riot/RIOT/examples/hello-world/bin/nucleo-l073rz/hello-world.elf...
Remote debugging using :3333
__set_PRIMASK (priMask=1) at /work/riot/RIOT/cpu/cortexm_common/include/vendor/cmsis_gcc.h:414
414	  __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
(gdb)
samr21-xpro

flash

$ PROGRAMMER=openocd make BOARD=samr21-xpro --no-print-directory -C examples/hello-world/ flash
Building application "hello-world" for "samr21-xpro" with MCU "samd21".

"make" -C /work/riot/RIOT/boards/samr21-xpro
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/samd21
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/sam0_common
"make" -C /work/riot/RIOT/cpu/sam0_common/periph
"make" -C /work/riot/RIOT/cpu/samd21/periph
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/pm_layered
"make" -C /work/riot/RIOT/sys/stdio_uart
   text	   data	    bss	    dec	    hex	filename
   8612	    112	   2560	  11284	   2c14	/work/riot/RIOT/examples/hello-world/bin/samr21-xpro/hello-world.elf
/work/riot/RIOT/dist/tools/openocd/openocd.sh flash /work/riot/RIOT/examples/hello-world/bin/samr21-xpro/hello-world.elf
### Flashing Target ###
Open On-Chip Debugger 0.10.0+dev-01047-g09ac9ab1 (2020-02-05-08:53)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 01.1A.00FB
Info : CMSIS-DAP: Serial# = ATML2127031800004624
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : at91samd.cpu: external reset detected
Info : Listening on port 43437 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* at91samd.cpu       cortex_m   little at91samd.cpu       running

target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000001c0 msp: 0x20000200
Info : SAMD MCU: SAMR21G18A (256KB Flash, 32KB RAM)
auto erase enabled
wrote 8960 bytes from file /work/riot/RIOT/examples/hello-world/bin/samr21-xpro/hello-world.elf in 0.965027s (9.067 KiB/s)

verified 8724 bytes in 0.808464s (10.538 KiB/s)

shutdown command invoked
Done flashing

reset

$ PROGRAMMER=openocd make BOARD=samr21-xpro --no-print-directory -C examples/hello-world/ reset
/work/riot/RIOT/dist/tools/openocd/openocd.sh reset
### Resetting Target ###
Open On-Chip Debugger 0.10.0+dev-01047-g09ac9ab1 (2020-02-05-08:53)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 01.1A.00FB
Info : CMSIS-DAP: Serial# = ATML2127031800004624
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : Listening on port 40421 for gdb connections
shutdown command invoked

debug

$ PROGRAMMER=openocd make BOARD=samr21-xpro --no-print-directory -C examples/hello-world/ debug
/work/riot/RIOT/dist/tools/openocd/openocd.sh debug /work/riot/RIOT/examples/hello-world/bin/samr21-xpro/hello-world.elf
### Starting Debugging ###
Open On-Chip Debugger 0.10.0+dev-01047-g09ac9ab1 (2020-02-05-08:53)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Reading symbols from /work/riot/RIOT/examples/hello-world/bin/samr21-xpro/hello-world.elf...
Remote debugging using :3333
__set_PRIMASK (priMask=1) at /work/riot/RIOT/cpu/cortexm_common/include/vendor/cmsis_gcc.h:414
414	  __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
(gdb) 

nrf52840dk

flash

$ PROGRAMMER=openocd make BOARD=nrf52840dk --no-print-directory -C examples/hello-world/ flash
Building application "hello-world" for "nrf52840dk" with MCU "nrf52".

"make" -C /work/riot/RIOT/boards/nrf52840dk
"make" -C /work/riot/RIOT/boards/common/nrf52xxxdk
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/nrf52
"make" -C /work/riot/RIOT/cpu/cortexm_common
"make" -C /work/riot/RIOT/cpu/cortexm_common/periph
"make" -C /work/riot/RIOT/cpu/nrf52/periph
"make" -C /work/riot/RIOT/cpu/nrf5x_common
"make" -C /work/riot/RIOT/cpu/nrf5x_common/periph
"make" -C /work/riot/RIOT/drivers
"make" -C /work/riot/RIOT/drivers/periph_common
"make" -C /work/riot/RIOT/sys
"make" -C /work/riot/RIOT/sys/auto_init
"make" -C /work/riot/RIOT/sys/newlib_syscalls_default
"make" -C /work/riot/RIOT/sys/stdio_uart
   text	   data	    bss	    dec	    hex	filename
   8328	    108	   2564	  11000	   2af8	/work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.elf
/work/riot/RIOT/dist/tools/openocd/openocd.sh flash /work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.elf
### Flashing Target ###
Open On-Chip Debugger 0.10.0+dev-01047-g09ac9ab1 (2020-02-05-08:53)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : J-Link OB-SAM3U128-V2-NordicSemi compiled Jan  7 2019 14:07:15
Info : Hardware version: 1.00
Info : VTarget = 3.300 V
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 46535 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* nrf52.cpu          cortex_m   little nrf52.cpu          running

target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000438 msp: 0x20000200
Info : nRF52840-xxAA(build code: C0) 1024kB Flash, 256kB RAM
Warn : Flash protection of this nRF device is not supported
Warn : Adding extra erase range, 0x000020f4 .. 0x00002fff
auto erase enabled
wrote 8436 bytes from file /work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.elf in 0.430620s (19.131 KiB/s)

verified 8436 bytes in 0.071297s (115.549 KiB/s)

shutdown command invoked
Done flashing

reset

$ PROGRAMMER=openocd make BOARD=nrf52840dk --no-print-directory -C examples/hello-world/ reset
/work/riot/RIOT/dist/tools/openocd/openocd.sh reset
### Resetting Target ###
Open On-Chip Debugger 0.10.0+dev-01047-g09ac9ab1 (2020-02-05-08:53)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : J-Link OB-SAM3U128-V2-NordicSemi compiled Jan  7 2019 14:07:15
Info : Hardware version: 1.00
Info : VTarget = 3.300 V
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 42923 for gdb connections
shutdown command invoked

debug

$ PROGRAMMER=openocd make BOARD=nrf52840dk --no-print-directory -C examples/hello-world/ debug
/work/riot/RIOT/dist/tools/openocd/openocd.sh debug /work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.elf
### Starting Debugging ###
Open On-Chip Debugger 0.10.0+dev-01047-g09ac9ab1 (2020-02-05-08:53)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Reading symbols from /work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.elf...
Remote debugging using :3333
pm_set_lowest () at /work/riot/RIOT/cpu/cortexm_common/include/cpu.h:177
177	    irq_restore(state);
(gdb) 

Issues/PRs references

Related to #10850

@aabadie aabadie requested a review from fjmolinas February 24, 2020 09:22
@aabadie aabadie added 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 CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation labels Feb 24, 2020
@kaspar030 kaspar030 self-assigned this Feb 25, 2020
Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

Tested on samr21-xpro, microbit and nucleo-f767zi. Works fine.

ACK.

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 CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants