blob: fbd53e29936dc0c66bf9f150c34dafe1cbf131c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
|