platform.sh 606 B

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