forked from fwup-home/fwup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimg2fwup
executable file
·42 lines (35 loc) · 859 Bytes
/
img2fwup
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
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
set -e
IMGFILE=$1
FWFILE=$2
if [ -z "$IMGFILE" ]; then
echo "Compress an image file into a .fw archive so that it can be written to a"
echo "MicroSD card using fwup."
echo
echo "Usage: img2fwup <imgfile> [output .fw file]"
exit 1
fi
if [ -z "$FWFILE" ]; then
FWFILE=${IMGFILE%.img}.fw
fi
echo "Compressing '$IMGFILE' to '$FWFILE'..."
fwup -c -o "$FWFILE" -f - <<EOF
meta-product = ""
meta-description = "$(basename "$IMGFILE")"
meta-version = ""
meta-platform = ""
meta-architecture = ""
meta-author = "$USER"
file-resource img {
host-path = "${IMGFILE}"
skip-holes = false # This optimization isn't safe for all .img files
}
define-eval(IMG_BLOCKS, "(\${FWUP_SIZE_img} + 511) / 512")
task complete {
on-resource img {
trim(0, \${IMG_BLOCKS})
raw_write(0)
}
}
EOF
echo "Done."