-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
19620: dist/tools/openocd: fix parsing of flash bank base r=aabadie a=maribu ### Contribution description Since [80fc9fabc66a0bc767467fa14c703e5a9f340cd3] the format of the `flash list` command changed to a more human readable multi-line variant. Technically, the change is white-space only. Still, the current approach of parsing them with awk, sed and cut doesn't like the new multi-line format. The parsing is now delegated into a python script that is compatible across OpenOCD versions. [80fc9fabc66a0bc767467fa14c703e5a9f340cd3]: openocd-org/openocd@80fc9fa 19636: sys: model ecc, evtimer, pipe and shell_lock in kconfig r=aabadie a=aabadie 19639: tests/net/gnrc_mac_timeout: add automated test r=aabadie a=aabadie Co-authored-by: Marian Buschsieweke <[email protected]> Co-authored-by: Alexandre Abadie <[email protected]>
- Loading branch information
Showing
27 changed files
with
268 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Utility to parse the output of OpenOCD's "flash list" command | ||
""" | ||
import argparse | ||
import sys | ||
|
||
NUMERIC_FIELDS = {"base", "size", "bus_width", "chip_width"} | ||
|
||
|
||
def parse_flash_info(lines): | ||
""" | ||
Read output of OpenOCD's "flash list" command given in lines into a list | ||
of dictionaries | ||
:param lines: Output of "flash list" lines | ||
:return: [{"name": "nrf52.flash", "base": 0, ...}, | ||
{"name": "nrf52.uicr", ...}, ...] | ||
""" | ||
tokens = [] | ||
for line in lines: | ||
for word in line.split(): | ||
if word.startswith('{') and len(word) > 1: | ||
tokens += ["{", word[1:]] | ||
elif word.endswith('}') and len(word) > 1: | ||
tokens += [word[:-1], "}"] | ||
else: | ||
tokens.append(word) | ||
|
||
idx = 0 | ||
result = [] | ||
while idx < len(tokens): | ||
entry = {} | ||
while idx < len(tokens) and tokens[idx] != "{": | ||
idx += 1 | ||
idx += 1 | ||
while idx < len(tokens) and tokens[idx] != "}": | ||
if idx + 1 >= len(tokens) or tokens[idx + 1] == "}": | ||
break | ||
key = tokens[idx] | ||
value = tokens[idx + 1] | ||
if key in NUMERIC_FIELDS: | ||
value = int(value, 0) | ||
entry[key] = value | ||
idx += 2 | ||
if idx < len(tokens) and tokens[idx] == "}": | ||
result.append(entry) | ||
|
||
return result | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description="Parse OpenOCD's \"flash list\" output") | ||
parser.add_argument("--field", default="base", type=str, | ||
help="Field to extract (default \"base\")") | ||
parser.add_argument("--idx", default=0, type=int, | ||
help="Index of the bank to extract info from " + | ||
"(default 0)") | ||
args = parser.parse_args() | ||
info = parse_flash_info(sys.stdin) | ||
if args.idx < 0 or args.idx >= len(info): | ||
sys.exit("flash bank index out of range") | ||
value = info[args.idx][args.field] | ||
if args.field in NUMERIC_FIELDS: | ||
print(f"0x{value:08x}") | ||
else: | ||
print(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (c) 2023 Inria | ||
# | ||
# This file is subject to the terms and conditions of the GNU Lesser | ||
# General Public License v2.1. See the file LICENSE in the top level | ||
# directory for more details. | ||
# | ||
|
||
menuconfig MODULE_ECC | ||
bool "Error Correction Code (ECC) algorithms" | ||
depends on TEST_KCONFIG | ||
help | ||
Provides Golay1412, Hamming256 and Repetition algorithms. | ||
|
||
if MODULE_ECC | ||
|
||
menu "ECC algorithms" | ||
|
||
config MODULE_ECC_GOLAY1412 | ||
bool "Golay1412 Error Correction Code (ECC) algorithm" | ||
help | ||
Provides Golay1412 ECC algorithm. | ||
|
||
config MODULE_ECC_HAMMING256 | ||
bool "Hamming256 Error Correction Code (ECC) algorithm" | ||
help | ||
Provides Hamming256 ECC algorithm. | ||
|
||
config MODULE_ECC_REPETITION | ||
bool "Repetition Error Correction Code (ECC) algorithm" | ||
help | ||
Provides Repetition ECC algorithm. | ||
|
||
endmenu # ECC algorithms | ||
|
||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) 2023 Inria | ||
# | ||
# This file is subject to the terms and conditions of the GNU Lesser | ||
# General Public License v2.1. See the file LICENSE in the top level | ||
# directory for more details. | ||
# | ||
|
||
config MODULE_EVTIMER | ||
bool "Event timer module" | ||
depends on TEST_KCONFIG | ||
select MODULE_ZTIMER | ||
select MODULE_ZTIMER_MSEC | ||
|
||
config MODULE_EVTIMER_MBOX | ||
bool "Use message box" | ||
select MODULE_CORE_MBOX | ||
select MODULE_EVTIMER | ||
help | ||
Use message box to implement event timer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.