-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathemmc_copy_boot.sh
executable file
·72 lines (57 loc) · 1.33 KB
/
emmc_copy_boot.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
#!/bin/sh
#
# Script to install a system onto the BBB eMMC
# This script handles the boot partition.
#
# This script should normally be run as
#
# ./emmc_copy_boot.sh
#
# Assumes the following files are available in the local directory:
#
# 1) MLO-beaglebone
# 2) u-boot-beaglebone.img
#
MACHINE=beaglebone
DEV=/dev/mmcblk1p1
if [ -z "${SRCDIR}" ]; then
SRCDIR=.
else
if [ ! -d "${SRCDIR}" ]; then
echo "Source directory not found: ${SRCDIR}"
exit 1
fi
fi
if [ ! -b ${DEV} ]; then
echo "Block device not found: ${DEV}"
exit 1
fi
if [ ! -d /media ]; then
echo "Mount point /media does not exist";
exit 1
fi
if [ ! -f ${SRCDIR}/MLO-${MACHINE} ]; then
echo -e "File not found: ${SRCDIR}/MLO-${MACHINE}\n"
exit 1
fi
if [ ! -f ${SRCDIR}/u-boot-${MACHINE}.img ]; then
echo -e "File not found: ${SRCDIR}/u-boot-${MACHINE}.img\n"
exit 1
fi
if [ ! -f "${SRCDIR}/emmc-uEnv.txt" ]; then
echo "File not found: ${SRCDIR}/emmc-uEnv.txt"
exit 1
fi
echo "Formatting FAT partition on $DEV"
mkfs.vfat -F 32 ${DEV} -n BOOT
echo "Mounting $DEV"
mount ${DEV} /media
echo "Copying MLO"
cp ${SRCDIR}/MLO-${MACHINE} /media/MLO
echo "Copying u-boot"
cp ${SRCDIR}/u-boot-${MACHINE}.img /media/u-boot.img
echo "Copying emmc-uEnv.txt to uEnv.txt"
cp ${SRCDIR}/emmc-uEnv.txt /media/uEnv.txt
echo "Unmounting ${DEV}"
umount ${DEV}
echo "Done"