Test mainline kernel and Ubuntu image on i.CoreMX6
Prerequisite packets:
install the packet:
sudo apt-get install gparted git build-essential libncurses5 wget u-boot-tools zlib1g-dev ncurses-dev \
cmake libc-dev-armhf-cross pkg-config-arm-linux-gnueabihf build-essential checkinstall cmake \
pkg-config lzop libc6 libstdc++6 debootstrap qemu-user-static binfmt-support
Prepare toolchain
Download the arm cross-compile:
wget https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabihf/gcc-linaro-7.2.1-2017.11-i686_arm-linux-gnueabihf.tar.xz
and unpack it.
tar -xvf gcc-linaro-7.2.1-2017.11-i686_arm-linux-gnueabihf.tar.xz
Download and build u-boot
git clone http://git.denx.de/u-boot.git/ -
git checkout v2017.11
/home/matteo/_work_/test-ubuntu/
export ARCH=arm
export CROSS_COMPILE=../gcc-linaro-7.2.1-2017.11-i686_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
make imx6qdl_icore_mmc_defconfig
make
Download and build Linux kernel
Download the latest source code:
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.15.7.tar.xz
and unpack it.
tar -xvf linux-4.15.7.tar.xz
build the kernel:
export ARCH=arm
export CROSS_COMPILE=../gcc-linaro-7.2.1-2017.11-i686_arm-linux-gnueabihf//bin/arm-linux-gnueabihf-
export LOADADDR=0x10008000
cd linux-4.15.7
make imx_v6_v7_defconfig
make -j 8 uImage
make dtbs
Download and build an Ubuntu root filesystem
We'll use the debootstrap tool:
export target=ubuntu-rootfs
export distro=artful
sudo debootstrap --arch=armhf --foreign --include=ubuntu-keyring,apt-transport-https,ca-certificates,openssl $distro "$target" http://ports.ubuntu.com
sudo cp /usr/bin/qemu-arm-static $target/usr/bin
sudo cp /etc/resolv.conf $target/etc
Now have a minimal Ubuntu rootfs - chroot to it and perform the 2nd stage install:
sudo chroot $target
distro=artful
export LC_ALL=C LANGUAGE=C LANG=C
/debootstrap/debootstrap --second-stage
Now Edit the sources. list repositories
vi /etc/apt/sources.list
and enter:
deb http://ports.ubuntu.com/ubuntu-ports/ artful main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ artful-updates main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ artful-security main restricted universe multiverse
set the root password:
passwd root
And then launch the visudo command
visudo
Under the line that looks like:
root ALL=(ALL:ALL) ALL
now add ubuntu keys
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32
apt-get update
apt -y -f install
apt-get upgrade
Now you can install extra packets with apt command. Ex:
apt-get install nano
Now your rootfs is ready.
Exit chroot and remove useless file:
exit
sudo rm $target/etc/resolv.conf
sudo rm $target/usr/bin/qemu-arm-static
Now build the kernel module and firmware:
cd linux-4.15.7/
export ARCH=arm
export CROSS_COMPILE=../gcc-linaro-7.2.1-2017.11-i686_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
make modules
sudo make modules_install INSTALL_MOD_PATH=../ubuntu-rootfs/ ARCH=arm
Prepare SD card.
suppose that your sd card is mounted as /dev/sdc
export DISK=/dev/sdc
- Flash the SPL image into the micro SD card:
sudo dd if=u-boot/SPL of=${DISK} bs=1k seek=1; sync
- Flash the u-boot-dtb.img image into the micro SD card:
sudo dd if=u-boot/u-boot-dtb.img of=${DISK} bs=1k seek=69; sync
sudo fdisk ${DISK}
steps:
d ///delete all partitions currently on sd
n // create new partition
p // Primary partition
1 // partition number 1
8192 //default
+32M //
n // created 2d parition
p
2
73728
default
w
sudo mkfs.vfat ${DISK}1
sudo mkfs.ext3 ${DISK}2
sudo mount ${DISK}1 /mnt
sudo cp linux-4.15.7/arch/arm/boot/uImage /mnt/
sudo cp linux-4.15.7/arch/arm/boot/dts/imx6q-icore.dtb /mnt/
sudo umount /mnt
sudo mount ${DISK}2 /mnt
sudo cp -arf ubuntu-rootfs/* /mnt/
sudo umount /mnt