[riot-notifications] [RIOT-OS/RIOT] kinetis/fcfield-check*: merge into single file (#11589)

Gaƫtan Harter notifications at github.com
Mon May 27 18:52:58 CEST 2019


cladmi requested changes on this pull request.

Without offset it works as expected (see comment)

The values with an `offset` have some issues:

If `${IMAGE_OFFSET} < 0x410` it is not taken into account and the checked memory is the one at offset 0.
No need to handle it properly, failing with "currently not handled" is a good solution.

```
IMAGE_OFFSET=0x400 FLASHFILE='$(BINFILE)' RIOT_CI_BUILD=1 BOARD=frdm-kw41z make -C examples/hello-world/ flash-only
make: Entering directory '/home/harter/work/git/RIOT/examples/hello-world'
/home/harter/work/git/RIOT/dist/tools/openocd/openocd.sh flash /home/harter/work/git/RIOT/examples/hello-world/bin/frdm-kw41z/hello-world.bin
### Flashing Target ###
Danger of bricking the device during flash!
Flash configuration field of /home/harter/work/git/RIOT/examples/hello-world/bin/frdm-kw41z/hello-world.bin:

/home/harter/work/git/RIOT/examples/hello-world/bin/frdm-kw41z/hello-world.bin:     file format binary

Contents of section .data:
 0400 00ffffff ffffffff ffffffff feffffff  ................
Abort flash procedure!
pre-flash checks failed, status=1
/home/harter/work/git/RIOT/examples/hello-world/../../Makefile.include:541: recipe for target 'flash-only' failed
make: *** [flash-only] Error 1
make: Leaving directory '/home/harter/work/git/RIOT/examples/hello-world'
```

`IMAGE_OFFSET==0x410` still triggers the check when it should not as the field is 16bytes long.

```
IMAGE_OFFSET=0x410 FLASHFILE='$(BINFILE)' RIOT_CI_BUILD=1 BOARD=frdm-kw41z make -C examples/hello-world/ flash
make: Entering directory '/home/harter/work/git/RIOT/examples/hello-world'
Building application "hello-world" for "frdm-kw41z" with MCU "kinetis".

   text    data     bss     dec     hex filename
   9084     116    2544   11744    2de0 /home/harter/work/git/RIOT/examples/hello-world/bin/frdm-kw41z/hello-world.elf
/home/harter/work/git/RIOT/dist/tools/openocd/openocd.sh flash /home/harter/work/git/RIOT/examples/hello-world/bin/frdm-kw41z/hello-world.bin
### Flashing Target ###
Danger of bricking the device during flash!
Flash configuration field of /home/harter/work/git/RIOT/examples/hello-world/bin/frdm-kw41z/hello-world.bin:

/home/harter/work/git/RIOT/examples/hello-world/bin/frdm-kw41z/hello-world.bin:     file format binary

Contents of section .data:
 0400 00ffffff ffffffff ffffffff feffffff  ................
Abort flash procedure!
pre-flash checks failed, status=1
/home/harter/work/git/RIOT/examples/hello-world/../../Makefile.include:538: recipe for target 'flash' failed
make: *** [flash] Error 1
make: Leaving directory '/home/harter/work/git/RIOT/examples/hello-world'
```


> +    fi
+}
+
+filter_fc_field()
+{
+    get_fc_field "${1}" | awk -F' ' "/${2}/ { print \$2 \$3 \$4 \$5; }"
+}
+
+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
+
+if [ $(printf '%d' "${IMAGE_OFFSET}") -gt $(printf '%d' "${FCFIELD_END}") ] ; then
+    echo "WARN: we don't check the fcfield value if flashing at \$IMAGE_OFFSET > 0x410"

No need to warn here I think. It is a normal case.

-- 
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/11589#pullrequestreview-242347145
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190527/98b0e758/attachment.html>


More information about the notifications mailing list