Building a Custom Debian Kernel for the BeagleBoard

While trying to get my WIFI dongle to work with the BeagleBoard, I noticed that the dongle’s module was not compiled into the kernel. So I had to build a new kernel from scratch. Since building a new kernel under the BeagleBoard will take a LOT of time, I decided to cross-compile a kernel for the ARM architecture under my AMD-64 arch PC.

The following steps describes building a custom Debian kernel for the BeagleBoard using cross-compiling:

Installing required dependencies

Install proper build environment:

apt-get install git-core kernel-package fakeroot build-essential \
curl libncurses-dev uboot-mkimage

Edit /etc/apt/sources.list and add the Embedded Debian Project sources:

#debian embedded
deb http://www.emdebian.org/debian/ unstable main

Now execute:

apt-get update
apt-get install cpp-4.3-arm-linux-gnu  g++-4.3-arm-linux-gnu gcc-4.3-arm-linux-gnu

You now have a build environment capable of compiling a kernel for the ARM platform. Next step is to acquire and compile the kernel

Acquiring and Compiling the Kernel

Retrieve the GIT checkout:

git clone git://git2.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git
cd linux-omap-2.6/
git checkout 58cf2f1 -b v2.6.29-58cf2f1
git archive --format=tar --prefix=v2.6.29-58cf2f1/ v2.6.29-58cf2f1 | gzip > ../v2.6.29-58cf2f1.tar.gz
git checkout master
git branch v2.6.29-58cf2f1 -D
cd ..

Download kernel diffs and kernel config:

wget http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/v2.6.29-58cf2f1-oer34.diff
wget http://rcn-ee.homeip.net:81/dl/omap/beagle/v2.6.29-58cf2f1-oer34/defconfig

Extract Kernel Source

tar -xf v2.6.29-58cf2f1.tar.gz
cd v2.6.29-58cf2f1/

Apply Patch

patch -p1 < ../v2.6.29-58cf2f1-oer34.diff

Copy Defconfig

cp ../defconfig .config

Configure the kernel (requires libncurses5-dev installed)

make menuconfig

Build, Cross-Compiling:

make CROSS_COMPILE=arm-linux-gnu- uImage

A few moments later, you can find your new kernel in the ‘arch/arm/boot/’ directory.

Make modules:

make CROSS_COMPILE=arm-linux-gnu- modules

make CROSS_COMPILE=arm-linux-gnu- modules_install

make CROSS_COMPILE=arm-linux-gnu- modules_install INSTALL_MOD_PATH=arch/arm/boot”

Congratulations, a new kernel is compiled! Now move uImage and the arch/arm/boot directory to the sdcard.

Next step is to boot and test my WIFI dongle again.

You can find some more information about building a Debian kernel here.

Installing Embedded Debian on the BeagleBoard

Embedded Debian (EMDebian) logo

The following post describes installing EABI Debian (Embedded Application Binary Interface Debian) on the BeagleBoard. Debian is my favorite distribution, I’ve been using it for nearly 13 years, so sticking with it on the embedded platform comes only natural for me.

SD Card preperation

The BeagleBoard supports the new SD 2.0 (SDHC) format, so I bought myself a nice 4.0GB SDHC card so I won’t be tight on installation space.

To prepare the card, I used gparted, to create:

  1. 50 MiB FAT32 partition
  2. free unallocated space to be used by the Debian installer

gparted-sd_card

Mount the card on /media/disk. Download and prepare the card:

cd /media/disk/
sudo wget http://www.rcn-ee.com/deb/kernel/CC-beagle-v2.6.29-58cf2f1-oer31.1
sudo wget http://ftp.debian.org/debian/dists/lenny/main/installer-armel/current/images/versatile/netboot/initrd.gz
sudo mv CC-beagle-v2.6.29-58cf2f1-oer31.1 uImage
sudo gzip -d initrd.gz
sudo dd if=initrd of=initrd.pad ibs=8388608 conv=sync

un-mount the card, and insert it to the BeagleBoard. Now mount the card and boot the Debian installer:

For Linux Kernel 2.6.29 and higher using DSS2
setenv bootcmd 'mmcinit; fatload mmc 0:1 0x80300000 uImage; fatload mmc 0:1 0x81600000 initrd.pad; bootm 0x80300000'

Debian Install over DVI Port
setenv bootargs 'console=tty0 ramdisk_size=8192 root=/dev/ram0 rw rootfstype=ext2 initrd=0x81600000,8M omapfb.mode=dvi:1280x720MR-16@60'

Debian Install over the Serial Port *(this seems to be a regression from 2.6.28, which allowed you to specify both...)
setenv bootargs 'console=ttyS2,115200n8 ramdisk_size=8192 root=/dev/ram0 rw rootfstype=ext2 initrd=0x81600000,8M'

saveenv

Proceed with the Debian installation. The next non-trivial step is setting up a network connection.

Setting up a network connection on the BeagleBoard

There are 3 common options to set up a network connection to the BeagleBoard: using ethernet over usb (requires no additional hardware), using usb<->ethernet dongle, and using usb-wifi dingle. I will describe using ethernet over USB as it requires no additional hardware:

Use Ethernet over USB connection

connect the BeagleBoard USB OTG port to a Linux PC Host.

You should see (in dmesg):

[138693.281224] usb0: register ‘cdc_ether’ at usb-0000:00:1d.7-3.4, CDC Ethernet Device, a2:5c:2c:33:2a:ba

establish a network connection, and add appropriate routing

ifconfig usb0 up 192.168.0.7

route add -host 192.168.0.6 usb0

Now configure network manually on the BeagleBoard:

IP: 192.168.0.6

Netmask: 255.255.255.0

Gateway: 192.168.0.1 (change to your host’s IP)

DNS: use your hosts DNS IP.

Proceed with the installation:

Continue the install without loading kernel modules? : <yes>
Partition disks: This partitioner doesn't have the inform.....? : <yes>
 Logical Volume Manager not available: <Continue>

Partition disks:
 Guided - Use the largest continuous free space

Finish partitioning and write changes to disk

No installable kernel was found in the defined APT sources? :
 Continue without installing a kernel? : <yes>

No boot loader has been installed <ok>

Installation completed! Reboot, and change Beagle’s boot parameters to:

setenv bootcmd 'mmcinit; fatload mmc 0:1 0x80300000 uImage; bootm 0x80300000'
DVI Port
setenv bootargs 'console=tty0 root=/dev/mmcblk0p2 rootwait rootfstype=ext3 ro omapfb.mode=dvi:1280x720MR-16@60'
Serial Port
setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p2 rootwait rootfstype=ext3 ro'
saveenv
boot

Kernel Image Installation

sudo apt-get install uboot-mkimage

wget http://www.rcn-ee.com/deb/kernel/beagle/lenny/v2.6.29-58cf2f1-oer31.2/linux-image-2.6.29-oer31.2_1.0lenny_armel.deb

dpkg -i linux-image-2.6.29-oer31.2_1.0lenny_armel.deb

dpkg -x linux-image-2.6* ./kernel-extract

mount /dev/mmcblk0p1 /mnt

mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 -n "Linux" -d ./kernel-extract/boot/vmlinuz* /mnt/uImage

rm -rf ./kernel-extract
sync
umount /mnt

now reboot, and welcome to your new Embedded Debian BeagleBoard Linux!

beagle-embeddeddebianboot

BeagleBoard booting Embedded Debian for ARM Processor

First Steps with the BeagleBoard

The BeagleBoard, capabale as it is, is not a standard PC, and thus beginning to work with is involves some non trivial steps.

The first step, naturally, is to get keyboard, mouse and monitor output. The second step is to get network controll (preferably Ethernet, but a Serial connection is fine for the beginning as well).

Connecting Keyboard, Mouse and Monitor to the BeagleBoard

The BeagleBoard comes with the following connections:

Beagle Board Connectors

BeagleBoard Components

  • Video Connectors
    • DVI-D via a HDMI connector #3)
    • S-Video (15)
  • Control Inputs:
    • RS-232 Serial Header (10)
    • USB 2.0 HS OTG (12)

Keyboard and Mouse connection

What is USB OTG?

USB On-The-Go, normally abbreviated USB OTG, is a supplement to the USB 2.0 specification.
The standard USB uses a master/slave architecture; a USB ‘Host’ acts as the protocol master, and a USB ‘Device’ acts as the slave. Only the Host can schedule the configuration and data transfers over the link. The Devices cannot initiate data transfers, they only respond to requests given by a host.
OTG introduces the concept that a ‘Device’ can perform both the master and slave roles, and so subtly changes the terminology. Now a ‘Device’ can be either a ‘Host’ (acting as the link master) or a ‘Peripheral’ (acting as the link slave).
The Device connected to the ‘A’ end of the cable at startup acts as the Default Host, while the ‘B’ end acts as the Default Peripheral.

The USB OTG port is the default power input of the BeagleBoard. In order to use is as a USB host, and connect a USB hub to it, you must power the BeagleBoard using the +5v power supply connector (11). Also, a USB hub with an external power supply should be used, as the BeagleBoard can source only 100mA.

beagle_usb_otgIn order to “configure” the OTG port to run in Host mode (rather than device), there are three options:

  1. Short connect pin4 (ID) and pin5 (GND) on the BeagleBoard
  2. Use a standard miniB cable and connect the pins
  3. Get a USB OTG (5-wire) cable.

Serial Connection to the BeagleBoard

The serial header on the BeagleBoard is an IDC-10 connector.  In order to connect it to the serial port in the PC, a “null modem” cable should be used. Here’s the pin connection diagram for a serial null modem:

Signal Name DB-25 Pin DE-9 Pin DE-9 Pin DB-25 Pin
FG (Frame Ground) 1 - X - 1 FG
TD (Transmit Data) 2 3 - 2 3 RD
RD (Receive Data) 3 2 - 3 2 TD
RTS (Request To Send) 4 7 - 8 5 CTS
CTS (Clear To Send) 5 8 - 7 4 RTS
SG (Signal Ground) 7 5 - 5 7 SG
DSR (Data Set Ready) 6 6 - 4 20 DTR
CD (Carrier Detect) 8 1 - 4 20 DTR
DTR (Data Terminal Ready) 20 4 - 1 8 CD
DTR (Data Terminal Ready) 20 4 - 6 6 DSR

Configuring Serial Connection

There are two nice serial connection programs in my distribution (Debian): minicom and cutecom. minicom is non-graphical, and cutecom is. I have used minicom years ago to connect to the Internet using a modem, so I liked the chance to use it again.

Minicom should be configured with the following settings (except the serial device which should be changed to the device that was used).

    +-------------------------------------------------------+
    | A -    Serial Device      : /dev/ttyS2                |
    | B - Lockfile Location     : /var/lock                 |
    | C -   Callin Program      :                           |
    | D -  Callout Program      :                           |
    | E -    Bps/Par/Bits       : 115200 8N1                |
    | F - Hardware Flow Control : No                        |
    | G - Software Flow Control : No                        |
    |                                                       |
    |    Change which setting?                              |
    +-------------------------------------------------------+

After saving the settings, restaring minicom and reseting the BeagleBoard, the serial connection is working! Hooray!

beagle-board-serial-connection-minicom

I now have a basic network control (with keyboard input) over the BeagleBoard. The next step is to install an Embedded Linux Distribution and proceed from there.

Choosing an Embedded Linux Board

I’ve recently began working on a new project- a wheeled robotic platform, which will be capable of navigating autonomously, not only by the help of various proximity sensors, but also by using real Computer Vision algorithms. The platform will communicate with the outside world using WIFI or BlueTooth.  To answer my requirements and design, and more importantly to experience  something new on the way, I decided to use an embedded Linux board. I’m quite a Linux expert (have been using and developing for Linux for more than a decade), so I don’t mind modifying distributions or even the kernel itself if it will be needed.

Choosing an embedded Linux board is not easy. There are a lot of variations, which come in difference prices, sizes, features, and power requirements.

For my project, I decided to keep the price limit at 150$, the size to roughly 10×10 cm, and the power requirements to less that 1 ampere at 5v. As for the features – connectivity is the most important aspect (USB, Ethernet, WIFI, Serial), and nice to have are on-board video & audio controllers.

After some research, I came up with the following list of boards:

BeagleBoard

Beagle Board

Beagle Board

The BeagleBoard is a USB powered, low-cost, fan-less single board computer.

Price: 150$

Features:

  • 600 MHz ARM Cortex-A8 CPU
  • 128mb LPDDR RAM, 256mb NAND Flash
  • MMC+/SD/SDIO interface for memory or wireless connectivity
  • OpenGL  capable 2D/3D graphics accelerator
  • Power consumption of 2W

Connectivity:

  • USB 2.0 On The Go
  • I2C, SPI
  • RS-232
  • DVI-D, S-Video out
  • Stereo audio in and out
  • JTAG (debugging)

It seems like there is a strong community behind the Beagle Board, with active mailing lists, a rich WIKI knowledge base, and an IRC channel.

Additional information:

Linux Stamp

Linux Stamp Board

Linux Stamp Board

The Linuxstamp is an open source processor module based on the AT91RM9200.

Price: 120$.

Features:

  • Atmel AT91RM9200 processor (Arm9 processor with MMU, 180Mhz operation)
  • 32MB SDRAM (Only limited by 1x 54-TSOP SDRAM chip)
  • 8MB SPI Dataflash
  • 1x SD card slot
  • POE capable (48v -> 5v Power supply can be implemented on a motherboard)

Connectivity:

  • 1x 10/100 Ethernet
  • 1x USB host port (allows wifi adapters, flash drives and other USB devices to be used)
  • Serial debug port access through FTDI USB/Serial converter
  • JTAG port

Additional Information:

Gumstix Overo

Gumstix Oveo Linux Board

Gumstix Oveo Linux Board

As it’s name, the Gumstix Overo is a gum-stick sized Linux board with impressive feature list, very small size, weight and with low power requirements.

Price: 150$

Features:

  • 600-MHz ARM Cortex™-A8 Core
  • 256 MB low power DDR RAM
  • 256 MB NAND Flash
  • microSD adapter

Connectivity

  • I2C, PWM lines (6), A/D (6), 1-wire, UART, SPI, Camera in, Extra MMC lines
  • audio in, audio out
  • USB OTG signals, USB HS Host

The main disadvantage of the gumstix overo from my point of view is the fact that all of the connectivity features come in ’signals’ and lack the connectors themselves, and thus require an expansion board.


Conclusions…

After some thought, I decided to order the Beagle Board.  It has more features than the Linux Stamp, and in my opinion it’s better in the price\value ratio.

What’s next?

The next thing to do is to choose an Embedded Linux Distribution to run over the Linux board. My next post will describe what is an “Embedded Linux Distribution”, and will compare between the main palyers in the market.

Welcome

I decided to write a blog that will describe projects I’m working on, ideas and thoughts regarding technology in general. My fields of interest are hardware, electronics, software development, linux, embedded devices – and especially the integration of them all.

Good luck!