ophub / amlogic-s9xxx-armbian

Support for Armbian in Amlogic, Rockchip and Allwinner boxes. Support a311d, s922x, s905x3, s905x2, s912, s905d, s905x, s905w, s905, s905l, rk3588, rk3568, rk3399, rk3328, h6, etc.
GNU General Public License v2.0
5.69k stars 1.82k forks source link

在 s905w 设备上使用其他内核 (Use other kernels on s905w devices) #859

Closed Scirese closed 1 year ago

Scirese commented 1 year ago

WARNING 对于6.x内核, PHYS_OFFSET也被移除了, 所以你需要下面的补丁 https://march7th.tk/offsets.patch

For 6.x kernel, PHYS_OFFSET was removed as well. So you need this following Patch: https://march7th.tk/offsets.patch

当前 s905w 系列的盒子只支持使用 5.4.y/5.15.y 内核,然而现在这两个版本有点尴尬:5.15还有10个月就要EOL, 5.4又太老...... 那我们有没有想过, 为什么 s905w 只支持 5.4.y/5.15.y 内核?

实际上这个问题关系到 ARM Linux 的启动原理. 可以看看这篇文章. 问题出在内核偏移量TEXT_OFFSET上. 在 Linux 5.10, 它被移除了(详见这个commit). 被移除自然有被移除的原因. 现代的 armv8 启动根本用不到它. 对于主线 u-boot 也是, 这个偏移可有可无. 但是 s905w 不一样, 它仍然使用旧的启动协议, 需要这个偏移. 没有它就没法启动.

那既然这个偏移已经在 5.10 被移除了, 为什么 5.15.y 还能用? 这是因为f大在他的内核里打了补丁, 把这个偏移加了回来(详见这里), 如果你不用f大的 5.15.y 而是用主线 5.15, 你会发现一样无法启动. 至于为什么f大只给 5.15 而没给身为 Super LTS 的 5.10 版本打补丁, 那就不知道了.

不过没关系, f大不打我们可以自己打, 只需要编译内核前, 在内核源码根目录执行这个来给内核打补丁:

patch -p1 <(curl -fsSL https://github.com/unifreq/linux-5.15.y/commit/ba506e2d948116d9e4c7ff8c526af6118e9f2ef6.patch)

不出所料应该会有一两个 reject, 自己处理下就行了. 这样编译出来的内核就能在 s905w 平台上正常启动, 哪怕不是 5.4.y/5.15.y .


The current s905w series of boxes only support 5.4.y/5.15.y kernel, but now these two versions are a bit embarrassing: 5.15 is only 10 months away from EOL, 5.4 is too old ...... But have we ever wondered why the s905w only supports the 5.4.y/5.15.y kernel?

Actually this question is related to the ARM Linux boot protocol. Check out this article (Chinese). The problem is with the kernel offset TEXT_OFFSET. In Linux 5.10, it was removed (see this commit for details). It was removed for a good reason. Modern armv8 boot does not use it at all. For mainline u-boot as well, this offset is optional. But s905w is different, it still uses the legacy boot protocol and needs this offset. Without it, it cannot boot.

So if this offset was removed in 5.10, why does 5.15.y still work? This is because flippy patched the kernel to add this offset back (see here), and if you use mainline 5.15 instead of flippy's 5.15.y, you'll find that it won't boot either. As to why flippy only patched 5.15 and not patch 5.10 which is Super LTS, I don't know.

But it doesn't matter, if flippy doesn't patch it, we can patch it ourselves. Just run this in the kernel root before compiling the kernel:

patch -p1 <(curl -fsSL https://github.com/unifreq/linux-5.15.y/commit/ba506e2d948116d9e4c7ff8c526af6118e9f2ef6.patch)

If as expected, there should be one or two rejects. Just deal with them yourself. With this way the compiled kernel will boot properly on the s905w platform, even if it is not 5.4.y/5.15.y .

最后效果 Final result: image 如图, 5.10 内核在 TX3 mini (s905w) 成功启动. As shown in the picture, the 5.10 kernel was successfully booted on the TX3 mini (s905w).

ophub commented 1 year ago

f大之前计划如果6.1是lts,这个也会打TEXT_OFFSET补丁使用(目前6.1.1没打)。

按他的计划,以后可能lts的是+o版,都会打TEXT_OFFSET补丁,可以不用u-boot,其他短周期的过度版本是+版,不打这个补丁,需要u-boot支持。

Scirese commented 1 year ago

f大之前计划如果6.1是lts,这个也会打TEXT_OFFSET补丁使用(目前6.1.1没打)。

按他的计划,以后可能lts的是+o版,都会打TEXT_OFFSET补丁,可以不用u-boot,其他短周期的过度版本是+版,不打这个补丁,需要u-boot支持。

今年还真不一定, 6.1 有 rust ,可能不是 LTS. 反正如果以后有人想要整其他内核的话, 这篇 issue 也能帮上他. 不至于还得自己研究.

livelier commented 1 year ago

感谢分享,春节期间抽空玩玩s905w的u-boot,看能否像ugoos x3 一样玩 #782

谁可以推荐一下,s905w 哪款盒子可玩性高一点。意向BL无锁,线刷包齐全,最好是安卓9,我需要先搞回来一台。

ophub commented 1 year ago

x96 mini, tx3 mini在某宝上都有

livelier commented 1 year ago

我搞了台tx3 mini 2+16 o大,工具链接里哪一文件是这款的安卓固件 https://github.com/ophub/kernel/releases/tag/tools

ophub commented 1 year ago

这里还没tx3-mini的系统,你找店家问问他们有系统没。 这里保存的,是大家在交流区反馈他们在测试时使用的安卓系统,我就转存一份到这里。

livelier commented 1 year ago

我已经在tx3的网页下载了,等盒子回来确认过后,传上来。

ophub commented 1 year ago

https://github.com/ophub/amlogic-s9xxx-armbian/issues/763#issuecomment-1336448913

https://pan.baidu.com/s/1qSmtBgSEbKs6ZFm-yCr-XQ

提取码: nnw3

这个帖子里有个网盘分享了很多安卓TV固件,我刚才浏览了一遍没TX3-mini的。

livelier commented 1 year ago

这个盘,我有看过,基本都是国内iptv盒子的固件,没关系等盒子回来再搞。 另外,o大,我们玩的内核版本 哪一个是f大他们修补最多最久的版本,想用一个最稳定的版本。

Scirese commented 1 year ago

5.10支持到2026年12月, 而且已经发布快3年, 是现在最稳的, 但是不新 5.15明年十月结束支持, 今年的LTS可能是刚发布没多久的6.1, 大概支持到2025年12月, 也可能到2028年12月. 对于ARM盒子我个人推荐使用最新的内核, 因为对这类设备的支持是一直在改进的, 求点稳的话用最新LTS, 但其实除了个别版本有bug都是很稳的 当然你要是求最佳的稳定性的话, 用老内核也行

ophub commented 1 year ago

5.4/5.10/5.15这3个是LTS

livelier commented 1 year ago

@Scirese 感谢 S大 讲解。我也倾向新内核,新内核在驱动方面着实改进非常大,手上的mt7663s在6.1.1中不在是搞负载状态。(5.10.y 负载 40% 左右,6.0.y 负载 22% 左右,6.1.y 3% 左右)

@ophub 感谢 o大 指明 LTS

r0bb10 commented 1 year ago

i can confirm that today's build 6.1.1 (bullseye server) works on s905w perfectly (tanix tx3 mini), also 5.10.161 works fine.

ophub commented 1 year ago

When tx3-mini uses 6.1.1/5.10.161, which u-boot file do you use?

meson-gxl-s905w-tx3-mini.dtb u-boot-s905x-s912.bin

Is this the default combination in the configuration file? Take a screenshot to see your configuration information.

cat /boot/uEnv.txt
ls -l /boot/u-boot*
r0bb10 commented 1 year ago

This is it


r88t@klipper:~$ uname -a
Linux klipper 6.1.1-flippy-80+ #11 SMP Sun Dec 25 22:58:40 CST 2022 aarch64 GNU/Linux
r88t@klipper:~$ cat /boot/uEnv.txt
LINUX=/zImage
INITRD=/uInitrd
FDT=/dtb/amlogic/meson-gxl-s905w-tx3-mini.dtb
APPEND=root=UUID=4dc30495-c7bd-4b3a-ab49-139836815dcb rootflags=compress=zstd:6 rootfstype=btrfs console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1
r88t@klipper:~$ ls -l /boot/u-boot*
-rwxr-xr-x 1 root root 704408 Dec 28 12:33 /boot/u-boot-e900v22c.bin
-rwxr-xr-x 1 root root 650183 Dec 28 12:33 /boot/u-boot.emmc
-rwxr-xr-x 1 root root 650183 Dec 28 12:33 /boot/u-boot.ext
-rwxr-xr-x 1 root root 757153 Dec 28 12:33 /boot/u-boot-gtking.bin
-rwxr-xr-x 1 root root 757080 Dec 28 12:33 /boot/u-boot-gtkingpro.bin
-rwxr-xr-x 1 root root 735459 Dec 28 12:33 /boot/u-boot-gtkingpro-rev-a.bin
-rwxr-xr-x 1 root root 702771 Dec 28 12:33 /boot/u-boot-n1.bin
-rwxr-xr-x 1 root root 761012 Dec 28 12:33 /boot/u-boot-odroid-n2.bin
-rwxr-xr-x 1 root root 553489 Dec 28 12:33 /boot/u-boot-p201.bin
-rwxr-xr-x 1 root root 606670 Dec 28 12:33 /boot/u-boot-p212.bin
-rwxr-xr-x 1 root root 609247 Dec 28 12:33 /boot/u-boot-s905.bin
-rwxr-xr-x 1 root root 740080 Dec 28 12:33 /boot/u-boot-s905x2-s922.bin
-rwxr-xr-x 1 root root 650183 Dec 28 12:33 /boot/u-boot-s905x-s912.bin
-rwxr-xr-x 1 root root 709768 Dec 28 12:33 /boot/u-boot.sd
-rwxr-xr-x 1 root root 754378 Dec 28 12:33 /boot/u-boot-sei510.bin
-rwxr-xr-x 1 root root 754384 Dec 28 12:33 /boot/u-boot-sei610.bin
-rwxr-xr-x 1 root root 880672 Dec 28 12:33 /boot/u-boot-skyworth-lb2004.bin
-rwxr-xr-x 1 root root 758664 Dec 28 12:33 /boot/u-boot-tx3-bz.bin
-rwxr-xr-x 1 root root 759112 Dec 28 12:33 /boot/u-boot-tx3-qz.bin
-rwxr-xr-x 1 root root 694755 Dec 28 12:33 /boot/u-boot-u200.bin
-rwxr-xr-x 1 root root 877080 Dec 28 12:33 /boot/u-boot-ugoos-x3.bin
-rwxr-xr-x 1 root root 709768 Dec 28 12:33 /boot/u-boot.usb
-rwxr-xr-x 1 root root 748175 Dec 28 12:33 /boot/u-boot-x96max.bin
-rwxr-xr-x 1 root root 746678 Dec 28 12:33 /boot/u-boot-x96maxplus.bin
-rwxr-xr-x 1 root root 703444 Dec 28 12:33 /boot/u-boot-zyxq.bin
Scirese commented 1 year ago

对于6.x内核, PHYS_OFFSET也被移除了, 所以你需要下面的补丁

https://march7th.tk/offsets.patch

ophub commented 1 year ago

多谢分享