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

west: runners: jlink: add support for -nogui 1 command line parameter #27617

Merged

Conversation

henrikbrixandersen
Copy link
Member

Add support for the J-Link Commander "-NoGui 1" command line parameter in the West J-Link runner.

This command line parameter suppresses GUI dialogs (except for license dialogs) in J-Link Commander starting from v6.80.

Signed-off-by: Henrik Brix Andersen hebad@vestas.com

@henrikbrixandersen
Copy link
Member Author

@mbolivar-nordic Thanks for the inspiration on how to discover the version of J-Link Commander. It is a bit of a hack, but I do think we should consider it for inclusion.

I have only tested this under GNU/Linux.

@henrikbrixandersen henrikbrixandersen force-pushed the jlink-no-gui branch 2 times, most recently from 6fc4d34 to 675c4e1 Compare August 17, 2020 13:02
Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

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

It is a bit of a hack, but I do think we should consider it for inclusion.

I agree. I consider the fact that JLinkExe doesn't seem to have a way to report its own version a bug in the tool, which we are working around in the best way we know how. If we think of something better we can always add it.

My only requested changes would be:

  • Please add a source code comment explaining why this odd code exists
  • Can you do this by adding **kwargs support to ZephyrBinaryRunner.check_output and passing the timeout parameter that way instead of calling subprocess manually? It's important that west -v debug prints all the subprocesses executed by the tool being wrapped, which we accomplish via the self._log_cmd calls in the ZephyrBinaryRunner call, check_call, and check_output methods.

@henrikbrixandersen
Copy link
Member Author

I agree. I consider the fact that JLinkExe doesn't seem to have a way to report its own version a bug in the tool, which we are working around in the best way we know how. If we think of something better we can always add it.

@mbolivar-nordic Good point.

  • Please add a source code comment explaining why this odd code exists

Done.

  • Can you do this by adding **kwargs support to ZephyrBinaryRunner.check_output and passing the timeout parameter that way instead of calling subprocess manually? It's important that west -v debug prints all the subprocesses executed by the tool being wrapped, which we accomplish via the self._log_cmd calls in the ZephyrBinaryRunner call, check_call, and check_output methods.

I deliberately left it out of the log in order not to confuse anybody, but I can see that argument supports including it as well. I have added support for **kwargs to ZephyrBinaryRunner.check_output and switched to using that.

Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. Seems sane to me.

@MaureenHelm
Copy link
Member

This doesn't seem to work on Windows:

C:\Users\nxa17364\zephyrproject\zephyr>west -vv flash
ZEPHYR_BASE=C:\Users\nxa17364\zephyrproject\zephyr\ (origin: env)
-- west flash: rebuilding
cmake version 3.13.4 is OK; minimum version is 3.13.1
Running CMake: 'C:\Program Files\CMake\bin\cmake.EXE' --build 'C:\Users\nxa17364\zephyrproject\zephyr\build' --target west_flash_depends
[0/1] cmd.exe /C "cd /D C:\Users\nxa17364\zephyrproject\ze...\flash && "C:\Program Files\CMake\bin\cmake.exe" -E echo "

-- west flash: using runner jlink
runners.jlink: JLink commander script:
runners.jlink: r
loadfile C:/Users/nxa17364/zephyrproject/zephyr/build/zephyr/zephyr.bin 0x60000000
g
writeDP 1 0
readDP 1
q
runners.jlink: JLink.exe -bogus-argument-that-does-not-exist
-- runners.jlink: Flashing file: C:/Users/nxa17364/zephyrproject/zephyr/build/zephyr/zephyr.bin
runners.jlink: JLink.exe -if swd -speed auto -device MCIMXRT1052 -CommanderScript 'C:\Users\nxa17364\AppData\Local\Temp\1\tmpc6khun99jlink\runner.jlink'
SEGGER J-Link Commander V6.80d (Compiled Jun 26 2020 17:17:12)
DLL version V6.80d, compiled Jun 26 2020 17:16:09


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 OpenSDA 2 compiled Jun 28 2018 09:45:18
Hardware version: V1.00
S/N: 621000000
VTref=3.300V
Target connection not established yet but required for command.
Device "MCIMXRT1052" selected.


Connecting to target via SWD
InitTarget() start
InitTarget()
_TargetHalt: CPU halted
InitTarget() end
Found SW-DP with ID 0x0BD11477
Unknown DP version. Assuming DPv0
Scanning AP map to find all available APs
AP[1]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x04770041)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FD000
CPUID register: 0x411FC271. Implementer code: 0x41 (ARM)
Found Cortex-M7 r1p1, Little endian.
FPUnit: 8 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl[0] @ E00FD000
ROMTbl[0][0]: E00FE000, CID: B105100D, PID: 000BB4C8 ROM Table
ROMTbl[1] @ E00FE000
ROMTbl[1][0]: E00FF000, CID: B105100D, PID: 000BB4C7 ROM Table
ROMTbl[2] @ E00FF000
ROMTbl[2][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[2][1]: E0001000, CID: B105E00D, PID: 000BB002 DWT
ROMTbl[2][2]: E0002000, CID: B105E00D, PID: 000BB00E FPB-M7
ROMTbl[2][3]: E0000000, CID: B105E00D, PID: 000BB001 ITM
ROMTbl[1][1]: E0041000, CID: B105900D, PID: 001BB975 ETM-M7
ROMTbl[1][2]: E0042000, CID: B105900D, PID: 004BB906 CTI
ROMTbl[0][1]: E0040000, CID: B105900D, PID: 000BB9A9 TPIU-M7
ROMTbl[0][2]: E0043000, CID: B105F00D, PID: 001BB101 TSG
Cache: Separate I- and D-cache.
I-Cache L1: 32 KB, 512 Sets, 32 Bytes/Line, 2-Way
D-Cache L1: 32 KB, 256 Sets, 32 Bytes/Line, 4-Way
Cortex-M7 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.

Downloading file [C:/Users/nxa17364/zephyrproject/zephyr/build/zephyr/zephyr.bin]...
J-Link: Flash download: Bank 0 @ 0x60000000: 1 range affected (262144 bytes)
J-Link: Flash download: Total: 7.674s (Prepare: 0.190s, Compare: 2.996s, Erase: 0.992s, Program: 0.514s, Verify: 2.968s, Restore: 0.013s)
J-Link: Flash download: Program speed: 498 KB/s
O.K.


Writing DP register 1 = 0x00000000 (0 write repetitions needed)

Reading DP register 1 = 0x00000040 (0 read repetitions needed)


Script processing completed.

@henrikbrixandersen
Copy link
Member Author

@MaureenHelm Could you please try with an increased timeout value? E.g. 0.2 seconds?

@MaureenHelm
Copy link
Member

@MaureenHelm Could you please try with an increased timeout value? E.g. 0.2 seconds?

No luck. I tried 0.2 and 1.0, but neither worked.

@henrikbrixandersen
Copy link
Member Author

Oh. The regex doesn't match on the windows version. I'll provide an update shortly.

@henrikbrixandersen
Copy link
Member Author

@MaureenHelm Please retest.

@MaureenHelm
Copy link
Member

@MaureenHelm Please retest.

The update doesn't work either.

@mbolivar-nordic
Copy link
Contributor

@henrikbrixandersen If there's no clean way to get this to work there, can I suggest skipping this test if platform.system() == 'Windows'?

Add support for the J-Link Commander "-NoGui 1" command line parameter
in the West J-Link runner.

This command line parameter suppresses GUI dialogs (except for license
dialogs) in J-Link Commander starting from v6.80.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
@henrikbrixandersen
Copy link
Member Author

@henrikbrixandersen If there's no clean way to get this to work there, can I suggest skipping this test if platform.system() == 'Windows'?

@mbolivar-nordic Thank. I have added such a check. Without access to a Windows-based development PC, it's a bit difficult for me to debug what is going on. I suggest leaving the check in and hopefully someone (on Windows) will step up and submit a PR for making the check work on that platform as well.

Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

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

@henrikbrixandersen If there's no clean way to get this to work there, can I suggest skipping this test if platform.system() == 'Windows'?

@mbolivar-nordic Thank. I have added such a check. Without access to a Windows-based development PC, it's a bit difficult for me to debug what is going on. I suggest leaving the check in and hopefully someone (on Windows) will step up and submit a PR for making the check work on that platform as well.

Sorry I wasn't particularly helpful and haven't much time this week to debug. You can assign an enhancement issue to me and I'll take a closer look later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: West West utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants