How to Run Headless Linux on Amlogic S905 Devices Such as MINI MX or K1 Plus

A few week ago, I had been informed that Amlogic S905 U-boot and Linux source code was released, and one person use the code and other resources to load a minimal Ubuntu 14.04 image to his K1 Plus TV box and released the installation instructions and the image (Thanks olin!). I also have K1 Plus here, but since I’ve just finished reviewing Beelink MINI MX, I decided to use the latter instead. The instructions below boot Linux from the (micro) SD card, and can still boot Android if you remove the SD card.

Modifying U-boot environment

The instructions include opening the box, and connecting or soldering a USB to TTL debug board to access U-boot and change some parameters. But later once an image with network is working, you could also build and load fw_setenv and fw_saveenv, and do the same steps with an Android shell and without the need to open the device.

Click to Enlarge
Serial connection to MINI MX (Click to Enlarge)

K1 Plus has the UART headers populated so you don’t have to solder anything, but MINI MX requires a little bit a soldering on the clearly marked Tx, Rx, GND pins.

Connect your USB to TTL debug board to your computer, configure minicom / putty / screen to 115200 8N1, start the board, and press the space bar to interrupt the boot:


You may want to run printenv in order to back the default settings:


Now you can change some settings in U-boot in order to allow for Linux to boot from SD card. If you are doing so directly in Android terminal via adb, you can replace setenv and saveenv by fw_setenv and fw_saveenv (no present in MINI MX firmware):

Flash Ubuntu image to the SD card

First download the Ubuntu image: ubuntu-14.04-headless-arm64.7z.

I’ve done this step in an Ubuntu computer, but you could also perform the same steps in Windows with 7pzip and Win32DiskImager. Install required tools and uncompress the image.


Insert the micro SD card (2GB or greater) in your computer, check the device with lsblk, and flash the image to your SD card by replacing /dev/sdX in the command below by your actual device.

Get the Device Tree File for Your device

If you are trying this on K1 Plus, you can skip that step, but if you are using another device, in my case Beelink MINI MX replacing the device tree file in /boot/dtb.img might be a good idea. For example, MINI MX would only get a Fast Ethernet connection with K1 Plus device tree file, but once I extracted the one from the Android firmware I got an Gigabit Ethernet connection.

If you’ll need to get boot.img either from some firmware update file, or directly from the NAND flash. I don’t have firmwre for MINI NX, so I dumped the boot partition with an adb shell:


Then I followed the instructions to extract a device tree file from Android, until I get boot.img-second.gz file, which I copied to the boot partition in the SD card with Ubuntu

Run Ubuntu in MINI MX

You may want to extend the rootfs partition in the SD card with gparted, or you’ll only have a small part of your SD card used. Now insert the SD into your Amlogic S905 TV box, and connect the power.

After some time getting wasted waiting for the network, you should be able to access to command line by logging in with user debian and password temppwd:


That’s a minimal image so there’s plenty of free space and memory:


All four cores are shown when I check the cpuinfo:


The kernel is build with Android’s option “CONFIG_ANDROID_PARANOID_NETWORK“, so all network configuration must be done with root:


So there’s some work to be done, but at least that’s a start.

[Update: It’s easy to put the case together with the serial wires by cutting the plastic case a little.

Beelink_MINI_MX_with_UART_cables]

 

Support CNX Software - Donate via PayPal or become a Patron on Patreon

120
Leave a Reply

avatar
117 Comment threads
3 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
40 Comment authors
RickPankajssrosebrann Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
maz
Guest
maz

“Only one core is shown when I check the CPU however”

One core? You definitely have 4 being up here. It is just an ancient kernel with a deprecated format for /proc/cpuinfo.

olin
Guest
olin

Thanks for the write-up.

Regarded the CPU – the kernel config (meson64) has the hot-plug cpu governor set as default (which I was not aware of) so the ‘top’ utility really displayed only one core (after presing key ‘1’) – the rest of the cores was disabled. This also casued issues with installation of cpufreq tools (basically the apt-get install hanged), so I changed the default CPU governor to ondemand in my kernel build, which fixed the installation issue and hopefully might be more convenient for benchmarking purposes etc.

miniNodes
Guest

Excellent work Olin, nice to see Linux running on the S905!

m][sko
Guest
m][sko

@olin
So I don’t need anything except original amlogic kernel + device tree file
to boot kernel on amlogic device ??

olin
Guest
olin

@m][sko
Correct. You also need a way how to start the kernel from the memory card – that’s what the u-boot scripts are for.

trackback

[…] I tried instructions to install Linux on Amlogic S905 Android TV boxes yesterday, I wanted to extract kernel.img file found in Android firmware, but Google did not help […]

Methanoid
Guest
Methanoid

Headless or can we run an Ubuntu with a desktop manager (LXDE or MATE or similar) ??

fossxplorer
Guest
fossxplorer

@cnxsoft, i have the usb-to-ttl i bought a while back, but where did you get the wiring that’s soldered into the board from? I need to buy it.

fossxplorer
Guest
fossxplorer

@cnxsoft
Awesome. Placing order now! Thx a lot.
Btw, is there a place to buy cheap soldering equips from? 🙂
Never soldered before though.

Movie78
Guest
Movie78

@cnxsoft
Can it run OpenElec or KodiBuntu?

trackback

[…] я вчера писал инструкцию по установке Linux на Amlogic S905 Android TV вчера, я столкнулся с проблемой […]

gcsuri
Guest
gcsuri

@cnxsoft
good work!
Is it possible to write the device’s bootenv with booting a modified recovery SDcard?
There is a set_bootloader_env() function in the updater-script.

Whiterat
Guest
Whiterat

Should be able to place uboot autoscript commands into “aml_autoscript” on a fat partitioned sdcard or usb, when you hit the physical upgrade button (or IR codes?) while booting It’ll try “usb burning > sd burning > sd recovery > usb recovery” in that order.

loadrunner
Guest
loadrunner

Does the S/PDIF output work? What about bluetooth?
Thanks.

olin
Guest
olin

@Whiterat @gcsuri
thats a good idea. there is a way how to trigger upgrade from mmc by pressing menu (hamburger) button on the remote during boot, which loads the recovery.img kernel. the only issue right now is the framebuffer doesn’t seem to be working correctly, so virtual console and terminal doesn’t work (nothing is displayed on the screen connected via hdmi) – but maybe it’s just a matter of reconfiguring kernel. so for now ony serial console or ssh works.

Stefan
Guest
Stefan

Where to get firmware for Mini MX? I would like to buy that device and run Ubuntu with correct Device Tree File. So I need firmware image to extract it.

Stane1983
Member

@cnxsoft
I sent you message on hangouts yesterday… 🙂

Amlogic released Linux SDK (Buildroot based) for S905 yesterday with updated kernel and drivers along with fb and x11 arm64 mali libs – http://openlinux.amlogic.com:8000/download/ARM/

gcsuri
Guest
gcsuri

@olin
I’ve just got my MXQ and Mini MX.
On MXQ I can use “setprop ubootenv.var.something val” command to change uboot variables from userspace.
It doesn’t work on MiniMX 🙁 – Is there any built-in utility in MiniMX to write /dev/block/env ?

gcsuri
Guest
gcsuri

@olin , @cnxsoft

OK, I got the solution to read/write the bootenv without jtag…

dumpsys system_control -b [ set | get ] bootenv [value]

for example:
dumpsys system_control -b get ubootenv.var.bootdelay

Methanoid
Guest
Methanoid

I’d love to see some noob friendly instructions to get Linux with desktop running on S905 boxes. Yes, Kodi would be great but for other uses. Or some dual boot instructions?

Stane1983
Member

@Methanoid
That is very optimistic thinking I must say 🙂

One solution is to wait for Odroid C2 board and their emmc with preinstalled Lubuntu 🙂

Number 63
Guest
Number 63

@Stane1983

Now amlogic have release a updated sdk

Does this mean we may see a openelec build for the mini mx soon?

m][sko
Guest
m][sko

Amlogic has worst display, mali GPU and video decoder drivers
they can’t fix v-sync mali drivers problem since they first release buildroot/kernel
only android drivers are fine

Number 63
Guest
Number 63

Erm ok, so is that big up amlogic?

Stane1983
Member

@Number 63
If someone is working on it then yes.

Number 63
Guest
Number 63

Thanks @Stane1983 i will keep my fingers and toes crossed. Not a lover of android.

Number 63
Guest
Number 63

Do you know if anyone is working on it stane?

gcsuri
Guest
gcsuri

@cnxsoft
How did you open MiniMX box? 🙂

Number 63
Guest
Number 63

Its just clipped in underneath

mdel
Guest
mdel

very nice tutorial i’ll test that on my s802/s812 boxes, both run openelec images but i’d like to have regular distros.
I’ve located the unpopulated rs232 headers on both boards, looks like most of them will have those debug pins.

I wanted to know if you had a chance to test the gigabit performance (iperf) with that kernel on your mini mx box, and if you noticed the same duplex behavior as in your review.

Also you mention the Android / Linux kernel, i’m a bit confused as to what amlogic actually released and if there’s a difference between the two. I assuming that to run a linux root fs i should only be interested in using a linux kernel, if i’m wrong about that please let me know.

mdel
Guest
mdel

@cnxsoft
i believe my s812 M8S box only has 100Mbit eth, but i’m quite familiar with those “usb gigabit” boards (pcduino), which are limited to usb bandwidth so 480Mbps at best, usually 300Mbps.
I was going to buy an M8S+ box (s812 with “GBe”) but i can’t find the s812 block diagram to see if it has hardware GBe interface, apparently the S805 diagram has GBe.

Thx for the kernel info, i’ll try building one for my S8xx boards and serial u-boot them over the weekend.

A couple of questions more on topic :
if a box can already boot a linux image from SD Card (beelink MXQ), is it simply because the existing nand uboot has the same configuration as the one you set through serial as described above ?

Also are there TTL voltage considerations to be careful about when plugin an adapter on those boards ?
i’m mentioning this because that’s something you need to know about when doing the same thing on a raspberry pi which has 3.3v GPIO, including its serial interface, and some (most?) USB/Serial TTL adapters use 5V signals..

gcsuri
Guest
gcsuri

Could any “distro” run X in this box?

mdel
Guest
mdel

gcsuri :
Could any “distro” run X in this box?

My knowledge on the matter is quite limited, so @cnxsoft will probably tell you more.

There are gpu drivers in the amlogic tarballs, so X should be able to run with some 2D acceleration, but “running” X does necessarily mean much, some basic use case could be barely functional (videos).
But so far i was able to boot and ubuntu (lxde) filesystem, using an openelec 6 kernel, on an s805 box and the desktop was running “fine”. It also works on similar platforms like raspberry pi, odroid, orange pi boards.
Advanced (3D) window managers, unity, gnome shell and so on, would require 3D acceleration and i have no idea what’s the state of the mali X driver in that regard..
I do believe Kodi uses 3D accel to work but i’m not sure it uses an X server, at least in standalone mode in openelec.

gcsuri
Guest
gcsuri

ok, I got X and LXDE run on my MiniMX. X uses fbdev. There are some graphic error around fonts and window frames but it works. 🙂

gcsuri
Guest
gcsuri

I’ve just made a simple network perf test with nc.
nc 10.1.0.55 3333|dd of=/dev/null bs=1024 count=1024000
1 GB copied, 10.6484s, 98.4MB/s
I think the eth interface works on full bandwidth 😉

my SDcard reading speed is about 10MB/sec
internal mmc is around 40MB/s

mdel
Guest
mdel

@gcsuri
most impressive gigabit stats.
too bad s805 boxes don’t make use of the chip gigabit capabilities (according to hardkernel datasheet).

Concerning your X test, did you build a kernel with the gpu driver or use the image provided by olin ?
Not sure which module X should load with a working gpu driver but fbdev is not accelerated so..

gcsuri
Guest
gcsuri

I’m using fbdev on X. Windows moving fast enough. There is a bug in the amlogic fb code so 32bpp doesn’t work well (there are a lot of black area in the screen). I had to define 24bpp in x.conf and changed the kernel driver to 24bit init to get fbcon work perfectly.
Now I’m working on the USB boot because it’s 4x faster than cardreader…

luyi
Guest
luyi

@gcsuri
You can use following u-boot command to boot from usb.
usb start
fatload usb 0 0x1080000 kernel.img
fatload usb 0 0x1000000 dtb.img
boots 0x1080000

luyi
Guest
luyi

@gcsuri
Can you tell me how to get fbcon working?
I already compile kernel with fbcon.
I only see the boot logo after “echo 0 > /sys/class/graphics/fb0/blank”.

gcsuri
Guest
gcsuri

You need to map the console. fbcon=map:0

hxm
Guest
hxm

hi,

can it be possible to make the mini mx dual boot so we can launch openelec from SD card ?

AC
Guest
AC

Hi,
I am newbie, trying to run headless Ubuntu server on MQX (s805) with Odroid c1 Ubuntu release.
I used the above procedure with minor changes according to the Odroid boot.ini.
The MQX boots from the SD but I get some errors and it get stuck after 3 seconds.
Can anyone help?

Steeve Morin
Guest
Steeve Morin

Ok so I managed to boot the Ubuntu 16.04 from the ODROID C2 on an MXQ Pro. I can ssh to it fine but X11 doesn’t show up on the screen. Only the boot logo stays. I’ll release the image for people to test.