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

boards: remove exports of jlink related variables #13567

Merged
merged 13 commits into from
Mar 10, 2020

Conversation

aabadie
Copy link
Contributor

@aabadie aabadie commented Mar 6, 2020

Contribution description

This PR removes all uses of export with JLink related variables and move the export in jlink.inc.mk. The variables are also now only exported with jlink related targets.

Static tests are also added to prevent future unwanted exports of theses variables.

Testing procedure

  • Verify that flash, reset, debug still works on affected boards.
nrf52840dk
  • flash:
$ PROGRAMMER=jlink make BOARD=nrf52840dk -C examples/hello-world --no-print-directory 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
   8408	    108	   2564	  11080	   2b48	/work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.elf
/work/riot/RIOT/dist/tools/jlink/jlink.sh flash /work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.bin
### Flashing Target ###
### Flashing at base address 0x0 with offset 0 ###
SEGGER J-Link Commander V6.56d (Compiled Dec 12 2019 13:05:00)
DLL version V6.56d, compiled Dec 12 2019 13:04:51

J-Link Commander will now exit on Error

J-Link Command File read successfully.
Processing script file...

J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jan  7 2019 14:07:15
Hardware version: V1.00
S/N: 683540885
VTref=3.300V
Target connection not established yet but required for command.
Device "NRF52" selected.


Connecting to target via SWD
InitTarget() start
InitTarget() end
Found SW-DP with ID 0x2BA01477
Scanning AP map to find all available APs
AP[2]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x24770011)
AP[1]: JTAG-AP (IDR: 0x02880000)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
Cortex-M4 identified.
Halting CPU for downloading file.
Downloading file [/work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.bin]...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
Verifying flash   [100%] Done.
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (12288 bytes)
J-Link: Flash download: Total time needed: 0.464s (Prepare: 0.040s, Compare: 0.004s, Erase: 0.254s, Program: 0.155s, Verify: 0.000s, Restore: 0.008s)
O.K.

Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.



Script processing completed.
  • reset:
$ PROGRAMMER=jlink make BOARD=nrf52840dk -C examples/hello-world --no-print-directory reset
/work/riot/RIOT/dist/tools/jlink/jlink.sh reset
### Resetting Target ###
SEGGER J-Link Commander V6.56d (Compiled Dec 12 2019 13:05:00)
DLL version V6.56d, compiled Dec 12 2019 13:04:51

J-Link Commander will now exit on Error

J-Link Command File read successfully.
Processing script file...

J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jan  7 2019 14:07:15
Hardware version: V1.00
S/N: 683540885
VTref=3.300V
Target connection not established yet but required for command.
Device "NRF52" selected.


Connecting to target via SWD
InitTarget() start
InitTarget() end
Found SW-DP with ID 0x2BA01477
Scanning AP map to find all available APs
AP[2]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x24770011)
AP[1]: JTAG-AP (IDR: 0x02880000)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
Cortex-M4 identified.
Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.



Script processing completed.

  • debug:
$ PROGRAMMER=jlink make BOARD=nrf52840dk -C examples/hello-world --no-print-directory debug
/work/riot/RIOT/dist/tools/jlink/jlink.sh debug /work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.elf
### Starting Debugging ###
SEGGER J-Link GDB Server V6.56d Command Line Version

JLinkARM.dll V6.56d (DLL compiled Dec 12 2019 13:04:51)

Command line: -device nrf52 -speed 2000 -if SWD -port 3333 -telnetport 4444
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     3333
SWO raw output listening port: 2332
Terminal I/O port:             4444
Accept remote connection:      yes
Generate logfile:              off
Verify download:               off
Init regs on start:            off
Silent mode:                   off
Single run mode:               off
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 nrf52
Target interface:              SWD
Target interface speed:        2000kHz
Target endian:                 little

Connecting to J-Link...
Reading symbols from /work/riot/RIOT/examples/hello-world/bin/nrf52840dk/hello-world.elf...
J-Link is connected.
Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jan  7 2019 14:07:15
Hardware: V1.00
S/N: 683540885
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 3333
Connecting to target...Remote debugging using :3333
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x0000089E (Data = 0x4008E8BD)
pm_set_lowest () at /work/riot/RIOT/cpu/cortexm_common/include/cpu.h:177
177	    irq_restore(state);
(gdb) quit
A debugging session is active.

	Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) EOF [assumed Y]
GDB closed TCP/IP connection
hifive1b
  • flash:
$ PROGRAMMER=jlink make BOARD=hifive1b -C examples/hello-world --no-print-directory flash
Building application "hello-world" for "hifive1b" with MCU "fe310".

"make" -C /work/riot/RIOT/boards/hifive1b
"make" -C /work/riot/RIOT/core
"make" -C /work/riot/RIOT/cpu/fe310
"make" -C /work/riot/RIOT/cpu/fe310/nano
"make" -C /work/riot/RIOT/cpu/fe310/periph
"make" -C /work/riot/RIOT/cpu/fe310/vendor
"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/stdio_uart
   text	   data	    bss	    dec	    hex	filename
   8940	    104	   2408	  11452	   2cbc	/work/riot/RIOT/examples/hello-world/bin/hifive1b/hello-world.elf
/work/riot/RIOT/dist/tools/jlink/jlink.sh flash /work/riot/RIOT/examples/hello-world/bin/hifive1b/hello-world.bin
### Flashing Target ###
### Flashing at base address 0x20010000 with offset 0 ###
SEGGER J-Link Commander V6.56d (Compiled Dec 12 2019 13:05:00)
DLL version V6.56d, compiled Dec 12 2019 13:04:51

J-Link Commander will now exit on Error

J-Link Command File read successfully.
Processing script file...

J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-K22-SiFive compiled Dec 12 2019 16:26:28
Hardware version: V1.00
S/N: 979001207
VTref=3.300V
Target connection not established yet but required for command.
Device "FE310" selected.


Connecting to target via JTAG
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 5, IRPrint = 0x01
JTAG chain detection found 1 devices:
 #0 Id: 0x20000913, IRLen: 05, Unknown device
Debug architecture:
  RISC-V debug: 0.13
  AddrBits: 7
  DataBits: 32
  IdleClks: 5
Memory access:
  Via system bus: No
  Via ProgBuf: Yes (16 ProgBuf entries)
DataBuf: 1 entries
  autoexec[0] implemented: Yes
Detected: RV32 core
CSR access via abs. commands: No
Temp. halted CPU for NumHWBP detection
HW instruction/data BPs: 8
Support set/clr BPs while running: No
HW data BPs trigger before execution of inst
RISC-V identified.
Halting CPU for downloading file.
Downloading file [/work/riot/RIOT/examples/hello-world/bin/hifive1b/hello-world.bin]...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
Verifying flash   [100%] Done.
J-Link: Flash download: Bank 0 @ 0x20000000: 1 range affected (65536 bytes)
J-Link: Flash download: Total time needed: 0.507s (Prepare: 0.103s, Compare: 0.034s, Erase: 0.146s, Program: 0.169s, Verify: 0.036s, Restore: 0.017s)
O.K.

Reset delay: 0 ms
Reset type Normal: Resets core & peripherals using <ndmreset> bit in <dmcontrol> debug register.



Script processing completed.


  • reset:
$ PROGRAMMER=jlink make BOARD=hifive1b -C examples/hello-world --no-print-directory reset
/work/riot/RIOT/dist/tools/jlink/jlink.sh reset
### Resetting Target ###
SEGGER J-Link Commander V6.56d (Compiled Dec 12 2019 13:05:00)
DLL version V6.56d, compiled Dec 12 2019 13:04:51

J-Link Commander will now exit on Error

J-Link Command File read successfully.
Processing script file...

J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-K22-SiFive compiled Dec 12 2019 16:26:28
Hardware version: V1.00
S/N: 979001207
VTref=3.300V
Target connection not established yet but required for command.
Device "FE310" selected.


Connecting to target via JTAG
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 5, IRPrint = 0x01
JTAG chain detection found 1 devices:
 #0 Id: 0x20000913, IRLen: 05, Unknown device
Debug architecture:
  RISC-V debug: 0.13
  AddrBits: 7
  DataBits: 32
  IdleClks: 5
Memory access:
  Via system bus: No
  Via ProgBuf: Yes (16 ProgBuf entries)
DataBuf: 1 entries
  autoexec[0] implemented: Yes
Detected: RV32 core
CSR access via abs. commands: No
Temp. halted CPU for NumHWBP detection
HW instruction/data BPs: 8
Support set/clr BPs while running: No
HW data BPs trigger before execution of inst
RISC-V identified.
Reset delay: 0 ms
Reset type Normal: Resets core & peripherals using <ndmreset> bit in <dmcontrol> debug register.



Script processing completed.
  • debug:
$ PROGRAMMER=jlink make BOARD=hifive1b -C examples/hello-world --no-print-directory debug
/work/riot/RIOT/dist/tools/jlink/jlink.sh debug /work/riot/RIOT/examples/hello-world/bin/hifive1b/hello-world.elf
### Starting Debugging ###
SEGGER J-Link GDB Server V6.56d Command Line Version

JLinkARM.dll V6.56d (DLL compiled Dec 12 2019 13:04:51)

Command line: -device FE310 -speed 2000 -if JTAG -port 3333 -telnetport 4444
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     3333
SWO raw output listening port: 2332
Terminal I/O port:             4444
Accept remote connection:      yes
Generate logfile:              off
Verify download:               off
Init regs on start:            off
Silent mode:                   off
Single run mode:               off
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 FE310
Target interface:              JTAG
Target interface speed:        2000kHz
Target endian:                 little

Connecting to J-Link...
Reading symbols from /work/riot/RIOT/examples/hello-world/bin/hifive1b/hello-world.elf...
J-Link is connected.
Firmware: J-Link OB-K22-SiFive compiled Dec 12 2019 16:26:28
Hardware: V1.00
S/N: 979001207
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 3333
Connecting to target...
J-Link found 1 JTAG device, Total IRLen = 5
JTAG ID: 0x20000913 (RISC-V)
Remote debugging using :3333
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
0x20010820 in pm_set_lowest () at /work/riot/RIOT/cpu/fe310/periph/pm.c:26
26	    __asm__ volatile ("wfi");
(gdb) quit
A debugging session is active.

	Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) EOF [assumed Y]
GDB closed TCP/IP connection
  • verify that make term still works with board using stdio_rtt (could not test this)

Issues/PRs references

Related to #10850

@aabadie aabadie added Area: build system Area: Build system Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation 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 Area: boards Area: Board ports labels Mar 6, 2020
@aabadie aabadie requested a review from fjmolinas as a code owner March 6, 2020 07:11
@aabadie aabadie force-pushed the pr/boards/jlink_export_cleanup branch 2 times, most recently from c6117da to 3bffd4b Compare March 6, 2020 19:25
@aabadie aabadie added CI: run tests If set, CI server will run tests on hardware for the labeled PR CI: disable test cache If set, CI will always run all tests regardless of whether they have been run successfully before 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 Mar 6, 2020
@aabadie aabadie force-pushed the pr/boards/jlink_export_cleanup branch from 3bffd4b to 6cfe1e9 Compare March 7, 2020 19:56
@aabadie aabadie added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: disable test cache If set, CI will always run all tests regardless of whether they have been run successfully before CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR labels Mar 7, 2020
Copy link
Contributor

@leandrolanzieri leandrolanzieri left a comment

Choose a reason for hiding this comment

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

Changes look good. I tested on the following boards, and everything works like in current master:

  • sensebox
  • ruuvitag (tested RTT terminal)
  • nrf52dk
  • slstk3402a

Maybe it would be nice to have further testing before merging.

makefiles/mcuboot.mk Outdated Show resolved Hide resolved
Copy link
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.

Good cleanup, there is an unrelated change in here though. @leandrolanzieri provided testing, I think there is no need for testing all the boards and the variables are still exported for all debugger related targets, IMO this is good to go. Please remove the unrelated changes and squash.

@@ -12,6 +12,24 @@ RESET_FLAGS ?= reset

JLINK_SERIAL ?= $(DEBUG_ADAPTER_ID)

JLINK_IF ?= SWD
Copy link
Contributor

Choose a reason for hiding this comment

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

why this default value? wasn't the case before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the default in jlink.sh:

_JLINK_IF=SWD

Copy link
Contributor

Choose a reason for hiding this comment

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

Missed that thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

although why set it again then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found it was simpler this way but I'll change that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

@fjmolinas fjmolinas self-assigned this Mar 10, 2020
@aabadie aabadie force-pushed the pr/boards/jlink_export_cleanup branch from 6cfe1e9 to 1b0b2c2 Compare March 10, 2020 11:49
Copy link
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.

tested:

  • hifiv1b
  • nrf52dk
  • nrf52840dk
  • slstk3402a

While all connected on the same machine.
ACK! Please squash @aabadie.

@aabadie aabadie force-pushed the pr/boards/jlink_export_cleanup branch from 8aceb6e to ad5b9d7 Compare March 10, 2020 15:32
@aabadie
Copy link
Contributor Author

aabadie commented Mar 10, 2020

Please squash

Done (this one was not easy!)

@fjmolinas fjmolinas merged commit db04522 into RIOT-OS:master Mar 10, 2020
@aabadie aabadie deleted the pr/boards/jlink_export_cleanup branch March 10, 2020 19:50
@leandrolanzieri leandrolanzieri added this to the Release 2020.04 milestone Mar 13, 2020
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: 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: 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