ning Posted July 7, 2022 Posted July 7, 2022 Hw Spec Soc: Amlogic S912-H, (S192 with dolby, DTS) Mem: 2G Ddr3 Emmc: 16G 4K HDMi AV out ethernet ?? Wifi/Bt ?? USB port *1 5V DC-IN IR receiver Reset hole OS: Ali YunOS Steps 1, connect UART from mainboard test points, (I can only find M17's UART port) 2, build u-boot follow q200.rst in u-boot doc, use VIM2 config and use VIM2 fip blobs (hope that works) 3, build Arm64 debian bookworm with default debian kernel to USB driver, and config system. 4, falsh u-boot to USB driver 5, connect to device with UART, hope to stop at u-boot cmdline, and erase emmc. if failed, find other way to erase, maybe Amlogic flash tool. 6, instert USB driver, and reboot device potaintial issues: can't find UART port on mainboard VIM2 mainline Uboot can't boot M16S device does not support boot from USB. No schematics for next step dev. 0 Quote
s-petersen Posted July 7, 2022 Posted July 7, 2022 (edited) I wouldn't erase the Emmc until you have a good working image on USB . It may be easier to build an image, and load it with a DFU or boot from USB Edited July 7, 2022 by s-petersen 0 Quote
ning Posted July 7, 2022 Author Posted July 7, 2022 yes, the main problem is whether we can make a bootable u-boot for this device. I remember someone told me, amlogic fip can be shared with same generation. it's too old memory, I don't know it's true or not. if this is true, the rests are open source. 0 Quote
SteeMan Posted July 7, 2022 Posted July 7, 2022 I guess I would start by asking what is your goal with this TV Box? Are you looking to be able to build a full firmware (potentially using armbian build framework) for the box to install on multiple boxes of this type? or is this just a one-off box to experiment with and you want to get a modern kernel running on it? If the latter, I would recommend going down the multiboot path that balbes150 created for these amlogic boxes (see this thread for some discussion on that: https://forum.armbian.com/topic/19004-trying-to-learn-more-about-u-boot-for-amlogic-devices) This path leaves the vendor u-boot in place and chainloads a modern u-boot bypassing the risk of bricking the box by installing a non-working u-boot on emmc. In general this path also has you working from sdcard storage (although balbes150 had scripts to copy a working sdcard environment to emmc if you wanted to run from emmc). The challenge as I understand it with amlogic tv boxes is that amlogic always boots from emmc if present which presents a risk of bricking when testing different u-boots. 0 Quote
ning Posted July 7, 2022 Author Posted July 7, 2022 No, I don't want to use multiboot to run mainline kernel on legacy u-boot. in this case I have to build kernel myself. mainline kernel need extra patch to boot on legacy u-boot, I think it's not acceptable by Debian. and current debian bookworm, runs very well on Amlogic Soc, I only need to take care dtb, no need to rebuild kernel. thus, I need mainline uboot, and mainline kernel. and I full understand the rise, brick the device. Tmall MagicBox M16S in my hand is not used for long time. thus it's acceptable. I have reviewed device HW: M16S, VIM2, Wetek Core2, and Libretech-cc. VIM2 and Wetek Core2 are Ddr4, and M16S and Libretech-cc are Ddr3. One job need done by fips are memory initial, thus it's better to use Libretech-cc's fip, which are release by Baylibre. but at first, I need to know whether they can share fips, the first experment I will do is use Wetek Core2's fip to generate VIM2‘s mainline uboot. and try it on VIM2. why that, I have VIM2. 0 Quote
SteeMan Posted July 7, 2022 Posted July 7, 2022 But with the multiboot strategy you are running a mainline uboot (chainloaded). I run mainline kernels on my amlogic based boxes (including upto the latest rc - I'm running right now 5.19.0-rc5 on one box). 0 Quote
ning Posted July 7, 2022 Author Posted July 7, 2022 chainloaded to mainline uboot looks good, Ali YunOS is different to Android Tv, it has adb. I don't know whether it can apply multiboot update.zip. 0 Quote
ning Posted July 7, 2022 Author Posted July 7, 2022 fatload mmc 0 0x01000000 u-boot.bin go 0x01000000 # use: mkimage -A arm64 -T script -O linux -d s905_autoscript.txt s905_autoscript.scr this is chainload? and before that, need store bootcmd to env setenv bootfromnand 0 setenv bootcmd "run start_autoscript; run storeboot;" setenv start_autoscript "if mmcinfo; then run start_mmc_autoscript; fi; if usb start ; then run start_usb_autoscript; fi;" setenv start_mmc_autoscript "if fatload mmc 0 1020000 s905_autoscript; then setenv autoscript_source mmc; autoscr 1020000; fi;" setenv start_usb_autoscript "if fatload usb 0 1020000 s905_autoscript; then setenv autoscript_source usb; autoscr 1020000; fi; if fatload usb 1 1020000 s905_autoscript; then setenv autoscript_source usb; autoscr 1020000; fi; if fatload usb 2 1020000 s905_autoscript; then setenv autoscript_source usb; autoscr 1020000; fi; if fatload usb 3 1020000 s905_autoscript; then setenv autoscript_source usb; autoscr 1020000; fi;" setenv upgrade_step "0" saveenv sleep 1 reboot 0 Quote
ning Posted July 8, 2022 Author Posted July 8, 2022 thank you. @SteeMan. I dig more in Khadas' U-boot tree, and ask develop about fips. ddr timings and power seq can't shared between devices. 0 Quote
ning Posted July 8, 2022 Author Posted July 8, 2022 so the only solution is multiboot. and I will keep vendor OS in emmc, thus I can develop mainline components reference to it. 0 Quote
SteeMan Posted July 8, 2022 Posted July 8, 2022 22 hours ago, ning said: fatload mmc 0 0x01000000 u-boot.bin go 0x01000000 # use: mkimage -A arm64 -T script -O linux -d s905_autoscript.txt s905_autoscript.scr this is chainload? and before that, need store bootcmd to env setenv bootfromnand 0 setenv bootcmd "run start_autoscript; run storeboot;" setenv start_autoscript "if mmcinfo; then run start_mmc_autoscript; fi; if usb start ; then run start_usb_autoscript; fi;" setenv start_mmc_autoscript "if fatload mmc 0 1020000 s905_autoscript; then setenv autoscript_source mmc; autoscr 1020000; fi;" setenv start_usb_autoscript "if fatload usb 0 1020000 s905_autoscript; then setenv autoscript_source usb; autoscr 1020000; fi; if fatload usb 1 1020000 s905_autoscript; then setenv autoscript_source usb; autoscr 1020000; fi; if fatload usb 2 1020000 s905_autoscript; then setenv autoscript_source usb; autoscr 1020000; fi; if fatload usb 3 1020000 s905_autoscript; then setenv autoscript_source usb; autoscr 1020000; fi;" setenv upgrade_step "0" saveenv sleep 1 reboot I don't know what code you are referencing here. This is not the code that is part of the armbian TV box images that balbes150 produced and I try to support through these forums. If you are looking for input from an armbian forum, please be using armbian code. You can find the download links for the code that in the TV Box FAQ post: https://forum.armbian.com/topic/17106-installation-instructions-for-tv-boxes-with-amlogic-cpus 0 Quote
SteeMan Posted July 8, 2022 Posted July 8, 2022 14 minutes ago, ning said: so the only solution is multiboot. and I will keep vendor OS in emmc, thus I can develop mainline components reference to it. multiboot doesn't mean you can't still have your os in emmc. That is what the /root/install-aml.sh script does in the tv box builds from balbes150 (copies the install from sd to emmc while preserving the native vendor u-boot on emmc). The concept is to reuse the vendor u-boots which are device specific (dealing with memory, storage, etc) (since there are tens if not hundreds of different amlogic tv boxes creating uboots for each is impossible) while having only a few generic chainloaded u-boots that are cpu specific bridge to loading the kernel. It is a bit tricky to preserve the vendor u-boot while overlaying the rest of the os into emmc, but generally balbes150's scripts work on most environments. 0 Quote
ning Posted July 10, 2022 Author Posted July 10, 2022 I have connect TTL cable to device, and store these command to emmc. 0 Quote
ning Posted July 10, 2022 Author Posted July 10, 2022 insert a usb driver with msdos partition, and first partition is fat32, and put VIM2 u-boot.bin ``` ## Starting application at 0x01000000 ... <debug_uart> U-Boot 2022.07-rc6-00007-gc519b82e7c (Jul 10 2022 - 16:21:18 +0800) khadas-vim2 Model: Khadas VIM2 SoC: Amlogic Meson GXM (S912) Revision 22:a (82:2) DRAM: 2 GiB Core: 176 devices, 27 uclasses, devicetree: separate MMC: mmc@70000: 0, mmc@72000: 1, mmc@74000: 2 Loading Environment from nowhere... OK In: serial Out: serial Err: serial Net: eth0: ethernet@c9410000 Hit any key to stop autoboot: 2 1 0 Card did not respond to voltage select! : -110 Card did not respond to voltage select! : -110 ** fs_devread read error - block Failed to mount ext2 filesystem... switch to partitions #0, OK mmc2 is current device ** No partition table - mmc 2 ** Couldn't find partition mmc 2:1 starting USB... Bus usb@c9000000: dwc3_meson_gxl_get_phys: usb2 ports: 3 Register 3000140 NbrPorts 3 Starting the controller USB XHCI 1.00 scanning bus usb@c9000000 for devices... XHCI timeout on event type 33... cannot recover. BUG at drivers/usb/host/xhci-ring.c:481/xhci_wait_for_event()! BUG! ``` stop at this setp 0 Quote
ning Posted July 10, 2022 Author Posted July 10, 2022 and I have changed autoboot script to Quote setenv OLDBOOTCMD "set_usb_boot 4;run storeboot" setenv USBBOOTCMD "usb start;if fatload usb 0 0x1000000 u-boot.bin; then go 0x1000000; fi;" setenv bootcmd "run USBBOOTCMD; run OLDBOOTCMD; run storeboot" 0 Quote
ning Posted July 11, 2022 Author Posted July 11, 2022 U-Boot 2022.07-rc6-00007-gc519b82e7c (Jul 11 2022 - 10:15:22 +0800) wetek-core2 Model: WeTek Core 2 SoC: Amlogic Meson GXM (S912) Revision 22:a (82:2) DRAM: 2 GiB Core: 172 devices, 25 uclasses, devicetree: separate MMC: mmc@70000: 0, mmc@72000: 1, mmc@74000: 2 Loading Environment from nowhere... OK In: serial Out: serial Err: serial Net: No ethernet found. Hit any key to stop autoboot: 2 1 0 Card did not respond to voltage select! : -110 Card did not respond to voltage select! : -110 ** fs_devread read error - block Failed to mount ext2 filesystem... switch to partitions #0, OK mmc2 is current device ** No partition table - mmc 2 ** Couldn't find partition mmc 2:1 starting USB... Bus usb@c9000000: dwc3_meson_gxl_get_phys: usb2 ports: 3 Register 3000140 NbrPorts 3 Starting the controller USB XHCI 1.00 scanning bus usb@c9000000 for devices... 2 USB Device(s) found scanning usb for storage devices... 1 Storage Device(s) found Device 0: Vendor: SanDisk Rev: 1.26 Prod: Cruzer Glide Type: Removable Hard Disk Capacity: 15267.0 MB = 14.9 GB (31266816 x 512) ... is now current device Scanning usb 0:1... => usb info 1: Hub, USB Revision 3.0 - U-Boot XHCI Host Controller - Class: Hub - PacketSize: 512 Configurations: 1 - Vendor: 0x0000 Product 0x0000 Version 1.0 Configuration: 1 - Interfaces: 1 Self Powered 0mA Interface: 0 - Alternate Setting 0, Endpoints: 1 - Class Hub - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms 2: Mass Storage, USB Revision 2.0 - SanDisk Cruzer Glide 2005425601028AD2549E - Class: (from Interface) Mass Storage - PacketSize: 64 Configurations: 1 - Vendor: 0x0781 Product 0x5575 Version 1.38 Configuration: 1 - Interfaces: 1 Bus Powered 200mA Interface: 0 - Alternate Setting 0, Endpoints: 2 - Class Mass Storage, Transp. SCSI, Bulk only - Endpoint 1 In Bulk MaxPacket 512 - Endpoint 2 Out Bulk MaxPacket 512 => e mmcinfo Device: mmc@74000 Manufacturer ID: 15 OEM: 0 Name: AWPD3R Bus Speed: 25000000 Mode: MMC legacy Rd Block Len: 512 MMC version 4.0 High Capacity: Yes Capacity: 2 TiB Bus Width: 1-bit Erase Group Size: 512 KiB => mmc list mmc@70000: 0 mmc@72000: 1 mmc@74000: 2 (eMMC) => everything looks good, after use wetek core2 dts. next step prepare OS. 0 Quote
ning Posted July 11, 2022 Author Posted July 11, 2022 after prepare OS: boot with cmd sysboot usb 0:2 any 0x1080000 /boot/extlinux/extlinux.conf """ 1:Debian GNU/Linux bookworm/sid 5.18.0-2-arm64 Retrieving file: /boot/initrd.img-5.18.0-2-arm64 Retrieving file: /boot/vmlinuz-5.18.0-2-arm64 append: root=UUID=567c947a-5776-4b05-9795-bd9b31af7f61 ro quiet Retrieving file: /usr/lib/linux-image-5.18.0-2-arm64/amlogic/meson-gxm-magicbox-m16s.dtb Moving Image from 0x8080000 to 0x8200000, end=9f30000 ## Flattened Device Tree blob at 08008000 Booting using the fdt blob at 0x8008000 Loading Ramdisk to 7a150000, end 7bf3c94a ... OK Loading Device Tree to 000000007a145000, end 000000007a14f751 ... OK "Synchronous Abort" handler, esr 0x96000004 elr: 0000000001065600 lr : 0000000001054ff4 (reloc) elr: 000000007dfb3600 lr : 000000007dfa2ff4 x0 : 9ecff6f44d0e10b2 x1 : 000000007dfbccc8 x2 : 0000000000000010 x3 : 000000007bf54340 x4 : 0000000000000000 x5 : 9ecff6f44d0e10b2 x6 : 0000000001000000 x7 : 0000000000000000 x8 : 0000000000000007 x9 : 0000000000000000 x10: 0000000000000180 x11: 000000007bf4100c x12: 00000000000000ac x13: 000000007bf40fc8 x14: 000000007a145000 x15: 0000000000000020 x16: 000000007df5533c x17: 0000000000000000 x18: 000000007bf4bdb0 x19: 000000007af3f040 x20: 000000007df4eb18 x21: 000000007dfbccc8 x22: 0000000000001000 x23: 000000007bf54290 x24: 000000007dfdb090 x25: 0000000001000000 x26: 0000000000000000 x27: 0000000001000000 x28: 0000000000001000 x29: 000000007bf40fc0 Code: eb04005f 54000061 52800000 14000006 (386468a3) Resetting CPU ... """ 0 Quote
ning Posted July 11, 2022 Author Posted July 11, 2022 if this crash is in u-boot, and it craches in memcmp, instruction: ldrb. but I strongly suspect it is in kernel. 0 Quote
ning Posted July 11, 2022 Author Posted July 11, 2022 echo 'Code: eb04005f 54000061 52800000 14000006 (386468a3) ' | ARCH=arm64 ./scripts/decodecode Code: eb04005f 54000061 52800000 14000006 (386468a3) All code ======== 0: eb04005f cmp x2, x4 4: 54000061 b.ne 0x10 // b.any 8: 52800000 mov w0, #0x0 // #0 😄 14000006 b 0x24 10:* 386468a3 ldrb w3, [x5, x4] <-- trapping instruction Code starting with the faulting instruction =========================================== 0: 386468a3 ldrb w3, [x5, x4] 0 Quote
ning Posted July 11, 2022 Author Posted July 11, 2022 disable EFI_LOADER fixed this issue. and wetek-core2 dts can boot it to OS.. Starting kernel ... [ 3.944250] hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19) [ 10.381974] panfrost d00c0000.gpu: dev_pm_opp_set_regulators: no regulator (mali) found: -19 [ 11.187847] platform regulatory.0: firmware: failed to load regulatory.db (-2) [ 11.187874] firmware_class: See https://wiki.debian.org/Firmware for information about missing firmware [ 11.254051] btmrvl_sdio mmc2:0001:2: firmware: failed to load mrvl/sd8897_uapsta.bin (-2) [ 11.256833] Bluetooth: Failed to download firmware! [ 11.261624] Bluetooth: Downloading firmware failed! [ 11.550305] mwifiex_sdio mmc2:0001:1: firmware: failed to load mrvl/sd8897_uapsta.bin (-2) Debian GNU/Linux bookworm/sid VIM ttyAML0 VIM login: [ 13.534098] Bluetooth: hci0: command 0xfc18 tx timeout 0 Quote
ning Posted July 12, 2022 Author Posted July 12, 2022 due to mainline u-boot will not search usb partition 2, thus need a jumper script in 1st partition. sysboot usb 0:2 any 0x1080000 /boot/extlinux/extlinux.conf # use: mkimage -A arm64 -T script -O linux -d boot.cmd boot.scr then, vendor u-boot use "NEWBOOTCMD" to jump to mainline uboot, and load boot.scr as jumper script to read extlinux as boot memu. 0 Quote
ning Posted July 12, 2022 Author Posted July 12, 2022 wifi works out of box, after install firmware-libertas 0 Quote
ning Posted July 12, 2022 Author Posted July 12, 2022 hdmi works out of box, just because there is hw issue for my box in hdmi connecter. ethernet not work, maybe need adjust dts. 0 Quote
ning Posted July 12, 2022 Author Posted July 12, 2022 after add ðmac { phy-mode = "rmii"; phy-handle = <&internal_phy>; }; ethernet works 0 Quote
ning Posted July 22, 2022 Author Posted July 22, 2022 http://lists.infradead.org/pipermail/linux-amlogic/2022-July/013022.html http://lists.infradead.org/pipermail/linux-amlogic/2022-July/013051.html 0 Quote
chewitt Posted July 23, 2022 Posted July 23, 2022 @ning please see the 4x commits in this branch https://github.com/chewitt/linux/commits/amlogic-5.19.y for an example of how the patches for a new board should be presented to LKML. e.g. First add vendor binding, then board binding, then board dts. The RC keymap goes to a different list and can be done separately. As long as the Amlogic maintainers can see that the keymap has been sent to the media mailing-list at the same time they are normally fine to accept the ir-keymap node in the board dts. NB: The maintainers are not fans of minimal dts files being added, followed by lots of patches to enable individual hardware features. It's not technically a "wrong" approach, but for a simple simple TV Box it is better "etiquette" to finalise the dts first (with lots of testing etc.) *then* send the finished patches upstream. The 'box' image here: https://chewitt.libreelec.tv/testing/LibreELEC-AMLGX.arm-10.85.0-box.img.gz includes the dts from my kernel repo. If you would like to test boot it (set the dtb name in uEnv.ini) and share the dmesg log it would help me/us to see what's working (or not) and what adjustments might be required. Most S912 boxes are clones of the Q200/Q201 reference designs so the dts should be quite simple to figure out. I guessed at the Marvell WiFi/BT pieces: WiFi might work, but BT will probably need some changes. 0 Quote
ning Posted July 25, 2022 Author Posted July 25, 2022 @chewitt your dts is wrong. LED gpio is GPIO_TEST_N, not GPIOAO_9, there is no adc key, need to set sdio_pwrseq reset pin, otherwise wifi lose after reboot. and bluetooth may not work with your dts. my dts is finished. I initial 2 patches are not finished, due to this devices is black box to everyone. and it's finished in v3. 0 Quote
ning Posted July 25, 2022 Author Posted July 25, 2022 you can check https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/net/marvell-bt-8xxx.txt?h=v5.19-rc8 , what you write follows bcm bluetooth. that's wrong. and wifi/bt DT items for its drivers are supplementary data, not for of_porbe, not such data, driver still work, but if you give wrong data, driver will not work. 0 Quote
chewitt Posted July 25, 2022 Posted July 25, 2022 (edited) You must add the vendor binding first, then you can add the board binding, and then you can add the board dts with the board compatible (so you need three separate patches). You can also combine the RC bindings and driver into a single patch; it's acceptable to the subsystem maintainer and makes his review easier. Edited July 25, 2022 by chewitt 0 Quote
ning Posted July 25, 2022 Author Posted July 25, 2022 already do it in v5: http://lists.infradead.org/pipermail/linux-amlogic/2022-July/013067.html 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.