Pages

Tuesday, 11 April 2017

Build Linux Kernel for BeagleBone Black


Hi there!
BeagleBone Black is one of the most economical, widely used, community supported development platform available in the market. BeagleBone Black has a AM335x 1GHz ARM® Cortex-A8 processor and it is produced by Texas Instruments.
If you plan to learn/practice embedded systems and Linux Kernel, I would recommend you to buy this or any other development platform. Using a development platform gives you practical experience and increases your confidence.
This post gives details about how to build Linux Kernel for BeagleBone Black. I hope that you have cross compilation environment ready to start the task. (if not, please configure your system by following these steps.)
For keeping things simple for now, we will git clone Linux Kernel from BeagleBoard repository which contains customized Kernel for BeagleBone Black.
$ git clone git://github.com/beagleboard/linux.git
$ cd linux
$ git checkout 4.1
Download Linux Kernel version 4.1

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- bb.org_defconfig

We need to specify which modules and subsystems do we need in our kernel, so this step configures Kernel with default configuration for BeagleBone Black. Different methods are available to configure Kernel. For eg., we can use make menuconfig command to open menu through which we can select modules, drivers and subsystems to be built in the kernel. After completion of this step, a .config file is generated in the Kernel directory. It is recommended to open and read this file to understand different kernel configurations.

Following step cross compiles Kernel for ARM architecture and toolchain prefix arm-linux-gnueabi-. j4 specifies the number of threads to be used to cross compile the Kernel.
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j4

Following command creates a uImage for this Kernel. uImage is a type of Kernel image. There are various other types of Kernel images like zImage etc. LOADADDR specifies the address from where UBOOT will read Kernel image.
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage dtbs LOADADDR=0x80008000 -j4


Following command cross compiles the modules which have been selected during Kernel configuration
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules -j4


Following command installs the cross compiled modules to path specified in INSTALL_MOD_PATH.
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=<path to rootfs directory> modules_install

If you have followed all the steps correctly, you would have uImage and various other cross compiled files.
But only these files will not enable you to boot up and run your system. You would need a bootloader and rootfs to get your system up and running.

No comments:

Post a Comment

Booting Linux from NFS

Hi There! This post is about booting your linux from Network File System. Network File System means that the uImage, rootfs and ot...