mvebu: use SOC to derive DEVICE_DTS
[openwrt/staging/wigyori.git] / target / linux / mvebu / 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 # Check which device is detected
13 [ -b "/dev/mmcblk0" ] && mmcdev="/dev/mmcblk0" || mmcdev="/dev/mmcblk1"
14
15 if [ -b "${mmcdev}p4" ]; then
16 mkdir /misc
17 mount -t f2fs ${mmcdev}p4 /misc
18 [ -f "/misc/$BACKUP_FILE" ] && {
19 echo "- Restoring configuration files -"
20 tar xzf "/misc/$BACKUP_FILE" -C /
21 rm -f "/misc/$BACKUP_FILE"
22 sync
23 }
24 [ -f "/misc/firmware/recovery.itb" ] && {
25 echo "- Updating /recovery partition -"
26 mkfs.ext4 -q ${mmcdev}p2 | echo y &> /dev/null
27 mkdir -p /tmp/recovery
28 mount ${mmcdev}p2 /tmp/recovery
29 cp /misc/firmware/recovery.itb /tmp/recovery
30 [ -f "/misc/firmware/boot.scr" ] && \
31 cp /misc/firmware/boot.scr /tmp/recovery
32 sync
33 umount /tmp/recovery
34 rm -rf /tmp/recovery
35
36 # Replace previous backup with the new one
37 [ -d "/misc/firmware_old" ] && rm -rf /misc/firmware_old
38 [ -d "/misc/firmware" ] && mv /misc/firmware /misc/firmware_old
39 }
40 fi
41
42 # Legacy support - if rootfs was booted, instruct u-boot to keep the current root dev
43 [ "$(df | grep /dev/root)" ] && fw_setenv root_ok '2'
44 ;;
45 esac
46 }
47
48 boot_hook_add preinit_main preinit_mount_udpu