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

Hi,
Please find my effort at a script that will completely build an image for the emmc. Suitable for VIM1.

Image will be Ubuntu 16.04.2 (Or optionally you can try 17.04)
Linux Kernel is 4.9
Mate GUI

** Note: Installing 17.04 works. BUT - its not automatic - The damn perl Locale warnings are back, and it will ask you about your terminal encoding (Select UTF8 if unsure!) . So it will work, but be aware at some point in the jail process it will stop and wait for you to respond.

https://github.com/Stifler6996/khadas-build-script

You should not need to muck around with anything (he says with fingers tightly crossed!)
Have a go!

3 Likes

Forgot to mention,

The importance of this is:

Build whatever Ubuntu version you want.
Kernel is complete compilable - so like me, you can add (or remove) kernel components as required.

It builds GUI - no mucking about with other roms.

As others have noted - the screen resolutions need to be fixed.

I personally think that a note should be taken from other ROMS, and put the config in /BOOT … Then at least it is not [as much of a] screw around to change a screen res…

Tks pal, i will surely give your scripts a try.

good little unit! - hope it doesn’t melt under the stress :stuck_out_tongue:

3 Likes

did manage up to his point, then it went bezerk!

Do you need to run build_chroot_filesystem? [y/n/q]y
(0x07)#########################
(0x07) build_chroot_filesystem
(0x07)#########################
(0x07)~-~-~-~-~-~-~-~-~-~-~-~-~-
(0x07) Andy Warhol got it wrong
(0x07) 15 minutes is too long…
(0x07)~-~-~-~-~-~-~-~-~-~-~-~-~-
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0,000867701 s, 0,0 kB/s
[sudo] password for raxy:
mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: done
Filesystem label=ROOTFS
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
(0x07) Slipping a quick mount in…
(0x07) Ubuntu base going in…
(0x07) Kernel modules going in…
make: Entering directory /home/raxy/project/khadas-build-script/Khadas-Components/kernel-4.9' arch/arm64/Makefile:23: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum INSTALL drivers/media/usb/gspca/gspca_main.ko INSTALL drivers/net/wireless/bcmdhd/dhd.ko INSTALL fs/efivarfs/efivarfs.ko INSTALL net/bridge/br_netfilter.ko DEPMOD 4.9.26 make: Leaving directory/home/raxy/project/khadas-build-script/Khadas-Components/kernel-4.9’
(0x07)~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
(0x07) Greg! You missed the stop sign!
(0x07)~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
(0x07) initramfs scripts going in…
(0x07) rc.local scripts going in…
(0x07) Syncing rootfs.
(0x07) unmounting rootfs.
(0x07)##############################
(0x07) END: build_chroot_filesystem
(0x07)##############################
Do you need to run chroot_jail_run? [y/n/q]y
(0x08)#################
(0x08) chroot_jail_run
(0x08)#################
(0x08) Getting my full mount on…
chroot (A)utorun script, (M)anual mode or (B)ack out? [a/m/b]a
(0x08) ch’rooting in full auto!
/bin/bash: ./99.ChrootScript.sh: Permission denied
(0x08) Syncing rootfs.
(0x08) unmount; Climbing off, and flushing the evidence…
(0x08)######################
(0x08) END: chroot_jail_run
(0x08)######################
Do you need to run chroot_jail_mkinitrfs? [y/n/q]y
(0x09)#######################
(0x09) chroot_jail_mkinitrfs
(0x09)#######################
(0x09) Getting my full mount on…
chroot: failed to run command ‘mkinitramfs’: No such file or directory
cp: cannot stat ‘/home/raxy/project/khadas-build-script/SBC-Images/rootfs/boot/initrd.img’: No such file or directory
(0x09) Syncing rootfs.
(0x09) unmount; Climbing off, and flushing the evidence…
(0x09)############################
(0x09) END: chroot_jail_mkinitrfs
(0x09)############################
Do you need to run build_firmware_image? [y/n/q]y
(0x0a)######################
(0x0a) build_firmware_image
(0x0a)######################
(0x0a) Copying over DTB, kernel Image, U-Boot bins and config files

(0x0a) Making the images/logo package

./1.2.3.Run.sh: line 416: /home/raxy/project/khadas-build-script/Khadas-Components/utils/logo_img_packer: Permission denied

(0x0a) Making the ramdisk image
./1.2.3.Run.sh: line 420: /home/raxy/project/khadas-build-script/Khadas-Components/utils/mkbootimg: Permission denied

(0x0a)~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
(0x0a) A baseball cap and a love of rap might need
(0x0a) sympathy but still; possibly a homeboy could be,
(0x0a) a dickhead pure and simple…!
(0x0a)~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

./1.2.3.Run.sh: line 430: /home/raxy/project/khadas-build-script/Khadas-Components/utils/aml_image_v2_packer: Permission denied
mv: cannot stat ‘/home/raxy/project/khadas-build-script/SBC-Images/update.img’: No such file or directory

(0x0a)###########################
(0x0a) END: build_firmware_image
(0x0a)###########################

All Done!

maybe some exec perm missing as seen here ?? come on… 1.2.3* i did manually chmod …

raxy@bodhi-giada:~/project/khadas-build-script/Khadas-Components/scripts$ ll
total 72
drwxrwxr-x 5 raxy raxy 4096 juil. 23 17:48 ./
drwxrwxr-x 9 raxy raxy 4096 juil. 23 17:59 …/
-rwxrwxr-x 1 raxy raxy 20137 juil. 23 17:48 1.2.3.Run.sh*
-rw-rw-r-- 1 raxy raxy 4774 juil. 23 17:48 99.ChrootScript.sh
-rw-rw-r-- 1 raxy raxy 15 juil. 23 17:48 all
drwxrwxr-x 2 raxy raxy 4096 juil. 23 17:48 configs/
drwxrwxr-x 3 raxy raxy 4096 juil. 23 17:48 etc/
-rw-rw-r-- 1 raxy raxy 1285 juil. 23 17:48 find-mirrors.sh
drwxrwxr-x 2 raxy raxy 4096 juil. 23 17:48 img-pack-cfg/
-rw-rw-r-- 1 raxy raxy 1248 juil. 23 17:48 README - u-boot bootarg settings.txt
-rw-rw-r-- 1 raxy raxy 12 juil. 23 17:48 setup
-rw-rw-r-- 1 raxy raxy 1572 juil. 23 17:48 X.RemountRootfs.sh
-rw-rw-r-- 1 raxy raxy 1822 juil. 23 17:48 ZZZ.CleanImageDir.sh

finally restarted with “< all”, it has been running for many hours now,
i gonna sleep and see tomorrow how it ends

Yeah, you have a permissions propblem there.

When you grab it, make sure you chown it.! At times, it will do some sudo items. These may ask for your password, depending on how long it has been since you last entered sudo,

Because it couldnt copy the 99.xx script into the jail, it couldnt run it. Which means it didnt install init-tools. So it couldnt create initrd.

Lots of stuff would not have worked!

chown -R user:user /home/raxy/project/khadas-build-script/

Not sure why you need to do this, if you git cloned with your user, should have been okay.

hin
surely, most of, if not all, the exec permissions of your files have died in the trip from your computer to mine!!
I just did git clone your repo by the way;
I already chmod +x all the .sh files around 123*sh but this was not enough as seen in the traces below

Setting up gtk2-engines-pixbuf:armhf (2.24.30-1ubuntu1.16.04.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/bluetooth-khadas.service, pointing to /lib/systemd/system/bluetooth-khadas.service.
(0x63) Setting up eth0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
(0x63)############################
(0x63) END: Chroot install script 
(0x63)############################
(0x08) Syncing rootfs.
[sudo] password for raxy: 
(0x08) unmount; Climbing off, and flushing the evidence..
(0x08)######################
(0x08) END: chroot_jail_run 
(0x08)######################
(0x09)#######################
(0x09) chroot_jail_mkinitrfs 
(0x09)#######################
(0x09) Getting my full mount on.. 
Unsupported ioctl: cmd=0x5331
/etc/initramfs-tools/scripts/local-top/khadas_init.sh: 5: /etc/initramfs-tools/scripts/local-top/khadas_init.sh: cannot create /sys/class/display/mode: Directory nonexistent
/etc/initramfs-tools/scripts/local-top/khadas_init.sh: 6: /etc/initramfs-tools/scripts/local-top/khadas_init.sh: cannot create /sys/class/graphics/fb0/free_scale: Directory nonexistent
/etc/initramfs-tools/scripts/local-top/khadas_init.sh: 7: /etc/initramfs-tools/scripts/local-top/khadas_init.sh: cannot create /sys/class/graphics/fb0/freescale_mode: Directory nonexistent
/etc/initramfs-tools/scripts/local-top/khadas_init.sh: 12: /etc/initramfs-tools/scripts/local-top/khadas_init.sh: cannot create /sys/class/graphics/fb1/free_scale: Directory nonexistent
/etc/initramfs-tools/scripts/local-top/khadas_init.sh: 13: /etc/initramfs-tools/scripts/local-top/khadas_init.sh: cannot create /sys/class/graphics/fb1/freescale_mode: Directory nonexistent
/etc/initramfs-tools/scripts/local-top/khadas_init.sh: 14: /etc/initramfs-tools/scripts/local-top/khadas_init.sh: cannot create /sys/class/graphics/fb1/blank: Directory nonexistent
/etc/initramfs-tools/scripts/local-top/khadas_init.sh: 17: /etc/initramfs-tools/scripts/local-top/khadas_init.sh: cannot create /sys/class/leds/red/trigger: Directory nonexistent
(0x09) Syncing rootfs.
(0x09) unmount; Climbing off, and flushing the evidence..
(0x09)############################
(0x09) END: chroot_jail_mkinitrfs 
(0x09)############################
(0x0a)######################
(0x0a) build_firmware_image 
(0x0a)######################


(0x0a) Copying over DTB, kernel Image, U-Boot bins and config files


(0x0a) Making the images/logo package


./1.2.3.Run.sh: line 418: /home/raxy/project/khadas-build-script/Khadas-Components/utils/logo_img_packer: Permission denied


(0x0a) Making the ramdisk image 
./1.2.3.Run.sh: line 422: /home/raxy/project/khadas-build-script/Khadas-Components/utils/mkbootimg: Permission denied


(0x0a)~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
(0x0a) A baseball cap and a love of rap might need 
(0x0a) sympathy but still; possibly a homeboy could be, 
(0x0a) a dickhead pure and simple..! 
(0x0a)~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-


./1.2.3.Run.sh: line 432: /home/raxy/project/khadas-build-script/Khadas-Components/utils/aml_image_v2_packer: Permission denied
mv: cannot stat ‘/home/raxy/project/khadas-build-script/SBC-Images/update.img’: No such file or directory


(0x0a)###########################
(0x0a) END: build_firmware_image 
(0x0a)###########################


All Done!

I think I need to manually re-run these failed steps to help the 123sh finish its damn job:

${COMPONENT_ROOT}/utils/logo_img_packer -r ${OUTPUT_ROOT}/addtoimage ${OUTPUT_ROOT}/logo.img
${COMPONENT_ROOT}/utils/mkbootimg --kernel ${OUTPUT_ROOT}/Image --ramdisk ${OUTPUT_ROOT}/initrd.img -o ${OUTPUT_ROOT}/ramdisk.img
${COMPONENT_ROOT}/utils/aml_image_v2_packer -r ${SCRIPT_ROOT}/img-pack-cfg/package.conf ${OUTPUT_ROOT}/ ${OUTPUT_ROOT}/update.img
mv ${OUTPUT_ROOT}/update.img ${OUTPUT_ROOT}/release-kvim-`cat ${OUTPUT_ROOT}/linux-version`-`date +"%Y%m%d%H%M"`.img

…but I’ve seen other errors in the trace,
alas your script does not yet do proper error handling and it just proceeds to the next steps when they occur;
so maybe no guarantee at the end that all is ok.

My terminal session has not enough log depth so that I cannot see the entire trace of the 123sh from its beginning and it is waaaaay verbose (especially when doing apt update and install in chroot with thousands of packages!)

Another annoying thing you impose is the apt-get -y upgrade you do on our computers: this applies unexpected and uncontrolled changes one might not be willing to blindly accept.

Its true, the script does attempt to keep going (that is why there are prompts! So I can see where the failure is)

But: I cannot fathom how permissions are incorrect. Github couldn’t have done it. I dont think it remembers users - ah, perhaps it doesnt remember execute though.

chmod -R +x *.sh
chmod +x to utils dir?

Regarding the apt-get, it is all done in the chroot jail for the image. The only apt-get that affects your computer is the first step which configures the initial setup. Everything is very clear as to what gets installed at that step, check inside 123 to see.

As for apt-get in the jail (99 script), you can modify it as you please. The items that are there will build a full gui + a bit more. You can remove java and gtk2 safely with no affect.
You can of course edit the hell out of it if you like! What is there will get you to a GUI.

I am going to “pull it” from git to see what is going on. (Ive been working locally here, so I wouldnt see if there is a problem grabing it from git)

okay its github. Doesnt preserve x permission.
You can either:
cd ~ the place you did the git clone and have khadas-build-script folder
chmod -R 777 *
or
cd ~ the place you did the git clone and have khadas-build-script folder
chmod +x `cat plusXfiles`
(note backticks ` not ’ )

I’ll add that file (plusXfiles) to the github - when you run it, it will complain about some files not existing - only because they exist here - linux source etc)

If this hiccup is the all of it, I can make the script sort this stuff out.

tks for plusXfiles! I used it (and I commented out the 1st apt-get -y update)

I now test the whole process on a different and hopefully faster computer…

I’m going to go on a limb and guess that you are not totally familiar with apt-get.

Apt-get update - updates the local ‘database’ as to what is available from the servers. Nothing else.
apt-get upgrade - will look at what is installed, and what the “now new local db” says, and update everything that is older than db.
apt-get install - installs something
apt-get -y - doesnt ask ‘are you sure’ (which ubu decides based on the install size - htop, it will just install, but percona will ask - first for example)

apt-get -y update is superfluous! update doesnt do anything other than update local db. If I did this - it was an accident! :stuck_out_tongue:

sorry, I meant apt-get -y upgrade !
my bad
in fact , I’me a bit familiar w/ apt…

tks

okay!

Well inside the chroot jail - you need to do the update and the upgrade.

  • (from a testing point - you do not)

But to have a proper working solution at the other end that doesnt need a lot of fiddling, it is better that you do that earlier on :slight_smile:

Sure ! i understand that doing the apt-get update in chroot session prepare an up to date rootfs;
we could wait for the VIM to be booted to do that; but it could take a bit longer and a few other things further in the building of the rootfs content could suffer;
the fact is, it will install a huge bunch of other things more or lrss closely related;
I would suggest you exclude suggested packages when doing apt-get installs.

How long does it take to build the update.img from scratch (supposing you stay next to the kbd ready to press on the keys when required) ?

I would also suggest that depending on one’s location on earth, the URL of the repos for ubuntu packages should be chossen not on the other side of the planet (au is very far from eu)

the update.img @ 5GB doesnt take long - ~5min?
From start to finish for me - ~1hour. But I have fast internet and a local repo!. That is the delay for me.
compiling u-boot - 1min
Kernel <15 mins.
Of course - if you run my script the way it is configured you do not need to repeat some of that.

If you do not reconfigure uboot or kernel - then it will just reuse the previously built one. (say no to rebuild these when asked in 123.)

the creating rootfs and installing the ubu-base and kernel{modules} - 1 min.

All the delay is in your internet speed and the update of the rootfs chroot jail.

  • And if you get that to work correctly the first time, you can make a copy of the rootfs image as a backup. Then use the X script to remount it and play some more.
    If you make a mess of it, use your backup!

There are not many mirrors for the ubu “ports” repo with arm64 and main…

I have listed them all in the script file.

Included in the scipts folder is another script that will search all ubu mirrors for a repos you choose. (find-mirrors)