-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_boot_sdcard.sh
executable file
·67 lines (57 loc) · 1.58 KB
/
build_boot_sdcard.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
#!/bin/bash
# Usage: ./build_boot_sdcard.sh <board name>
BOARD_DIRS=$(find . -maxdepth 1 -type d -name "*$1*")
if [ x"$BOARD_DIRS" = x ]; then
echo "Error: not found folder: $1"
exit 1
fi
# find two of them, just use the first one
BOARD_DIR=`echo $BOARD_DIRS | cut -d\ -f 1`
echo "Genrate U-Boot environment in folder: ${BOARD_DIR}"
./scripts/gen_ubootenv.sh $1 || exit 1
echo "Done! you can check the env in output/sd/uboot.env"
echo
SD_ENV_DIR=output/sd
# find the mounted SD card.
SDCARD_NAME=SDCARD_BOOT
SDCARD_PATH="/media/${USER}/${SDCARD_NAME}"
if [ ! -d ${SDCARD_PATH} ]; then
echo "Error: not found sd card in: ${SDCARD_PATH}"
exit 1
fi
# copy boot files (boot-sd.bin, u-boot-sd.bin, output/sd/uboot.env) to SD card.
while true
do
read -n 1 -p "Will copy ${BOARD_DIR}/(boot-sd.bin, u-boot-sd.bin) & output/sd/uboot.env to ${SDCARD_PATH} [y/n]:"
case $REPLY in
Y|y)
echo -e "\nCopying boot files and U-Boot .env file to SD card......"
cp ${BOARD_DIR}/boot-sd.bin ${SDCARD_PATH}/BOOT.BIN
cp ${BOARD_DIR}/u-boot-sd.bin ${SDCARD_PATH}/u-boot.bin
[ -f ${BOARD_DIR}/*.dtb ] && cp ${BOARD_DIR}/*.dtb ${SDCARD_PATH}/
[ -f ${BOARD_DIR}/zImage ] && cp ${BOARD_DIR}/zImage ${SDCARD_PATH}/
cp ${SD_ENV_DIR}/uboot.env ${SDCARD_PATH}/
sync
break;
;;
*)
echo "You cancelled the build process, So nothing changed in SD card!";
break;
;;
esac
done
# umount the SD card
while true
do
read -n 1 -p "Do you want to reject the SD card? [y/n]:"
case $REPLY in
Y|y)
sudo umount /media/${LOGNAME}/${SDCARD_NAME}
break;
;;
*)
break;
;;
esac
done
echo ""