Skip to content
Snippets Groups Projects
Unverified Commit 291a80c6 authored by cladmi's avatar cladmi Committed by Gaëtan Harter
Browse files

openocd.sh: refactor splitting banks in a separate function

Prepare for other refactoring.
parent 365d82ed
No related branches found
No related tags found
No related merge requests found
...@@ -159,6 +159,20 @@ _is_binfile() { ...@@ -159,6 +159,20 @@ _is_binfile() {
[[ -z "${firmware_type}" ]] && _has_bin_extension "${firmware}"; } [[ -z "${firmware_type}" ]] && _has_bin_extension "${firmware}"; }
} }
# Split bank info on different lines without the '{}'
_split_banks() {
# Input:
# ...
# {name nrf51 base 0 size 0 bus_width 1 chip_width 1} {name nrf51 base 268439552 size 0 bus_width 1 chip_width 1}
# ...
#
# Output:
# name nrf51 base 0 size 0 bus_width 1 chip_width 1
# name nrf51 base 268439552 size 0 bus_width 1 chip_width 1
sed -n '/^{.*}$/ {s/\} /\}\n/g;s/[{}]//g;p}'
}
# Outputs bank info on different lines without the '{}' # Outputs bank info on different lines without the '{}'
_flash_list() { _flash_list() {
# Openocd output for 'flash list' is # Openocd output for 'flash list' is
...@@ -169,7 +183,7 @@ _flash_list() { ...@@ -169,7 +183,7 @@ _flash_list() {
${OPENOCD_ADAPTER_INIT} \ ${OPENOCD_ADAPTER_INIT} \
-f '${OPENOCD_CONFIG}' \ -f '${OPENOCD_CONFIG}' \
-c 'flash list' \ -c 'flash list' \
-c 'shutdown'" 2>&1 | sed -n '/^{.*}$/ {s/\} /\}\n/g;s/[{}]//g;p}' -c 'shutdown'" 2>&1 | _split_banks
} }
# Print flash address for 'bank_num' num defaults to 1 # Print flash address for 'bank_num' num defaults to 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment