Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 64 lines (48 sloc) 1.521 kb
89d390a @fhunleth Add script to build a disk image.
fhunleth authored
1 #!/bin/sh
2
3 set -e
4 export LC_ALL=C
5
6 if [ $# -ne 0 ]; then
7 echo "Usage: $0"
8 exit 1
9 fi
10
11 make beaglebone_erlang_defconfig
12 make
13
61a0217 @fhunleth Fix typo in build_disk_image.sh
fhunleth authored
14 OUTPUTFILE=bbone-erlang-`git describe`.img
89d390a @fhunleth Add script to build a disk image.
fhunleth authored
15
16 MBRFILE=/tmp/mbr.bin
17 VFATFILE=/tmp/vfat.bin
18
19 HEADS=255
20 SECTORS=63
21
22 VFAT_PART_CYLINDERS=1
23 ROOTFS_PART_CYLINDERS=16
24 USER_PART_CYLINDERS=124
25
26 dd if=/dev/zero of=$MBRFILE count=1
27 sfdisk -f -H $HEADS -S $SECTORS $MBRFILE << EOF
28 0,$VFAT_PART_CYLINDERS,c,*
29 ,$ROOTFS_PART_CYLINDERS
30 ,$USER_PART_CYLINDERS
31 EOF
32
33 # Keep mcopy from complaining
34 export MTOOLS_SKIP_CHECK=1
35
36 # Create a file for making the VFAT boot partition.
37 # It loses 1 block due to the MBR taking up the first block
38 dd if=/dev/zero of=$VFATFILE count=$(( $VFAT_PART_CYLINDERS * $HEADS * $SECTORS - 1 ))
39 mkfs.vfat $VFATFILE -n boot
40 mcopy -i $VFATFILE output/images/MLO ::
41 mcopy -i $VFATFILE output/images/uImage ::
42 mcopy -i $VFATFILE output/images/u-boot.img ::
43
44 # Mark that this is the first boot, so that the init scripts
45 # can format the user partition
46 touch /tmp/1stboot
47 mcopy -i $VFATFILE /tmp/1stboot ::
48
49 cat $MBRFILE $VFATFILE output/images/rootfs.ext2 > $OUTPUTFILE
50 zip ${OUTPUTFILE}.zip $OUTPUTFILE
51
52 # Clean up
53 rm $VFATFILE $MBRFILE /tmp/1stboot
54
55 echo "==================================================================="
56 echo "Created $OUTPUTFILE and $OUTPUTFILE.zip."
57 echo
58 echo "Write to a MicroSD card by running:"
59 echo
e27cdce @fhunleth Add first time boot code to format the user partition if invalid.
fhunleth authored
60 echo "find /dev -name \"sdX?\" -exec umount \"{}\" \";\""
89d390a @fhunleth Add script to build a disk image.
fhunleth authored
61 echo "sudo dd if=$OUTPUTFILE of=/dev/sdX bs=128k"
62 echo "where sdX is where the MicroSD card was mounted."
63
Something went wrong with that request. Please try again.