Ubuntu 14.04.2 – Beagle Bone Black (BBB) Building a Custom Kernel

Last Modified 2015.05.06

Ubuntu 14.04.2 – Beagle Bone Black (BBB) Building a Custom Kernel – https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.14.4.tar.gz

01. Install prerequisite software on BBB Ubuntu build system (Virtualbox VM install of Ubuntu 14.04.2 32bit Desktop):
$ sudo apt-get update
$ sudo apt-get install aptitude ssh
$ sudo aptitude full-upgrade –full-resolver
$ sudo aptitude install automake autoconf binfmt-support bridge-utils build-essential cpu-checker curl debootstrap fakeroot fuseext2 gawk gcc-arm-linux-gnueabi genext2fs gettext gnome-shell sshfs ubuntu-gnome-desktop gnome-tweak-tool elementary-icon-theme gnome-system-tools gobjc++-arm-linux-gnueabi hwdata kvm-ipxe libaio1 libfdt1 libglib2.0-dev libltdl-dev libncurses5-dev librados2 librbd1 libsdl1.2debian libssl-dev libtool libvde0 libvdeplug2 libwrap0-dev lzop make module-assistant msr-tools pkg-config python python-software-properties qemu-common qemu-keymaps qemu-kvm qemu-system qemu-user qemu-user-static qemu-utils seabios software-properties-common subversion sysfsutils u-boot-tools vde2 vgabios xmlto xmltoman
$ reboot
$ sudo apt-get install –install-recommends linux-generic-lts-utopic xserver-xorg-lts-utopic libgl1-mesa-glx-lts-utopic libegl1-mesa-drivers-lts-utopic
$ reboot

After reboot install virtualbox guest additions.

02. Install latest GIT:
$ sudo add-apt-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git git-core
$ git config –global user.email “rbianchi@kuttatech.com”
03. U-Boot:
$ cd /root
$ mkdir /root/beaglebone/ && mkdir /root/beaglebone/u-boot/
$ cd /root/beaglebone/u-boot/
$ wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2
$ tar -xjf u-boot-latest.tar.bz2
$ cd /root/beaglebone/u-boot/u-boot-2015.04
$ make sandbox_defconfig tools-only
$ sudo install tools/mkimage /usr/local/bin
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- am335x_boneblack_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
04. Compiling the BeagleBone Black Kernel:
$ cd /root/beaglebone/
$ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.14.4.tar.gz
$ tar -zxvf linux-3.14.4.tar.gz
$ cd linux-3.14.4
$ cp /root/beaglebone/config- /root/beaglebone/linux-3.14.4/arch/arm/configs/beaglebone_defconfig
$ wget http://arago-project.org/git/projects/?p=am33x-cm3.git\;a=blob_plain\;f=bin/am335x-pm-firmware.bin\;hb=HEAD -O firmware/am335x-pm-firmware.bin

BBB Kernel 3.14 .config file:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- beaglebone_defconfig -j4

Edit the .config file to reflect your changes, if any:
$ nano /root/beaglebone/linux-3.14.4/.config


You could also use menuconfig to edit the .config file:
$ cd /root/beaglebone/linux-3.14.4
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig

This step builds the kernel and may take 15-20 minutes or longer:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage dtbs LOADADDR=0x80008000 -j4

This step builds the kernel for the BBB:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage am335x-boneblack.dtb LOADADDR=0x80008000 -j4

This builds the kernel modules and may take 20 minutes or longer:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules -j4
The following steps assume you already have a working Ubuntu 14.04.2 MicroSD with boot and rootfs partitions.

05. Update u-boot:
$ su
$ cd /root
$ mkdir boot
$ fdisk -l
$ mount /dev/sdX1 boot
$ cp /root/beaglebone/u-boot/u-boot-2015.04/MLO /root/boot
$ cp /root/beaglebone/u-boot/u-boot-2015.04/u-boot.img /root/boot
$ sync
$ cd /root
$ umount boot
06a. Update rootfs and zImage (kernel):
$ su
$ cd /root
$ mkdir rootfs
$ fdisk -l
$ mount /dev/sdX2 rootfs
$ cd /root/beaglebone/linux-3.14.4
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=/root/rootfs modules_install
$ cp /root/beaglebone/linux-3.14.4/arch/arm/boot/zImage /root/rootfs/boot/vmlinuz-
$ cp /root/beaglebone/linux-3.14.4/.config /root/rootfs/boot/config-
$ sync
$ cd /root
$ umount rootfs

Remove the MicroSD card from your adapter and boot into your custom kernel.
06b. Update rootfs and zImage (kernel) via SSH:
$ cd /root
$ mkdir sftpBBB
$ sshfs root@ /root/sftpBBB
$ cd /root/beaglebone/linux-3.14.4
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=/root/sftpBBB modules_install
$ cp /root/beaglebone/linux-3.14.4/arch/arm/boot/zImage /root/sftpBBB/boot/vmlinuz-
$ cp /root/beaglebone/linux-3.14.4/.config /root/sftpBBB/boot/config-

N01. Check current running kernel .config:
$ cat /proc/config.gz | gunzip > running.config
$ cat running.config | grep IPIP
$ cat running.config | grep NOWAY
$ cat running.config | grep DS1307

N02. Check UARTs:
$ ls -l /dev/ttyO*

N03. Set Hardware Clock:
$ aptitude install i2c-tools
$ i2cdetect -y -r 2
$ date -s “6 MAY 2015 18:43:00”
$ echo ds3231 0x68 >/sys/bus/i2c/devices/i2c-2/new_device
$ hwclock -f /dev/rtc1 -w
$ hwclock

N04. Enable UARTs 00, 01, and 02:
$ cd /boot/dtbs/
$ cp /boot/dtbs/am335x-boneblack.dtb /boot/dtbs/am335x-boneblack.dtb.org
$ cp /boot/dtbs/am335x-boneblack-ttyO2.dtb /boot/dtbs/am335x-boneblack.dtb

N05. References:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s