10 10
balbes150

Armbian for TV box rk3328

Recommended Posts

Big thanks to Balbes, perfect work!

 

I own a MXQ PRO max. This box looks like SCISHION AI ONE / RX4B. (rk3328, 4gb ram, 32gb emmc, 100mbit lan, 2.4ghz wlan, bt)

 

Goal: Use box as thin client (vnc, rdp,...) using armbian/ubuntu desktop istalled on emmc.

 

With Balbes newest image and jeanrhrum hints (https://forum.armbian.com/topic/8082-armbian-for-tv-box-rk3328/?do=findComment&comment=68975) i am able to make the box boot armbian from sd card. (SD card booting is not reliable. In many cases the box ignores the sd and boots Android. After a number of restarts the box boots from sd to Bionic desktop. I did not find the root cause, but i suspect the problem be around psu / sd card / timing. As soon as sd boot is detected, armbian boots and works very reliable) 

 

/boot/extlinux/extlinux.conf

LABEL Armbian
  LINUX /Image
  INITRD /uInitrd
  FDT /dtb/rockchip/rk3328-box.dtb
  APPEND root=LABEL=ROOTFS rootflags=data=writeback rw console=uart8250,mmio32,0xff130000 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 

Using this dtb: lan and spdif work well, i did not go into details with bt, wifi.

 

I find:

  armbian@rk3328:~$ ls /dev/mmc*
  /dev/mmcblk0    /dev/mmcblk0p2  /dev/mmcblk2boot0  /dev/mmcblk2rpmb
  /dev/mmcblk0p1  /dev/mmcblk2    /dev/mmcblk2boot1
  armbian@rk3328:~$ 

 

I was able to backup emmc (/dev/mmcblk2) to an external usb disk drive using dd. I could not use the ddbr script  (sd card too small, forced into zip mode even though plenty of space on external drive)

 

Now, I would like to extract the device tree from android image to optimize for bt, wifi and possibly access the 7-segment display of the box.

 

How can I get access to androids device tree file? Could I mount /dev/mmcblk2boot<x> somehow?

 

Any hints on this? Best,
Markus

Share this post


Link to post
Share on other sites
On 12/16/2018 at 12:28 AM, balbes150 said:

Wi-Fi to work you need three things: support in the kernel + DTB + firmware (possibly with extra parameters).

 

Now my tv box works fine, but I miss wifi. The box has RTL8821CU chip, so will you include support for this chip in future build or can you guide me how to compile and put it in the system? I have downloaded your deb for linux headers and try to compile from this repo (https://github.com/whitebatman2/rtl8821CU) but there's no spec for rk3328. And after some editing, I run into "build fails with implicit declaration of function" error, don't know what cause the problem C or GCC. 

Share this post


Link to post
Share on other sites
14 hours ago, mb16 said:

Could I mount /dev/mmcblk2boot<x> somehow?

Ah, android.. No, if you run fdisk -l on your mmcblk2 file you will see 3 4mB partitions,,

where is the rest?? 15 or 30 gB missing, right?

The rest is in a mtd filesystem,, under the stanza "chosen" you may see something like this

bootargs .........

 mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),\

0x00002000@0x00006000(misc),0x00000800@0x00008000(baseparameter),0x00008000@0x00008800(resource),\

0x00010000@0x00010800(kernel)...and so on (#'s are blocks/sectors,,,, length@offset (+12M))

You want the first 70k of resource, starts 2k in, magic is 0xd00dfeed, about 64k long. The rest is 2 png or jpg,

the splash screen, 1st is for 720p, 2nd (larger) for 1080p

I don't know how to mount mtd filesystems, AND I have had no luck

converting android dtb to linux dtb,, nothing that I have found on google either

Usually it just doesn't boot, fails very early on kernel load (serial console)

-----

but usually with these tv boxes you have root in adb,, have you tried?

If so, cd to proc, somewhere in there is the device tree, use busybox tar and write it to sdcard,

and then to your computer (on an ext fs), then expand and use dtc -fs on the expanded directory,,

then you will have the android dtb

Or,, easier, if you have adb root,,,

find which partition resource is , /dev/mmcblk2p??? ,,

dd 70k to internal sdcard (I think this is ext fs,, vfat will lose permissions etc)

then to computer, chop leading 2k, trim excess from end (hexeditor and dd)

BTW the reason adb has root but not android...

the su in /system/xbin is no good,, the one in /sbin is the right one

Use verity off to make /system rw, then you can mv xbin/su xbin/su.bak

and /sbin/su  -> xbin and then get su in android

Share this post


Link to post
Share on other sites

The easiest way to get the desired dtb is to unpack the native firmware file with the customization tool. Details can be found on the  Freactab forum.

Share this post


Link to post
Share on other sites
2 hours ago, balbes150 said:

The easiest way to get the desired dtb is to unpack the native firmware file with the customization tool. Details can be found on the  Freactab forum.

Thank you, will have a look there. 

Share this post


Link to post
Share on other sites
7 hours ago, wdtz said:

Or,, easier, if you have adb root,,,

 

Thank you for all these details! I can connect adb and have root.  Lets see, what I can get, will take me some time.

Share this post


Link to post
Share on other sites

Added images SERVER with kernel 5.0.0 NEXT 20190110.

Monitor output (HDMI) does not work yet. On the model MVR9 working wired LAN and UART, it is possible through them to operate the system.

Share this post


Link to post
Share on other sites
7 hours ago, balbes150 said:

The easiest way to get the desired dtb is to unpack the native firmware file

There are dozens of different tv boxes, easy to get wrong image, usually does not "work out"

in output/Image (specifically my box, h96max+-ssv, from the vendor, ssv is wifi)

ls -l *.img
-rw-rw-r-- 1 d d    1048576 Nov 11 12:35 baseparameter.img
-rw-rw-r-- 1 d d    1708536 Nov 11 12:35 boot.img
-rw-rw-r-- 1 d d   19036180 Nov 11 12:35 kernel.img
-rw-rw-r-- 1 d d      49152 Nov 11 12:35 misc.img
-rw-rw-r-- 1 d d     168060 Nov 11 12:36 oem.img
-rw-rw-r-- 1 d d    8971308 Nov 11 12:35 recovery.img
-rw-rw-r-- 1 d d    5592576 Nov 11 12:35 resource.img
-rw-rw-r-- 1 d d 1547079912 Nov 11 12:36 system.img
-rw-rw-r-- 1 d d    4194304 Nov 11 12:35 trust.img
-rw-rw-r-- 1 d d    4194304 Nov 11 12:35 uboot.img
-rw-rw-r-- 1 d d  163962992 Nov 11 12:36 vendor.img

and in output

-rw-rw-r-- 1 d d 162126 Nov 11 12:33 boot.bin
drwxrwxr-x 4 d d   4096 Nov 30 01:54 Image/
-rw-rw-r-- 1 d d 162126 Nov 11 12:35 MiniLoaderAll.bin
-rw-rw-r-- 1 d d    724 Nov 11 12:35 package-file
-rw-rw-r-- 1 d d    981 Nov 11 12:35 parameter.txt

 

Still have to extract dtb from resource.img

Share this post


Link to post
Share on other sites

As a newcomer, I have to start by thanking balbes150 for his excellent work.

I'm running my first tests with Armbian With following environment:
- box:   A5XMax with 4GB RAM 32GB disk
- image: Armbian_5.68_Rk3328-tv_Ubuntu_bionic_default_4.4.154_desktop_20190110.img
- FDT:   /dtb/rockchip/rk3328-evb.dtb

Armbian boots without problems from microSD card (Sandisk Ultra 16 GB) and runs fine.

When I try eMMC installation and run /boot/create-mbr-linux.sh, I get following output:
 

Start script create MBR and filesystem
/dev/mmcblk0p1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 0
/dev/mmcblk1
Start backup u-boot default
dd: failed to open '/dev/mmcblk1': No such file or directory
Start create MBR and partittion
Error: Could not stat device /dev/mmcblk1 - No such file or directory.
Error: Could not stat device /dev/mmcblk1 - No such file or directory.
Error: Could not stat device /dev/mmcblk1 - No such file or directory.
Start restore u-boot
8192+0 records in
8192+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.195129 s, 21.5 MB/s
Done

It seems that the script selects /dev/mmcblk1 as DEV_EMMC, but /dev/mmcblk1 does not exists, while /dev/mmcblk0 is there.

This is the relevant section of /proc/mounts, that is used by the script for evaluating DEV_EMMC value.
 

/dev/mmcblk0p2 / ext4 rw,noatime,nodiratime,errors=remount-ro,commit=600 0 0
/dev/mmcblk0p1 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 0
/dev/mmcblk0p2 /var/log.hdd ext4 rw,noatime,nodiratime,errors=remount-ro,commit=600 0 0

This is the output of ls -lh /dev/mmc* 

brw-rw---- 1 root disk 179,   0 Jan 10 09:04 /dev/mmcblk0
brw-rw---- 1 root disk 179,   1 Jan 10 09:04 /dev/mmcblk0p1
brw-rw---- 1 root disk 179,   2 Jan 10 09:04 /dev/mmcblk0p2
-rw-r--r-- 1 root root      12M Jan 10 22:19 /dev/mmcblk1
brw-rw---- 1 root disk 179,  32 Jan 10 09:04 /dev/mmcblk2
brw-rw---- 1 root disk 179,  64 Jan 10 09:04 /dev/mmcblk2boot0
brw-rw---- 1 root disk 179,  96 Jan 10 09:04 /dev/mmcblk2boot1
brw-rw---- 1 root disk 179, 128 Jan 10 09:04 /dev/mmcblk2rpmb

I'm tempted to modify create-mbr-linux.sh and to force
DEV_EMMC=/dev/mmcblk0

and to do a similar modification in /root/install.sh, where there is the same mismatch, but I prefer to ask for your suggestion before taking and risk.

Mauro

Share this post


Link to post
Share on other sites
11 hours ago, balbes150 said:

New version 5.68 20190110. Added dtb support for MX10 model.

 

  Reveal hidden contents

 

For those who are interested in details on my experiments with this model, you can see in this topic. :)

http://forum.puppyrus.org/index.php?topic=21337.0

 

 

Does the dtb for MX10 make the builtin (evil) wifi/bt work? 

I could not figure out for sure from the puppyrus translation :) Is the MX10 board same as the A5X Max ?

Great work !!

 

Share this post


Link to post
Share on other sites
5 hours ago, mg-to said:

DEV_EMMC=/dev/mmcblk0

No, mmcblk0 is almost certainly your sdcard, just from the partitions on it

It's really common for android to have boot0, boot1, rpmb on the emmc, that is likely where it is (blk2)

If you have checked your evb.dtb by turning it into a dts, check dwmmc@ff500000, and  @ff520000

for  bus-width = < 0x04 >;  or 0x08 and the  aliases {  ,, then you will know for sure

You do know this will wipe out your android?  Before you do that, it would be good to

extract the android dtb because it is sometimes hard to get the right image for your hardware,

there are so many slightly different images

Share this post


Link to post
Share on other sites
8 hours ago, mg-to said:

When I try eMMC installation and run /boot/create-mbr-linux.sh, I get following output:

Try to run the utility ddbr and create a full backup of the eMMC. If the utility can not read eMMC you need to deal with the parameters of DTB (which are responsible for eMMC).

 

8 hours ago, armar said:

Does the dtb for MX10 make the builtin (evil) wifi/bt work? 

no

 

8 hours ago, armar said:

Is the MX10 board same as the A5X Max ?

It is similar, but different manufacturers can change the content (components) themselves.

Share this post


Link to post
Share on other sites
7 hours ago, wdtz said:

No, mmcblk0 is almost certainly your sdcard, just from the partitions on it

It's really common for android to have boot0, boot1, rpmb on the emmc, that is likely where it is (blk2)

If you have checked your evb.dtb by turning it into a dts, check dwmmc@ff500000, and  @ff520000

for  bus-width = < 0x04 >;  or 0x08 and the  aliases {  ,, then you will know for sure

You do know this will wipe out your android?  Before you do that, it would be good to

extract the android dtb because it is sometimes hard to get the right image for your hardware,

there are so many slightly different images

wdtz,
thanks for your reply. I didn't check the dtb, I've simply selected the dtb selected by another user with the same device (A5X MAX) . So it seems that I'm using a wrong dtb and that I have to
- get the right dtm by extracting it from android.
- put a reference to it in /extlinux/extlinux.conf

Am I correct?

Share this post


Link to post
Share on other sites
6 hours ago, mg-to said:

Am I correct?

As I said, usually an android dtb won't work for linux, but it is a guide on how to change

an almost working dtb

For wifi,, 3 things have to be "right".  A reference in the dtb, a module, and the firmware

You will really have to get dtc (device tree compiler) and learn how to use it,

it is not that hard..  Harder is making the "right" device tree

IMO,, you really should have a "perfect" boot with sdcard (everything works, no glitches)

before thinking about overwriting emmc

----more--

For wifi the reference in the dtb is not at all important, only if you

want it to work during boot. I have seen wrong wifi chip referenced in dtb,

modprobe right module (if firmware is there) and the wifi works

This assumes it is talking to the right gpio

There is a discussion about that in this thread a few pages previous

Share this post


Link to post
Share on other sites
7 hours ago, wdtz said:

As I said, usually an android dtb won't work for linux, but it is a guide on how to change

an almost working dtb

For wifi,, 3 things have to be "right".  A reference in the dtb, a module, and the firmware

You will really have to get dtc (device tree compiler) and learn how to use it,

it is not that hard..  Harder is making the "right" device tree

IMO,, you really should have a "perfect" boot with sdcard (everything works, no glitches)

before thinking about overwriting emmc

----more--

For wifi the reference in the dtb is not at all important, only if you

want it to work during boot. I have seen wrong wifi chip referenced in dtb,

modprobe right module (if firmware is there) and the wifi works

This assumes it is talking to the right gpio

There is a discussion about that in this thread a few pages previous

 

 

What do the firmware files for  wifi look like? And how does the module know where to pick it up from? My wifi chip is rtl8723bs. I can modprobe 8723bs and see it in lsmod but wifi does not work. I looked for 8723bs files and I see
 

% find /lib/firmware -name "*8723bs*"
/lib/firmware/rkwifi/wifi_efuse_8723bs-vq0.map
/lib/firmware/rtlwifi/rtl8723bs_bt.bin
/lib/firmware/rtlwifi/rtl8723bs_ap_wowlan.bin
/lib/firmware/rtlwifi/rtl8723bs_nic.bin
/lib/firmware/rtlwifi/rtl8723bs_wowlan.bin

% find /lib/modules -name "*8723bs*"
/lib/modules/4.4.143-rk3328-tv/kernel/drivers/net/wireless/rockchip_wlan/rtl8723bs
/lib/modules/4.4.143-rk3328-tv/kernel/drivers/net/wireless/rockchip_wlan/rtl8723bs/8723bs.ko

 

On my desktop is a mountpoint /vendor which is on /dev/mmcblk2p17 . Is this the android directory?

In there I see

% sudo find . -name "*8723bs*"
./etc/firmware/wifi_efuse_8723bs-vq0.map
./etc/firmware/rtl8723bs_VQ0_fw
./etc/firmware/rtl8723bs_config
./etc/firmware/rtl8723bs_fw
./etc/firmware/rtl8723bs_VQ0_config
./lib/modules/8723bs.ko

The 8723bs.ko is different (in size) than the earlier 8723bs.ko (modprobe probably loads the earlier /lib/modules/..../8723bs.ko)

Do I need to copy the vendor 8723bs* files into the SD armbian dirs?  Where? I don't see any firmware dir in /etc of the armbian install. @balbes150 talked about some firmware parameters. Where should they be set?

 

Share this post


Link to post
Share on other sites

I am also a user of the A5X Max and it simply works out of the box (without wifi).

Big thanks!

Unfortunately I am not expert enough to help with finding how that on board wifi works, but my hope is in armar, who seems to be on the right way. Also thanks for that.

Share this post


Link to post
Share on other sites
17 hours ago, armar said:

 

What do the firmware files for  wifi look like? And how does the module know where to pick it up from?

Well, it varies, alas. The firmware files can be bin or fw or other. Usually from /lib/firmware or a folder there BUT

can be in /usr/somewhere, this is not common

I don't know how the ko knows where to find the firmware

Firmware are for the wifi chip, are version and OS independent

17 hours ago, armar said:

is a mountpoint /vendor which is on /dev/mmcblk2p17 . Is this the android directory? 

It is 1 of them, there are 9 or 10 in total plus uboot and miniLoader and ?

Maybe I'm telling you something you already know, / in Android is only in mem,

loaded from the boot part, a gz cpio. Most of the folders in / (android ) are links to

the appropriate partition

 

17 hours ago, armar said:

/etc/firmware/rtl8723bs_fw  ./etc/firmware/rtl8723bs_config./etc/firmware/rtl8723bs_VQ0_config /etc/firmware/rtl8723bs_VQ0_fw

I would guess that these are the ones you need, try copy them to lib/firmware/rtlwifi

Share this post


Link to post
Share on other sites
4 hours ago, wdtz said:

I would guess that these are the ones you need, try copy them to lib/firmware/rtlwifi

 

Tried it,  does not work. The android 8723bs.ko does not modprobe due to exec format error. Looks like there is a magic number check for the modules to make sure they are built for the correct kernel. Doing a modprobe --force to get around, reports all kinds of unknown symbols from the module. Adding just the fw files and the config with the old 8723bs.ko does not work either (modprobes...but no wifi).
 

[ 3302.546786] 8723bs: version magic '4.4.159 SMP preempt mod_unload modversions aarch64' should be '4.4.154-rk3328-tv SMP mod_unload aarch64'


[ 3434.436109] 8723bs: bad vermagic: kernel tainted.
[ 3434.436134] Disabling lock debugging due to kernel taint
[ 3434.444852] 8723bs: Unknown symbol __stack_chk_guard (err 0)
[ 3434.445330] 8723bs: Unknown symbol preempt_schedule (err 0)
[ 3434.445471] 8723bs: Unknown symbol __rcu_read_unlock (err 0)
[ 3434.445538] 8723bs: Unknown symbol __rcu_read_lock (err 0)
[ 3434.445803] 8723bs: Unknown symbol __check_object_size (err 0)
[ 3434.445849] 8723bs: Unknown symbol __stack_chk_fail (err 0)
9 hours ago, slaven said:

but my hope is in armar, who seems to be on the right way. Also thanks for that.

 

Like the blind leading the blind ...... in the dark :lol:

Share this post


Link to post
Share on other sites
(edited)

Hello.

First of all,  thanks and congratulations to armbian team. I must mention Igor and Balbes. Very good job.

Secondly, I`d like to say that I`ve succesfully installed Armbian 5.44 Ubuntu Bionic Mate 3.14 20180726 on X96 and X96 Míni (everything working But BT) and been able to install it in eMMC.

Now, my goal is focused on MX10. Just tried your current image for Rk3328, changed the DTS entry to MX10 one, and almost everithing working in the  first boot. All but wifi. In order to  try to fix it,  I need the kernel source to add more wifi drivers. Where can I download it?  Can I use the one in the apto.armbian repository (linux-source-4.4.156-rockchip64)?

Edited by CarlosPiles
mispelled

Share this post


Link to post
Share on other sites

@CarlosPiles I'm in the same boat, I'm trying to compile rtl8821cu for my box but stuck at some error. I've found this installable kernel header here https://yadi.sk/d/apAYXzjHA2Pekw you can try it.

Share this post


Link to post
Share on other sites

New version 5.69 20190113.

Expanded the list of WiFi modules (but I don't know if it will work or not).

There is a model ssv6051. It loads fine, but WiFi didn't show up on the MX10. You can try to find the reason yourself. Most likely you need to change the DTB (take the necessary data from the native dtb from Android firmware).

Share this post


Link to post
Share on other sites
16 hours ago, armar said:

dding just the fw files and the config with the old 8723bs.ko does not work either (modprobes...but no wifi).

Dmesg , if all is well, will give a message, ie  (dmesg |grep firmw)

usb 1-1.4.3: rtl8xxxu: Loading firmware rtlwifi/rtl8192cufw_TMSC.bin

for a usb dongle

Share this post


Link to post
Share on other sites

Hello community, I am very grateful with the Armbian forum, since I have all my arm boards with this operating system and now I have the tv box https://es.aliexpress.com/item/MX-TV-caja-Android-8-1-9-0-mx10-4-GB-DDR4-32-GB-64-GB/32858434465.html?spm=a2g0s.9042311.0.0.7e6863c02aoLoU and I have it working all right server mode, here I share the backup of android 9 MX10 4G-32G  .

http://www.mediafire.com/file/55p1pffcjooaoc5/backup_image.img/file

 

 

Share this post


Link to post
Share on other sites

Hi. Back to forum after some tests. I have compiled the kernel with most of wifi modules included.  It compiled without errors and generated correspinding modules. I need to know how I can update kernel (named without rk3328 suffix) in order to boot from a diferent kernel.

I expect to be able to keep current boot options without overwrite, and edit some files to boot an alternative kernel. Can you tell me if it is possible and which files must be changed?

Share this post


Link to post
Share on other sites
15 hours ago, wdtz said:

Dmesg , if all is well, will give a message, ie  (dmesg |grep firmw)

usb 1-1.4.3: rtl8xxxu: Loading firmware rtlwifi/rtl8192cufw_TMSC.bin

for a usb dongle

No such message after modprobe. Will play around with the dtb more. I think the 8723bs is also in MVR9 which is working as balbes150 has mentioned. So most likely the problem is with the dtb for the A5XMAX. Must be something other than the wlan sections. Maybe a power regulator or gpio setting is wrong....

Share this post


Link to post
Share on other sites
6 hours ago, CarlosPiles said:

Hi. Back to forum after some tests. I have compiled the kernel with most of wifi modules included.  It compiled without errors and generated correspinding modules. I need to know how I can update kernel (named without rk3328 suffix) in order to boot from a diferent kernel.

I expect to be able to keep current boot options without overwrite, and edit some files to boot an alternative kernel. Can you tell me if it is possible and which files must be changed?

What kernel files to use is described in the file " /extlinux/extlinux.conf"

 

 

Share this post


Link to post
Share on other sites

Update:

 

I managed to get Wifi work. I've successfully compiled rtl8821cu from this repo.  First, it throws lots of error. I've change the target to RPI3, then it got compiled. I did "sudo make install", "sudo modprobe 8821cu", it loads to kernel but no wlan0 yet. Until today, I did some change to dtb file by changing the Wifi entry to match my box. Then to my surprise, it load automatically on boot and I can connect wifi to my router.

 

This is what my wifi entry:

    wireless-wlan {
        compatible = "wlan-platdata";
        rockchip,grf = <0x1c>;
        wifi_chip_type = "rtl8821cu";
        sdio_vref = <0x708>;
        keep_wifi_power_on;
        WIFI,poweren_gpio = <0x3f 0x13 0x1>;
        WIFI,host_wake_irq = <0xcd 0x1 0x0>;
        WIFI,reset_gpio = <0xcd 0x8 0x1>;
        status = "okay";
    };

My original's dtb has this pointer for wake_irq: &gpio3 1 GPIO_ACTIVE_HIGH

The bluetooth might not work though, since I haven't test it yet. However, this is very complete environment for an Armbian device for me.

It did have some other lockups, I not sure what cause it, I doubt it's because of I'm using USB3 sata for storage. I will post here to see if anyone has solution.

 

I attach these two files in case anyone has same box as me or just want to have a look of what I've done.

rk3328-evba1.dts

rk3328-evba1.dtb

Share this post


Link to post
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...
10 10