Use Fenix scripts to build your own ubuntu image


Hi Oleg,

Yes.When you setup the enviromment, you have choose server or mate, so it’s not necessary to specify again.


Hi there,

i am trying to Build Ubuntu Server 16 with EMMC support, but I am unable to burn this image.
Also there seems like a missing ln-s in fenix.


For Building this image I had to add in /scripts/ the line 610 with ln -s ~/project/khadas/ubuntu/build/images/linux-mainline/meson-gxl-s905x-khadas-vim.dtb kvim.dtb

looks like:

case “$LINUX” in
ln -s …/…/linux/arch/arm64/boot/dts/amlogic/$LINUX_DTB kvim.dtb
ln -s …/…/linux/arch/arm64/boot/dts/$LINUX_DTB kvim.dtb
ln -s ~/project/khadas/ubuntu/build/images/linux-mainline/meson-gxl-s905x-khadas-vim.dtb kvim.dtb
error_msg $CURRENT_FILE $LINENO "Unsupported linux version:$LINUX"

cd -

return $ret

Furthermore I had to increase the rootfs/image size to 1200MB, but I am unable to burn this image to my Khadas VIm1, and I dont know why. I dont get any errors on my build.

Build Image ist here:

Can someone point my to a solution?


Hi tavoc,

Mainline linux doesn’t support eMMC installation now.


one solution to be able to flash to emmc a mainline kernel based Ubuntu is to go back to 4.13 and apply known and working patches.
but a few hardware are still unsupported back then!


Thanks for your answer.
Is there a idea if or when emmc support will be added to mainline?

I thought that only with mainline uboot there is no emmc, therefore i tried to use the 2015-Version.


supporting a particular emmc on a specific board is difficult to request from the mainline linux kernel (which adresses thousands of boards), so it could only be supported thru patches to apply to mainline C code


I have 2 problems trying to install/run this on my VIM2:


recommends install lib32stdc++6 - I could find no such package (there are a whole bunch with architecture suffix such as mips, armhf etc). Anyway I tried to proceed without installing lib32stdc++6

(not sure if a consequence of the first) - things go OK till

# configuration written to .config
make[1]: Leaving directory '/home/chris/bin/ProjectKhadas/fenix/u-boot'
make[1]: Entering directory '/home/chris/bin/ProjectKhadas/fenix/u-boot'
/lib/ No such file or directory
/lib/ No such file or directory
dirname: missing operand
Try 'dirname --help' for more information.
  GEN     ./Makefile
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/config.h
  UPD     include/config.h
  GEN     include/
  GEN     include/
/lib/ No such file or directory
/lib/ No such file or directory
../scripts/Makefile.autoconf:40: recipe for target 'include/' failed
make[4]: *** [include/] Error 1
make[4]: *** Waiting for unfinished jobs....
../scripts/Makefile.autoconf:64: recipe for target 'include/' failed
make[4]: *** [include/] Error 1
../Makefile:477: recipe for target 'silentoldconfig' failed
make[3]: *** [silentoldconfig] Error 1
make[2]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/uboot.release'.  Stop.
Makefile:147: recipe for target 'sub-make' failed
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory '/home/chris/bin/ProjectKhadas/fenix/u-boot'
Makefile:7: recipe for target 'all' failed
make: *** [all] Error 2

I have never compiled a kernel before and my scripts rarely exceed 5 lines so am unable to debug this too much further myself.



After a long pause in building distros from sources (and tar of ubuntu), I wante to check what is the situation w/ the fenix scripts.

So I wanted to build a VIM1 kernel 4.9 server and EMMC image;
After a couple of isssues, I managed to produce…


[Msg]version:0x2 crc:0xa789747e size:842081812 bytes[803MB]
Pack image[/home/raxy/project/khadas/ubuntu/build/images/khadas_vim_emmc.img] OK

Sunday 22 avril 2018, 22:24:45 (UTC+0200)
Time elapsed: 0 days 0 hours 44 minutes 33 seconds.

on my beefy Teclast T16 power running xubuntu

I am pleased to see taht the scripts run smoother than in the past,
next step is to flash the image and test it on my VIM1 pro.

But I am deceived the scripts cannot build 4.12+ mainline kernel to be flashed directly on EMMC (I managed to do that in the past)

By the way,
can anyone tell if, at last, we can use linux to flash an img to the VIM over the usb-C cable ?


Do you mean burn image on linux?

You can refer to this topic:

Burning command:

$ burn-tool -i /path/to/update.img



bad news guys :disappointed_relieved:
the image I’ve build does not boot, the screen display the khadas logo and nothing else.
So I plugged my usb console cable and here are the messages from the linux console at boot time on the VIM1:

Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyUSB0, 22:05:00

Press CTRL-A Z for help on special keys

TE: 102980

BL2 Built : 14:59:36, Aug 9 2017.
gxl ge8c6a83 -

set vcck to 1120 mv
set vddee to 1000 mv
Board ID = 6
CPU clk: 1200MHz
DQS-corr enabled
DDR scramble enabled
DDR3 chl: Rank0+1 @ 768MHz - PASS
Rank0: 1024MB(auto)-2T-11
Rank1: 1024MB(auto)-2T-11
DataBus test pass!
AddrBus test pass!
Load fip header from eMMC, src: 0x0000c200, des: 0x01400000, size: 0x00004000
New fip structure!
Load bl30 from eMMC, src: 0x00010200, des: 0x01100000, size: 0x0000d600
Load bl31 from eMMC, src: 0x00020200, des: 0x05100000, size: 0x0002c600
Load bl33 from eMMC, src: 0x00050200, des: 0x01000000, size: 0x00065a00
NOTICE: BL3-1: v1.0(release):801e730
NOTICE: BL3-1: Built : 22:09:38, Aug 10 2017
[BL31]: GXL CPU setup!
NOTICE: BL31: BL33 decompress pass
[Image: gxl_v1.1.3244-a3237e2 2017-08-16 14:01:18 hong.guo@droid04]
9d 42 bd c7 a1 12 ec 2f 5f 6 30 b8 [0.328532 Inits done]
secure task start!
high task start!
low task start!
ERROR: Error initializing runtime service opteed_fast

U-Boot 2015.01-gffc14fcca3 (Apr 22 2018 - 21:41:07)

Relocation Offset is: 76eb3000
register usb cfg[0][1] = 0000000077f592b0
[CANVAS]canvas init
vpu: error: vpu: check dts: FDT_ERR_BADMAGIC, load default parameters
vpu: clk_level = 7
vpu: set clk: 666667000Hz, readback: 666660000Hz(0x300)
vpu: vpu_clk_gate_init_off
vpp: vpp_init
boot_device_flag : 1
Nand PHY Ver: © 2013 Amlogic Inc.
init bus_cycle=6, bus_timing=7, system=5.0ns
reset failed
get_chip_type and ret:fffffffe
get_chip_type and ret:fffffffe
chip detect failed and ret:fffffffe
nandphy_init failed and ret=0xfffffff1
MMC: aml_priv->desc_buf = 0x0000000073eb36b0
aml_priv->desc_buf = 0x0000000073eb59d0
SDIO Port B: 0, SDIO Port C: 1
emmc/sd response timeout, cmd8, status=0x3ff2800
emmc/sd response timeout, cmd55, status=0x3ff2800
init_part() 293: PART_TYPE_AML
[mmc_init] mmc init success
start dts,buffer=0000000073eb8200,dt_addr=0000000073eb8200
parts: 3
00: logo 0000000002000000 1
01: ramdisk 0000000002000000 1
02: rootfs ffffffffffffffff 4
init_part() 293: PART_TYPE_AML
eMMC/TSD partition table have been checked OK!
check pattern success
mmc env offset: 0x6c00000
In: serial
Out: serial
Err: serial
set hdmitx VIC = 16
config HPLL = 2970000
HPLL: 0xc000027b
config HPLL done
j = 4 vid_clk_div = 1
hdmitx: set enc for VIC: 16
HDMITX-DWC addr=0x10004006 rd_data=0x40
Error: HDMITX-DWC exp_data=0xff mask=0x9f
rx version is 1.4 or below div=10
hdmtix: set audio
hdmitx phy setting done
[store]To run cmd[emmc dtb_read 0x1000000 0x40000]
_verify_dtb_checksum()-909: calc ebced8c2, store ebced8c2
_verify_dtb_checksum()-909: calc ebced8c2, store ebced8c2
dtb_read()-1031: total valid 2
dtb_read()-1098: do nothing
Product checking: Khadas VIM.
Net: dwmac.c9410000amlkey_init() enter!
[EFUSE_MSG]keynum is 4
[BL31]: tee size: 0

[OSD]load fb addr from dts
[OSD]fb_addr for logo: 0x7e000000
[OSD]load fb addr from dts
[OSD]fb_addr for logo: 0x7e000000
[CANVAS]addr=0x7e000000 width=3840, height=2160
saradc - saradc sub-system

saradc saradc open - open a SARADC channel
saradc close - close the SARADC
saradc getval - get the value in current channel
saradc test - test the SARADC by channel-7
saradc get_in_range - return 0 if current value in the range of current channel

gpio: pin GPIOAO_2 (gpio 102) value is 1
Hit Enter or space or Ctrl+C key to stop autoboot – : 0
card out
emmc/sd response timeout, cmd8, status=0x1ff2800
emmc/sd response timeout, cmd55, status=0x1ff2800
emmc/sd response timeout, cmd1, status=0x1ff2800
** Bad device mmc 0 **
cfgload: no boot.ini or empty file
** File not found Image **
** File not found uInitrd **
** File not found kvim.dtb **
[rsvmem] get fdtaddr NULL!
rsvmem - reserve memory

rsvmem check - check reserved memory
rsvmem dump - dump reserved memory

rsvmem check failed
Bad Linux ARM64 Image magic!

Does anyone have a clue on what has gone wrong :thinking:
it seems to be the u-boot and / or many missing files from the image…

cfgload: no boot.ini or empty file
** File not found Image **
** File not found uInitrd **
** File not found kvim.dtb **


Hi ravelo,

Do you use the latest Fenix repo? Have you modified u-boot or linux?
I’ve tried to build with the following config and boot successfully.

Current environment:





no, this time I wanted to use the latest fenix tools to build unmodified uboot and unmodified kernel 4.9


Exactly same error as ravelo.

Thought I would see how your new script was coming along. Apparently its a fail.

VIM1, uboot 2015, 4.9 Kernel, 16.04, server, emmc.

Fails with “Bad Linux ARM64 Image magic!” once loaded to emmc.


It’s ok for me at VIM1, uboot 2015, 4.9 Kernel, 16.04, server, emmc


What OS did you build on? that is the only thing left then. I was tinkering with a totally fresh VM and Ubu18 server, so I decided to git fenix and just ran it as is. Didn’t work.

My personal [manual] builds for VIM1 work fine however.

I presume you are using Ubu16 or similar to run the scripts from?

The error from the fenix build is regarding boot.ini not existing or being empty.

My first thought was that it might be related to latest changes to the script (bootm/booti change according to commit log), but Ive done nothing to check.

Could also be changes to the linux 4.9 repo on the khadas git. Its possible there have been changes to it, and you have not pulled the latest version of it. (same goes for uboot actually, I havent checked.)


I have not test on Ubuntu 18.04 yet, but will do it soon.

This does not affect anything.

Can you try the lastest version of u-boot, kernel and Fenix on GitHub?


I presume I did that numbqq.

I literally: git clone fenix && source env/ && 1121111 && make
Burned emmc with amlogic tool.

So whatever git repo items that grabs. I assume it is still your “linux/ubuntu-4.9” kernel and your “u-boot/ubuntu” u-boot. Either way, I nothing more or less.

… Bad Linux ARM64 Image magic!


Hi freeasinbeer,

I will push the latest code this week. Maybe you can try the new version.



Ill give it a go when I have a minute.

What is the problem with building emmc/mainline in your fenix script?

Seems that if you choose mainline anything (linux or uboot) your script forces TF card only.


Yes, when you choose mainline linux it force set to SD/USB installation.

For eMMC installation, if you want to use Amlogic USB Upgrade Tool to burn the image, you need to add Amlogic partitions patches, I have did this before, you can refer to this: