kinetis/fcfield-check*: merge into single file and support binary flash#11589
kinetis/fcfield-check*: merge into single file and support binary flash#11589cladmi merged 3 commits intoRIOT-OS:masterfrom
Conversation
cpu/kinetis/dist/check-fcfield.sh
Outdated
| 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}") |
7413651 to
25a0cca
Compare
|
@cladmi I have addressed your comments. I split merging the scripts and adding binary check in separate commits. Also refactored to use functions and avoid assigning command output to variables, Hopefully it looks better now :) ! (And thanks for the feedback) |
|
I get the correct output without offset: |
cladmi
left a comment
There was a problem hiding this comment.
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'
cpu/kinetis/dist/check-fcfield.sh
Outdated
| 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" |
There was a problem hiding this comment.
No need to warn here I think. It is a normal case.
|
@cladmi Addressed comments! |
|
Tests from my previous comments now work as I expect. |
|
Please squash. For the commit in |
- fcfield is located in memory at 0x400-0x40f. Its content is only read upon reset, therefore if in presence of a bootloader and multiple applications, the fcfield will only be read when the bootloader is loaded. As long as we flash at IMAGE_OFFSET > 0x410 we do not care about the fcfield content since it won't get overwritten.
ed9d888 to
c219fdc
Compare
cladmi
left a comment
There was a problem hiding this comment.
The described tests work as expected, same for my additional ones in the comments.
The RIOT test suite works with similar results to master.
I agree with the change and the way they are done.
Contribution description
This PR merges the two existing scripts to check for the fcfield contents on kinetis boards. It also adds to the merged scipt the capacity of checking for bin files.
Regarding flashing at an offset, since the
fcfieldcontent is only read on reset, we don't care for its content when flashing an Image after 0x410 or 1040, therefore we won't check its content.Testing procedure
Modify any value in the fcfield:
RIOT/cpu/kinetis/fcfield.c
Lines 55 to 73 in 8fe12bc
Flash an elf, hex and bin file and see that it is properly checked:
make -C examples/hello-world/ BOARD=frdm-kw41z flashFFLAGS='flash $(HEXFILE)' make -C examples/hello-world/ BOARD=frdm-kw41z flashFFLAGS='flash $(BINFILE)' make -C examples/hello-world/ BOARD=frdm-kw41z binfile flashFlashing Target
Danger of bricking the device during flash!
Flash configuration field of /home/francisco/workspace/RIOT/examples/hello-world/bin/frdm-kw41z/hello-world.bin:
Remove the changes to fcfield, and repeat the above procedure, no errors will be encountered.
Issues/PRs references
Used by #11562