]> git.siccegge.de Git - forks/vmdebootstrap.git/blob - examples/wandboard-uboot.sh
fix typo in script
[forks/vmdebootstrap.git] / examples / wandboard-uboot.sh
1 #!/bin/sh
2
3 set -e
4
5 # This script is experimental and incomplete.
6
7 # Expects a tarball rootfs which includes a kernel, e.g.
8 # wandboard6q.sh --tarball wandboard.tgz
9 # wandboard-uboot.sh /dev/mmcblk0 wandboard.tgz
10
11 device=$1
12 tarball=$2
13
14 if [ -z "${device}" ]; then
15 echo "Block device not specified"
16 exit
17 fi
18
19 if [ ! -f "${device}" ]; then
20 echo "Specified device does not exist: ${device}"
21 exit
22 fi
23
24 if [ -z "${tarball}" ]; then
25 echo "Tarball not specified"
26 exit
27 fi
28
29 if [ ! -f '/usr/lib/u-boot/wandboard_quad/u-boot.imx' ]; then
30 echo "Unable to find wandboard u-boot file"
31 exit
32 fi
33
34 # u-boot needs to be dd'd to the device, not a partition
35 # but kpartx does not setup the device, just the partitions
36
37 sudo dd if=/dev/zero of=${device} bs=1M count=10
38 sudo dd if=/usr/lib/u-boot/wandboard_quad/u-boot.imx of=${device} seek=1 conv=fsync bs=1k
39 sudo sfdisk --in-order --Linux --unit M ${device} <<-__EOF__
40 1,,0x83,-
41 __EOF__
42 sudo mkfs.ext4 ${device}p1 -L rootfs
43
44 dir=`mktemp -d`
45 sudo mount ${Ddevice}p1 ${dir}
46 sudo tar -xzf ${tarball} -C ${dir}
47
48 # assumes a single partition deployment to SD card
49
50 ver=$(basename `find $rootdir/lib/modules/ -maxdepth 1 -mindepth 1 -type d`)
51 sudo touch ${dir}/uEnv.txt
52 sudo chmod 666 ${dir}/uEnv.txt
53 echo fdt_file=/boot/dtbs/imx6q-wandboard.dtb > ${dir}/uEnv.txt
54 echo image=/boot/vmlinuz-${ver} >> ${dir}/uEnv.txt
55 echo mmcroot=/dev/mmcblk0p1 rootwait rw >> ${dir}/uEnv.txt
56 echo loadaddr='0x11000000' >> ${dir}/uEnv.txt
57 echo initrd_addr_r='0x13000000' >> ${dir}/uEnv.txt
58 echo fdt_addr='0x12000000' >> ${dir}/uEnv.txt
59 echo initrd_high='0xffffffff' >> ${dir}/uEnv.txt
60 echo fdt_high='0xffffffff' >> ${dir}/uEnv.txt
61 echo console=ttymxc0,115200 >> ${dir}/uEnv.txt
62 echo loadinitrd=load mmc ${mmcdev}:${mmcpart} ${initrd_addr_r} /boot/initrd.img-${ver}.uboot; setenv initrd_size ${filesize} >> ${dir}/uEnv.txt
63 echo bootargs=console=${console},${baudrate} root=${mmcroot} >> ${dir}/uEnv.txt
64 echo bootcmd=run loadfdt; run loadimage; run loadinitrd; bootz ${loadaddr} ${ramdisk_addr_r}:${filesize} ${fdt_addr} >> ${dir}/uEnv.txt
65 sudo chmod 644 ${dir}/uEnv.txt
66 sudo umount ${dir}
67 sudo rm -rf ${dir}