Ok,
here is the latest list of all the steps I followed to build an intermediate target : khadas UBOOT + linux 4.12 mainline + xenial on VIM pro
###Prepare project tree
cd ~ install -d ~/project/khadas/ubuntu/{linux,rootfs,archives/{ubuntu-base,debs,hwpacks},images,scripts} cd ~/project/khadas/ubuntu/
###Clone the utils repository to fetch the tools for development:
git clone https://github.com/khadas/utils.git
###Download the U-Boot source tree, take a notice of the branch ubuntu as the option when you run git clone:
git clone https://github.com/khadas/u-boot -b ubuntu
###Edit and change bootargs in
~/project/khadas/ubuntu/u-boot/board/khadas/configs/kvim.h
replace
"root=LABEL=ROOTFS rootflags=data=writeback rw logo=osd1,loaded,0x3d800000,1080p60hz vout=1080p60hz,enable hdmimode=1080p60hz console=ttyS0,115200n8 console=tty0 no_consol
with
"root=/dev/mmcblk0p1 rootflags=data=writeback rw rootwait console=ttyAML0,115200 console=tty0 earlyprintk=aml-uart,0xc81004c0 fsck.repair=yes governor=ondemand no_console_suspend elevator=noop\0" \
###Build UBOOT for Khadas VIM:
cd ~/project/khadas/ubuntu/u-boot/
make kvim_defconfig
make -j4 CROSS_COMPILE=aarch64-linux-gnu-
Generated files:
fip/u-boot.bin: bootloader blob for eMMC
###Build linux kernel mainline:
Fetch the linux mainline repository from Linus Torvalds’s GitHub repository:
cd ~/project/khadas/ubuntu/linux
git init
git remote add torvalds https://github.com/torvalds/linux.git
git fetch torvalds master
git checkout remotes/torvalds/master
###Patch a few files
Retrieve this patchset
Do a tar xzf on it, this will create a patches/ folder containing 7 .patch files
In that folder, replace 0004*patch with this newer version
Assuming that the patches are in ~/Downloads/patches/
apply these 4 ones…
cd ~/project/khadas/ubuntu/linux
git am ~/Downloads/patches/0001-CONFIG-add-kvim_defconfig-from-defconfig-for-VIM.patch
git am ~/Downloads/patches/0002-CONFIG-config-wifi-ethmac.patch
git am ~/Downloads/patches/0003-DTS-disable-scpi_clocks.patch
git am ~/Downloads/patches/0004-EMMC-add-EMMC-partitions-porting-from-amlogic-linux-.patch
git am ~/Downloads/patches/0006-CONFIG-remove-some-unused-modules.patch
###Patch ~/project/khadas/ubuntu/linux/drivers/Makefile manually
diff --git a/drivers/Makefile b/drivers/Makefile
index dfdcda0…ec2731d 100644
— a/drivers/Makefile
+++ b/drivers/Makefile
@@ -182,3 +182,4 @@ obj-$(CONFIG_FPGA) += fpga/
obj-$(CONFIG_FSI) += fsi/
obj-$(CONFIG_TEE) += tee/
obj-$(CONFIG_MULTIPLEXER) += mux/
+obj-$(CONFIG_AMLOGIC_DRIVER) += amlogic/
###Building kernel, dtb & modules
cd ~/project/khadas/ubuntu/linux
touch .scmversion
make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image amlogic/meson-gxl-s905x-khadas-vim.dtb modules
NB=> Answer ‘y’ for any question asked related to amlogic config option !
###Get ubuntu xenial base tarball…
cd ~/project
sudo wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.2/release/ubuntu-base-16.04.2-base-arm64.tar.gz
Now get inspired from [How to] Debian Stretch + Linux 4.9 from scratch (w/download, EMMC only)
and
###Build rootfs
cd ~/project
truncate --size 1300M rootfs.img
mkfs.ext4 -F -L ROOTFS rootfs.img
sudo mkdir /mnt/kvimrootfs
sudo mount -o loop rootfs.img /mnt/kvimrootfs
cd /mnt/kvimrootfs
sudo rm -rf * lost+found/
###expand xenial in this new rootfs
cd /mnt/kvimrootfs
sudo tar -xzf ~/project/ubuntu-base-16.04.2-base-arm64.tar.gz
###install kernel modules…
cd ~/project/khadas/ubuntu/linux
sudo make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH=/mnt/kvimrootfs
last output line will show
DEPMOD 4.12.0
(or 4.13.0-rc1 as of 22july17)
###prepare for chroot and apt installs…
sudo apt-get install qemu qemu-user-static binfmt-support debootstrap
###Setup the Chroot environment:
sudo cp -a /usr/bin/qemu-aarch64-static /mnt/kvimrootfs/usr/bin/
sudo mount -o bind /proc /mnt/kvimrootfs/proc
sudo mount -o bind /sys /mnt/kvimrootfs/sys
sudo mount -o bind /dev /mnt/kvimrootfs/dev
sudo mount -o bind /dev/pts /mnt/kvimrootfs/dev/pts
User account
USERNAME=khadas
PASSWORD=khadas
sudo chroot /mnt/kvimrootfs adduser --disabled-password --gecos "" $USERNAME
sudo chroot /mnt/kvimrootfs usermod -aG sudo $USERNAME
echo "$USERNAME:$PASSWORD" | sudo chroot /mnt/kvimrootfs chpasswd
Serial console
sudo chroot /mnt/kvimrootfs ln -s /lib/systemd/system/serial-getty\@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service
misc Packages
sudo chroot /mnt/kvimrootfs bash -c "echo 'nameserver 8.8.8.8' > /etc/resolv.conf"
sudo chroot /mnt/kvimrootfs apt update
sudo chroot /mnt/kvimrootfs apt install --yes --no-install-recommends sudo fbset network-manager initramfs-tools openssh-server
sudo chroot /mnt/kvimrootfs apt install --yes --no-install-recommends ifupdown net-tools udev vim ssh ping
Hostname
sudo chroot /mnt/kvimrootfs bash -c "echo ivnKhadasVIM > /etc/hostname"
Ramdisk build…
sudo chroot /mnt/kvimrootfs mkinitramfs -o /boot/initrd.img 4.13.0-rc1
will output lots of nvida warnings and one ERROR…
W: Possible missing firmware /lib/firmware/nvidia/gk20a/fecs_data.bin for module nouveau
Unsupported ioctl: cmd=0x5331
###Handle new initrd.img
sudo mv /mnt/kvimrootfs/boot/initrd.img ~/project
###Clean rootfs…
sudo chroot /mnt/kvimrootfs apt clean
sudo rm -f /mnt/kvimrootfs/usr/bin/qemu-aarch64-static
cd ~/project/khadas/ubuntu
sudo cp linux/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dtb /mnt/kvimrootfs
sudo sync
sudo umount /mnt/kvimrootfs/dev/pts
sudo umount /mnt/kvimrootfs/dev
sudo umount /mnt/kvimrootfs/sys
sudo umount /mnt/kvimrootfs/proc
sudo umount /mnt/kvimrootfs
###produce ramdisk.img
cd ~/project
khadas/ubuntu/utils/mkbootimg --kernel khadas/ubuntu/linux/arch/arm64/boot/Image --ramdisk initrd.img -o ramdisk.img
rm -f initrd.img
###Pack a logo
cd ~/project
wget https://meyer.io/dl/khadasvim/debian-bootup.bmp
khadas/ubuntu/utils/logo_img_packer debian-bootup.bmp logo.img
rm -f debian-bootup.bmp
###Fix the symlinks in image_upgrade/
cd ~/project/images_upgrade
ln -f -s ~/project/khadas/ubuntu/u-boot/fip/u-boot.bin u-boot.bin
ln -f -s ~/project/khadas/ubuntu/u-boot/fip/u-boot.bin.sd.bin u-boot.bin.sd.bin
ln -f -s ~/project/khadas/ubuntu/u-boot/fip/u-boot.bin.usb.bl2 u-boot.bin.usb.bl2
ln -f -s ~/project/khadas/ubuntu/u-boot/fip/u-boot.bin.usb.tpl u-boot.bin.usb.tpl
ln -f -s …/rootfs.img rootfs.img
ln -f -s …/ramdisk.img ramdisk.img
ln -f -s …/logo.img logo.img
ln -f -s ~/project/khadas/ubuntu/linux/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-khadas-vim.dtb kvim.dtb
###Pack the system update image…
cd ~/project
khadas/ubuntu/utils/aml_image_v2_packer -r images_upgrade/package.conf images_upgrade update.img
OUTPUTS…
raxy@bodhi-giada:~/project$ khadas/ubuntu/utils/aml_image_v2_packer -r images_upgrade/package.conf images_upgrade update.img
[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 bf01c06d1c6796cbf06f385038bfef2835fab42a]
[Msg]Pack Item[PARTITION , logo] from (images_upgrade/logo.img),sz[0x3f4910]B,ft[normal]
[Msg]Pack Item[VERIFY , logo] from (images_upgrade/logo.img),vry[sha1sum 16b3cc7f3ef4dc8480ffa75d73d7429eda975164]
[Msg]Pack Item[dtb , meson1] from (images_upgrade/kvim.dtb),sz[0x52c7]B,
[Msg]Pack Item[conf , platform] from (images_upgrade/platform.conf),sz[0xca]B,
[Msg]Pack Item[PARTITION , ramdisk] from (images_upgrade/ramdisk.img),sz[0x4c01000]B,ft[normal]
[Msg]Pack Item[VERIFY , ramdisk] from (images_upgrade/ramdisk.img),vry[sha1sum f59412522599c7f38fe58bdb6e4d1f835bde9db5]
[Msg]Pack Item[PARTITION , rootfs] from (images_upgrade/rootfs.img),sz[0x44c00000]B,ft[normal]
[Msg]Pack Item[VERIFY , rootfs] from (images_upgrade/rootfs.img),vry[sha1sum e65688a8c809600c3421001bba1fb77dbf37bc43]
[Msg]version:0x2 crc:0x9d8a56c5 size:1240060276 bytes[1182MB]
Pack image[update.img] OK
###nb: DOES THIS EVEN SEEM CORRECT FOR emmc ?
Then, flash the resulting update.img
Alas,
during burning of update.img, I get blocking errors