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.

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:
1 2 3 4 |
Enter USB burn Try connect time out 701, 700, 834 Hit any key to stop autoboot: 0 gxb_p200_v1# |
You may want to run printenv in order to back the default settings:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
baudrate=115200 bootargs=rootfstype=ramfs init=/init console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0 ramoops.mem_address=0x20000000 ramoops.mem_size=0x100000 ramoops.record_size=0x8000 ramoops.conf bootcmd=run storeboot bootdelay=1 bootmode_check=get_rebootmode; echo reboot_mode=${reboot_mode};if test ${reboot_mode} = factory_reset; then defenv_reserv aml_dt;setenv upgrade_step 2; save;fi; bootup_offset=0x10ac270 bootup_size=0x5eec36 cmdline_keys=if keyman init 0x1234; then if keyman read usid ${loadaddr} str; then setenv bootargs ${bootargs} androidboot.serialno=${usid};fi;if keyman read mac ${loadaddr} str; then setenv bootargs ${bo; cvbsmode=576cvbs digitaudiooutput=PCM display_bpp=24 display_color_bg=0 display_color_fg=0xffff display_color_index=24 display_height=2160 display_layer=osd1 display_width=3840 dtb_mem_addr=0x1000000 edid.crcvalue=0xa62c0000 ethact=Meson_Ethernet ethaddr=00:15:18:01:81:31 factory_reset_poweroff_protect=echo wipe_data=${wipe_data}; echo wipe_cache=${wipe_cache};if test ${wipe_data} = failed; then run init_display; run storeargs;if mmcinfo; then run recovery_from_sdcard;fi;i fb_addr=0x3f800000 fb_height=1080 fb_width=1920 fdt_high=0x20000000 firstboot=0 gatewayip=10.18.9.1 hdmimode=2160p60hz420 hostname=arm_gxbb init_display=hdmitx hpd;osd open;osd clear;vout output ${outputmode};imgread pic logo bootup $loadaddr;bmp display $bootup_offset;bmp scale initargs=rootfstype=ramfs init=/init console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0 ramoops.mem_address=0x20000000 ramoops.mem_size=0x100000 ramoops.record_size=0x8000 ramoops.cone ipaddr=10.18.9.97 irremote_update=if irkey 0xe31cfb04 0xb748fb04 2500000; then echo read irkey ok!; if itest ${irkey_value} == 0xe31cfb04; then run update;else if itest ${irkey_value} == 0xb748fb04; then run update;\ fi;fi;fi; is.bestmode=false loadaddr=1080000 mac=da:7b:db:4e:28:af netmask=255.255.255.0 outputmode=2160p60hz420 preboot=run factory_reset_poweroff_protect;run upgrade_check;run bootmode_check;run init_display;run storeargs;run upgrade_key;run switch_bootmode; reboot_mode=normal recovery_from_flash=if imgread kernel recovery ${loadaddr}; then bootm ${loadaddr}; fi recovery_from_sdcard=if fatload mmc 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;if fatload mmc 0 ${loadaddr} recovery.img; then if fatload mmc 0 ${dtb_mem_addr} dtb.img; then echo sd dtb.im; recovery_from_udisk=if fatload usb 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;if fatload usb 0 ${loadaddr} recovery.img; then if fatload usb 0 ${dtb_mem_addr} dtb.img; then echo udisk dtb.; sdc_burning=sdc_burn ${sdcburncfg} sdcburncfg=aml_sdc_burn.ini serverip=10.18.9.113 stderr=serial stdin=serial stdout=serial storeargs=setenv bootargs ${initargs} logo=${display_layer},loaded,${fb_addr},${outputmode} hdmimode=${hdmimode} cvbsmode=${cvbsmode} hdmitx=${cecconfig} androidboot.firstboot=${firstboot}; run cmdline_ke; storeboot=if imgread kernel boot ${loadaddr}; then store dtb read $dtb_mem_addr; bootm ${loadaddr}; fi;run update; switch_bootmode=get_rebootmode;if test ${reboot_mode} = factory_reset; then run recovery_from_flash;else if test ${reboot_mode} = update; then run update;else if test ${reboot_mode} = cold_boot; then run ; try_auto_burn=update 700 750; update=run usb_burning; run sdc_burning; if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash; upgrade_check=echo upgrade_step=${upgrade_step}; if itest ${upgrade_step} == 3; then run init_display; run storeargs; run update;else if itest ${upgrade_step} == 1; then defenv_reserv; setenv upgrade_step; upgrade_key=saradc open 0; if saradc get_in_range 0x0 0x50; then echo detect upgrade key; run update;fi; upgrade_step=2 usb_burning=update 1000 wipe_cache=successful wipe_data=successful Environment size: 4777/65532 bytes |
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):
1 2 3 4 |
setenv preboot "run factory_reset_poweroff_protect;run upgrade_check;run bootmode_check;run init_display;run storeargs;run update_key;run irremote_update;run user_start;run switch_bootmode;" setenv user_start "if mmcinfo; then run linux_start_mmc;fi;" setenv linux_start_mmc "if fatload mmc 0 1080000 kernel.img; then if fatload mmc 0 0x1000000 dtb.img; then echo sd dtb.img loaded; fi;echo ===[LINUX START from mmc]===; bootm 1080000;fi;" saveenv |
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.
1 2 |
sudo apt-get install p7zip-full pv 7z x ubuntu-14.04-headless-arm64.7z |
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.
1 2 |
sudo dd if=ubuntu-14.04-headless-arm64.img | pv | sudo dd of=/dev/sdX bs=16M sync |
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:
1 |
dd if=/dev/block/boot of=<sdcard_path>/boot.img |
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
1 |
cp boot.img-second.gz /media/jaufranc/boot/dtb.img |
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:
1 2 3 4 5 6 7 8 9 |
Ubuntu 14.04 LTS koneplus ttyS0 koneplus login: debian Password: Last login: Thu Jan 1 00:02:46 UTC 2015 on ttyS0 Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.14.29 aarch64) * Documentation: https://help.ubuntu.com/ debian@koneplus:~$ |
That’s a minimal image so there’s plenty of free space and memory:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
debian@koneplus:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mmcblk0p2 29G 462M 28G 2% / devtmpfs 280M 4.0K 280M 1% /dev none 4.0K 0 4.0K 0% /sys/fs/cgroup tmpfs 404M 0 404M 0% /tmp none 81M 252K 81M 1% /run none 5.0M 0 5.0M 0% /run/lock none 404M 0 404M 0% /run/shm none 100M 0 100M 0% /run/user debian@koneplus:~$ free -h total used free shared buffers cached Mem: 807M 125M 681M 256K 3.1M 22M -/+ buffers/cache: 99M 707M Swap: 0B 0B 0B |
All four cores are shown when I check the cpuinfo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
cat /proc/cpuinfo Processor : AArch64 Processor rev 4 (aarch64) processor : 0 processor : 1 processor : 2 processor : 3 Features : fp asimd crc32 CPU implementer : 0x41 CPU architecture: AArch64 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 Hardware : Amlogic |
The kernel is build with Android’s option “CONFIG_ANDROID_PARANOID_NETWORK“, so all network configuration must be done with root:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
ifconfig eth0 eth0 Link encap:Ethernet HWaddr da:7b:db:4e:28:af inet6 addr: fe80::d87b:dbff:fe4e:28af/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1788 errors:0 dropped:0 overruns:0 frame:0 TX packets:178 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:265549 (265.5 KB) TX bytes:14810 (14.8 KB) Interrupt:40 ifconfig eth0 192.168.0.201 up No support for INET on this system. sudo ifconfig eth0 192.168.0.201 up sudo ifconfig sudo: unable to resolve host koneplus eth0 Link encap:Ethernet HWaddr da:7b:db:4e:28:af inet addr:192.168.0.201 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::d87b:dbff:fe4e:28af/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2570 errors:0 dropped:0 overruns:0 frame:0 TX packets:248 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:384945 (384.9 KB) TX bytes:19904 (19.9 KB) Interrupt:40 |
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.

Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress