Fenix: One Stop Scripts Set to build Ubuntu

thanks !
regarding archives/ubuntu-base/ubuntu-base-16.04.2-base-arm64.tar.gz
and [quote=“Gouwa, post:5, topic:828, full:true”]

Note that to use fenix scripts, you need download all the necessary repos (like linux, utils) by manually first.

where can we find this ubuntu 16.04 precompiled tar file for arm64 ?

This is excellent. Explains a great deal that was missing.

I see that this repo contains drivers for wifi, bluetooth and Mali too :slight_smile:

Do this:
cd ~/project/khadas/ubuntu/archives/ubuntu-base

wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.2/release/ubuntu-base-16.04.2-base-arm64.tar.gz

Will download them into the directory.
If you go here: http://cdimage.ubuntu.com/ubuntu-base/releases/
you can peruse all versions

1 Like

I see there is also http://cdimage.ubuntu.com/ubuntu-base/releases/17.04/release/ubuntu-base-17.04-base-arm64.tar.gz
why not just try that one to get buntu17 running on VIM ?
And may I ask what is the difference between BASE and SERVER images ?

I dont know. Im still learning, but I guess you could use that.

What I dont know is how/where the kernel is coming and loaded. There is one compiled into the ramdisk image:

git clone https://github.com/khadas/linux -b ubuntu
git clone https://github.com/khadas/initrd
make ARCH=arm64 kvim_defconfig
make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image kvim.dtb modules
make -C initrd
./utils/mkbootimg --kernel linux/arch/arm64/boot/Image --ramdisk images/initrd.img -o images/boot.img

The one from the github is 4.9.29

Then the kernel in the 16.04.2 is 4.4

once I have an image made and loaded and I run it, I might know a little more!

Perhaps @Gouwa could weigh in.

1 Like

in this thread : [How to] Debian Stretch + Linux 4.9 from scratch (w/download, EMMC only)
they explain how to compile initrd, kernel, uboot, etc… for debian 9
maybe we should get complementary info from there!

IHMO for the BSP kernel (3.14) only.

Sorry, in your server.sh, this command fails
sudo cp -r archives/filesystems/etc/initramfs-tools/ XXX
because there is no filesystems/etc/initramfs-tools/ in https://github.com/khadas/fenix/tree/master/archives

you maybe did not upload thoses files yet ??

Rough rundown:

Setup working dirs

cd ~
install -d ~/project/khadas/ubuntu/{linux,rootfs,archives/{ubuntu-base,debs,hwpacks},images,scripts,logo,release}
cd ~/project/khadas/ubuntu/


sudo apt-get install gcc-arm-none-eabi
sudo apt-get install gcc-aarch64-linux-gnu
sudo apt-get install qemu qemu-user-static binfmt-support debootstrap
sudo apt-get install lib32stdc++6 libstdc++6

Git Clones

cd ~/project/khadas/ubuntu/
git clone https://github.com/khadas/u-boot -b ubuntu
git clone https://github.com/khadas/linux -b ubuntu
git clone https://github.com/khadas/initrd
git clone https://github.com/khadas/utils.git
cd ~/project/khadas/ubuntu/images
git clone https://github.com/khadas/images_upgrade.git upgrade
cd ~/project/khadas/
git clone https://github.com/khadas/fenix.git

###Download core
cd ~/project/khadas/ubuntu/archives/ubuntu-base
wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.2/release/ubuntu-base-16.04-base-arm64.tar.gz

Make a logo

  • Needed for the script, or edit the script! - I just nicked this bmp link from the forums (mmeyer) and probably doesnt relate to ubuntu specifically.

cd ~/project/khadas/ubuntu/logo
wget https://meyer.io/dl/khadasvim/debian-bootup.bmp
cd ~/project/khadas/ubuntu
./utils/logo_img_packer logo/debian-bootup.bmp images/logo.img

Move fenix scripts

cp -r …/fenix/scripts/* scripts
cp -r …/fenix/archives/* archives


cd ~/project/khadas/ubuntu/scripts

All this is copy/paste from my notes and off my head (I just had a monumental HDD failure, and am rebuilding). Let me know if it doesnt work or I missed a step, I’ll make an amendment.

Hmmm… This seems to only work for server images, however the makefile shows other images as well. And ofcourse there are the mali binaries. So the obvious question is, how do i build an ubuntu mate image with mali drivers.

Hopefully we see the scripts for making the ubunt-mate image soon also.
I got to having an Xserver running, and mate installed. But still lots more to do.

Perhaps @gouwa can post the other scripts in due course.

The only major changes will be what is in the RUNME.sh script I would imagine.

Currently, as Chroot still didn’t support some feature(forgot),so we still use a stupid approach to build Mate(on target):

  1. Build Ubuntu server ROM
  2. Burn to VIM
  3. install Mate Desktop(run a script)
  4. backup rootfs and tarball Mate ROMs manually.

Here paste the script for reference first, and we will keep researching:


## Backup root file system
## Usage: run follows manualy
# 1) mount /dev/sda1 /media
# 2) /media/mate.sh <MAC-ADDRESS>

## Admin user
# To generate encrypted password:
# 1) password="khadas"
# 2) perl -e 'printf("%s\n", crypt($ARGV[0], "password"))' "$password"
useradd -m -p "pal8k5d7/m9GY" -s /bin/bash khadas
usermod -aG sudo,adm khadas

## Network
cp -a /etc/network/interfaces /etc/network/interfaces.orig
echo "auto eth0" >> /etc/network/interfaces
echo "iface eth0 inet dhcp" >> /etc/network/interfaces
ifconfig eth0 down
if [ -n "$1" ] ; then
	echo "Mac address: $1"
	ifconfig eth0 hw ether $1
	echo "Use default Mac address: 00:15:18:01:81:32"
	ifconfig eth0 hw ether 00:15:18:01:81:32
ifconfig eth0 up
/etc/init.d/networking restart

## Apt sources.list: add [universe] and [multiverse] repositories
sed -i "s/^# deb http/deb http/g" /etc/apt/sources.list

## Mirrors
cp -a /etc/apt/sources.list /etc/apt/sources.list.orig
sed -i "s/http:\/\/ports.ubuntu.com\/ubuntu-ports\//http:\/\/mirrors.ustc.edu.cn\/ubuntu-ports\//g" /etc/apt/sources.list

## Mate desktop
apt update
apt -y upgrade
apt -y install mate-desktop-environment ubuntu-mate-core

## Gnome-player
apt -y install gnome-mplayer

## Bluetooth menu
apt -y install bluetooth blueman

## Restore
apt clean
mv /etc/apt/sources.list.orig /etc/apt/sources.list
mv /etc/network/interfaces.orig /etc/network/interfaces
# TODO history -c
# TODO /var/log

## Done
echo "Done."

## backup rootfs.img
echo "Start to backup root file system ..."
dd if=/dev/rootfs of=/media/rootfs.img
echo "Generating MD5 checksum:"
md5sum /media/rootfs.img > /media/rootfs.img.md5

## umount
sleep 3
umount /media

One item that might not “work” is blueman. However… If you install it during the RUNME script, it will be okay (error that it didnt configure). But at first apt-get when booted, it will then configure itself.

I have a script that essentially builds a ubuntu-mate based on fenix.

I will post it shortly once I tidy it up. However - I cannot seem to get wifi to be recognised at this stage, looking into it.

ok, as my previous attempts did more or less fail while following the other published howTos, I today give your walkthrough instructions a try, I’ll let everybody know the result below… wish me luck

while running clean.sh for the very 1st time, this is what I got

Cleaning: images...

Cleaning: U-Boot...

Cleaning: Linux...

scripts/basic/fixdep.c:462:1: fatal error: opening dependency file scripts/basic/.fixdep.d: Permission denied
compilation terminated.
make[4]: *** [scripts/basic/fixdep] Error 1
make[3]: *** [scripts_basic] Error 2

@Gouwa, @Tang73 is this a blocking error ? tks

and I get another error at the end :slight_smile: when I exit the chroot session…

 root@bodhi-giada:/# exit
cp: cannot stat ‘rootfs/boot/initrd.img’: No such file or directory
error: could not load ramdisk 'images/initrd.img'
rm: cannot remove ‘rootfs/boot/initrd.img’: No such file or directory
[Msg]Pack Item[USB         ,              DDR] from (images/upgrade/u-boot.bin.usb.bl2),sz[0xc000]B,
[Msg]Pack Item[USB         ,            UBOOT] from (images/upgrade/u-boot.bin.usb.tpl),sz[0xd4000]B,ft[normal]
[Msg]Pack Item[UBOOT       ,     aml_sdc_burn] from (images/upgrade/u-boot.bin.sd.bin),sz[0xe0200]B,ft[normal]
[Msg]Pack Item[ini         ,     aml_sdc_burn] from (images/upgrade/aml_sdc_burn.ini),sz[0x24d]B,
[Msg]Pack Item[PARTITION   ,       bootloader] from (images/upgrade/u-boot.bin),sz[0xe0000]B,ft[normal]
[Msg]Pack Item[VERIFY      ,       bootloader] from (images/upgrade/u-boot.bin),vry[sha1sum 1a8bde91fe7e4f4f807692e3f7d907d86d1ac5ce]
[Msg]Pack Item[PARTITION   ,             logo] from (images/upgrade/logo.img),[ERR]f(AmlImagePack.cpp)L1332:failed to open source file : images/upgrade/logo.img 
Image pack FAILED


Something definitely went wrong; I cannot say yet that the info from @Tang73 were enough for me to succeed !

sorry to report another failure, this time when applying your instructions @Gouwa,
make clean was ok, but
here is the end of “make server” :

INSTALL drivers/usb/serial/cp210x.ko
INSTALL drivers/usb/serial/ftdi_sio.ko
INSTALL drivers/video/backlight/lcd.ko
INSTALL drivers/usb/serial/iuu_phoenix.ko
INSTALL drivers/video/fb_sys_fops.ko
INSTALL drivers/video/syscopyarea.ko
INSTALL drivers/video/sysimgblt.ko
INSTALL drivers/video/sysfillrect.ko
INSTALL fs/autofs4/autofs4.ko
INSTALL fs/cifs/cifs.ko
INSTALL fs/ecryptfs/ecryptfs.ko
INSTALL fs/f2fs/f2fs.ko
INSTALL fs/fscache/fscache.ko
INSTALL fs/fuse/fuse.ko
INSTALL fs/hfs/hfs.ko
INSTALL fs/hfsplus/hfsplus.ko
INSTALL fs/jfs/jfs.ko
INSTALL fs/lockd/lockd.ko
INSTALL fs/nfs/blocklayout/blocklayoutdriver.ko
INSTALL fs/nfs/nfs.ko
INSTALL fs/nfs/nfs_layout_nfsv41_files.ko
INSTALL fs/nfs/nfsv2.ko
INSTALL fs/nfs/nfsv3.ko
INSTALL fs/nfs/nfsv4.ko
INSTALL fs/nfs_common/nfs_acl.ko
INSTALL fs/nfsd/nfsd.ko
INSTALL fs/nls/nls_utf8.ko
INSTALL fs/ntfs/ntfs.ko
INSTALL fs/squashfs/squashfs.ko
INSTALL fs/xfs/xfs.ko
INSTALL lib/asn1_decoder.ko
INSTALL lib/cordic.ko
INSTALL lib/crc-t10dif.ko
INSTALL lib/lz4/lz4_compress.ko
INSTALL lib/lz4/lz4hc_compress.ko
INSTALL lib/oid_registry.ko
INSTALL lib/mpi/mpi.ko
INSTALL net/mac80211/mac80211.ko
INSTALL net/netfilter/ipset/ip_set.ko
INSTALL net/sunrpc/auth_gss/rpcsec_gss_krb5.ko
INSTALL net/sunrpc/auth_gss/auth_rpcgss.ko
INSTALL net/sunrpc/sunrpc.ko
INSTALL net/wireless/cfg80211.ko
INSTALL sound/core/snd-hwdep.ko
INSTALL sound/core/snd-rawmidi.ko
INSTALL sound/usb/caiaq/snd-usb-caiaq.ko
INSTALL sound/usb/6fire/snd-usb-6fire.ko
INSTALL sound/usb/hiface/snd-usb-hiface.ko
INSTALL sound/usb/misc/snd-ua101.ko
INSTALL sound/usb/snd-usb-audio.ko
INSTALL sound/usb/snd-usbmidi-lib.ko
DEPMOD 3.14.29
make: Leaving directory `/home/raxy/project/khadas/ubuntu/linux’
cp: cannot create regular file ‘rootfs/usr/local/bin/’: No such file or directory
cp: cannot create regular file ‘rootfs/lib/systemd/system/’: No such file or directory
cp: cannot create regular file ‘rootfs/usr/local/bin/’: No such file or directory
touch: cannot touch ‘rootfs/etc/default/FIRSTBOOT’: No such file or directory
cp: cannot create regular file ‘rootfs/usr/bin/’: No such file or directory


mount: mount point rootfs/proc does not exist
mount: mount point rootfs/sys does not exist
mount: mount point rootfs/dev does not exist
mount: mount point rootfs/dev/pts does not exist
chroot: failed to run command ‘/bin/bash’: No such file or directory
cp: cannot stat ‘rootfs/boot/initrd.img’: No such file or directory
error: could not load ramdisk 'images/initrd.img’
rm: cannot remove ‘rootfs/boot/initrd.img’: No such file or directory
umount: rootfs/dev/pts: not found
umount: rootfs/dev: not found
umount: rootfs/proc: not found
umount: rootfs/sys: not found
[Msg]Pack Item[USB , DDR] from (images/upgrade/u-boot.bin.usb.bl2),sz[0xc000]B,
[Msg]Pack Item[USB , UBOOT] from (images/upgrade/u-boot.bin.usb.tpl),sz[0xd4000]B,ft[normal]
[Msg]Pack Item[UBOOT , aml_sdc_burn] from (images/upgrade/u-boot.bin.sd.bin),sz[0xe0200]B,ft[normal]
[Msg]Pack Item[ini , aml_sdc_burn] from (images/upgrade/aml_sdc_burn.ini),sz[0x24d]B,
[Msg]Pack Item[PARTITION , bootloader] from (images/upgrade/u-boot.bin),sz[0xe0000]B,ft[normal]
[Msg]Pack Item[VERIFY , bootloader] from (images/upgrade/u-boot.bin),vry[sha1sum 13ff70bcbb0b2ac7367305656f0e6df58d2475f1]
[Msg]Pack Item[PARTITION , logo] from (images/upgrade/logo.img),[ERR]f(AmlImagePack.cpp)L1332:failed to open source file : images/upgrade/logo.img
Image pack FAILED


Hi ravelo,

Did you run RUNME.sh successfully in chroot? It seems that rootfs/boot/initrd.img which created by command mkinitramfs -o /boot/initrd.imgcat linux-version2>/dev/null in script RUNME.sh does not exist.


1 Like

Hi ravelo,

It seems that some directories are not exist. Which ubuntu base did you use?


hi, I used Ubuntu base 17.04
and I forgot to adjust server.sh to take it into account!
I gonna restart with fixed script and will report later.

by the way, the fenix instructions do build a kernel 3.14.29, right?