How to build an upstream kernel for the phyBoard-Mira i.MX6 Quad utilizing an SDK
Objectives
This post shows you: “How to build an upstream kernel for the phyBoard-Mira i.MX6 Quad utilizing an SDK.
Prerequisites
I assume that you have git
and a suitable Yocto Project® standard or extensible software development kit (SDK) installed. In case you don’t have such an SDK and want to build one you could set up my build framework as described here:
Mission
In a development workflow kernel developers typically want to compile the upstream Linux kernel without bitbake
. They might want to use an SDK created by the Yocto Project®, or as a matter of fact, any somewhat recent Linux SDK .
Get the code and patch, if necessary
Now what?
First we need to get the kernel sources. Let’s do that with git
.
# in case it does not exist, create it mkdir -p ${HOME}/imx6q-phytec-mira-rdk-nand # get into the dir cd ${HOME}/imx6q-phytec-mira-rdk-nand # clone from kernel.org git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-stable-custom
Let’s get a very specifc version
# in case you are not already there, get into the dir cd ${HOME}/imx6q-phytec-mira-rdk-nand/linux-stable-custom # check branches git branch # checkout the master branch git checkout master # check tags on master git tag -l # in case the branch already exits you could remove it like this: (optional) git branch -D v5.10.17_LOCAL # checking out version v5.10.17 git checkout v5.10.17 # create local branch, which is a copy of it git checkout -b v5.10.17_LOCAL
In case we want to boot with a root file system over nfs we need a patch
Something like that:
From 1e56c6abb1901aa482936d8d809ebd489d2a48dd Mon Sep 17 00:00:00 2001 From: Robert Berger <git@ReliableEmbeddedSystems.com> Date: Wed, 30 May 2018 20:04:18 +0200 Subject: [PATCH] revert patch e7e73b10d690c5352cb11b1941a09e4f3dc4c8ce because I can not use imx6q-phytec-mira-rdk-nand with it - no network Signed-off-by: Robert Berger <git@ReliableEmbeddedSystems.com> --- drivers/net/ethernet/freescale/fec_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index eb2ea23..aca7e10 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3458,10 +3458,12 @@ fec_probe(struct platform_device *pdev) goto failed_regulator; } } else { + #if 0 if (PTR_ERR(fep->reg_phy) == -EPROBE_DEFER) { ret = -EPROBE_DEFER; goto failed_regulator; } + #endif fep->reg_phy = NULL; } -- 2.7.4
Build
Build the statically linked kernel
# in case you are not already there, get into the dir cd ${HOME}/imx6q-phytec-mira-rdk-nand/linux-stable-custom # set up the cross-compile environment (this assumes you installed an SDK before) e.g. source /opt/resy/3.2+snapshot/environment-setup-armv7at2hf-vfp-resy-linux-gnueabi # build the default configuration make multi_v7_defconfig # build the kernel time make -j $(getconf _NPROCESSORS_ONLN) LOADADDR=0x00 uImage UIMAGE_TYPE=kernel_noload EXTRAVERSION=-custom-${USER}
How to build the flattened device tree (fdt)?
# in case you are not already there, get into the dir cd ${HOME}/imx6q-phytec-mira-rdk-nand/linux-stable-custom # build the fdt make imx6q-phytec-mira-rdk-nand.dtb EXTRAVERSION=-custom-${USER}
Build the kernel modules
# in case you are not already there, get into the dir cd ${HOME}/imx6q-phytec-mira-rdk-nand/linux-stable-custom # build the kernel modules time make -j $(getconf _NPROCESSORS_ONLN) modules EXTRAVERSION=-custom-${USER}
Installation of various things
Install kernel modules
# in case you are not already there, get into the dir cd ${HOME}/imx6q-phytec-mira-rdk-nand/linux-stable-custom # install kernel modules on some nfs export sudo make modules_install ARCH=${ARCH} INSTALL_MOD_PATH=/opt/resy/3.2+snapshot/multi-v7-ml/imx6q-phytec-mira-rdk-nand/core-image-sato-sdk-multi-v7-ml
Copy the statically linked kernel/fdt to the tftp
Note: My boot loader is configured in a way, that it grabs the kernel/fdt over tftp.
# assumption: # the tftp export is: /tftpboot/imx6q-phytec-mira-rdk-nand # the bootloader wants to load over tftp: # kernel: uImage # fdt: uImage-imx6q-phytec-mira-rdk-nand.dtb # # in case you are not already there, get into the dir cd ${HOME}/imx6q-phytec-mira-rdk-nand/linux-stable-custom # statically linked kernel cp ${HOME}/imx6q-phytec-mira-rdk-nand/linux-stable-custom/arch/arm/boot/uImage /tftpboot/imx6q-phytec-mira-rdk-nand/uImage-linux-stable-custom-v5.10.17 pushd /tftpboot/imx6q-phytec-mira-rdk-nand ln -sf uImage-linux-stable-custom-v5.10.17 uImage ls -la /tftpboot/imx6q-phytec-mira-rdk-nand popd # fdt cp ${HOME}/imx6q-phytec-mira-rdk-nand/linux-stable-custom/arch/arm/boot/dts/imx6q-phytec-mira-rdk-nand.dtb /tftpboot/imx6q-phytec-mira-rdk-nand/imx6q-phytec-mira-rdk-nand.dtb-linux-stable-custom-v5.10.17 pushd /tftpboot/imx6q-phytec-mira-rdk-nand ln -sf imx6q-phytec-mira-rdk-nand.dtb-linux-stable-custom-v5.10.17 uImage-imx6q-phytec-mira-rdk-nand.dtb ls -la /tftpboot/imx6q-phytec-mira-rdk-nand
Conclusion
Now you should be able to build your own upstream kernel. For a blog post about the Yocto Project® kernel tooling have a look here. If you want to learn more about how Embedded Linux works have a look here. To learn more about the Yocto Project® have a look here.