Dealing with the BeagleBone

The BeagleBone is a low-power open source hardware single-board computer designed with open source software development in mind, and as a way of demonstrating the Texas Instrument’s OMAP3530 system-on-a-chip.


Initial steps

It comes with a 4GB SD card with a preinstalled Angström Linux. The simplest method to use the console is to connect the board to your PC with the supplied USB cable. It will bring up a serial interface (it should mount the SD card on the PC for the first time but this never worked for me – if it mounts the card for you, just unmount it). Use a terminal (like minicom, gtkterm or RealTerm in a Windows world) with the settings 115200 baud, 8 bits, 1 stop bit.

After bootup you can login with root without a password. The usb0 network interface should come up, if it doesn’t, issue the following commands on the Bone:

1
2
3
4
modprobe g_ether
ifconfig usb0 192.168.7.2
route add default gw 192.168.7.1
echo “nameserver 8.8.8.8” > /etc/resolv.conf

The PC should have a new eth1 interface by now, set an address for it and enable NAT, so the Bone can reach the internet:

1
2
3
ifconfig eth1 192.168.7.1
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "1" >/proc/sys/net/ipv4/ip_forward

Replace eth0 with the interface of your internet connection (if you’re using Wi-Fi, probably it’s wlan0).

The boot process

Here’s the BeagleBone boot sequence:

  • On-chip bootloader starts
  • Loads the MLO from the SD card
  • The MLO loads U-Boot
  • U-Boot loads the Linux kernel image

There should be 2 partitions on the SD card, a smaller FAT32 boot partition (bootfs) and a larger system partition (rootfs, with an ext3, ext4 or other filesystem). The boot partition has the MLO and u-boot.img files. Some U-Boot versions search for the kernel image in the boot partition, some just simply mount the system partition and search for the image in it’s /boot folder. Make sure there’s only one kernel image on the SD card, preferably in the /boot folder of the rootfs.

If you want to replace the boot loader, just simply overwrite these files. Be sure to make a full backup of the SD card before you proceed with replacing the factory Angström distrib with your custom one. Put the SD card into a card reader on your PC and issue the following command:

1
sudo dd if=/dev/sde bs=8M | bzip2 -c > beaglebone-default.img.bz2

Replace /dev/sde with the SD card device file.

There are some commands you can use in the U-Boot shell. The most important ones are:

  • boot – boot default, i.e., run ‘bootcmd’
  • set bootfile something.img – sets the filename to load to the given parameter

Building a custom Angström distribution

You’ll need bitbake (apt-get install bitbake).

1
2
3
4
5
6
git clone git://github.com/Angstrom-distribution/setup-scripts.git
cd setup-scripts
MACHINE=beaglebone ./oebb.sh config beaglebone
MACHINE=beaglebone ./oebb.sh update
MACHINE=beaglebone ./oebb.sh bitbake virtual/kernel
MACHINE=beaglebone ./oebb.sh bitbake console-image

The latter command missed some packages for me, install those and proceed. After everything’s finished, you’ll have a rootfs and a bootfs in the build/tmp-angstrom_v2012_05-eglibc/deploy/images/beaglebone directory. Simply erase everything on the SD card and copy the contents of these two files to their partitions.

Building a custom kernel for the BeagleBone

You’ll need the TI Arago cross-compiler which is in the BeagleBone SDK. Download it from here (ti-sdk-am335x-evm-05.04.01.00-Linux-x86-Install). There are some useful development documentations here too.

After installing I had the SDK in my home in the ti-sdk-am335x-evm-05.04.01.00 directory. To have the cross-compiler in the path, I added this to the end of my ~/.bashrc:

1
PATH=$PATH:~/ti-sdk-am335x-evm-05.04.01.00/linux-devkit/bin

I downloaded a fresh kernel source for the Bone:

1
2
3
4
5
git clone https://github.com/RobertCNelson/linux-dev.git
cd linux-dev
git checkout origin/am33x-v3.2 -b am33x-v3.2
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cp system.sh.sample system.sh

Edit system.sh and change the LINUX_GIT and CC lines to these:

1
2
LINUX_GIT=linux-stable/
CC=arm-arago-linux-gnueabi-

Run the ./build_kernel.sh script to start compiling. Next time you want to recompile just issue the following command in the KERNEL directory:

1
make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- uImage

This way only the modified components get recompiled. You’ll have the uImage file in the arch/arm/boot/ directory. Here’s how to compile the modules to the ~/0modules/ directory:

1
2
make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- modules
make ARCH=arm CROSS_COMPILE=arm-arago-linux-gnueabi- INSTALL_MOD_PATH=~/0modules/ modules_install

Copy the created uImage file to the SD card’s /boot directory (on the rootfs), and copy the modules to the rootfs’ /lib/modules directory.

SCP and Midnight Commander on the BeagleBone

Anström has dropbear by default. To get scp to work, I had to make a symlink:

1
ln -s /usr/sbin/dropbearmulti /usr/bin/scp

Click here for the Midnight Commander compiling howto.

mcc 2012-08-08 03:46:39

Hi,

thank you for your explanations ! :)

I have two questions:
– Why is the kernel sources of RobertCNelson needed?
– The command git checkout https://github.com/RobertCNelson/linux-dev.git ends with
fatal: Not a git repository (or any parent up to mount parent /home/mccramer/data/pools)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
[1] 21280 exit 128 git checkout https://github.com/RobertCNelson/linux-dev.git

here. How can I fix it?
Thank you very much for any help in advance!
Best regards,
mcc

Nonoo 2012-08-08 08:36:47

Hello!

I’ve tried several kernel sources for the BeagleBone and I found that the RobertCNelson tree is a fairly latest source and easily compilable one. You have to use the command clone instead of checkout. Sorry for the mistake.

 
 
mcc 2012-08-08 10:39:31

Hi,

when following the instructions above, the call of ./build_kernel.sh the compilation process starts. However, menu config is called.
I did not configure anything (since it should be a default config for the beaglebone there) and left the kernel configuratin dialog with exit. The compilation resumes but failed with:
*** End of the configuration.
*** Execute ‘make’ to start the build or try ‘make help’.

`.config’ -> `/home/mccramer/data/pools/pool04/BEAGLEDEV/BEAGLEBONE/RobertCNelson/linux-dev/patches/defconfig’
make -j7 ARCH=arm LOCALVERSION=-d0 CROSS_COMPILE=”ccache armv7a-unknown-linux-gnueabi-” zImage modules
make: execvp: ccache: Permission denied
scripts/kconfig/conf –silentoldconfig Kconfig
make: execvp: ccache: Permission denied
WRAP arch/arm/include/generated/asm/auxvec.h
WRAP arch/arm/include/generated/asm/bitsperlong.h
WRAP arch/arm/include/generated/asm/cputime.h
WRAP arch/arm/include/generated/asm/errno.h
WRAP arch/arm/include/generated/asm/emergency-restart.h
WRAP arch/arm/include/generated/asm/ioctl.h
WRAP arch/arm/include/generated/asm/irq_regs.h
CHK include/linux/version.h
WRAP arch/arm/include/generated/asm/kdebug.h
UPD include/linux/version.h
WRAP arch/arm/include/generated/asm/local64.h
WRAP arch/arm/include/generated/asm/local.h
WRAP arch/arm/include/generated/asm/percpu.h
WRAP arch/arm/include/generated/asm/poll.h
WRAP arch/arm/include/generated/asm/sections.h
WRAP arch/arm/include/generated/asm/resource.h
WRAP arch/arm/include/generated/asm/siginfo.h
WRAP arch/arm/include/generated/asm/sizes.h
CHK include/generated/utsrelease.h
UPD include/generated/utsrelease.h
HOSTCC scripts/dtc/checks.o
HOSTCC scripts/genksyms/genksyms.o
SHIPPED scripts/genksyms/lex.lex.c
HOSTCC scripts/dtc/data.o
CC scripts/mod/empty.o
/bin/sh: ccache: command not found
make[2]: *** [scripts/mod/empty.o] Error 127
make[1]: *** [scripts/mod] Error 2
make[1]: *** Waiting for unfinished jobs….
HOSTCC scripts/dtc/dtc-lexer.lex.o
SHIPPED scripts/genksyms/keywords.hash.c
HOSTCC scripts/dtc/dtc-parser.tab.o
SHIPPED scripts/genksyms/parse.tab.h
Generating include/generated/mach-types.h
HOSTCC scripts/dtc/dtc.o
SHIPPED scripts/genksyms/parse.tab.c
CC kernel/bounds.s
/bin/sh: ccache: command not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2
make: *** Waiting for unfinished jobs….
HOSTCC scripts/dtc/flattree.o
HOSTCC scripts/dtc/fstree.o
HOSTCC scripts/genksyms/lex.lex.o
HOSTCC scripts/genksyms/parse.tab.o
HOSTCC scripts/dtc/livetree.o
scripts/genksyms/lex.lex.c_shipped: In function ‘yylex1’:
scripts/genksyms/lex.lex.c_shipped:904:1: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result
HOSTCC scripts/dtc/srcpos.o
HOSTCC scripts/dtc/treesource.o
HOSTCC scripts/dtc/util.o
HOSTLD scripts/dtc/dtc
HOSTLD scripts/genksyms/genksyms
make: *** [scripts] Error 2
[1] 6398 exit 2 ./build_kernel.sh

What did I wrong? How can I fix that?

Thank you very much in advance for any help!
Best regards,
mcc

Nonoo 2012-08-08 11:35:33

Try

1
cp KERNEL/arch/arm/configs/am335x_evm_defconfig KERNEL/.config
 
 
mcc 2012-08-08 11:59:27

Hi Nonoo,

sorry, but there is no “am335x_evm_defconfig” below linux-dev…

Best regards,
mcc

Nonoo 2012-08-08 12:09:24

I think I forgot to mention to switch branches after downloading the kernel source from git. Sorry about that.

git clone https://github.com/RobertCNelson/linux-dev.git
cd linux-dev
git checkout -b am33x-v3.2
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cp system.sh.sample system.sh

 
 
mcc 2012-08-08 13:31:35

Hi Nonoo,

I deleted the whole stuff and did as you have mentioned above.

But there is still no am335x_evm_defconfig.

The directory layout below linux-dev now is:
-rw-r–r– 1 user users 1496 2012-08-08 12:27 README
-rwxr-xr-x 1 user users 4416 2012-08-08 12:27 build_deb.sh
-rwxr-xr-x 1 user users 6137 2012-08-08 12:27 build_kernel.sh
-rwxr-xr-x 1 user users 8041 2012-08-08 12:27 build_mainline.sh
drwxr-xr-x 24 user users 4096 2012-08-08 13:10 linux-stable
-rw-r–r– 1 user users 5373 2012-08-08 12:27 patch.sh
drwxr-xr-x 13 user users 4096 2012-08-08 12:27 patches
drwxr-xr-x 2 user users 4096 2012-08-08 12:27 scripts
-rw-r–r– 1 user users 3360 2012-08-08 13:20 system.sh
-rw-r–r– 1 user users 3327 2012-08-08 12:27 system.sh.sample
drwxr-xr-x 2 user users 4096 2012-08-08 12:27 tools
-rw-r–r– 1 user users 526 2012-08-08 12:27 version.sh

The directory KERNEL is missing now….
defconfig-files can be found here:
./linux-dev/linux-stable/arch
but it seems that there is nothing appropiate…

What did I wrong? How can I fix it?

Best regards,
mcc

 
mcc 2012-08-09 02:39:56

Hi,

Finally I got it working…
I used a different checkout command to change the branch, didnt mix linux-stable with linux-dev and disabled multi-core compiling, which
gave spurious compilation errors at least on my system (AMD64).
(There is a youtube video by Derek Molloy, which shows the correct way. Thank you, Derek =>http://www.youtube.com/watch?v=HJ9nUqYMjqs)
See script below:
#! /bin/zsh
git clone https://github.com/RobertCNelson/linux-dev.git
cd linux-dev
git checkout origin/am33x-v3.2 -b am33x-v3.2
cd ..
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cd linux-dev
cp system.sh.sample system.sh
vim system.sh
# In vim change the following settings:
# Line 14: Set CC to the _prefix_ of your arm crosscompile. In my case the arm gcc
# crosscompiler was named “armv7a-unknown-linux-gnueabi-gcc”, so set
# CC=armv7a-unknown-linux-gnueabi-
#
# Line 61: Let Linux_GIT point to the directory “linux-satble”, which get cloned by the
# according command above.
#
# Line 70: Uncomment “# ZRELADDR=0x80008000”
#
./build_kernel.sh
# In the kernel config simply save the default settings and exit. The kernel build
# proceed then.
# If you are on a multi core system crosscompiling the kernel and get build errors
# edit “linux-dev/version.sh”:
# Comment out line 6-9, where the CORES count is increased. At least on my system
# this was the root of spurious compilation errors.
#
# Good luck!
#
# Have a lot of fun!
# mcc
#

Nonoo 2012-08-09 09:13:59

Did the BeagleBone boot with your kernel? I had problems with the armv7a-unknown-linux-gnueabi- suite. Only the kernel compiled with the Arago compiler booted successfully.

 
 
mcc 2012-08-16 20:20:48

Hi,

the Beaglebone arrives yesterday and yes, the kernel boots fine.

Best regards,
mcc

 
Name (required)
E-mail (required - never shown publicly)
Webpage URL
Comment:
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> in your comment.

Trackback responses to this post

About me

Nonoo
I'm Nonoo. This is my blog about music, sounds, filmmaking, amateur radio, computers, programming, electronics and other things I'm obsessed with. ... »

Twitter

Listening now

My favorite artists