Try to build Ubuntu image


#1

I will try to build ubuntu EMMC image. Refer to Docs.khadas.com.

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

$ cd ~/project/khadas/ubuntu/

1. Clone the utils
$ cd ~/project/khadas/ubuntu/
$ git clone https://github.com/khadas/utils.git

  1. download and build u-boot
    $ cd ~/project/khadas/ubuntu/
    $ git clone https://github.com/khadas/u-boot -b ubuntu
    $ cd u-boot
    $ make kvim_defconfig
    $ make -j8 CROSS_COMPILE=aarch64-linux-gnu-
    $ cp fip/gxl/u-boot.bin …/images

  2. download and build linux kernel
    $ cd ~/project/khadas/ubuntu/
    $ git clone https://github.com/khadas/linux -b ubuntu
    $ cd linux
    $ make ARCH=arm64 kvim_defconfig
    $ make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image kvim.dtb modules

  3. Get ubuntu base
    $ cd ~/project/khadas/ubuntu/
    $ sudo wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.2/release/ubuntu-base-16.04.2-base-arm64.tar.gz

  4. Build rootfs
    $ install -d rootfs
    $ dd if=/dev/zero of=images/rootfs.img bs=1M count=0 seek=3584
    $ sudo mkfs.ext4 -F -L ROOTFS images/rootfs.img
    $ sudo mount -o loop images/rootfs.img rootfs
    $ sudo rm -rf rootfs/lost+found
    $ sudo tar -xzf ubuntu-base-16.04.2-base-arm64.tar.gz rootfs/
    $ ls /rootfs/
    bin boot dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
    $ cd linux
    $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH=…/rootfs/ -j8
    check modules:
    $ ls /rootfs/lib/modules

  5. Chroot and Setup
    $ sudo apt-get install qemu qemu-user-static binfmt-support debootstrap
    $ cd ~/project/khadas/ubuntu/
    $ sudo cp -a /usr/bin/qemu-aarch64-static /mnt/usr/bin/
    $ sudo mount -o bind /proc /mnt/proc
    $ sudo mount -o bind /sys /mnt/sys
    $ sudo mount -o bind /dev /mnt/dev
    $ sudo mount -o bind /dev/pts /mnt/dev/pts
    $ sudo chroot rootfs/
    Now starting setup the rootfs

echo root:khadas | chpasswd

useradd -G sudo -m -s /bin/bash khadas

echo khadas:khadas | chpasswd

echo Khadas > /etc/hostname

echo “127.0.0.1 localhost.localdomain localhost” > /etc/hosts

echo “127.0.0.1 Khadas” >> /etc/hosts

echo “nameserver 8.8.8.8” > /etc/resolv.conf

Fetch the package:

apt-get update

apt-get upgrade

apt-get install ifupdown net-tools

apt-get install udev

apt-get install vim sudo ssh

apt-get install initramfs-tools

mkinitramfs -o /boot/initrd.img 3.14.29

apt-get install fbset

exit

  1. Generate ramdisk.img
    $ sudo cp rootfs/boot/initrd.img images/initrd.img
    $ cd ~/project/khadas/ubuntu
    $ sudo ./utils/mkbootimg --kernel linux/arch/arm64/boot/Image --ramdisk /images/initrd.img -o /images/ramdisk.img

Test the u-boot.bin and ramdisk.img
Copy the u-boot.bin and ramdisk.img to U disk. Then boot the VIM target board and insert the U disk
to VIM board USB port.
Power on VIM board, type the enter key on the console window, then enter the cmd line.

usb-update bootloader u-boot.bin

reboot the board, it’s ok.

usb-update ramdisk ramdisk.img

update complete. reboot the board, currupt, it can not load the Image.


#2

Hi yamyahan,

Please refer to this topic