wdbook.sh 624 B

123456789101112131415161718192021222324252627282930313233343536
  1. . /lib/functions.sh
  2. get_magic_at() {
  3. local file="$1"
  4. local pos="$2"
  5. get_image "$file" | dd bs=1 count=2 skip="$pos" 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
  6. }
  7. mbl_do_platform_check() {
  8. local board="$1"
  9. local file="$2"
  10. local magic
  11. magic=$(get_magic_at "$file" 510)
  12. [ "$magic" != "55aa" ] && {
  13. echo "Failed to verify MBR boot signature."
  14. return 1
  15. }
  16. return 0;
  17. }
  18. mbl_do_upgrade() {
  19. sync
  20. get_image "$1" | dd of=/dev/sda bs=2M conv=fsync
  21. sleep 1
  22. }
  23. mbl_copy_config() {
  24. mkdir -p /boot
  25. [ -f /boot/uImage ] || mount -t ext4 -o rw,noatime /dev/sda1 /boot
  26. cp -af "$CONF_TAR" /boot/
  27. sync
  28. umount /boot
  29. }