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.45k stars 1.74k forks source link

Support for g12a_u212_v1 #720

Closed redfast00 closed 1 year ago

redfast00 commented 1 year ago

(I unfortunately don't understand Chinese, so I would be very happy for any replies to be in English. If not, I'll use an autotranslate application, but might not understand replies then)

Device Information

Armbian Version

Describe the bug

I'm trying to run Armbian on a board that's not mentioned yet in the README. This set-top-box cannot be bought: an ISP gives this as part of a subscription to watch their TV channels with. I'm trying to repurpose this e-waste.

I was able to get a uBoot shell using the serial console on the device. Using that, I dumped the EMMC memory to a USB stick, from which I then copied it to my computer. Using ./split_bootimg.pl and aml-dtbtools on the boot partition, I was able to extract 2 dtbs: g12a-u212-2g.dtb and sm1-ac213-2g.dtb. I put these dtbs in the dtbs/amlogic folder on the Armbian USB stick and modified uEnv.txt to use the g12a-u212-2g.dtb device blob (since that matches the uBoot prompt).

I then read https://7ji.github.io/embedded/2022/11/11/amlogic-booting.html this blogpost on how to boot from a USB stick and executed the following commands in uBoot:

g12a_u212_v1#usb start
Host not halted after 16000 microseconds.
(Re)start USB...
USB0:   USB3.0 XHCI init start
Register 3000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus 0 for devices... 2 USB Device(s) found
       scanning usb for storage devices... init_part() 282: PART_TYPE_DOS
1 Storage Device(s) found
g12a_u212_v1#fatload usb 0:1 0x1000000 uEnv.txt
349 bytes read in 31 ms (10.7 KiB/s)
g12a_u212_v1#env import -t 0x1000000
## Info: input data size = 350 = 0x15E
g12a_u212_v1#fatload usb 0:1 0x1000000 ${FDT}
80173 bytes read in 267 ms (293 KiB/s)
g12a_u212_v1#fatload usb 0:1 0x11000000 ${LINUX}
24734208 bytes read in 1622 ms (14.5 MiB/s)
g12a_u212_v1#fatload usb 0:1 0x13000000 ${INITRD}
17285150 bytes read in 1165 ms (14.1 MiB/s)
g12a_u212_v1#setenv bootargs ${APPEND}
g12a_u212_v1#booti 0x11000000 0x13000000 0x1000000
libfdt fdt_getprop(): FDT_ERR_NOTFOUND
## Loading init Ramdisk from Legacy Image at 13000000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
   Data Size:    17285086 Bytes = 16.5 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
      Amlogic multi-dtb tool
      Cannot find legal dtb!
[store]Err:do_decrypt_dtb,L319:Fail in fdt check header
active_slot is normal
load dtb from 0x1000000 ......
      Amlogic multi-dtb tool
      Cannot find legal dtb!
ERROR: Did not find a cmdline Flattened Device Tree
load dtb from 0x0 ......
      Amlogic multi-dtb tool
      Cannot find legal dtb!
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree

What are the steps to get this working? I feel like I'm pretty close, but missing a crucial step. I've attached the DTBs.

dtbs.zip

ophub commented 1 year ago

Android dtb files cannot be used in armbian.

redfast00 commented 1 year ago

Thank you for the fast answer! Could you please give some pointers on how to convert an Android dtb file to a dtb file that can be used for armbian?

ophub commented 1 year ago

https://github.com/unifreq/linux-5.15.y/tree/main/arch/arm64/boot/dts/amlogic

I don't know of a tool to do the conversion. I refer to similar boxes, combined with Android nodes, and manually debug.

redfast00 commented 1 year ago

I managed to get it booting, I first chainbooted u-boot-s905x2-s922.bin, then used meson-g12a-radxa-zero.dtb as dtb. This mostly works, only Ethernet doesn't work yet. In the Android DTB, I read:

ethernet@ff3f0000 {
        compatible = "amlogic, g12a-eth-dwmac\0snps,dwmac";
        reg = <0x00 0xff3f0000 0x00 0x10000 0x00 0xff634540 0x00 0x08 0x00 0xff64c000 0x00 0xa0 0x00 0xffd01008 0x00 0x04>;
        reg-names = "eth_base\0eth_cfg\0eth_pll\0eth_reset";
        interrupts = <0x00 0x08 0x01>;
        interrupt-names = "macirq";
        status = "okay";
        clocks = <0x02 0x38>;
        clock-names = "ethclk81";
        pll_val = <0x9c0040a 0x927e0000 0xac5f49e5>;
        analog_val = <0x20200000 0xc000 0x23>;
        pinctrl-names = "internal_eth_pins\0internal_gpio_pins";
        pinctrl-0 = <0x0f>;
        pinctrl-1 = <0x10>;
        mc_val = <0x4be04>;
        internal_phy = <0x01>;
        phandle = <0x9c>;
    };

but in the meson-g12a-radxa-zero blob, I read

ethernet@ff3f0000 {
            compatible = "amlogic,meson-g12a-dwmac\0snps,dwmac-3.70a\0snps,dwmac";
            reg = <0x00 0xff3f0000 0x00 0x10000 0x00 0xff634540 0x00 0x08>;
            interrupts = <0x00 0x08 0x04>;
            interrupt-names = "macirq";
            clocks = <0x02 0x26 0x02 0x02 0x02 0x0d 0x02 0x02>;
            clock-names = "stmmaceth\0clkin0\0clkin1\0timing-adjustment";
            rx-fifo-depth = <0x1000>;
            tx-fifo-depth = <0x800>;
            status = "okay";
            power-domains = <0x03 0x01>;
            pinctrl-0 = <0x11 0x12>;
            pinctrl-names = "default";
            phy-mode = "rgmii";
            phy-handle = <0x13>;
            amlogic,tx-delay-ns = <0x02>;

            mdio {
                #address-cells = <0x01>;
                #size-cells = <0x00>;
                compatible = "snps,dwmac-mdio";
                phandle = <0x1d>;
            };
        };

I haven't found a driver that has g12a-eth-dwmac, is it an Android-kernel-only thing?

ophub commented 1 year ago

What is your equipment, find a product link on the Internet and send it, what soc, what type of wired network card.

redfast00 commented 1 year ago

I'm unable to send a product link, this set-top box is not sold individually and I haven't been able to find a similar product. The only page I found is https://www.askey.com.tw/products-detail/sti6030/. However, I've gotten it to work with meson-g12a-sei510.dtb blob: network and video works.