blob: 402c630b5c9137c4df6e582a12fa6a8c5347ed92 (
plain) (
blame)
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/bash
#
# This script automates the process of setting up an SD card for
# either "raw" or FAT mode booting for the Beaglebone Black.
if [ $# -ne 2 ]; then
echo -e "Please specify both the boot mode and the SD card to set up\n"
echo -e "Usage: ./sd_setup.sh <boot mode> /dev/<device>\n"
echo -e "where <boot mode> is either RAW or FAT and <device> is the SD card"
exit 1
fi
BOOTMODE=$1
SDDEV=$2
case $1 in
RAW)
if [ ! -e ./build_BEAGLEBONEBLACK/rawboot.bin ]; then
echo -e "rawboot.bin does not exist in ./build_BEAGLEBONEBLACK\n"
echo -e "Please build uMon before proceeding"
exit 1
fi
# Clear all offsets where a vaild uMon image for "raw" mode booting can exist
dd if=/dev/zero of=${SDDEV} bs=1M count=1
# Get the size of the uMon image to transfer into the SD card.
UMON_IMG_SIZE=`wc --bytes ./build_BEAGLEBONEBLACK/rawboot.bin | cut -f 1 -d ' '`
# Store the uMon image at offset 0x00000 by default
dd if=./build_BEAGLEBONEBLACK/rawboot.bin of=${SDDEV} bs=1 count=${UMON_IMG_SIZE}
;;
FAT)
if [ ! -e ./build_BEAGLEBONEBLACK/MLO ]; then
echo -e "MLO does not exist in ./build_BEAGLEBONEBLACK\n"
echo -e "Please build uMon before proceeding"
exit 1
fi
# Clear the partition table at the base of the SD card
dd if=/dev/zero of=${SDDEV} bs=1M count=1
# Create the FAT16 primary partition and mark it bootable
echo -e "n\np\n1\n\n+3M\nt\n6\na\n1\nw\n" | fdisk ${SDDEV}
# Wait for some time to allow the partition to register under /dev
sleep 1
mkfs.fat -v -f 2 -F 16 -M 0xF8 -s 1 -S 512 ${SDDEV}1
mkdir mnt
mount ${SDDEV}1 mnt
cp ./build_BEAGLEBONEBLACK/MLO mnt
sync
umount mnt
sync
rm -rf mnt
;;
*)
echo -e "Invalid boot mode specified. Valid boot modes are RAW/FAT."
exit 1
;;
esac
|