forked from hardkernel/u-boot
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build_recovery.sh
executable file
·119 lines (97 loc) · 4.45 KB
/
build_recovery.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
#
# Copyright (c) 2019 Hardkernel Co., Ltd
#
# SPDX-License-Identifier: GPL-2.0
#
PWD=$(pwd)
IMAGES=./tools/images/hardkernel
OUT=./sd_fuse
MNT=${PWD}/sd_fuse/mnt
pack_spi_full_image()
{
gzip -k -f ${IMAGES}/*.bmp
dd if=/dev/zero of=${OUT}/spi_recovery.img bs=512 count=16592 conv=fsync,notrunc
# mbr, uboot and trust
dd if=${OUT}/rk3326_header_miniloader_spiboot.img of=${OUT}/spi_recovery.img bs=512 seek=0 count=2048 conv=fsync,notrunc
dd if=${OUT}/uboot_spi.img of=${OUT}/spi_recovery.img bs=512 seek=2048 count=2048 conv=fsync,notrunc
dd if=${OUT}/trust_spi.img of=${OUT}/spi_recovery.img bs=512 seek=4096 count=4096 conv=fsync,notrunc
# ODROID-GO2 dtb
dd if=./arch/arm/dts/rg351p-uboot.dtb of=${OUT}/spi_recovery.img bs=512 seek=8192 count=200 conv=fsync,notrunc
# ODROID-GO2 bmp images
dd if=${IMAGES}/logo_hardkernel.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=8392 conv=fsync,notrunc
dd if=${IMAGES}/low_battery.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=8792 conv=fsync,notrunc
dd if=${IMAGES}/recovery.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=9192 conv=fsync,notrunc
dd if=${IMAGES}/system_error.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=9592 conv=fsync,notrunc
dd if=${IMAGES}/no_sdcard.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=9992 conv=fsync,notrunc
dd if=${IMAGES}/battery_0.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=10392 conv=fsync,notrunc
dd if=${IMAGES}/battery_1.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=10792 conv=fsync,notrunc
dd if=${IMAGES}/battery_2.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=11192 conv=fsync,notrunc
dd if=${IMAGES}/battery_3.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=11592 conv=fsync,notrunc
dd if=${IMAGES}/battery_fail.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=11992 conv=fsync,notrunc
# ODROID-GO3 dtb
dd if=./arch/arm/dts/rg351mp-uboot.dtb of=${OUT}/spi_recovery.img bs=512 seek=12392 count=200 conv=fsync,notrunc
# ODROID-GO3 bmp images
dd if=${IMAGES}/logo_hardkernel_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=12592 conv=fsync,notrunc
dd if=${IMAGES}/low_battery_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=12992 conv=fsync,notrunc
dd if=${IMAGES}/recovery_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=13392 conv=fsync,notrunc
dd if=${IMAGES}/system_error_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=13792 conv=fsync,notrunc
dd if=${IMAGES}/no_sdcard_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=14192 conv=fsync,notrunc
dd if=${IMAGES}/battery_0_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=14592 conv=fsync,notrunc
dd if=${IMAGES}/battery_1_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=14992 conv=fsync,notrunc
dd if=${IMAGES}/battery_2_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=15392 conv=fsync,notrunc
dd if=${IMAGES}/battery_3_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=15792 conv=fsync,notrunc
dd if=${IMAGES}/battery_fail_b.bmp.gz of=${OUT}/spi_recovery.img bs=512 seek=16192 conv=fsync,notrunc
rm ${IMAGES}/*.bmp.gz
md5sum ${OUT}/spi_recovery.img > ${OUT}/spi_recovery.img.md5sum
}
pack_recovery_sdcard_img()
{
dd if=/dev/zero of=${OUT}/vfat.fs bs=1M count=32 conv=fsync
mkfs.vfat ${OUT}/vfat.fs
if [ ! -d "$MNT" ]; then
mkdir -p "${MNT}"
fi
sudo mount ${OUT}/vfat.fs ${MNT}
sudo cp ${OUT}/spi_recovery.img* ${MNT}
# ODROID-GO2 rev1.0/rev1.1
sudo cp ${IMAGES}/recovery.bmp ${MNT}
sudo cp ${IMAGES}/system_error.bmp ${MNT}
sudo cp ${IMAGES}/no_sdcard.bmp ${MNT}
sudo cp ${IMAGES}/low_battery.bmp ${MNT}
sudo cp ./arch/arm/dts/rg351p-uboot.dtb ${MNT}/rg351p-uboot.dtb
# ODROID-GO3 rev1.0
sudo cp ${IMAGES}/recovery_b.bmp ${MNT}
sudo cp ${IMAGES}/system_error_b.bmp ${MNT}
sudo cp ${IMAGES}/no_sdcard_b.bmp ${MNT}
sudo cp ${IMAGES}/low_battery_b.bmp ${MNT}
sudo cp ./arch/arm/dts/rg351mp-uboot.dtb ${MNT}/rg351mp-uboot.dtb
sudo cp ./arch/arm/dts/rg351v-uboot.dtb ${MNT}/rg351v-uboot.dtb
sync
sudo umount ${MNT}
dd if=/dev/zero of=${OUT}/sdcard_recovery.img conv=fsync bs=512 count=64
dd if=${OUT}/idbloader.img of=${OUT}/sdcard_recovery.img conv=fsync bs=512 seek=64
dd if=${OUT}/uboot.img of=${OUT}/sdcard_recovery.img conv=fsync bs=512 seek=16384
dd if=${OUT}/trust.img of=${OUT}/sdcard_recovery.img conv=fsync bs=512 seek=24576
dd if=${OUT}/vfat.fs of=${OUT}/sdcard_recovery.img bs=512 seek=32768
fdisk -u ${OUT}/sdcard_recovery.img << EOF
n
p
1
32768
98303
t
c
w
EOF
sync
}
finish()
{
rm ${OUT}/spi_recovery.img*
rm ${OUT}/vfat.fs
echo "Build Recovery Image Done!!!"
}
pack_spi_full_image
pack_recovery_sdcard_img
finish