Jump to content

Armbian for H313 X96-Q LPDDR3 TV-Box


Recommended Posts

Armbian & Khadas are rewarding contributors

Allwinner h618 (and maybe h626/h313) has an issue reading emmc during boot. The code is noway perfect. The read and write speeds go back to normal when the kernel is loaded. I guess we can add code to prevent other SOC’s from loading the code if not needed.

Link to comment
Share on other sites

@sicxnull After you ported the code from Miniarch, I compared the differences in the configs of x96q-lpddr3 and x96q-ddr3-v5.1 and I managed to build and run the image on my TV box. But I did it roughly, replacing the differences in the code, I'm not very friendly with Linux. Could you please format it correctly and upload it to github. I'm attaching the differences in the code.

  • In the file build/patch/kernel/archive/sunxi-6.6/patches.armbian/arm64-dts-sun50i-h313-x96q-lpddr3.patch in line 246-247 I changed regulator-min-microvolt and regulator-max-microvolt to 1360000. and copied the modified file to the sunxi-6.7 and sunxi-6.10 folders along the same path.
  • In the file build/patch/u-boot/u-boot-sunxi/board_x96q/arm64-sun50i-h313-add-x96q-lpddr3-defconfig.patch also in lines 189-190 changed regulator-min-microvolt and regulator-max-microvolt to 1360000. 
  • And also replaced the values:
    Скрытый текст

    +CONFIG_ARM=y
    +CONFIG_ARCH_SUNXI=y
    +CONFIG_DEFAULT_DEVICE_TREE="sun50i-h313-x96q-lpddr3"
    +CONFIG_SPL=y
    +CONFIG_SUNXI_DRAM_H616_DDR3_1333=y
    +CONFIG_DRAM_CLK=600
    +CONFIG_DRAM_ODT_EN=y
    +CONFIG_DRAM_SUN50I_H616_DX_ODT=0x03030303
    +CONFIG_DRAM_SUN50I_H616_DX_DRI=0x0e0e0e0e
    +CONFIG_DRAM_SUN50I_H616_CA_DRI=0x00001c12
    +CONFIG_DRAM_SUN50I_H616_ODT_EN=0x1
    +CONFIG_DRAM_SUN50I_H616_TPR0=0xc0000a05
    +CONFIG_DRAM_SUN50I_H616_TPR2=0x00000000
    +CONFIG_DRAM_SUN50I_H616_TPR10=0x002f0006
    +CONFIG_DRAM_SUN50I_H616_TPR11=0xddddcccc
    +CONFIG_DRAM_SUN50I_H616_TPR12=0xeddc7564
    +CONFIG_MACH_SUN50I_H616=y
    +CONFIG_R_I2C_ENABLE=y
    +CONFIG_SPL_I2C=y
    +CONFIG_SPL_I2C_SUPPORT=y
    +CONFIG_SPL_SYS_I2C_LEGACY=y
    +CONFIG_SYS_I2C_MVTWSI=y
    +CONFIG_SYS_I2C_SLAVE=0x7f
    +CONFIG_SYS_I2C_SPEED=100000
    +CONFIG_PHY_REALTEK=y
    +CONFIG_SUN8I_EMAC=y
    +CONFIG_I2C3_ENABLE=y
    +CONFIG_AXP313_POWER=y
    +CONFIG_AXP_DCDC3_VOLT=1360
    +CONFIG_USB_EHCI_HCD=y
    +CONFIG_USB_OHCI_HCD=y
    +CONFIG_USB_MUSB_GADGET=y

     

x96q.png

Edited by zra123
Link to comment
Share on other sites

29 minutes ago, zra123 said:

After you ported the code from Miniarch, I compared the differences in the configs of x96q-lpddr3 and x96q-ddr3-v5.1 and I managed to build and run the image on my TV box. But I did it roughly, replacing the differences in the code, I'm not very friendly with Linux. Could you please format it correctly and upload it to github. I'm attaching the differences in the code.


I only have the 1.3 board. I actually need to rename this to x96qv1.3

I was not aware how many versions of this board were out there when i initally made this

I'm going to try and order some more and hope the other versions come.  If i can get one i'll absolutely upload it after testing. it seems like it's pretty easy after what you just posted 

Edited by sicxnull
Link to comment
Share on other sites

@sicxnull I would have handled it myself, but I don't know how to correctly format *.patch so that it would calculate all the amounts and indexes for me.

And another question: does the installation work on EMMC? Have you added the patch for EMMC from minimyth to your github?

Link to comment
Share on other sites

52 minutes ago, zra123 said:

@sicxnull I would have handled it myself, but I don't know how to correctly format *.patch so that it would calculate all the amounts and indexes for me.

And another question: does the installation work on EMMC? Have you added the patch for EMMC from minimyth to your github?

My Git boots from EMMC. i haven't sent it over to the main armbian repo because i want to tidy some stuff up first and just do one last pull request
 

Link to comment
Share on other sites

@sicxnull

I confirm that I test:

https://github.com/sicXnull/armbian-build/releases/download/v24.8.0-trunk.425/Armbian-unofficial_24.11.0-trunk_X96q_bookworm_current_6.6.44_mate_desktop.img.xz

boots from eMMC and runs well on my old Z1 (x9q v1.3 lpddr3)  variant. Ethernet, Hdmi, CPU Temp is working correctly now.

 

Great job.

 

PS: Unfortunately Z1 manufacturer changed the Hardware configuration on new tv-box version with different eMMC and the firmware requires secure boot TOC0 to boot.

      the above image is not working with the second newer Z1 device.

   

 

IMG_20240923_144213.jpg

Link to comment
Share on other sites

4 hours ago, rafman said:

I confirm that I test:

https://github.com/sicXnull/armbian-build/releases/download/v24.8.0-trunk.425/Armbian-unofficial_24.11.0-trunk_X96q_bookworm_current_6.6.44_mate_desktop.img.xz

boots from eMMC and runs well on my old Z1 (x9q v1.3 lpddr3)  variant. Ethernet, Hdmi, CPU Temp is working correctly now.


Nice! I just ordered another X96Q off aliexpress, hoping its a different version so we can get all variants on Armbian. 

Link to comment
Share on other sites

13 minutes ago, sicxnull said:

Nice! I just ordered another X96Q off aliexpress, hoping its a different version so we can get all variants on Armbian. 

 

I solved the issue with Secure Boot today with your github branch (https://github.com/sicXnull/armbian-build.git --branch X96Q-TVBOX-LPDDR3 --single-branch) 

 with an additional patch from @Nick A  for SECURE BOOT.

 

Right now i  check further the box.

 

NOTE: Take care with X96Q boxes from Alliexpress because you may receive Rockchip BOX  (rk322x) that works, but is less powerfull than H313 and they stencil the chip as h313  there are lot of scammers. ( i Already have one )

 

Thanks again.

Edited by rafman
Link to comment
Share on other sites

Hello everyone,

 

I got my X96Q "variant" from Aliexpress just some days ago. I almost expected some fake stuff and wasn't disappointed:

20240923_195807_2.thumb.jpg.d31bfdaf47f70f8174c731ac6ee4fb9f.jpg

 

The chip marked as "H313S" isn't a relabeled Allwinner or Rockchip-soc, but a HiSilicon Hi3798mv300 (at least that is, what the bootlog says).

 

So another warning to anyone thinking about buying this kind of box.

 

Link to comment
Share on other sites

Ive been watching this topic for about a week, and i'll be honest, I've no idea on half of what you're talking about.

However, I too have a redundant X96Q box, which i'd like to try and run linux so I can then try and run Home Assistant.

I flashed Armbian-unofficial_24.11.0-trunk_X96q_bookworm_current_6.6.44_mate_desktop.img to an SD card with Rufus and then again with Belena Etcher, but the TV box wont start with the SD card inserted, although when I say it doesnt boot.. I see nothing through HDMI and the LED remains red.

I know its a long shot.

But is it currently possible to run on the V4 board (image attached),

i see that youre all working hard in the background, so maybe something for me to come back and look at in a few weeks/months. ?

 

20240924_105229.jpg

Edited by K R
additional information
Link to comment
Share on other sites

3 hours ago, K R said:

Ive been watching this topic for about a week, and i'll be honest, I've no idea on half of what you're talking about.

However, I too have a redundant X96Q box, which i'd like to try and run linux so I can then try and run Home Assistant.

I flashed Armbian-unofficial_24.11.0-trunk_X96q_bookworm_current_6.6.44_mate_desktop.img to an SD card with Rufus and then again with Belena Etcher, but the TV box wont start with the SD card inserted, although when I say it doesnt boot.. I see nothing through HDMI and the LED remains red.

I know its a long shot.

But is it currently possible to run on the V4 board (image attached),

i see that youre all working hard in the background, so maybe something for me to come back and look at in a few weeks/months. ?



hmmm. that's another variant

Can you try one of these miniarch images and see if they boot? we know X96Q LPDDR3 does not but there are two other variants to try

if one of those boot we will atleast know what we are dealing with, unless someone here is already familiar with that board. 

https://github.com/warpme/miniarch/releases/tag/v20240916

Link to comment
Share on other sites

5 hours ago, K R said:

MiniArch-20240715-6.10.10-board-h313.x96_q-SD-Image.img boots with a linux command line prompt.

 


The image that @zra123 built may work for you if you're willing to try it and if he is willing to upload it 

 

Edited by sicxnull
Link to comment
Share on other sites

@Nick A @sicxnull 

 

According to device test results with secure boot image  bellow.

 

And because Bluetooth and WiFi does not work on both boxes Q1 and Z1 (same hardware except eMMC)

I found and extract the Q1 stock android firmware dtb  file (same hardware on both devices)  and I need to modify or patch my local

copy of  (https://github.com/sicXnull/armbian-build.git --branch X96Q-TVBOX-LPDDR3 --single-branch) 

 

 I want to ask if Android DTBs are Compatible with Armbian or they need additional maintenance ?

 

Hardware is the bellow:

wifi : SV6256P   (Same on Z1 and Q1)

Bluetooth: BR8052A01   (Same on Z1 and Q1)

 

The android DTB for Q1 contains the below section information about BT and WiFi/Wlan:
        wlan {
            compatible = "allwinner,sunxi-wlan";
            clocks = <0x1b>;
            pinctrl-0 = <0xd3>;
            pinctrl-names = "default";
            wlan_busnum = <0x01>;
            wlan_power;
            wlan_io_regulator;
            wlan_regon = <0x53 0x06 0x12 0x01 0xffffffff 0xffffffff 0x00>;
            wlan_hostwake = <0x53 0x06 0x0f 0x06 0xffffffff 0xffffffff 0x00>;
            chip_en;
            power_en;
            status = "okay";
            linux,phandle = <0x17d>;
            phandle = <0x17d>;
        };

        bt {
            compatible = "allwinner,sunxi-bt";
            clocks = <0x1b>;
            bt_power;
            bt_io_regulator;
            bt_rst_n = <0x53 0x06 0x13 0x01 0xffffffff 0xffffffff 0x00>;
            status = "okay";
            linux,phandle = <0x17e>;
            phandle = <0x17e>;
        };

 

Were i have to place this information to recompile Armbian ?

FYI: I attach bellow the full DTB and decompiled DTS file of Q1 tv-Box from Android stock firmware.

Q1_device_tree.dtb.tar.gz Q1_device_tree.dts

Edited by rafman
Link to comment
Share on other sites

You can't use your android dts. It needs to be converted to mainline linux.

 

But you can use some of the information.

 

For example these are the gpio settings for wifi.           

Android:

wlan_regon = <0x53 0x06 0x12 0x01 0xffffffff 0xffffffff 0x00>;

Linux:

gpio = <&pio 6 18 GPIO_ACTIVE_HIGH>; /* PG18 WL_REG_ON */

 

Android:

wlan_hostwake = <0x53 0x06 0x0f 0x06 0xffffffff 0xffffffff 0x00>;

Linux:

interrupts = <6 15 IRQ_TYPE_EDGE_RISING>; /* PG15 WL_HOSTWAKE*/

 

 

https://www.rapidtables.com/convert/number/hex-to-binary.html

https://github.com/warpme/minimyth2/blob/master/script/kernel/linux-6.10/files/0644-arm64-dts-allwinner-h313-add-x96q-TVbox.patch

 

I think your problem is the wifi driver. SV6256P uses the ssv6x5x driver. Only source I can find is for linux 4.4 kernel.

https://github.com/paolosabatino/ssv6x5x/tree/master

 

 

 

Edited by Nick A
Link to comment
Share on other sites

@K R

20 hours ago, K R said:

Im willing to try anything, even if i dont achieve anything at my end, it may help others.

 

In the meantime you can try a Hack in order to boot Armbian to your box from miniarch image that boots with your box (MiniArch-20240715-6.10.10-board-h313.x96_q-SD-Image.img) 

i can't give any guarantee that it will succeeds but you can try it. (Warning if you are not familiar with below tools don't attempt to continue because if you make a mistake  you may damage your hard drive)

 

You will need :

A PC with linux (Debian or ubuntu )

Gparted 

Disks utility (gnome-disks)

An SD card 32GB (minimum) and an SD to USB card reader/adapter

Balena Etcher (appimage)

 

Armbian Image:

  https://github.com/sicXnull/armbian-build/releases/download/v24.8.0-trunk.425/Armbian-unofficial_24.11.0-trunk_X96q_bookworm_current_6.6.44_mate_desktop.img.xz

 

Miniarch Image:

MiniArch-20240715-6.10.10-board-h313.x96_q-SD-Image.img  (you already have it)

 

Steps:  (Warning if you are not familiar with above tools don't attempt to continue because if you make a mistake  you may damage your hard drive)

 

1:> Burn MiniArch-20240715-6.10.10-board-h313.x96_q-SD-Image.img using Balena Etcher to your SD card.

2:> After you Burn the image your SD Card will contain 2 partitions (BOOT, ROOT).

3:>  Open gparted select your SD Card and remove/delete the ROOT partition on SD card. (apply all operations)

4:> create a new Ext4 partition on SD card  (size at least 6 GB) and label it as ROOT. and (apply all operations) and after close gparted

5> unpack Armbian-unofficial_24.11.0-trunk_X96q_bookworm_current_6.6.44_mate_desktop.img.xz and now you will have --> Armbian-unofficial_24.11.0-trunk_X96q_bookworm_current_6.6.44_mate_desktop.img

5:> open Disks Utility, select your SD card on disks (left panel), and select ROOT partition (make it green on right panel)

6:> click on gear icon and select Restore Partition Image...,  choose --> Armbian-unofficial_24.11.0-trunk_X96q_bookworm_current_6.6.44_mate_desktop.img

 

When the process finish you will have BOOT, armbi_root partitions on your SD Card.

 

Unmount/Remove and reinsert you SD Card to your PC.
 

Open BOOT partition on SD card and remove/delete the bellow files:

 

Image

Image.gz

 

open armbi_root/boot  and copy the bellow files to BOOT/

 

armbianEnv.txt

boot.bmp

boot.cmd

boot.scr

config-6.6.44-current-sunxi64

initrd.img-6.6.44-current-sunxi64  --> rename to Image.gz

System.map-6.6.44-current-sunxi64

uInitrd-6.6.44-current-sunxi64

vmlinuz-6.6.44-current-sunxi64 --> rename to Image

 

Unmount the disks -->  Insert SD card to your TV-Box and try to boot.

 

With this method you don't need to modify the extlinux.conf, I have used his method to boot armbian  when the it was not mature for my devices .

 

Try it with you own risk, No guarantees.  (if you encounter problems with Hdmi just wait for an upcoming release for your box) but if the system is booting you may have a working system from SD.

 

 

 

Link to comment
Share on other sites

You will need : 

A PC with linux (Debian or ubuntu )
 

Already failed.😞 

unless I can run Ubuntu in a sandbox or emu etc.

 

having said that, I’m now investigating whether or not Home Assistant will run on miniarch

Link to comment
Share on other sites

On 9/24/2024 at 11:37 AM, K R said:

MiniArch-20240715-6.10.10-board-h313.x96_q-SD-Image.img boots with a linux command line prompt.

 


i just built a 5.1 image. Should work for you 

https://github.com/sicXnull/armbian-build/releases/download/v24.8.0-trunk.425/Armbian-unofficial_24.11.0-trunk_X96q-v5-1_bookworm_current_6.6.44_mate_desktop.img.xz

https://github.com/sicXnull/armbian-build/tree/X96Q-5.1-DDR3

Link to comment
Share on other sites

10 часов назад, sicxnull сказал:
01.10.2024 в 09:17, going сказал:

Has there been a health check in your work with u-boot patches if you apply your fixes only to the configuration file
and do not apply the patch piece that lowers the eMMC frequency?


haven't tried. 

 

https://github.com/sicXnull/armbian-build/commit/333e462466670e9a8609771ccd05977b87800881#diff-60905755e35d9115365c06e07ef492c1e5cfde8cdd018a10496129e19b6b7b2d

The first piece affects all devices and will be applied directly in the u-boot code.

diff --git a/arch/arm/dts/sun50i-h616.dtsi b/arch/arm/dts/sun50i-h616.dtsi
--- a/arch/arm/dts/sun50i-h616.dtsi
+++ b/arch/arm/dts/sun50i-h616.dtsi
@@ -324,7 +324,7 @@
 			pinctrl-names = "default";
 			pinctrl-0 = <&mmc2_pins>;
 			status = "disabled";
-			max-frequency = <150000000>;
+			max-frequency = <12000000>;
 			cap-sd-highspeed;
 			cap-mmc-highspeed;
 			mmc-ddr-3_3v;

Instead, you can specify the frequency directly in the device's DTS, if necessary.

In any case, the u-boot code is more advanced and it doesn't really matter to him.

 

This part is done in SPL:

diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
--- a/drivers/mmc/sunxi_mmc.c	2024-01-08 16:37:48.000000000 +0100
+++ b/drivers/mmc/sunxi_mmc.c	2024-03-08 10:51:44.771585037 +0100
@@ -542,7 +542,7 @@
 	cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;

 	cfg->f_min = 400000;
-	cfg->f_max = 52000000;
+	cfg->f_max = 12000000;

 	if (mmc_resource_init(sdc_no) != 0)
 		return NULL;

Try to exclude it first.
If you get a non-bootable system, we will need to think about how to surround this ifdef code with directives so that it does not apply to everyone.

 

Link to comment
Share on other sites

3 hours ago, going said:

The first piece affects all devices and will be applied directly in the u-boot code.

 


correct me if i'm wrong, but the point of a board level patch is so that it does not apply to all devices, no? 

that's the point of creating the board_x96q subdirectory instead of just adding the patches to the u-boot sunxi directory. 

You can see this when building armbian.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines