Message ID | 20190806131039.51484-2-freifunk@adrianschmutzler.de |
---|---|
State | Changes Requested |
Delegated to: | John Crispin |
Headers | show |
Series | [OpenWrt-Devel,1/3] ath79: tidy up and fix IMAGE_SIZE for Ubiquiti devices | expand |
Hi Looks like there were many doubts about image size over the years. One thing that should be considered is use of OEM firmware, either in case of just a single revert after OpenWrt flashing, or multiple reverts/switching between OEM/OpenWrt firmwares. Relevant in this case is config partition within OEM fw, and by specifying OpenWrt image size to occupy all available flash space between u-boot and art partitions destroys config contents which may turn up very impractical for those that do frequent switching between the two. Further, config partition size also varies from device to device, some have it 64KB others 128KB in size, at least what I observed with my devices. So, the correct image size for Archer C7 v1 turned out to be 0x7b0000 On 06/08/2019, Adrian Schmutzler <freifunk@adrianschmutzler.de> wrote: > So far, IMAGE_SIZE is set as follows: > tplink-4m* 3904k 0x3d0000 > tplink-8m* 7936k 0x7c0000 > tplink-16m* 15872k 0xf80000 > > However, based on the size of firmware partitions in DTS it should > be: > tplink-4m* 3904k 0x3d0000 > tplink-8m* 8000k 0x7d0000 > tplink-16m* 16192k 0xfd0000 > > All (!) 8m*/16m* devices actually follow the latter scheme, which > is also consistent in terms of left free space for other > partitions. Thus, fix it. > > Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> > --- > target/linux/ath79/image/common-tp-link.mk | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/target/linux/ath79/image/common-tp-link.mk > b/target/linux/ath79/image/common-tp-link.mk > index da4616482a..d05ac028c7 100644 > --- a/target/linux/ath79/image/common-tp-link.mk > +++ b/target/linux/ath79/image/common-tp-link.mk > @@ -83,19 +83,19 @@ endef > define Device/tplink-8m > $(Device/tplink-nolzma) > TPLINK_FLASHLAYOUT := 8M > - IMAGE_SIZE := 7936k > + IMAGE_SIZE := 8000k > endef > > define Device/tplink-8mlzma > $(Device/tplink) > TPLINK_FLASHLAYOUT := 8Mlzma > - IMAGE_SIZE := 7936k > + IMAGE_SIZE := 8000k > endef > > define Device/tplink-16mlzma > $(Device/tplink) > TPLINK_FLASHLAYOUT := 16Mlzma > - IMAGE_SIZE := 15872k > + IMAGE_SIZE := 16192k > endef > > define Device/tplink-safeloader > -- > 2.20.1 > > > _______________________________________________ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel >
> -----Original Message----- > From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org] On Behalf Of Tom Psyborg > Sent: Mittwoch, 7. August 2019 17:58 > To: Adrian Schmutzler <freifunk@adrianschmutzler.de> > Cc: openwrt-devel@lists.openwrt.org > Subject: Re: [OpenWrt-Devel] [PATCH 2/3] ath79: fix IMAGE_SIZE for common TP-Link definitions > > Hi > > Looks like there were many doubts about image size over the years. > > One thing that should be considered is use of OEM firmware, either in > case of just a single revert after OpenWrt flashing, or multiple > reverts/switching between OEM/OpenWrt firmwares. > > Relevant in this case is config partition within OEM fw, and by > specifying OpenWrt image size to occupy all available flash space > between u-boot and art partitions destroys config contents which may > turn up very impractical for those that do frequent switching between > the two. > > Further, config partition size also varies from device to device, some > have it 64KB others 128KB in size, at least what I observed with my > devices. > > So, the correct image size for Archer C7 v1 turned out to be 0x7b0000 But wouldn't this call for introducing a config partition for the C7 v1? I'm not sure how your analysis is affecting the IMAGE_SIZE discussion (unless you say TP-Link devices generally have this config partition with different sizes, and thus the whole concept of including IMAGE_SIZE in common definitions is "wrong")... Best Adrian
Correct me if I'm wrong but I thought all the data beyond IMAGE_SIZE remain intact by OpenWrt on firstboot. Experimenting with Archer C7 v1 recently I was able to flash OpenWrt image (ar71xx) and after reflashing tplink fw previous settings were still valid indicating config partition hasn't been overwritten. At least TL-MR22U has config partition of 64KB and Archer C7 has 128KB - I've gone through GPL sources of Archer and it seems between two firmware versions this partition was increased from 64 to 128KB, actually I discovered this by hexdiff-ing u-boot versions from each firmware version On 07/08/2019, Adrian Schmutzler <mail@adrianschmutzler.de> wrote: >> -----Original Message----- >> From: openwrt-devel [mailto:openwrt-devel-bounces@lists.openwrt.org] On >> Behalf Of Tom Psyborg >> Sent: Mittwoch, 7. August 2019 17:58 >> To: Adrian Schmutzler <freifunk@adrianschmutzler.de> >> Cc: openwrt-devel@lists.openwrt.org >> Subject: Re: [OpenWrt-Devel] [PATCH 2/3] ath79: fix IMAGE_SIZE for common >> TP-Link definitions >> >> Hi >> >> Looks like there were many doubts about image size over the years. >> >> One thing that should be considered is use of OEM firmware, either in >> case of just a single revert after OpenWrt flashing, or multiple >> reverts/switching between OEM/OpenWrt firmwares. >> >> Relevant in this case is config partition within OEM fw, and by >> specifying OpenWrt image size to occupy all available flash space >> between u-boot and art partitions destroys config contents which may >> turn up very impractical for those that do frequent switching between >> the two. >> >> Further, config partition size also varies from device to device, some >> have it 64KB others 128KB in size, at least what I observed with my >> devices. >> >> So, the correct image size for Archer C7 v1 turned out to be 0x7b0000 > > But wouldn't this call for introducing a config partition for the C7 v1? > I'm not sure how your analysis is affecting the IMAGE_SIZE discussion > (unless you say TP-Link devices generally have this config partition with > different sizes, and thus the whole concept of including IMAGE_SIZE in > common definitions is "wrong")... > > Best > > Adrian >
> -----Original Message----- > From: Tom Psyborg [mailto:pozega.tomislav@gmail.com] > Sent: Mittwoch, 7. August 2019 23:19 > To: Adrian Schmutzler <mail@adrianschmutzler.de> > Cc: openwrt-devel@lists.openwrt.org > Subject: Re: [OpenWrt-Devel] [PATCH 2/3] ath79: fix IMAGE_SIZE for > common TP-Link definitions > > Correct me if I'm wrong but I thought all the data beyond IMAGE_SIZE > remain intact by OpenWrt on firstboot. Experimenting with Archer C7 v1 > recently I was able to flash OpenWrt image (ar71xx) and after reflashing > tplink fw previous settings were still valid indicating config partition hasn't > been overwritten. > At least TL-MR22U has config partition of 64KB and Archer C7 has 128KB > - I've gone through GPL sources of Archer and it seems between two > firmware versions this partition was increased from 64 to 128KB, actually I > discovered this by hexdiff-ing u-boot versions from each firmware version Nevertheless, addressing this with IMAGE_SIZE would still be just a hack. If there is config data to be preserved, one should add a partition for it. Then IMAGE_SIZE would just shrink according to the (then correct) firmware partition. Now that we have DTS files with individual partition schemes, this would be even easier than for ar71xx. Best Adrian
> > Correct me if I'm wrong but I thought all the data beyond IMAGE_SIZE > > remain intact by OpenWrt on firstboot. Experimenting with Archer C7 v1 > > recently I was able to flash OpenWrt image (ar71xx) and after reflashing > > tplink fw previous settings were still valid indicating config partition hasn't > > been overwritten. > > At least TL-MR22U has config partition of 64KB and Archer C7 has 128KB > > - I've gone through GPL sources of Archer and it seems between two > > firmware versions this partition was increased from 64 to 128KB, actually I > > discovered this by hexdiff-ing u-boot versions from each firmware version > Nevertheless, addressing this with IMAGE_SIZE would still be just a hack. > If there is config data to be preserved, one should add a partition for it. Then IMAGE_SIZE would just shrink according to the (then correct) firmware partition. Now that we have DTS files with individual partition > schemes, this would be even easier than for ar71xx. > Best > Adrian To put this in a more positive frame: If you think that there is a config partition on C7v1 or other devices and you know where it is, please send a patch adding it as read-only partition in DTS. Best Adrian
diff --git a/target/linux/ath79/image/common-tp-link.mk b/target/linux/ath79/image/common-tp-link.mk index da4616482a..d05ac028c7 100644 --- a/target/linux/ath79/image/common-tp-link.mk +++ b/target/linux/ath79/image/common-tp-link.mk @@ -83,19 +83,19 @@ endef define Device/tplink-8m $(Device/tplink-nolzma) TPLINK_FLASHLAYOUT := 8M - IMAGE_SIZE := 7936k + IMAGE_SIZE := 8000k endef define Device/tplink-8mlzma $(Device/tplink) TPLINK_FLASHLAYOUT := 8Mlzma - IMAGE_SIZE := 7936k + IMAGE_SIZE := 8000k endef define Device/tplink-16mlzma $(Device/tplink) TPLINK_FLASHLAYOUT := 16Mlzma - IMAGE_SIZE := 15872k + IMAGE_SIZE := 16192k endef define Device/tplink-safeloader
So far, IMAGE_SIZE is set as follows: tplink-4m* 3904k 0x3d0000 tplink-8m* 7936k 0x7c0000 tplink-16m* 15872k 0xf80000 However, based on the size of firmware partitions in DTS it should be: tplink-4m* 3904k 0x3d0000 tplink-8m* 8000k 0x7d0000 tplink-16m* 16192k 0xfd0000 All (!) 8m*/16m* devices actually follow the latter scheme, which is also consistent in terms of left free space for other partitions. Thus, fix it. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> --- target/linux/ath79/image/common-tp-link.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)