PKGBUILDs/alarm/uboot-oxnas/flash
2014-01-25 03:23:33 +00:00

36 lines
759 B
Bash
Executable file

#!/bin/sh
# uncomment line below and set to the correct disk
#disk=/dev/sdX
if [ -z "${disk}" ] ; then
echo "You must uncomment/set the 'disk' variable"
exit -1
fi
stage1File=/boot/u-boot-spl.bin
ubootFile=/boot/u-boot.wrapped
perl <<EOF | dd of="$disk" bs=512
print "\x00" x 0x1a4;
print "\x00\x5f\x01\x00";
print "\x00\xdf\x00\x00";
print "\x00\x80\x00\x00";
print "\x00" x (0x1b0 -0x1a4 -12 );
print "\x22\x80\x00\x00";
print "\x22\x00\x00\x00";
print "\x00\x80\x00\x00";
EOF
if [ -f $stage1File ];then
echo "Writing stage 1"
dd if=$stage1File of="$disk" bs=512 seek=34
fi
if [ -f $ubootFile ];then
echo "Writing uboot"
dd if=$ubootFile of="$disk" bs=512 seek=154
fi
sync