Build Ubuntu 16.04.2 (or 17.04) w/ Mate and Linux-4.9


the fact is,
a thousand+ packages get downloaded from an .au xenial arm64 repo, I do not know why au is chosen;
and the network speed between here and those mirror repos is tens of kilobytes/s; so it takes forever to download…


hooray Scott; I finally managed to build a image ,flashed it on my vim pro , booted and loged in as scott/ttosc
thanks a lot;

my initial goal was 1st to build a leaner image (without mate, but i failed to put aside xorg & co so the build time was still a few hours)

I tried on 3 computers : 2 with bodhi linux 3 (kernel 3.14 + buntu 14.04.5 LTS based) and one with xubuntu 16.10 with various mileages and the following blocking error to build u-boot on the 16.10 box;

...	CC dvfs.o
	CC lib/delay.o
	CC task_entry.o
	CC misc.o
In file included from uart.c:2:0:
/usr/lib/gcc/arm-none-eabi/4.9.3/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
 # include_next <stdint.h>
compilation terminated.
Makefile:84: recipe for target '/home/raxy/project/khadas-build-script/Khadas-Components/u-boot/build/scp_task/uart.o' failed
make[2]: *** [/home/raxy/project/khadas-build-script/Khadas-Components/u-boot/build/scp_task/uart.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/raxy/project/khadas-build-script/Khadas-Components/u-boot/Makefile:896: recipe for target 'bl301.bin' failed
make[1]: *** [bl301.bin] Error 2
Makefile:147: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2

(0x05) END: compile_firmware_u-boot 

finally the slowest/smallest of the bodhi machines did the trick;
now trying to understand how to cleanly build a proper lean distro, and later, experiment w/ mate.


hi Scott & all,
is the serial usb console interface supposed to be enabled by your scripts ?
on my vim pro, i get nothing displayed in the putty session even when I try to send keystrokes (I’m familiar enough with using console like that on this board)…
tks in advance


The serial console should be enabled. There is a line in the 99 script you can add, but I noticed that at least on my units, I did not need to use it.

That is basically because it is enabled by the bootargs line (u-boot)


I can be sure. You are doing something that I didnt sanction or have tested.
I know that there will be problems if you use the latest Ubuntu because of the compiler version that is supplied with it. (gcc6).

I’ve never used bohdi. So I have no idea about any quirks it might have, nor do I know its base distro.


I cannot help you there! Perhaps a better ISP, or move to Slovakia!

You can change the repo in the script. Just make sure you escape the url properly! :wink:


i did change the repo url to a german one, and it’s better like that.

it is gcc5 in the 16.10 xubuntu machine, and the error seems known U-boot compilation error
i ll try to fix it


sudo apt-get install libnewlib-arm-none-eabi

did fix the issue!
and I now have managed to build another image on a second (and faster) computer;
this image boots ok


hey @Tang73 ,
why did you remove plusXfiles from your repo ?

It was convenient,
I’m being updating your 123sh file to handle mainline kernel and on ubuntu running inside windows10 (you know, the Windows Subsystem for Linux (WSL) nice stuff…)


I was testing, and as far as I can tell, the only files needed to be made executable are the scripts in the scripts folder (I did also update the readme, but I am guessing that you have already read it once!)


let me know what files cause you problems. Ill update the readme to make them +x


you already updated your readme for
cd ~/khadas-build-script/Khadas-Components/scripts
chmod +x *sh

Here are the other files:
cd ~/khadas-build-script/Khadas-Components/utils
chmod +x *


thanks. Added to readme.


I gave up regarding the win10 thing because disk perf is awful ; it took more than 10 hours to do the whole build and it even did not end correctly.
my tentative to use a mainline kernel (the @umiddelb’s fork at ) instead of the khadas custom 4.9 failed so far when i want to flash the 5GB update image I manage to build


meh win10!

Anyway, I got 4.9 and 17.04 working. Problems are with network-manager package, but networking works. There are probably other issues because 17.04 really expects to be sitting on top of 4.10.

Once the 5GB image is flashed, it only takes up 2.9GB in emmc. As I said in my script, it is just working space for the chroot jail. You could cut it down before flashing, but eh! not worth the effort.

If you want to be successful, I suggest dropping all the lesser mainstream linux oses (bhodi etc) so you are not fighting an uphill battle figuring their quirks out - and just do as I recommended (Ubuntu SERVER 16.04 x64) - it will work first time!


As you commented in your 123sh script,
target should be to not to use custom khadas source trees but mainline ones , both for u-boot and for linux :wink:

Let’s put aside u-boot for now;
my initial purpose was and still is more to build a system w/ a newer and mainline kernel :sparkler: than to have a system w/ the old khadas customized (w/ poor documentation :joy_cat:) 3.14 or 4.9 kernel + newer ubuntu.

GUI will be my very last concern, first concern is to have everything work in CLI (ie serial console and ssh).

I was indeed successfull in reproducing on a lesser know linux your 4.9 + xenial success (but without mate) :sweat_smile:


Would you be interested in investing a bit of your time trying to build a mainline kernel (4.12 or more) with a base xenial using your existing tools, scripts and expertise ?
here is ummiddelb’s github :
he forked 4.13-rc3 and seems to keep it up to date with torvalds’s master branch…
1st thing I compared was config file, alas, the differences are huge betwen his gx-defconfig, torvalds’ defconfig and khadas 4.9’s kvim_defconfig !


already doing so - ignoring u-boot for now…


gx_defconfig is used to build one kernel image for both the ODROID-C2 and the Khadas VIM. I’ve merged it with the Archlinux defaults for Aarch64. This may explain the amount of diffs.

This kernel still has some caveats.

  • you need to boot it as an uImage with the bootm method in u-boot.
  • The internal network stalls on “heavy” load (even it’s 100MBit only)
  • USB doesn’t work
  • and many more


so, @Tang73, from which mainline kernel git would you start then ? and using which config file ?


Once again Ill say it, The kernel is not a problem - it will never be a problem.

The problem is the total Abortion that Khadas have created that makes the Device Tree for the kernel. The mess that works in 4.9 doesnt come close in 4.12. The one in 4.12 does not work as it sits. The patches listed elsewhere are also an abortion becase they clearly were not tracked properly.

I can see problems and differences with dts in memory allocations alone between the one supplied with 4.9 (kvim.dts) and the various include files that meson-gxl-s905x-khadas-vim.dts calls up in 4.12.

A clean build of the supplied 4.12 dts, gets me this:

Hit Enter or space or Ctrl+C key to stop autoboot -- :  0
ee_gate_off ...
## Booting Android Image at 0x01080000 ...
load dtb from 0x1000000 ......
   Loading Kernel Image(COMP_NONE) ... OK
   kernel loaded at 0x01080000, end = 0x01f4da00
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
[rsvmem] bl31 reserved memory set addr error.
   Loading Ramdisk to 73b24000, end 73ebff63 ... OK
   Loading Device Tree to 000000001fff7000, end 000000001ffff077 ... OK

Starting kernel ...

uboot time: 1625037 us

So I adjusted the memory to resemble the old 4.9 settings which gets me a happy dtb load:

it Enter or space or Ctrl+C key to stop autoboot -- :  0
ee_gate_off ...
## Booting Android Image at 0x01080000 ...
load dtb from 0x1000000 ......
   Loading Kernel Image(COMP_NONE) ... OK
   kernel loaded at 0x01080000, end = 0x02139a00
   Loading Ramdisk to 7377b000, end 73ec02cd ... OK
   Loading Device Tree to 000000001fff3000, end 000000001ffffdf0 ... OK

Starting kernel ...

But nothing actually loads.

So I am not even going to attempt to decipher the mess that exists, in order to get 4.12 working.
Becides that umiddelb keeps saying that there are many problems with other things like usb and networking.

I know that these problems will be a combination of amlogic/khadas/kernel. But since the devs of this product cannot keep things in order or run a git that maintains a complete working set of files to patch a vanilla kernel with (even if the files are a work in progress) there is little hope.

And aside from that, I didnt see a good response to my other post on this product. It is just a Shenzen Tomato product. Weison (even if they are a part of the same company) are using it to make money, and they are using our labour of love.

If our efforts go back into making the Karoke product better or their signage better or their kitchens better - I want a pay check.

Anything else I do, any other successes I have in my own time tinkering with this bit of junk will not be posted or shared.