Reference

ArchLinux Kernel Compilation on BeagleBone Black

I recently had to modify and recompile the kernels on my BBB’s. Cross-compilation is well documented on the internet, but what if you want to compile directly on the device? Here are the steps.

Tags: archlinux beaglebone kde

Prerequisites

The on-board flash memory is not large enough to compile the kernel. You have to insert and mount an external SD card or USB drive for storage:

# mkdir /storage
# nano /etc/fstab

/dev/mmcblk0p1  /storage        ext2    auto,exec,rw,user    0       0

Now you can install git and acquire the kernel sources from GitHub:

# pacman -S git
# cd /storage
# git clone git://github.com/archlinuxarm/PKGBUILDs.git

Compilation

You are now ready to configure, compile and install the kernel. To customize the kernel edit its configuration file:

# cd PKGBUILDs/core/linux-am33x[-legacy]
# nano config

Note: it looks like the legacy kernel does not compile at the time of this writing. The normal kernel (without -legacy) seems to work fine though.

After modifying the kernel configuration, the corresponding kernel config checksum in the PKGBUILD must be updated:

# md5sum config
c7c70df48ae7523be130818c2643deec  config

# nano PKBBUILD

Replace the last entry in md5sums=(..) with your checksum above, and then compile the kernel:

# makepkg -Acs

Note: The –asroot option allows compilation as the root user (not recommended). The PKGBUILDs/core/linux-am33x[-legacy] directory must be writable if not running as root.

Finally, the kernel can be installed:

# pacman -U [the two .xz files that were created]

For example:
pacman -U linux-am33x-3.18.0-1-armv7h.pkg.tar.xz linux-am33x-headers-3.18.0-1-armv7h.pkg.tar.xz

Notes

  • The linux-am33x kernel is newer than the linux-am33x-legacy kernel, but the latter has better support for BeagleBone I/O and other hardware specific features
  • Kernel modules are stored in /usr/lib/modules/kernel_release
  • To show all currently loaded kernel modules: # lsmod
  • To show information about a module: # modinfo module_name
  • To add a module to the kernel: # modprobe module_name
  • To unload a module from the kernel: # modprobe -r module_name

Related Resources