[OpenWrt-Devel] [PATCH] ramips: Fix sysupgrade for Xiaomi mir3g
Hauke Mehrtens
hauke at hauke-m.de
Sun Jan 5 11:48:44 EST 2020
On 1/5/20 5:37 PM, mail at adrianschmutzler.de wrote:
> Hi Hauke,
>
>> -----Original Message-----
>> From: Hauke Mehrtens [mailto:hauke at hauke-m.de]
>> Sent: Sonntag, 5. Januar 2020 15:18
>> To: openwrt-devel at lists.openwrt.org
>> Cc: mail at adrianschmutzler.de; dev at kresin.me; Hauke Mehrtens
>> <hauke at hauke-m.de>
>> Subject: [PATCH] ramips: Fix sysupgrade for Xiaomi mir3g
>>
>> Without this change sysupgrade from 18.06 to 19.07 is only possible with the -
>> F option.
>> In OpenWrt 18.06 the nand_do_platform_check() function is called with the
>> board name mir3g only, if the tar does not use mir3g it will fail.
>> OpenWrt 19.07 and later support the metadata with the supported_devices
>> attribute to allow renaming. Do the renaming of the target between 19.07
>> and master like it is done for some other boards.
>>
>> I tested the following sysupgrades successfully without -F
>> 18.06 -> 19.07
>> 19.07 -> master
>> master -> 19.07
>>
>> Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
>> ---
>> target/linux/ramips/image/mt7621.mk | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/target/linux/ramips/image/mt7621.mk
>> b/target/linux/ramips/image/mt7621.mk
>> index 7eb59188fb..39017a48e1 100644
>> --- a/target/linux/ramips/image/mt7621.mk
>> +++ b/target/linux/ramips/image/mt7621.mk
>> @@ -269,7 +269,7 @@ define Device/xiaomi_mir3p endef TARGET_DEVICES
>> += xiaomi_mir3p
>>
>> -define Device/xiaomi_mir3g
>> +define Device/mir3g
>> DTS := MIR3G
>> BLOCKSIZE := 128k
>> PAGESIZE := 2048
>> @@ -282,12 +282,12 @@ define Device/xiaomi_mir3g
>> IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
>> DEVICE_TITLE := Xiaomi Mi Router 3G
>> SUPPORTED_DEVICES += R3G
>> - SUPPORTED_DEVICES += mir3g
>> + SUPPORTED_DEVICES += xiaomi,mir3g
>
> I do not really understand this patch, as still the names will be the same, but just the order will change. If you really rely on the first name to be mir3g, you could achieve this much easier by just using:
OpenWrt 18.06 does not support the SUPPORTED_DEVICES fully. I only added
xiaomi,mir3g there to allow a downgrade from master to 19.07, which is
not so important.
> SUPPORTED_DEVICES := mir3g R3G xiaomi,mir3g
>
> With that, you would not have to change the device node name at all.
When I use sysupgrade in 18.06 it executes the platform_check_image()
functions which calls nand_do_platform_check("mir3g",
"/tmp/openwrt-19.07-ramips-mt7621-xiaomi_mir3g-squashfs-sysupgrade.bin")
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ramips/base-files/lib/upgrade/platform.sh;h=ffdc5e73e0ede286c10396810954a230c8ea32fc;hb=refs/heads/openwrt-18.06#l296
The nand_do_platform_check() function is located here:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/base-files/files/lib/upgrade/nand.sh;h=42f488c118fab514de7d2aee78bc431f7b8be157;hb=refs/heads/openwrt-18.06#l317
It calls this:
local control_length=`(tar xf $tar_file sysupgrade-$board_name/CONTROL
-O | wc -c) 2> /dev/null`
which expands to
tar xf
/tmp/openwrt-19.07-ramips-mt7621-xiaomi_mir3g-squashfs-sysupgrade.bin
sysupgrade-mir3g/CONTROL
This file does not exists:
sysupgrade-mir3g/CONTROL
But this is there:
sysupgrade-xiaomi_mir3g/CONTROL
The system does not find it and aborts.
The control_length is set to 0 and we expect the file_type detection to
work, but it does not because the ubi is inside the tar.
The sysupgrade in 19.07 supports the SUPPORTED_DEVICES, the sysupgrade
in 18.06 does not support the metadata fully.
When we do the board rename between 19.07 and master it is fine, but we
should not rename the board between 18.06 and 19.07.
Hauke
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20200105/7b03df21/attachment.sig>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list