diff options
| author | Jan Sucan <sucanjan@fit.cvut.cz> | 2019-06-04 14:34:27 +0200 |
|---|---|---|
| committer | Jan Sucan <sucanjan@fit.cvut.cz> | 2019-06-04 14:34:27 +0200 |
| commit | dc8703206e3f0f69605c56d0e1127f7e17f3476a (patch) | |
| tree | 166823a741dc420c10d54250cb53d1e3a6b74faf /testing/DMBootloader/generate_cmd_write_DMAppFpgaProg.sh | |
Initial commit
Diffstat (limited to 'testing/DMBootloader/generate_cmd_write_DMAppFpgaProg.sh')
| -rw-r--r-- | testing/DMBootloader/generate_cmd_write_DMAppFpgaProg.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/testing/DMBootloader/generate_cmd_write_DMAppFpgaProg.sh b/testing/DMBootloader/generate_cmd_write_DMAppFpgaProg.sh new file mode 100644 index 0000000..fbd53e2 --- /dev/null +++ b/testing/DMBootloader/generate_cmd_write_DMAppFpgaProg.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# Generates commands to Write DMAppFpgaProg the the FLASH memory +# through DMBootloader + +APPIMAGE=../../impl/DMAppFpgaProg/DMAppFpgaProg/Release/DMAppFpgaProg.bin +OUTDIR=7_write_DMAppFpgaProg + +# Compute number of FLASH memory pages to write +APPSIZE=$(du -b $APPIMAGE | awk '{ print $1 }') +APPPAGES=$(( $APPSIZE / 512)) +[ $(( $APPSIZE % 512 )) -ne 0 ] && APPPAGES=$(( $APPPAGES + 1 )) + +for i in $(seq 1 $(( $APPPAGES ))); do + virtual_page=$(( $i - 1 )) + wr=${OUTDIR}/${i}_cmd + + # Generate write command + ./create_dmbootloader_cmd.sh write $virtual_page $wr + + # Replace random data in the command with the page from application image + dd bs=1 count=512 if=$APPIMAGE of=$wr skip=$(( $virtual_page * 512 )) seek=3 2>/dev/null + + echo "Generated $(( $i )) / $APPPAGES" +done + +# Each Write command must complete with success +printf '\x00' >${OUTDIR}/reply + +exit 0 |
