Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # This scripts boots the sunxi kernel over fel
- #
- # Make sure only root can run our script
- if [[ $EUID -ne 0 ]]; then
- echo "This script must be run as root" 1>&2
- exit 1
- fi
- if [ ! -d /tmp/Hacking ]; then
- echo "Hacking Directory not found!"
- mkdir /tmp/Hacking
- fi
- # need to mount the build computer
- if grep -qs '/tmp/Hacking' /proc/mounts; then
- echo "Hacking Directory is mounted."
- else
- echo "Hacking Directory is not mounted. Attach to build computer"
- mount -t nfs BLAH/Hacking /tmp/Hacking
- fi
- #is any device in fel mode
- if [ "`./fel 2>&1 >/dev/null | grep ERROR`" ] ; then
- echo "Device in fel mode not detected."
- exit 1
- else
- echo "Device in fel mode."
- fi
- echo "Checking correct kernel is available"
- if [ "`./fel ver | grep A20`" ] ; then
- if grep -ciqm1 CONFIG_ARCH_SUN7I=y /tmp/Hacking/sunxi/linux-sunxi/.config; then
- echo "A20 device located and SUN7I build found."
- else
- echo "A20 device located but SUN7I build not found."
- exit
- fi
- fi
- if [ "`./fel ver | grep A31`" ] ; then
- if grep -ciqm1 CONFIG_ARCH_SUN6I=y /tmp/Hacking/sunxi/linux-sunxi/.config; then
- echo "A31 device located and SUN6I build found."
- else
- echo "A31 device located but SUN6I build not found."
- exit
- fi
- fi
- echo "Uploading u-boot"
- if [ "`./fel ver | grep A20`" ] ; then
- echo "to the mk808c"
- ./fel write 0x2000 /tmp/Hacking/dumping_ground/mk808c-u-boot-spl-old.bin
- ./fel exe 0x2000
- sleep 2
- ./fel write 0x4a000000 /tmp/Hacking/dumping_ground/mk808c-u-boot-old.bin
- fi
- if [ "`./fel ver | grep A31`" ] ; then
- echo "to the mele i7"
- ./fel write 0x2000 /tmp/Hacking/dumping_ground/mele-i7-u-boot-spl-old.bin
- ./fel exe 0x2000
- sleep 2
- ./fel write 0x4a000000 /tmp/Hacking/dumping_ground/mele-i7-u-boot-old.bin
- fi
- echo "Uploading kernel"
- ./fel -v write 0x44000000 /tmp/Hacking/sunxi/linux-sunxi/arch/arm/boot/uImage
- echo "Uploading initramfs - modify if any modules are required"
- if grep -ciqm1 CONFIG_MODULES=y /tmp/Hacking/sunxi/linux-sunxi/.config; then
- echo "Modules are used in this build"
- cp /tmp/Hacking/openwrt/bin/sunxi/openwrt-sunxi-rootfs.cpio.gz /tmp/rootfs.cpio.gz
- rm -rf /tmp/rootfs
- gzip -df /tmp/rootfs.cpio.gz
- mkdir /tmp/rootfs
- cd /tmp/rootfs
- cpio -idm < /tmp/rootfs.cpio
- VERSION=(`strings /tmp/Hacking/sunxi/linux-sunxi/vmlinux | grep "Linux version" | awk '{ print $3 }'`)
- cp -rp /tmp/Hacking/sunxi/linux-sunxi/output/lib/modules/$VERSION /tmp/rootfs/lib/modules/.
- find ./ | cpio -H newc -o > /tmp/rootfs.cpio
- gzip /tmp/rootfs.cpio
- cd -
- else
- echo "Modules are not used in this build"
- cp /tmp/Hacking/openwrt/bin/sunxi/openwrt-sunxi-rootfs.cpio.gz /tmp/rootfs.cpio.gz
- fi
- mkimage -A arm -T ramdisk -C none -n uInitrd -d /tmp/rootfs.cpio.gz /tmp/coops.uboot
- ./fel -v write 0x4c000000 /tmp/coops.uboot
- if [ "`./fel ver | grep A20`" ] ; then
- echo "Uploading mk808c script.bin"
- ./fex2bin /tmp/Hacking/sunxi/sunxi-boards/sys_config/a20/mk808c.fex > /tmp/script.bin
- ./fel write 0x43000000 /tmp/script.bin
- fi
- if [ "`./fel ver | grep A31`" ] ; then
- echo "Uploading mele i7 script.bin"
- ./fex2bin /tmp/Hacking/sunxi/sunxi-boards/sys_config/a31/mele_i7.fex > /tmp/script.bin
- ./fel write 0x43000000 /tmp/script.bin
- fi
- mkimage -C none -A arm -T script -d linux-sunxi.cmd /tmp/boot.scr
- ./fel write 0x43100000 /tmp/boot.scr
- ./fel exe 0x4a000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement