Skip to content

Commit 7f1c3d1

Browse files
rettichschnidicarlescufi
authored andcommitted
twister: runner: j-link: Fix parameter passing
To specify the serial number, JLink expects either one argument ('--dev-id=xxx') or two (e.g. '--dev-id' 'xxx'), but it can not deal with a single one that is '--dev-id xxx'. The problem has been introduced (or just made visible?) by commit 5ee4284 (twister: runner: j-link: use dev-id instead of SelectEmuBySN) in PR zephyrproject-rtos#76931. How to reproduce: 1. Create a HW configuration map, e.g.: ``` $ cat zephyr-hw-map-nrf52840dk-1.yml - connected: true id: '683517317' platform: nrf52840dk/nrf52840 product: nRF52840 DK 1 runner: jlink serial: /dev/ttyACM-nrf-dk-1 ``` 2. Run test `logging.dictionary` with Twister: ``` $ west twister --platform nrf52840dk/nrf52840 --device-testing \ --hardware-map zephyr-hw-map-nrf52840dk-1.yml -s logging.dictionary ``` 3. The build will fail, and the `twister_harness.log` contains: ``` 10:21:24.375:DEBUG:twister_harness.device.factory: Get device type "hardware" 10:21:24.375:DEBUG:twister_harness.device.hardware_adapter: Opening serial connection for /dev/ttyACM-nrf-dk-1 10:21:24.376:DEBUG:twister_harness.device.hardware_adapter: Flashing device 683517317 10:21:24.376:DEBUG:twister_harness.device.hardware_adapter: Flashing command: <snip>/bin/west flash --skip-rebuild --build-dir twister-out/<snip>/tests/subsys/logging/dictionary/logging.dictionary --runner jlink '--dev-id 683517317' 10:21:24.590:ERROR:twister_harness.device.hardware_adapter: Could not flash device 683517317 10:21:24.592:DEBUG:twister_harness.device.hardware_adapter: Closed serial connection for /dev/ttyACM-nrf-dk-1 ``` (note the '--dev-id 683517317' part) 4. Running the stated `west flash` command shows the following error message: ``` -- west flash: using runner jlink FATAL ERROR: runner jlink received unknown arguments: ['--dev-id 683517317'] ``` Signed-off-by: Reto Schneider <[email protected]>
1 parent b3776ca commit 7f1c3d1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def _prepare_runner_args(self) -> tuple[list[str], list[str]]:
8686
extra_args.append("--cmd-pre-init")
8787
extra_args.append(f'adapter serial {board_id}')
8888
elif runner == 'jlink':
89-
base_args.append(f'--dev-id {board_id}')
89+
base_args.append('--dev-id')
90+
base_args.append(board_id)
9091
elif runner == 'stm32cubeprogrammer':
9192
base_args.append(f'--tool-opt=sn={board_id}')
9293
elif runner == 'linkserver':

scripts/pylib/pytest-twister-harness/tests/device/hardware_adapter_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_if_get_command_returns_proper_string_6(patched_which, device: HardwareA
9999
assert isinstance(device.command, list)
100100
assert device.command == [
101101
'west', 'flash', '--skip-rebuild', '--build-dir', 'build', '--runner', 'jlink',
102-
'--dev-id p_id'
102+
'--dev-id', 'p_id'
103103
]
104104

105105

0 commit comments

Comments
 (0)