[riot-notifications] [RIOT-OS/RIOT] boards/frdm-kw41z: add riotboot (#11562)

Gaëtan Harter notifications at github.com
Mon May 27 16:55:29 CEST 2019


cladmi commented on this pull request.



> +fi
+
+if [ $# -ne 1 ]; then
+    echo "Usage: $0 FLASHFILE"
+    echo "Checks the flash configuration field protection bits to avoid flashing a locked image to a Kinetis MCU (protection against accidental bricking)."
+    exit 2
+fi
+
+FLASHFILE="$1"
+
+FCFIELD_START='0x400'
+FCFIELD_END='0x410'
+FCFIELD_AWK_REGEX='^ 0400 '
+
+if [ ${FLASHFILE##*.} = bin ]; then
+    OBJDUMP=$(arm-none-eabi-objdump --start-address=${FCFIELD_START} --stop-address=${FCFIELD_END} -bbinary -marm ${FLASHFILE} -s)

Better not use `OBJDUMP` as variable name here. In the build system `OBJDUMP` is the name of the tool, and I have a pull request to use `OBJDUMP` from the build system in this file :D (I will do it after this one).

I personally tend to not put commands output into a variable when possible (from this source, in French https://linuxfr.org/news/revue-des-techniques-de-programmation-en-shell). So would more refactor this in a function and use the output with `get_fc_field "${FLASHFILE}" | awk`.
The fact that you need to do `printf %s ${OBJDUMP}` somehow shows the pattern issue.

So at least rename it, and maybe put it in a function

> +if [ $# -ne 1 ]; then
+    echo "Usage: $0 FLASHFILE"
+    echo "Checks the flash configuration field protection bits to avoid flashing a locked image to a Kinetis MCU (protection against accidental bricking)."
+    exit 2
+fi
+
+FLASHFILE="$1"
+
+FCFIELD_START='0x400'
+FCFIELD_END='0x410'
+FCFIELD_AWK_REGEX='^ 0400 '
+
+if [ ${FLASHFILE##*.} = bin ]; then
+    OBJDUMP=$(arm-none-eabi-objdump --start-address=${FCFIELD_START} --stop-address=${FCFIELD_END} -bbinary -marm ${FLASHFILE} -s)
+elif [ ${FLASHFILE##*.} = elf ]; then
+    OBJDUMP=$(arm-none-eabi-objdump -j.fcfield -s "${ELFFILE}")

Here should be using `FLASHFILE`

> +    echo "Checks the flash configuration field protection bits to avoid flashing a locked image to a Kinetis MCU (protection against accidental bricking)."
+    exit 2
+fi
+
+FLASHFILE="$1"
+
+FCFIELD_START='0x400'
+FCFIELD_END='0x410'
+FCFIELD_AWK_REGEX='^ 0400 '
+
+if [ ${FLASHFILE##*.} = bin ]; then
+    OBJDUMP=$(arm-none-eabi-objdump --start-address=${FCFIELD_START} --stop-address=${FCFIELD_END} -bbinary -marm ${FLASHFILE} -s)
+elif [ ${FLASHFILE##*.} = elf ]; then
+    OBJDUMP=$(arm-none-eabi-objdump -j.fcfield -s "${ELFFILE}")
+elif [ ${FLASHFILE##*.} = hex ]; then
+    OBJDUMP=$(arm-none-eabi-objdump --start-address=${FCFIELD_START} --stop-address=${FCFIELD_END} ${HEXFILE} -s)

Here FLASHFILE too.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11562#pullrequestreview-242314535
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190527/60f78a30/attachment.html>


More information about the notifications mailing list