Linux Kernel¶
- Table of contents
- Linux Kernel
Before you begin¶
There are multiple ways to customize and compile the Linux kernel for your project. Please try to build the kernel as-is with no changes before you try to add your customizations. This will ensure your environment and toolchain are setup correctly.
- ARM toolchain - You can use a previously compiled ARM toolchain provided by ARM.
- Yocto Environment - If you are using the docker environment and Yocto for your filesystem, you can use its tools to customize and build your kernel.
In most cases, you will use one of the first two options for initial bring-up and testing. Then, once you have everything working you can integrate into Yocto.
Critical Link Kernel Repository¶
Critical Link recommends using the mitysom-linux-4.19
branch on our git server: https://support.criticallink.com/gitweb/?p=processor-sdk-linux.git;a=summary.
Other MitySOM-AM57x branches seen on the repository should not be considered stable, and are used for internal feature development.
The mitysom-linux-4.19 branch contains extensions to TI's processor-sdk-linux-4.19.y branch
TI also has the following linux repo which seem to contain patches not yet released to their processor-sdk. ti-linux-kernel
Kernel Build - ARM toolchain¶
Configuring the Kernel Build Environment¶
Install host utilities (Should only need to be done once)
sudo apt update sudo apt install build-essential bison flex libssl-dev you will need one of the following: sudo apt install libncurses-dev sudo apt install ncurses-devel
Download the ARM toolchain (Should only need to be done once)
mkdir -p /home/tools/mitysom-57x wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.xz -O - | tar -Jxv -C /home/tools/mitysom-57x/
Clone the kernel sources
git clone --branch mitysom-linux-4.19 https://support.criticallink.com/git/processor-sdk-linux.git cd processor-sdk-linux
Setup the build environment using the following commands (Required everytime you launch a new shell):
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf- export PATH=$PATH:/home/tools/mitysom-57x/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin
Customize your kernel¶
Now that you have the kernel source code, you can customize as needed. For most projects, you will want a custom defconfig and a custom device tree. One way to create a custom defconfig is to start with a known config and edit it using the kernel's menuconfig interface:
$ make mitysom-am57x-devkit_defconfig $ make menuconfig
Press <esc> to exit the menuconfig interface and make sure you save your changes.
Please contact Critical Link at info@criticallink.com if you need help with customizing your defconfig and Device Tree for your application.
DRAFT: Add notes on how to integrate new dts and to extract the Critical Link baseboard defconfig and dts from the Yocto build.
Building the kernel¶
Run the following commands to build the kernel.
$ make dtbs $ make zImage $ make modules $ make INSTALL_MOD_PATH=../rootfs modules_install
This will build the required modules and then install them under ../rootfs
The zImage will be located at arch/arm/boot/zImage
The built dtbs will be located at arch/arm/boot/dts/*.dtb
Note: We've added a build.sh script to the kernel directory to make it easier remember how to run a build. Feel free to modify and use it. Of note, it builds the kernel in a separate build directory "./build-mitysom57x" so all build outputs will be under that directory instead.
If you are building the kernel in /home/username/build/processor-sdk-linux
, the modules can be found in /home/username/build/rootfs/lib/.
You would then copy the lib directory onto your target FS under /lib.
Alternatively, you can modify INSTALL_MOD_PATH to point to the location of your mounted rootfs. This will allow you to skip the manual copy step.
If INSTALL_MOD_PATH is omitted, the modules_install target will install the modules under /lib on your build machine, which is highly likely to NOT be what you want!
Note: There are several out of tree kernel modules which are built by yocto and needed for some peripherals like the gpu or pruss/dsp communication. This extra directory needs to be copied to the newly created /lib/modules directory as well.
root@mitysom-am57x:~# ls /lib/modules/4.19.94-g913a232ac5/extra/ cmemk.ko debugss_kmodule.ko gdbserverproxy.ko uio_module_drv.ko cryptodev.ko galcore.ko pvrsrvkm.ko
Sample copy commands for all the artifacts:
# use your IP address instead of 10.0.103.50 TARGET=root@10.0.103.50 ssh ${TARGET} ln -s -f zImage-custom /boot/zImage scp arch/arm/boot/zImage ${TARGET}:/boot/zImage-custom scp arch/arm/boot/dts/*am57xx-mitysom*.dtb ${TARGET}:/boot # cd to where INSTALL_MOD_PATH was pointing to cd ../rootfs/ rsync -avr lib ${TARGET}:/ # Copy extra directory ssh ${TARGET} root@mitysom-am57x:~# cd /lib/modules/ root@mitysom-am57x:~# ls 4.19.94-g913a232ac5/extra/ cmemk.ko debugss_kmodule.ko gdbserverproxy.ko uio_module_drv.ko cryptodev.ko galcore.ko pvrsrvkm.ko root@mitysom-am57x:~# cp -R 4.19.94-g913a232ac5/extra 4.19<rest_of_name>/
Note: We've added a push.sh script to the kernel directory to make it easier to push changes to a running board. Feel free to modify and use it. Note it expects the build to be run with the options from the build.sh script.
Kernel Build - Yocto¶
For this option, you should have an environment setup as described in Docker build environment and Building the Yocto Root Filesystem for MitySOM-AM57X.
With this option, the general Yocto setup configures your build environment. You can compile your kernel by running bitbake commands from your build directory.
Customize your kernel¶
You can change the configuration of the kernel by running:
user@8ec23474095b:~$ MACHINE=mitysom-am57x bitbake -c menuconfig virtual/kernel
Building the kernel¶
Then, to build the kernel:
user@8ec23474095b:~$ MACHINE=mitysom-am57x bitbake virtual/kernel
Go to top