1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 22:43:50 +01:00

openocd.sh: add functions to access board flash address

This allows getting the ROM base address.

It may not be available in the build system directly so better extract it from
openocd. Also openocd is board specific and this address is cpu specific
so would have definition order issue in the build system.
This commit is contained in:
cladmi 2018-08-16 15:17:18 +02:00
parent 5748d6a75f
commit 36b51467dd
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B

View File

@ -159,6 +159,29 @@ _is_binfile() {
[[ -z "${firmware_type}" ]] && _has_bin_extension "${firmware}"; }
}
# Outputs bank info on different lines without the '{}'
_flash_list() {
# Openocd output for 'flash list' is
# ....
# {name nrf51 base 0 size 0 bus_width 1 chip_width 1} {name nrf51 base 268439552 size 0 bus_width 1 chip_width 1}
# ....
sh -c "${OPENOCD} \
${OPENOCD_ADAPTER_INIT} \
-f '${OPENOCD_CONFIG}' \
-c 'flash list' \
-c 'shutdown'" 2>&1 | sed -n '/^{.*}$/ {s/\} /\}\n/g;s/[{}]//g;p}'
}
# Print flash address for 'bank_num' num defaults to 1
# _flash_address [bank_num:1]
_flash_address() {
bank_num=${1:-1}
# extract 'base' value and print as hexadecimal
# name nrf51 base 268439552 size 0 bus_width 1 chip_width 1
_flash_list | awk "NR==${bank_num}"'{printf "0x%08x\n", $4}'
}
#
# now comes the actual actions
#