Skip to content

Commit

Permalink
mediatek: mt7622: skip build also for Xiaomi AX6S
Browse files Browse the repository at this point in the history
Also here build fails due to increased kernel size.

Fixes: da970d6 ("mediatek: switch to Linux version 6.1")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  • Loading branch information
dangowrt committed Feb 17, 2024
1 parent cbc7393 commit dadad6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion target/linux/mediatek/image/mt7622.mk
Expand Up @@ -466,4 +466,4 @@ define Device/xiaomi_redmi-router-ax6s
IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += xiaomi_redmi-router-ax6s
# TARGET_DEVICES += xiaomi_redmi-router-ax6s

35 comments on commit dadad6b

@K900
Copy link
Contributor

@K900 K900 commented on dadad6b Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what I'm doing differently, but it builds (and runs) fine on mine?

@K900
Copy link
Contributor

@K900 K900 commented on dadad6b Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The answer is simple: You don't have CONFIG_ALL_KMODS=y set in your .config (which is what the buildbots are doing). Compiling the kernel with the option to have all kmods increases the size beyond the boundary of the current partition layout of the AX6S.

@K900
Copy link
Contributor

@K900 K900 commented on dadad6b Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I'll have to check how much space is left, but it looked like there was still some spare. I guess I'll have to look into a new device at some point though...

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is enough space for everything, just the way the stock bootloader expects that space to be partitioned is restricting. One option is of course to replace that bootloader...

@K900
Copy link
Contributor

@K900 K900 commented on dadad6b Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, yeah. Replacing the bootloader would be nice, but I'm pretty sure there's some kind of signature check there.

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure there isn't any check of the preloader or bootloader. All it takes is replacing bl2 and then we can have the same flash layout as on Linksys E8450/Belkin RT3200. I just don't have the hardware to test.

@remittor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabolcs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't have the hardware to test.

Hi @dangowrt , a remote secure shell would suffice? Or do you need serial access too?

@dangowrt
Copy link
Member Author

@dangowrt dangowrt commented on dadad6b Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dangowrt , a remote secure shell would suffice?

Mostly we need to check the bootloader environment and/or how the vendor bootloader handles kernel images larger than 4 MiB. As the image is stored on SPI-NAND it will have to be copied into RAM before running, and we need to figure out if the bootloader relies on a hard-coded size or partition layout or if it reads the uImage headers to know the size. In the first case it means replacing the loader or introducing a 2nd stage loader, in the latter case we are good.

Edit: So yes, serial access would be better.

@xabolcs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: So yes, serial access would be better.

😁

Sure!
Let me try building some debugging environment for you. Will be back in a few days.

@remittor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try building some debugging environment for you.

I have already tested 2 methods of upgrading to the new partition layout with a 6 MiB kernel:
https://forum.openwrt.org/t/adding-openwrt-support-for-xiaomi-redmi-router-ax6s-xiaomi-router-ax3200/111085/1776

@remittor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and we need to figure out if the bootloader relies on a hard-coded size or partition layout or if it reads the uImage headers to know the size.

There are no such restrictions in the stock bootloader. I even checked his code in a disassembler.

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice then, someone with the device at hand please make open a pull request and let's go with 8 MiB instead of 6 MiB so the drama doesn't repeat too soon.

@remittor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's go with 8 MiB instead of 6 MiB so the drama doesn't repeat too soon.

This will be redundant! 6 MiB definitely enough for 10 years. Example: e8646f5

please make open a pull request

I can’t, because I don’t know how to prevent users from upgrading when using the -F flag.

@edrikk
Copy link

@edrikk edrikk commented on dadad6b Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remittor I don't think there is a need to prevent users from upgrading using the -F flag is there?
The default is to stop the upgrade, and there are plenty of warnings that back things will happen if forced.
I believe including that comment in the DEVICE_COMPAT_MESSAGE is good though. i.e. forcing this upgrade WILL result in a brick etc.

@remittor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's go with 8 MiB instead

I noticed that on the ipq807X platform the gziped kernel takes up more than 5 MiB. Therefore, you probably really need to increase the space to 8 MiB...

please make open a pull request
I believe including that comment in the DEVICE_COMPAT_MESSAGE is good though. i.e. forcing this upgrade WILL result in a brick etc.

I have no luck with pull requests and reviewers. It’s better to create a similar pull request yourself.

@danpawlik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remittor hey, would you like to propose your patch into OpenWRT project? It wound be good to move the discussion there instead of continuing here.

@981213
Copy link
Member

@981213 981213 commented on dadad6b Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to chainload a second u-boot. See: https://web.archive.org/web/20230327231316/https://lunarius.fe80.eu/blog/tag/mt7622.html
I think a better option than increasing kernel partition size is to package a mainline u-boot as FIT, place it where the kernel is supposed to be, and put OpenWrt kernel+rootfs into UBI.

@rany2
Copy link
Contributor

@rany2 rany2 commented on dadad6b Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, wouldn't it make sense to reduce the kernel size? I wasn't aware that uboot had UBI support

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware that uboot had UBI support

Even MediaTek's ARM TrustedFirmware-A supports UBI by now, so on MT7622 devices where we anyway replace the bootchain we can have very simple MTD layout:

0x00000 ~ 0x80000 TF-A BL2
0x80000 ~ END     UBI

@danpawlik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done similar change to what @nbd168 (c6319de) has done for AX6S - main...danpawlik:openwrt:resurrect-ax3200 which is working well after using sysupgrade image.
Tomorrow I will do test on fresh setup and check if its fine upgrading from stock to openwrt and between openwrt versions

@981213
Copy link
Member

@981213 981213 commented on dadad6b Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danpawlik I still prefer the 2nd-uboot approach I mentioned above. I could prepare a PR for testing in a few days.

@dangowrt
Copy link
Member Author

@dangowrt dangowrt commented on dadad6b Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which is working well after using sysupgrade image.

Did you create the image with CONFIG_ALL_KMODS=y so you actually end up with a kernel larger than 4 MiB?
(as this is what buildbots are doing)

@danpawlik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dangowrt not yet, currently I just take my config that does not set this. Will try to make it tomorrow.

@dangowrt
Copy link
Member Author

@dangowrt dangowrt commented on dadad6b Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still prefer the 2nd-uboot approach I mentioned above.

As the device apparently has a dual-boot mechanism which is already a bit cumbersome to work-around my preference would be to replace the bootchain with something more flexible. But not a strong preference, having an example for 2nd-stage U-Boot in-tree is certainly also a good thing.

@rany2
Copy link
Contributor

@rany2 rany2 commented on dadad6b Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danpawlik I still prefer the 2nd-uboot approach I mentioned above. I could prepare a PR for testing in a few days.

I do see the appeal to the 2nd-uboot approach, and I think it means the kernel partition could be tiny (as it would only contain 2nd-uboot) and more space could be dedicated to UBI... with the user having more free space depending on the size of their kernel. I like that a lot and if this could be replicated for other devices I think it would be great.

@981213
Copy link
Member

@981213 981213 commented on dadad6b Mar 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the device apparently has a dual-boot mechanism which is already a bit cumbersome to work-around my preference would be to replace the bootchain with something more flexible. But not a strong preference, having an example for 2nd-stage U-Boot in-tree is certainly also a good thing.

A u-boot mod is better indeed. But I don't have an AX6S myself so I can't do that.

@remittor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danpawlik

hey, would you like to propose your patch into OpenWRT project? It wound be good to move the discussion there instead of continuing here.

my patch: #14768

@danpawlik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dangowrt I tested with CONFIG_ALL_KMODS=y - https://github.com/danpawlik/openwrt/releases/tag/resurrect-ax3200 and it works fine \o/ .
I will make one more test, due I check a build where I enable BPF and.... it does not want to start. Don't have serial interface now to debug what's happening.

@xabolcs
Copy link
Contributor

@xabolcs xabolcs commented on dadad6b Mar 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with CONFIG_ALL_KMODS=y - and it works fine \o/ .

Sadly It doesn't prove anything as the kernel is still below 4096K. 😕
Could you try include some more kernel module?

$ tar -tvf openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.bin 
drwxr-xr-x 0/0               0 2024-03-01 16:53 sysupgrade-xiaomi,redmi-router-ax6s/
-rw-r--r-- 0/0              31 2024-03-01 16:53 sysupgrade-xiaomi,redmi-router-ax6s/CONTROL
-rw-r--r-- 0/0         4100096 2024-03-01 16:53 sysupgrade-xiaomi,redmi-router-ax6s/kernel
-rw-r--r-- 0/0         9952256 2024-03-01 16:53 sysupgrade-xiaomi,redmi-router-ax6s/root

@danpawlik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabolcs sure, could you propose me some please?

@xabolcs
Copy link
Contributor

@xabolcs xabolcs commented on dadad6b Mar 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that BPF stuff looks good, but it works for anything that increases the kernel size - check the sysupgrade file after building, as I did above!

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly It doesn't prove anything as the kernel is still below 4096K. 😕

Did you do

scripts/feeds update -a
scripts/feeds install -a

so you also build all modules from feeds (like the buildbot does).

It definitely ends up with more than 4 MiB size on the buildbots which is why I had to disable the board to unbreak the build...

@danpawlik
Copy link

@danpawlik danpawlik commented on dadad6b Mar 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabolcs https://github.com/danpawlik/openwrt/releases/tag/resurrect-ax3200-bpf - enabled bpf, also works well on the device with fresh build

root@AX3200:~# uptime
 15:40:11 up 11 min,  load average: 0.00, 0.00, 0.00
root@AX3200:~# cat /dev/mtd8 | wc -c
6291456
root@AX3200:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00020000 "Preloader"
mtd1: 00040000 00020000 "ATF"
mtd2: 00080000 00020000 "u-boot"
mtd3: 00040000 00020000 "u-boot-env"
mtd4: 00040000 00020000 "bdata"
mtd5: 00080000 00020000 "factory"
mtd6: 00040000 00020000 "crash"
mtd7: 00040000 00020000 "crash_log"
mtd8: 00600000 00020000 "kernel"
mtd9: 06d00000 00020000 "ubi"

@dangowrt And about build:

[user@b23256e80eba mt7622]$ tar -tvf openwrt-mediatek-mt7622-xiaomi_redmi-router-ax6s-squashfs-sysupgrade.bin
drwxr-xr-x 0/0               0 2024-03-01 15:53 sysupgrade-xiaomi,redmi-router-ax6s/
-rw-r--r-- 0/0              31 2024-03-01 15:53 sysupgrade-xiaomi,redmi-router-ax6s/CONTROL
-rw-r--r-- 0/0         4236920 2024-03-01 15:53 sysupgrade-xiaomi,redmi-router-ax6s/kernel
-rw-r--r-- 0/0         9960448 2024-03-01 15:53 sysupgrade-xiaomi,redmi-router-ax6s/root

Please sign in to comment.