-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_zimage.sh
executable file
·64 lines (51 loc) · 1.21 KB
/
make_zimage.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
KERN_BDIR="./build"
KERN_DTB="nvidia/tegra210-smaug.dtb"
OUTDIR="./output"
if [ -n "$1" ]; then
KERN_BDIR="$1"
fi
if [ -n "$2" ]; then
OUTDIR="$2"
fi
if [ ! -x "$(command -v mkimage)" ]; then
echo "mkimage not found (install u-boot-tools), exitting..."
exit 1
fi
if [ ! -d "$KERN_BDIR" ]; then
echo "Kernel build directory not found, exitting..."
exit 1
fi
echo "Cleaning up..."
rm -rf "$OUTDIR"
echo "Creating output directory ${OUTDIR}..."
mkdir -p "$OUTDIR"
echo "Copying config..."
cp conf/* "$OUTDIR"
echo "Copying raw image..."
cp "${KERN_BDIR}/arch/arm64/boot/Image" "$OUTDIR"
if [ $? -ne 0 ]; then
echo "Image copy failed (not found?), exitting..."
rm -rf "$OUTDIR"
exit 1
fi
echo "Copying device tree blob..."
cp "${KERN_BDIR}/arch/arm64/boot/dts/${KERN_DTB}" "$OUTDIR"
cd "$OUTDIR"
echo "Compressing image..."
lz4c -9 ./Image Image.lz4
if [ $? -ne 0 ]; then
echo "Image compression failed, exitting..."
cd ..
rm -rf "$OUTDIR"
exit 1
fi
echo "Creating Image.fit..."
mkimage -f Image.its Image.fit
if [ $? -ne 0 ]; then
echo "U-boot image creation failed, exitting..."
cd ..
rm -rf "$OUTDIR"
exit 1
fi
echo "Created ${OUTDIR}/Image.fit."