Advertisement
codekipper

sunxi-linux fel script

Mar 15th, 2015
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # This scripts boots the sunxi kernel over fel
  4. #
  5. # Make sure only root can run our script
  6. if [[ $EUID -ne 0 ]]; then
  7. echo "This script must be run as root" 1>&2
  8. exit 1
  9. fi
  10. if [ ! -d /tmp/Hacking ]; then
  11. echo "Hacking Directory not found!"
  12. mkdir /tmp/Hacking
  13. fi
  14. # need to mount the build computer
  15. if grep -qs '/tmp/Hacking' /proc/mounts; then
  16. echo "Hacking Directory is mounted."
  17. else
  18. echo "Hacking Directory is not mounted. Attach to build computer"
  19. mount -t nfs BLAH/Hacking /tmp/Hacking
  20. fi
  21. #is any device in fel mode
  22. if [ "`./fel 2>&1 >/dev/null | grep ERROR`" ] ; then
  23. echo "Device in fel mode not detected."
  24. exit 1
  25. else
  26. echo "Device in fel mode."
  27. fi
  28. echo "Checking correct kernel is available"
  29. if [ "`./fel ver | grep A20`" ] ; then
  30. if grep -ciqm1 CONFIG_ARCH_SUN7I=y /tmp/Hacking/sunxi/linux-sunxi/.config; then
  31. echo "A20 device located and SUN7I build found."
  32. else
  33. echo "A20 device located but SUN7I build not found."
  34. exit
  35. fi
  36. fi
  37. if [ "`./fel ver | grep A31`" ] ; then
  38. if grep -ciqm1 CONFIG_ARCH_SUN6I=y /tmp/Hacking/sunxi/linux-sunxi/.config; then
  39. echo "A31 device located and SUN6I build found."
  40. else
  41. echo "A31 device located but SUN6I build not found."
  42. exit
  43. fi
  44. fi
  45. echo "Uploading u-boot"
  46. if [ "`./fel ver | grep A20`" ] ; then
  47. echo "to the mk808c"
  48. ./fel write 0x2000 /tmp/Hacking/dumping_ground/mk808c-u-boot-spl-old.bin
  49. ./fel exe 0x2000
  50. sleep 2
  51. ./fel write 0x4a000000 /tmp/Hacking/dumping_ground/mk808c-u-boot-old.bin
  52. fi
  53. if [ "`./fel ver | grep A31`" ] ; then
  54. echo "to the mele i7"
  55. ./fel write 0x2000 /tmp/Hacking/dumping_ground/mele-i7-u-boot-spl-old.bin
  56. ./fel exe 0x2000
  57. sleep 2
  58. ./fel write 0x4a000000 /tmp/Hacking/dumping_ground/mele-i7-u-boot-old.bin
  59. fi
  60. echo "Uploading kernel"
  61. ./fel -v write 0x44000000 /tmp/Hacking/sunxi/linux-sunxi/arch/arm/boot/uImage
  62.  
  63. echo "Uploading initramfs - modify if any modules are required"
  64. if grep -ciqm1 CONFIG_MODULES=y /tmp/Hacking/sunxi/linux-sunxi/.config; then
  65. echo "Modules are used in this build"
  66. cp /tmp/Hacking/openwrt/bin/sunxi/openwrt-sunxi-rootfs.cpio.gz /tmp/rootfs.cpio.gz
  67. rm -rf /tmp/rootfs
  68. gzip -df /tmp/rootfs.cpio.gz
  69. mkdir /tmp/rootfs
  70. cd /tmp/rootfs
  71. cpio -idm < /tmp/rootfs.cpio
  72. VERSION=(`strings /tmp/Hacking/sunxi/linux-sunxi/vmlinux | grep "Linux version" | awk '{ print $3 }'`)
  73. cp -rp /tmp/Hacking/sunxi/linux-sunxi/output/lib/modules/$VERSION /tmp/rootfs/lib/modules/.
  74. find ./ | cpio -H newc -o > /tmp/rootfs.cpio
  75. gzip /tmp/rootfs.cpio
  76. cd -
  77. else
  78. echo "Modules are not used in this build"
  79. cp /tmp/Hacking/openwrt/bin/sunxi/openwrt-sunxi-rootfs.cpio.gz /tmp/rootfs.cpio.gz
  80. fi
  81.  
  82. mkimage -A arm -T ramdisk -C none -n uInitrd -d /tmp/rootfs.cpio.gz /tmp/coops.uboot
  83. ./fel -v write 0x4c000000 /tmp/coops.uboot
  84.  
  85. if [ "`./fel ver | grep A20`" ] ; then
  86. echo "Uploading mk808c script.bin"
  87. ./fex2bin /tmp/Hacking/sunxi/sunxi-boards/sys_config/a20/mk808c.fex > /tmp/script.bin
  88. ./fel write 0x43000000 /tmp/script.bin
  89. fi
  90.  
  91. if [ "`./fel ver | grep A31`" ] ; then
  92. echo "Uploading mele i7 script.bin"
  93. ./fex2bin /tmp/Hacking/sunxi/sunxi-boards/sys_config/a31/mele_i7.fex > /tmp/script.bin
  94. ./fel write 0x43000000 /tmp/script.bin
  95. fi
  96. mkimage -C none -A arm -T script -d linux-sunxi.cmd /tmp/boot.scr
  97. ./fel write 0x43100000 /tmp/boot.scr
  98.  
  99. ./fel exe 0x4a000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement