3 # Prepare UBI devices for OpenWrt installation
5 # - remove "ubi_rootfs" volume (rootfs on stock)
6 # - remove "fw_hash" volume (firmware hash)
7 # - user_property (mtd24)
8 # - remove "user_property_ubi" volume (user configuration)
9 # - remove "extra_property" volume (gzipped syslog)
10 buffalo_upgrade_prepare
() {
11 local ubi_rootdev ubi_propdev
13 if ! ubi_rootdev
="$(nand_attach_ubi rootfs)" || \
14 ! ubi_propdev
="$(nand_attach_ubi user_property)"; then
15 echo "failed to attach UBI volume \"rootfs\" or \"user_property\", rebooting..."
19 ubirmvol
/dev
/$ubi_rootdev -N ubi_rootfs
&> /dev
/null || true
20 ubirmvol
/dev
/$ubi_rootdev -N fw_hash
&> /dev
/null || true
22 ubirmvol
/dev
/$ubi_propdev -N user_property_ubi
&> /dev
/null || true
23 ubirmvol
/dev
/$ubi_propdev -N extra_property
&> /dev
/null || true
26 # Re-create small dummy ubi_rootfs volume and update
27 # fw_hash volume to pass the checking by U-Boot
29 # - re-create "ubi_rootfs" volume
30 # - re-create and update "fw_hash" volume
31 # - rootfs_recover (mtd23)
32 # - update "fw_hash" volume
33 buffalo_upgrade_optvol
() {
34 local ubi_rootdev ubi_rcvrdev
35 local hashvol_root hashvol_rcvr
37 if ! ubi_rootdev
="$(nand_attach_ubi rootfs)" || \
38 ! ubi_rcvrdev
="$(nand_attach_ubi rootfs_recover)"; then
39 echo "failed to attach UBI volume \"rootfs\" or \"rootfs_recover\", rebooting..."
43 ubimkvol
/dev
/$ubi_rootdev -N ubi_rootfs
-S 1
44 ubimkvol
/dev
/$ubi_rootdev -N fw_hash
-S 1 -t static
46 if ! hashvol_root
="$(nand_find_volume $ubi_rootdev fw_hash)" || \
47 ! hashvol_rcvr
="$(nand_find_volume $ubi_rcvrdev fw_hash)"; then
48 echo "\"fw_hash\" volume in \"rootfs\" or \"rootfs_recover\" not found, rebooting..."
52 echo -n "00000000000000000000000000000000" > /tmp
/dummyhash.txt
53 ubiupdatevol
/dev
/$hashvol_root /tmp
/dummyhash.txt
54 ubiupdatevol
/dev
/$hashvol_rcvr /tmp
/dummyhash.txt