mvebu: add Methode euroDPU support
[openwrt/staging/ansuel.git] / target / linux / mvebu / cortexa53 / base-files / lib / preinit / 82_uDPU
1 #
2 # Copyright (C) 2014-2019 OpenWrt.org
3 # Copyright (C) 2016 LEDE-Project.org
4 #
5
6 preinit_mount_udpu() {
7 . /lib/functions.sh
8 . /lib/upgrade/common.sh
9
10 case $(board_name) in
11 methode,udpu|\
12 methode,edpu)
13 # Check which device is detected
14 [ -b "/dev/mmcblk0" ] && mmcdev="/dev/mmcblk0" || mmcdev="/dev/mmcblk1"
15
16 if [ -b "${mmcdev}p4" ]; then
17 mkdir /misc
18 mount -t f2fs ${mmcdev}p4 /misc
19 [ -f "/misc/$BACKUP_FILE" ] && {
20 echo "- Restoring configuration files -"
21 tar xzf "/misc/$BACKUP_FILE" -C /
22 rm -f "/misc/$BACKUP_FILE"
23 sync
24 }
25 [ -f "/misc/firmware/recovery.itb" ] && {
26 echo "- Updating /recovery partition -"
27 mkfs.ext4 -q ${mmcdev}p2 | echo y &> /dev/null
28 mkdir -p /tmp/recovery
29 mount ${mmcdev}p2 /tmp/recovery
30 cp /misc/firmware/recovery.itb /tmp/recovery
31 [ -f "/misc/firmware/boot.scr" ] && \
32 cp /misc/firmware/boot.scr /tmp/recovery
33 sync
34 umount /tmp/recovery
35 rm -rf /tmp/recovery
36
37 # Replace previous backup with the new one
38 [ -d "/misc/firmware_old" ] && rm -rf /misc/firmware_old
39 [ -d "/misc/firmware" ] && mv /misc/firmware /misc/firmware_old
40 }
41 fi
42
43 # Legacy support - if rootfs was booted, instruct u-boot to keep the current root dev
44 [ "$(df | grep /dev/root)" ] && fw_setenv root_ok '2'
45 ;;
46 esac
47 }
48
49 boot_hook_add preinit_main preinit_mount_udpu