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