Installing Armbian full fledged Linux on original Beelink MiniMX

Beelink MiniMX is an Adnroid TV box, back from 2016, containing S905 system chip, 1 Giga RAM, 8 Giga eMMC, HDMI output, 2 USB 2.0 ports and a Gigabit ethernet. The original Android system which was shipped with the device, was very buggy, but even today you can upgrade the operating system to Linux. In this blog, we will show how you can install Ubuntu based Armbian linux on it, and how to make use of it as a desktop computer.

There is an updated article on this topic, please read that.

Before you start the upgrade, you should know, that even if you upgrade the software, the hardware is not very strong, 1 Gigabyte RAM is not enough for using a modern browser on a modern web page. What you can do after the upgrade:

  • Use it as a terminal server log in to other Windows/Linux machines 
  • Use it for lightweight development environment
  • Use it as a mini server, run web sites, firewall, docker etc.
If you would like to use it as a TV Box, then you can install CoreELEC (the legacy version), which gives you a ready to use Kodi environment, exactly developed as a TV box.



Install Armbian base system

On the Armbian Forum this thread is dealing with this hardware and by reading the first post, you can read, how to install the system.

From here you can download the version you like, I used the focal-desktop, which is Ubuntu 2002 LTS Desktop. Copy the contents of the image to and SD card, which is at least 8 Gigabytes. On Windows I used HDDRawCopy Portable, which is an older tool, but works perfectly for me.

After writing the image, you will can see the BOOT drive in windows, go there and edit extlinux/extlinux.conf.

You should edit it, to reflect your hardware, in the end in our case it should look like this:

LABEL Armbian
LINUX /zImage
INITRD /uInitrd

# aml s9xxx
FDT /dtb/amlogic/meson-gxbb-p200.dtb
APPEND root=LABEL=ROOTFS rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0


The important part is the FDT line, the mason-gxbb-p200.dtb is the file describing the hardware of our device.

Beside this you have to copy the file u-boot-s905 in the root folder to u-boot-ext.

Now you are ready to boot. Eject the card from windows, and insert it to the device. Take a paper clip and push the reset button on the bottom of your device (through a small hole, near the power connector), plug in the power, a look at the monitor. 

Keep the reset button pushed, until the cute bear flashes once, then you can release it and wait till the Armbian system boots up. Once it is up and running, connect an USB keyboard and mouse to it, and do the initial customization. You will soon notice, that the wired ethernet is not working 😟.

Fixing Wired Ethernet

Ethernet is not working, because in the hardware description file, there is a mismatch. To fix it, first decomplie the binary file to a text file (you should do it on the device itself):

dtc -I dtb -O dts -o minimx.dts /boot/dtb/amlogic/meson-gxbb-p200.dtb

This will create the minimx.dts text file in your actual directory. You need to edit this.

pico minimx.dts


Look for the ethernet@c9410000 section, and delete the complete mdio part. In addition to this change the amlogic,tx-delay-ns to <0x04>. The result should look like this:

 ethernet@c9410000 {
         compatible = "amlogic,meson-gxbb-dwmac\0snps,dwmac-3.70a\0snps,dwmac";
         reg = <0x00 0xc9410000 0x00 0x10000 0x00 0xc8834540 0x00 0x04>;
         interrupts = <0x00 0x08 0x04>;
         interrupt-names = "macirq";
         rx-fifo-depth = <0x1000>;
         tx-fifo-depth = <0x800>;
         power-domains = <0x02 0x01>;
         status = "okay";
         clocks = <0x03 0x24 0x03 0x04 0x03 0x0f 0x03 0x04>;
         clock-names = "stmmaceth\0clkin0\0clkin1\0timing-adjustment";
         pinctrl-0 = <0x20>;
         pinctrl-names = "default";
         phy-handle = <0x21>;
         phy-mode = "rgmii";
         amlogic,tx-delay-ns = <0x02>;
 };


Save it and we need to compile it to binary:

dtc -I dts -O dtb -o /boot/dtb/amlogic/minimx.dtb minimx.dts


Now we need to adjust the /boot/extlinux/extlinux.conf and update the FDT line:

FDT /dtb/amlogic/minimx.dtb

Now reboot the box and the Ethernet interface should work.

Fixing multiple IP addresses

Sometimes (but not always), the box is getting 2 addresses for the same interface. After looking into it, for me it seems that it is a conflict between ifup-down scripts and network manager. So I commented out all eth0 related lines in /etc/network/interfaces and it seems to solve the problem.

Copy to eMMC

There is a script in the /root directory to copy the system to the built in eMMC of the device. Unfortunately this was not working for me, after running the script, the device tried to boot from the network. I spent a lot of time trying to fix this, but could get only half result. This means, that I had to use a 64 Megabytes, old SD card, for the boot sector, and could use the eMMC for the linux root partition.

The easy way to do this is just running the copy script in /root, then copy the contents of the BOOT partition of the SD card to a smaller SD card, edit the APPEND line in /extlinux/extlinux.conf to the following:

APPEND root=LABEL=ROOT_EMMC rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0

Then you can boot again, and you can check that the root filesystem is on /dev/mmcblk2p2.

df


The disadvantage if this approach is that the u-boot used in the copy doesn't handle the power led of the box, so it will remain red for the whole operation. To fix this, after a lot of experimentation I could keep the original u-boot, but use the eMMC for the ROOT partition.

Copy to eMMC, original u-boot


The steps were the following:

  1. With the original u-boot you can not change the eMMC partition table, because it will cause checksum error and u-boot will not boot
  2. So copy out the original u-boot, (dd /dev/mmcblk0 first 8196 sectors) then install on a computer the meson-tools. Extract the u-boot part with unamlbootsig, this is the raw u-boot image.
  3. Now create the partition table, and display it's content with dd if=/dev/mmcblk0 bs=512 count=1 | hexdump -C. The partition data begins at 0x01BE.
  4. Patch the amlbootsig program from the meson-tools, to include the partition table
  5. Use the patched amlbootsig program to create an updated partition table

Before doing the partitioning, I logged in to android, and using dmesg checked the Android partition table:

[mmcblk1p01]           bootloader  offset 0x000000000000, size 0x000000400000
[mmcblk1p02]             reserved  offset 0x000002400000, size 0x000004000000
[mmcblk1p03]                cache  offset 0x000006c00000, size 0x000020000000
[mmcblk1p04]                  env  offset 0x000027400000, size 0x000000800000
[mmcblk1p05]                 logo  offset 0x000028400000, size 0x000002000000
[mmcblk1p06]             recovery  offset 0x00002ac00000, size 0x000002000000
[mmcblk1p07]                  rsv  offset 0x00002d400000, size 0x000000800000
[mmcblk1p08]                  tee  offset 0x00002e400000, size 0x000000800000
[mmcblk1p09]                crypt  offset 0x00002f400000, size 0x000002000000
[mmcblk1p10]                 misc  offset 0x000031c00000, size 0x000002000000
[mmcblk1p11]            instaboot  offset 0x000034400000, size 0x000020000000
[mmcblk1p12]                 boot  offset 0x000054c00000, size 0x000002000000
[mmcblk1p13]               system  offset 0x000057400000, size 0x000040000000
[mmcblk1p14]                 data  offset 0x000097c00000, size 0x000136500000



I used the cache partition for the first (boot) linux partition and used the system and data partition as to second (root) partition. The boot loader needs at least the logo partition, so you can not overwrite everything.

After doing the partitioning, the partition table looked like this:

000001c0  41 80 83 03 50 7f 00 60  03 00 00 00 10 00 00 00  |A...P..`........|
000001d0  81 80 83 03 10 1f 00 a0  2b 00 00 68 bb 00 00 00  |........+..h....|
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|

So I did the following patch to amlbootsig:

From line 231 inserted the blue lines:

memset(buf, 0, hdr.size);

memset(buf+510-16,0x55,1);
memset(buf+511-16,0xaa,1);
memcpy(buf+0x1b0, (uint8_t[]){ 0x41, 0x80, 0x83, 0x03, 0x50, 0x7f, 0x00, 0x60,  0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 }, 16);
memcpy(buf+0x1c0, (uint8_t[]){ 0x81, 0x80, 0x83, 0x03, 0x10, 0x1f, 0x00, 0xa0,  0x2b, 0x00, 0x00, 0x68, 0xbb, 0x00, 0x00, 0x00 }, 16);

memcpy(buf, &hdr, sizeof(struct AmlogicHeader));

The resulting u-boot image can be downloaded from here.

To install it easily, just copy this file to the /root/u-boot/u-boot-s905/u-boot.img and run the emmc install script form /root.

With the low prices of mmc cards, probably it is not worth playing with this, but for me it was an interesting challenge.

Good luck with your MiniMX box.

(Last note: I am using a non English keyboard, the easiest way in Armbian to change the keyboard layout is the armbian-config utility.)


Comments

Frank said…
Thanks for the article. I have a Beelink Mini MX, as well, but with 2GB RAM, though. I have followed your instructions (over and over) to perfection, but still cannot make the ethernet port come alive (and hence, I cannot use headless Focal server from Balbes).

I want to point out a typo in the article, by the way. Your instructions mention the need for changing amlogic,tx-delay-ns to <0x04>, but the recap of the change below still holds the original setting of <0x02>, though.

I have tried with the <0x04> and when that didn't work, I tried reverting to <0x02>. But, to no avail. So I'm back with <0x04>. But I still cannot get any connectivity. I also tried commenting out the eth0 part in the interfaces, but it made no change.

I am trying to setup a local server for Unifi Controller and Adguard (or PiHole). So ethernet is mandatory :)

Could you try and upload and share your dtb file from your working Beelink Mini MX? And any other pointers, ideas and hacks to make the ethernet work are more than welcome, of course.
Lacó said…
Sorry for the late answer, in this link you can find my dtb and dts files from the device. May be they do not correspond to each other, but the dtb is my actual working dtb file.

https://drive.google.com/drive/folders/1yMitV9ZfSkZkqJXlIOSQ1gkOxn8DZWyM?usp=sharing

Popular posts from this blog

Setting ethernet interface speed in /etc/network/interfaces