Fenix: One Stop Scripts Set to build Ubuntu

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/

Apt-Gets

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

GO!

cd ~/project/khadas/ubuntu/scripts
./clean.sh
./server.sh

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.

Correct,
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:

#!/bin/sh

## 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
else
	echo "Use default Mac address: 00:15:18:01:81:32"
	ifconfig eth0 hw ether 00:15:18:01:81:32
fi
ifconfig eth0 up
/etc/init.d/networking restart
#ifconfig


## 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."
reboot


## backup rootfs.img
echo "Start to backup root file system ..."
dd if=/dev/rootfs of=/media/rootfs.img
sync
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...
KBUILD_CFLAGS_MODULE:-DMODULE

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
Done.

@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
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

Done.

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

NOTE: YOU ARE NOW IN THE VIRTUAL TARGET, SETUP ANYTHING YOU WANT.
TYPE ‘exit’ TO CONTINUE IF FINISHED.

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

Done.

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.

Thanks.

1 Like

Hi ravelo,

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

Thanks.

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?

Hi ravelo,

Yes, it is OK.

  INSTALL sound/usb/caiaq/snd-usb-caiaq.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/nick/project/khadas/ubuntu/linux'

NOTE: YOU ARE NOW IN THE VIRTUAL TARGET, SETUP ANYTHING YOU WANT.
      TYPE 'exit' TO CONTINUE IF FINISHED.

root@Server:/# ls
RUNME.sh  bin  boot  dev  etc  home  lib  linux-version  media	mnt  opt  proc	root  run  sbin  srv  sys  tmp	usr  var
root@Server:/# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=17.04
DISTRIB_CODENAME=zesty
DISTRIB_DESCRIPTION="Ubuntu 17.04"

2 Likes

hello, ok, here are some new errors after I adjusted server.sh to handle ubuntu 17.04;
the errors are when I enter the chroot session and I run ./RUNME.sh

NOTE: YOU ARE NOW IN THE VIRTUAL TARGET, SETUP ANYTHING YOU WANT.
      TYPE 'exit' TO CONTINUE IF FINISHED.
root@bodhi-DELL-T3400:/# ls
RUNME.sh  boot  etc   lib            media  opt   root  sbin  sys  usr
bin       dev   home  linux-version  mnt    proc  run   srv   tmp  var
root@bodhi-DELL-T3400:/# ./RUNME.sh
/
Get:1 http://mirrors.ustc.edu.cn/ubuntu-ports zesty InRelease [243 kB]
Get:2 http://mirrors.ustc.edu.cn/ubuntu-ports zesty-updates InRelease [89.2 kB]           
Err:1 http://mirrors.ustc.edu.cn/ubuntu-ports zesty InRelease                             
  Unknown error executing apt-key
Get:3 http://mirrors.ustc.edu.cn/ubuntu-ports zesty-backports InRelease [89.2 kB]         
Err:2 http://mirrors.ustc.edu.cn/ubuntu-ports zesty-updates InRelease                     
  Unknown error executing apt-key
Get:4 http://mirrors.ustc.edu.cn/ubuntu-ports zesty-security InRelease [89.2 kB]          
Err:3 http://mirrors.ustc.edu.cn/ubuntu-ports zesty-backports InRelease                   
  Unknown error executing apt-key
Err:4 http://mirrors.ustc.edu.cn/ubuntu-ports zesty-security InRelease                    
  Unknown error executing apt-key
Reading package lists... Done                                                             
W: GPG error: http://mirrors.ustc.edu.cn/ubuntu-ports zesty InRelease: Unknown error executing apt-key
E: The repository 'http://mirrors.ustc.edu.cn/ubuntu-ports zesty InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.ustc.edu.cn/ubuntu-ports zesty-updates InRelease: Unknown error executing apt-key
E: The repository 'http://mirrors.ustc.edu.cn/ubuntu-ports zesty-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.ustc.edu.cn/ubuntu-ports zesty-backports InRelease: Unknown error executing apt-key
E: The repository 'http://mirrors.ustc.edu.cn/ubuntu-ports zesty-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.ustc.edu.cn/ubuntu-ports zesty-security InRelease: Unknown error executing apt-key
E: The repository 'http://mirrors.ustc.edu.cn/ubuntu-ports zesty-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Reading package lists... Done
Building dependency tree... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree... Done
E: Unable to locate package ifupdown
E: Unable to locate package net-tools
E: Unable to locate package udev
E: Unable to locate package fbset
E: Unable to locate package vim
E: Unable to locate package sudo
E: Unable to locate package initramfs-tools
E: Unable to locate package bluez
E: Unable to locate package rfkill
E: Unable to locate package libbluetooth-dev
E: Unable to locate package iputils-ping
./RUNME.sh: 48: ./RUNME.sh: systemctl: not found

maybe I have some connectivity issues ?

regarding absence of initrd.img,
I made this observation :
mkinitramfs should have been installed by a “apt get install initramfs-tools” but this command failed for some reason.

No mkinitramfs means no initrd.img,
so everything is messed up because of that.

I try to understand what is blocking and how to install the arm64 packages anyway

I checked on a 2nd computer, definitely, in the chroot session,
and in RUNME.sh, apt get install is able to find none of the wanted packages :

root@bodhi-giada:/# apt -y install ifupdown net-tools udev fbset vim sudo initramfs-tools bluez rfkill libbluetooth-dev iputils-ping
Reading package lists... Done
Building dependency tree... Done
E: Unable to locate package ifupdown
E: Unable to locate package net-tools
E: Unable to locate package udev
E: Unable to locate package fbset
E: Unable to locate package vim
E: Unable to locate package sudo
E: Unable to locate package initramfs-tools
E: Unable to locate package bluez
E: Unable to locate package rfkill
E: Unable to locate package libbluetooth-dev
E: Unable to locate package iputils-ping

Hi ravelo,

For Ubuntu 17.04, you may try the following commands in chroot session:

# cp /etc/apt/sources.list.orig /etc/apt/sources.list
# apt-get update
# apt-get -y --allow-unauthenticated upgrade
# apt-get -y --allow-unauthenticated  install ifupdown net-tools udev fbset vim sudo initramfs-tools  bluez rfkill libbluetooth-dev iputils-ping

Replace apt with apt-get in script RUNME.sh.

Thanks.

unable to locate most like means your nameserver isnt workling properly in chroot

You probably need to:
echo “nameserver 127.0.1.1” > /etc/resolv.conf
echo “nameserver 8.8.8.8” >> /etc/resolv.conf
That should fix it.

On another note, I dont think I will continue…
It is very disappointing to see a product like this with a total lack of support and process…

Khadas team - You need to supply a step-by-step for ANY build that is fully functional. I honestly dont believe you can work like this efficiently.

You have half baked scripts that create a linux with NO drivers.
You have half baked scripts that COPY drivers (so useless to even attempt to generate a newer version since depmod will fail).
You have not created a ‘proper’ GUI version.

Eveything that has been posted to build a system -forgets something- and then when that is fixed - forgets something else-

At some point you built a Ubuntu with a kernel 4.9 (if I remember correctly) in both server and in GUI. So how come someone on your team can not post an absolutely definitive step-to-step to recreate that process?

This needs to include all the little quirk modifications (like tweaking DTS files). everything.
This needs to be from scratch - no downloading core ingredients from your github. DRIVERS/Linux Core/Kernel/ U-Boot/ etc must all come from the lowest common possible denominator. Mali might be the only exception, but it should still be buildable for any kernel version etc…

And completion to a eMMC image - (or TF card, but either way) - complete steps for both, because there are some differences…

If you had this - people would be able to logically change one step at a time and test everything properly starting from a base process.

Also your forums would not be taken up with so much of the simpler support…

You would be helping yourselves out here.

I might also post this separately so its not lost.

1 Like