openwrt icon indicating copy to clipboard operation
openwrt copied to clipboard

meson: new target for amlogic S805 and S9 SoCs

Open ChalesYu opened this issue 3 years ago • 8 comments

Hi , This may be looks like an RFC . These amlogic SoCs released at 2017 and have more than 5 years old. For now , these board has been supported by some repo: https://github.com/ophub/amlogic-s9xxx-openwrt https://github.com/hyphop/khadas-openwrt But master branch still didn't support that, so want to add it.

These is based on Stijn Tintel tree on: https://git.openwrt.org/?p=openwrt/staging/stintel.git;a=shortlog;h=refs/heads/meson https://patchwork.ozlabs.org/project/openwrt/cover/[email protected]/

Boot progress: For S805 , Armbian is used to support that board. mainline uboot didn't support yet. Can only use vendor uboot shell to load mainline uboot and dtb from SD/USB to boot. For S905 , mainline uboot is supported and can use go command to load from vendor uboot , then do boot progress.

For more information , see https://linux-meson.com/howto.html

Tested on : meson8b S805 Odroid C1 variant board mesongx GXBB S905(M) Odroid C1 variant board mesongx GXL S905X/L Khadas VIM 1

But I guess this code style also need some change, need peoples suggestion. And , Of course , these commits looks not ready , will fix it by git force-push .

ChalesYu avatar Jul 24 '22 14:07 ChalesYu

There is a reason there are multiple commits in my tree. Please follow https://openwrt.org/submitting-patches#creating_and_sending_your_change. Pay special attention to point 3 in the above link. This PR right now is unreviewable in its current form. I would suggest you start from my tree and make your changes on top, do not squash any of my or your commits (yet).

stintel avatar Aug 03 '22 09:08 stintel

Yes, That is why I still mark this PR as draft status. Now , mark it as ready for review . But , There are still something to do :

  • forget mainline uboot an give each board a s905(s805)_autoscript use BSP uboot to boot kernel (as I didn't know how to add u-boot package to build and now meson8b doesn't have mainline uboot).
  • make code structure more like other target (sunxi , rockchip , rpi etc). (In fact , just replace kernel config in sunxi target is more easy, but it seems really dirty way.)
  • add more newer(variant) board (I can only test mesongx and meson8b board, didn't have g12a and more newer board to test).

The last thing is (re)format this commits and let it reviewable.

ChalesYu avatar Aug 04 '22 01:08 ChalesYu

Thanks. I'm currently travelling, will try to review this when I'm back home next week. Did you not have trouble booting 5.10? I have the 5.10 bump in a local branch, with a remark that it doesn't boot. Tested on Odroid C2. I also have a VIM3 and a VIM3L, so we can have a nice set of supported boards once this is ready to go in master.

stintel avatar Aug 05 '22 10:08 stintel

  • forget mainline uboot ...

For Odroid N2 the mainline U-Boot is far better than the BSP version, and it's more conpatible with the mainline kernel. (See the few comments on odroid's forum!)

If there is support for any of these board in mainline U-Boot, then it should be used for that board, IMHO.

xabolcs avatar Aug 06 '22 09:08 xabolcs

This PR is only talk about mesongx and meson8b , Odroid N2 and VIM3 is mesong12a/b mesonsm , so seems a little off-topic. These new board have enough performance so using armbian kernel looks like a better choice.

Did you not have trouble booting 5.10? I have the 5.10 bump in a local branch, with a remark that it doesn't boot. Tested on Odroid C2.

Odroid C2 is a GXBB board, I remember it need to update latest mainline u-boot to boot kernel 5.10. But using BSP uboot didn't have that issue , tested on a S905X(GXL) board.

make[6]: *** [scripts/Makefile.host:95: scripts/extract-cert] Error 1

looks like your build host environment have some issue, This PR may meed to fix(add) something to kernel config , but won't have this kind of error.

For S805 , Armbian is used to support that board. mainline uboot didn't support yet. Can only use vendor uboot shell to load mainline uboot kernel and dtb from SD/USB to boot.

I have write something wrong , meson8b didn't support mainline u-boot (yet), but it can boot kernel 5.10/5.15 using vendor BSP u-boot. And this is why I keep these target didn't using mainline u-boot.

Maybe some day mainline u-boot works good, other people can add some code to build and switch to that. But I won't write that code.

ChalesYu avatar Aug 10 '22 13:08 ChalesYu

If there is support for any of these board in mainline U-Boot, then it should be used for that board, IMHO.

If user really want use mainline u-boot , they can do this manually by themselves.

The boot progress may finally like @LibreELEC did , If someone want to write compile step code ,can ask suggestion from @chewitt. And, looks like GXBB board still have some issue https://github.com/LibreELEC/amlogic-boot-fip/pull/8 some prebuilt u-boot blob: https://chewitt.libreelec.tv/testing/

ChalesYu avatar Aug 16 '22 10:08 ChalesYu

I wouldn't personally seek to support Meson8 hardware. Upstream kernel support is incomplete and while MartinB's linux branches are better (due to lots of not-yet-upstream patches) there is no upstream u-boot support (not likely to change anytime soon or ever) and the boards are old and few people have them.

GXBB/GXL/GXM and newer G12A/G12B/SM1 devices have good core OS support except for media codec things (not sure if that's important to OpenWRT). Upstream u-boot works well on boards/devices that have support and https://github.com/LibreELEC/amlogic-boot-fip has all the FIP sources you'd need to create single .img files that can SD/eMMC boot the boards. The repo is deliberately structured to suit distro build-systems and .img packaging; LE/Armbian both use it.

I would advocate using recent kernels not ancient LTS releases because fewer people are testing the backports that drip-feed into them and recent kernels generally have more things fixed/added. Amlogic doesn't have much community support in the form of board/driver development, but there is slow feed of improvements.

I would avoid supporting TV boxes except for the few that have FIPs and upstream u-boot support, because everything else uses cheap parts and low-bin RAM and you're dependent on vendor u-boot, which works but complicates distro packaging with the bootscript garbage needed for hooking vendor u-boot. I would also avoid the generic reference design boards, as while they often work it mostly attracts people with TV boxes that can't tell their arse from elbow who don't figure out boot requirements and are a drain on support efforts. Focus on the SBC devices.

chewitt avatar Aug 16 '22 14:08 chewitt

I have M401A with s905l3a running armbian, if there's anything I can help, please contact me :)

0x5e avatar Aug 17 '22 17:08 0x5e

The last thing is (re)format this commits and let it reviewable.

IMO it's easier to follow best practices from the start. For everyone involved.

This PR is only talk about mesongx and meson8b , Odroid N2 and VIM3 is mesong12a/b mesonsm , so seems a little off-topic.

If the target is going to be called meson, meson* is on topic.

If user really want use mainline u-boot , they can do this manually by themselves.

To be frank, I think you got it backwards. We shall use mainline u-boot and if the user really wants to use some broken vendor fork they can do it themselves.

stintel avatar Aug 20 '22 00:08 stintel

GXBB/GXL/GXM and newer G12A/G12B/SM1 devices have good core OS support except for media codec things (not sure if that's important to OpenWRT).

I'd say no. As much as I'd like to run Kodi (or Jellyfin maybe) on OpenWrt, for those purposes people can use *ELEC.

I would advocate using recent kernels not ancient LTS releases

OpenWrt is based on LTS releases, 22.03 uses 5.10, master is evolving to 5.15 so I suggest we focus on 5.15. Should be recent enough to support many boards.

@chewitt thank you for your insights.

stintel avatar Aug 20 '22 08:08 stintel

To be frank, I think you got it backwards. We shall use mainline u-boot and if the user really wants to use some broken vendor fork they can do it themselves.

No, not backwards. I still suggest focus on compatibility , both vendor and mainline u-boot should able to boot (If vendor don't want support this ,they have burned eFUSE ,some GXM board did that already) . For mainline u-boot, add a simpile boot.scr is enough.

And yes, the next step may fix configs for kernel 5.15 (or more newer).

ChalesYu avatar Aug 31 '22 12:08 ChalesYu

I have a TBee-Box device this is amlogic s905x can this be added? I see it can run openwrt using armbian kernel amlogic/meson-gxl-s905x-p212.dtb https://github.com/ophub/amlogic-s9xxx-openwrt/releases/download/OpenWrt_Aml_official_09.06.0730/openwrt_s905x_k5.10.141_2022.09.06.img.gz

predators46 avatar Sep 08 '22 12:09 predators46

i am trying to build on openwrt 22.03.0

i added meson patch

I'm using ubuntu 20.04 LTS

when i build meson on openwrt 22.03.0 i get warning and error while building it here I will attach those warnings and errors here.

although i know this is for openwrt master branch

  1. Error

i saw this on the openwrt forum and solved this error. I don't know what's wrong

https://forum.openwrt.org/t/undefined-reference-to-pthread-once/65789/3

gcc -Wp,-MD,scripts/.extract-cert.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -O2 -I/usr/src/openwrt/staging_dir/host/include -Wall -Wmissing-prototypes -Wstrict-prototypes -I/usr/src/openwrt/staging_dir/host/include -I./tools/include -o scripts/extract-cert scripts/extract-cert.c -L/usr/src/openwrt/staging_dir/host/lib -lcrypto /usr/bin/ld: /usr/src/openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-eng_all.o): in function ENGINE_load_builtin_engines': eng_all.c:(.text+0x30): undefined reference to pthread_once' /usr/bin/ld: /usr/src/openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-err.o): in function ERR_load_ERR_strings': err.c:(.text+0xd2e): undefined reference to pthread_once' /usr/bin/ld: /usr/src/openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-err_all.o): in function ERR_load_crypto_strings': err_all.c:(.text+0x9f): undefined reference to pthread_once' /usr/bin/ld: /usr/src/openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-c_all.o): in function OpenSSL_add_all_ciphers': c_all.c:(.text+0x9df): undefined reference to pthread_once' /usr/bin/ld: /usr/src/openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-c_all.o): in function OpenSSL_add_all_digests': c_all.c:(.text+0x9ff): undefined reference to pthread_once' /usr/bin/ld: /usr/src/openwrt/staging_dir/host/lib/libcrypto.a(libcrypto_la-crypto_init.o):crypto_init.c:(.text+0x51): more undefined references to `pthread_once' follow collect2: error: ld returned 1 exit status

2.Error /warning

it seems that in config-5.10 something is missing, I set it like below. whether it's right or wrong

Amlogic AIU (SND_MESON_AIU) [N/m/?] (NEW) n
Amlogic AXG Playback FIFO support (SND_MESON_AXG_FRDDR) [N/m/?] (NEW) n
Amlogic AXG Capture FIFO support (SND_MESON_AXG_TODDR) [N/m/?] (NEW) n
Amlogic AXG TDM Input Support (SND_MESON_AXG_TDMIN) [N/m/?] (NEW) n
Amlogic AXG TDM Output Support (SND_MESON_AXG_TDMOUT) [N/m/?] (NEW) n
Amlogic AXG Sound Card Support (SND_MESON_AXG_SOUND_CARD) [N/m/?] (NEW) n
Amlogic AXG SPDIF Output Support (SND_MESON_AXG_SPDIFOUT) [N/m/?] (NEW) n
Amlogic AXG SPDIF Input Support (SND_MESON_AXG_SPDIFIN) [N/m/?] (NEW) n
Amlogic AXG PDM Input Support (SND_MESON_AXG_PDM) [N/m/?] (NEW) n
Amlogic GX Sound Card Support (SND_MESON_GX_SOUND_CARD) [N/m/?] (NEW) n
Amlogic G12A To Internal DAC Control Support (SND_MESON_G12A_TOACODEC) [N/m/?] (NEW) n Amlogic G12A To HDMI TX Control Support (SND_MESON_G12A_TOHDMITX) [N/m/?] (NEW) n
Amlogic T9015 DAC (SND_SOC_MESON_T9015) [N/m/?] (NEW) n

  1. warning

and lastly i got a warning error and it didn't stop the build

https://forum.openwrt.org/t/adding-openwrt-support-for-xiaomi-ax3600/55049/1587?u=

musl-ld: warning: orphan section __ksymtab_strings' from arch/arm64/lib/memcmp.o' being placed in section __ksymtab_strings' aarch64-openwrt-linux-musl-ld: warning: orphan section __ksymtab_strings' from arch/arm64/lib/memcpy.o' being placed in section __ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section __ksymtab_strings' from arch/arm64/lib/memmove.o' being placed in section __ksymtab_strings' aarch64-openwrt-linux-musl-ld: warning: orphan section __ksymtab_strings' from arch/arm64/lib/memset.o' being placed in section __ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section __ksymtab_strings' from arch/arm64/lib/strchr.o' being placed in section __ksymtab_strings' aarch64-openwrt-linux-musl-ld: warning: orphan section __ksymtab_strings' from arch/arm64/lib/strcmp.o' being placed in section __ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section __ksymtab_strings' from arch/arm64/lib/strlen.o' being placed in section __ksymtab_strings' aarch64-openwrt-linux-musl-ld: warning: orphan section __ksymtab_strings' from `arch/arm64/lib/strncmp.o' being placed in sectio

and finally i finished it. I haven't tried burning on the sd card, I don't have an odroid and khadas vim1 device for me to test. if anyone wants to try please download here

https://github.com/openwrtfirmwarecostum/amlogic/tree/main/targets/meson/cortexa53

openwrtfirmwarecostum avatar Sep 09 '22 07:09 openwrtfirmwarecostum