diff --git a/target/configs/d211_demo128_nand_defconfig b/target/configs/d211_demo128_nand_defconfig index 157393c46..94aa6734b 100644 --- a/target/configs/d211_demo128_nand_defconfig +++ b/target/configs/d211_demo128_nand_defconfig @@ -22,14 +22,9 @@ BR2_TARGET_USERFS1_NAME="system" BR2_TARGET_USERFS1_TYPE_UBIFS=y BR2_TARGET_USERFS1_OVERLAY="target/$(LUBAN_CHIP_NAME)/$(LUBAN_BOARD_NAME)/system" BR2_TARGET_USERFS2=y -BR2_TARGET_USERFS2_NAME="ota" +BR2_TARGET_USERFS2_NAME="data" BR2_TARGET_USERFS2_TYPE_UBIFS=y -BR2_TARGET_USERFS2_OVERLAY="target/$(LUBAN_CHIP_NAME)/$(LUBAN_BOARD_NAME)/ota" -BR2_TARGET_USERFS2_UBIFS_MAX_SIZE=0x03200000 -BR2_TARGET_USERFS3=y -BR2_TARGET_USERFS3_NAME="data" -BR2_TARGET_USERFS3_TYPE_UBIFS=y -BR2_TARGET_USERFS3_OVERLAY="target/$(LUBAN_CHIP_NAME)/$(LUBAN_BOARD_NAME)/data" +BR2_TARGET_USERFS2_OVERLAY="target/$(LUBAN_CHIP_NAME)/$(LUBAN_BOARD_NAME)/data" BR2_GENERATE_BURNER_IMAGE=y BR2_GENERATE_IMAGE_AUTO_CALCULATE_SIZE=y BR2_PACKAGE_OPENSBI_FW_TEXT_BASE=0x47FE0000 diff --git a/target/d211/common/Recovery.gz b/target/d211/common/Recovery.gz index 853607162..83c49a4f6 100644 Binary files a/target/d211/common/Recovery.gz and b/target/d211/common/Recovery.gz differ diff --git a/target/d211/demo128_nand/image_cfg.json b/target/d211/demo128_nand/image_cfg.json index 5070df4bb..929620ad9 100644 --- a/target/d211/demo128_nand/image_cfg.json +++ b/target/d211/demo128_nand/image_cfg.json @@ -22,7 +22,6 @@ "size": "-", "ubi": { // Volume in UBI device "system": { "size": "8m" }, - "ota": { "size": "55m" }, "data": { "size": "-" }, }, }, @@ -115,11 +114,6 @@ "attr": ["ubi", "optional"], "part": ["ubisystem:data"] }, - "ota": { - "file": "ota*.ubifs", - "attr": ["ubi", "optional"], - "part": ["ubisystem:ota"] - }, }, }, "pre-process": { // Pre-proccess to generate image components from raw data diff --git a/target/d211/demo128_nand/rootfs_overlay/etc/init.d/S02ota b/target/d211/demo128_nand/rootfs_overlay/etc/init.d/S02ota deleted file mode 100755 index 5bbf22bf9..000000000 --- a/target/d211/demo128_nand/rootfs_overlay/etc/init.d/S02ota +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# Auto-mount OTA volume to /mnt/ota at boot -# - -case "$1" in - start) - [ -x /etc/swupdate_main ] && /etc/swupdate_main start - ;; - stop) - [ -x /etc/swupdate_main ] && /etc/swupdate_main stop - ;; - restart|reload) - [ -x /etc/swupdate_main ] && /etc/swupdate_main stop - [ -x /etc/swupdate_main ] && /etc/swupdate_main start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 - ;; -esac - -exit 0 - diff --git a/target/d211/demo128_nand/rootfs_overlay/etc/ota_build_id b/target/d211/demo128_nand/rootfs_overlay/etc/ota_build_id index c21339fb7..693850970 100644 --- a/target/d211/demo128_nand/rootfs_overlay/etc/ota_build_id +++ b/target/d211/demo128_nand/rootfs_overlay/etc/ota_build_id @@ -1 +1 @@ -demo128_nand-ota-marker=2026-04-27_v1 +demo128_nand-ota-marker=2026-04-27_v9999 diff --git a/target/d211/demo128_nand/rootfs_overlay/etc/swupdate_main b/target/d211/demo128_nand/rootfs_overlay/etc/swupdate_main index c2cb87e7b..bb593e9b4 100755 --- a/target/d211/demo128_nand/rootfs_overlay/etc/swupdate_main +++ b/target/d211/demo128_nand/rootfs_overlay/etc/swupdate_main @@ -2,41 +2,13 @@ # Run the swupdate daemon case "$1" in - start) - echo -n "Starting swupdate... " - # obtain ubisystem mtd number - - param=$(cat /proc/mtd | grep "ubisystem") - mtd_param=$(echo "$param" | awk -F ':' '{print $1}') - mtd_num=$(echo "$mtd_param" | awk -F 'mtd' '{print $2}') - echo "ubisystem mtd number is $mtd_num" - - # ubisystem might already be attached (EEXIST). Don't fail in that case. - if [ ! -e /dev/ubi1 ]; then - ubiattach /dev/ubi_ctrl -m $mtd_num - else - cur_mtd_num=$(cat /sys/class/ubi/ubi1/mtd_num 2>/dev/null) - if [ "x$cur_mtd_num" != "x$mtd_num" ]; then - ubiattach /dev/ubi_ctrl -m $mtd_num - fi - fi - - # obtain the ota part device node - - param=$(grep -H -r "ota" /sys/class/ubi/* | sed 1q) - ubi_param=$(echo "$param" | awk -F '/name:ota' '{print $1}') - ubi_param=$(echo "$ubi_param" | awk -F '/sys/class/ubi/' '{print $2}') - ubi_param=$(echo "$ubi_param" | awk -F '/' '{print $2}') - echo "ota part device node is /dev/$ubi_param" - - if [ -c "/dev/$ubi_param" ]; then - mkdir -p /mnt/ota - mount -t ubifs /dev/$ubi_param /mnt/ota - fi + start) + echo "swupdate_main: /data should already be mounted by S01ubivol" + mountpoint -q /data && echo "/data is ready" || \ + echo "Warning: /data is NOT mounted" ;; stop) - echo -n "Stopping swupdate... " - umount /mnt/ota - ;; + echo "swupdate_main: nothing to do (/data is managed by S01ubivol)" + ;; esac diff --git a/target/d211/ota/rootfs_overlay/etc/init.d/S91swupdate_ota b/target/d211/ota/rootfs_overlay/etc/init.d/S91swupdate_ota index 9f6be1279..ffe426a77 100755 --- a/target/d211/ota/rootfs_overlay/etc/init.d/S91swupdate_ota +++ b/target/d211/ota/rootfs_overlay/etc/init.d/S91swupdate_ota @@ -1,42 +1,58 @@ #!/bin/sh -# Run the swupdate daemon +# Run the swupdate daemon (recovery side, second stage of OTA) + +attach_ubi_by_name() +{ + want="$1" + mtdline=$(grep "\"$want\"" /proc/mtd) + [ -z "$mtdline" ] && { + echo "S91: cannot find mtd partition '$want'" + return 1 + } + mtd_num=$(echo "$mtdline" | sed -e 's/^mtd//' -e 's/:.*//') + echo "S91: '$want' is on mtd${mtd_num}" + + # If some ubi device is already on this mtd, do nothing. + for u in /sys/class/ubi/ubi[0-9]*; do + [ -e "$u/mtd_num" ] || continue + cur=$(cat "$u/mtd_num" 2>/dev/null) + [ "x$cur" = "x$mtd_num" ] && { + echo "S91: $u already attached to mtd${mtd_num}" + return 0 + } + done + ubiattach /dev/ubi_ctrl -m "$mtd_num" 2>&1 +} case "$1" in start) - echo -n "Starting swupdate... " - # obtain ubisystem mtd number - param=$(cat /proc/mtd | grep "ubisystem") - mtd_param=$(echo "$param" | awk -F ':' '{print $1}') - mtd_num=$(echo "$mtd_param" | awk -F 'mtd' '{print $2}') + echo "S91: starting OTA second stage" - echo "ubisystem mtd number is $mtd_num" - # ubisystem might already be attached (EEXIST). Don't fail in that case. - if [ ! -e /dev/ubi1 ]; then - ubiattach /dev/ubi_ctrl -m $mtd_num - else - cur_mtd_num=$(cat /sys/class/ubi/ubi1/mtd_num 2>/dev/null) - if [ "x$cur_mtd_num" != "x$mtd_num" ]; then - ubiattach /dev/ubi_ctrl -m $mtd_num - fi + # Attach both UBI devices so swupdate can write to: + # /dev/mtdX (logo, kernel, recovery) + # ubi0:rootfs (ubiroot) + # ubi1:data (ubisystem) -- holds the .swu package + attach_ubi_by_name "ubiroot" + attach_ubi_by_name "ubisystem" + + # Mount ubi*:data so we can read the .swu placed there by main system. + mkdir -p /data + if ! mountpoint -q /data; then + # Try ubi0 then ubi1 — depending on attach order data may be on either. + for d in /dev/ubi1 /dev/ubi0; do + [ -e "$d" ] || continue + idx=$(echo "$d" | sed 's|.*ubi||') + if mount -t ubifs "ubi${idx}:data" /data 2>/dev/null; then + echo "S91: mounted ubi${idx}:data on /data" + break + fi + done + mountpoint -q /data || echo "S91: WARNING /data not mounted" fi - # obtain the ota part device node - param=$(grep -H -r "ota" /sys/class/ubi/* | sed 1q) - ubi_param=$(echo "$param" | awk -F '/name:ota' '{print $1}') - ubi_param=$(echo "$ubi_param" | awk -F '/sys/class/ubi/' '{print $2}') - ubi_param=$(echo "$ubi_param" | awk -F '/' '{print $2}') - - echo "ota part device node is /dev/$ubi_param" - - if [ -c "/dev/$ubi_param" ]; then - mkdir -p /mnt/ota - mount -t ubifs /dev/$ubi_param /mnt/ota - fi - - /usr/lib/swupdate/swupdate_cmd.sh + exec /usr/lib/swupdate/swupdate_cmd.sh ;; stop) - echo -n "Stopping swupdate... " - umount /mnt/ota + umount /data 2>/dev/null ;; esac