Architectures/ARM/BeagleBoardxMSDCard

From FedoraProject

Jump to: navigation, search
Warning (medium size).png
This page is a draft only
It is still under construction and content may change. Do not rely on the information on this page.

Contents

How To: Use the Fedora 12 rootfs on a BeagleBoard-xM

The BeagleBoard-xM ships with a MicroSD card, which contains a working Angstrom validation image. This how-to guide will lead the user through how to modify the xM's SD card to run Fedora 12. This guide assumes that the user is running a recent version of Fedora on his or her local machine, but should apply to users of any recent linux distribution.

What you need

To complete this guide, you'll need

  • Pre-formatted SD card that came with the BeagleBoard-xM
  • Serial cable to access BeagleBoard-xM's serial console
  • SD card reader on your PC, with a MicroSD to SD adapter

SD card formatting

Insert the SD card into a card reader. Substitute the actual device name for sdX in the following commands. Start up a partition editor like gparted. You should see that there is a FAT32 partition at the beginning of the card, a small "unknown" partition, and then lots of free space. Delete the "unknown" partition, then create a new partition taking up all of the available free space.

Note.png
Newer BeagleBoards (e.g. purchased after 2011-APR-21 or so) are shipped with a 4GiB MicroSD card labeled xMTEST beta 3-30. This has the FAT32 partition and a 3+ GB linux partition. When inserted on my F14 laptop it appears as /dev/mmcblk0 with partitions /dev/mmcblk0p1 (FAT32) and /dev/mmcblk0p2 (linux).

Label the partition ROOTFS, and format it as ext3:

mke2fs -L ROOTFS -t ext3 /dev/sdX2

Mount the partition:

mkdir /media/ROOTFS
mount /dev/sdX2 /media/ROOTFS

Copy rootfs to SD card

Now that the ROOTFS partition has been created, it's time to extract the Fedora 12 root filesystem onto it. First, download the prebuilt root file system. Once it's downloaded, navigate to the ROOTFS partition in a terminal, and extract the rootfs using the following commands:

su -c 'tar xvf /path/to/rootfs-f12.tar.bz2 ./'
su -c 'mv rootfs-f12/* ./'
su -c 'rmdir rootfs-f12'

Replace /path/to/rootfs-f12.tar.bz2 with the path to rootfs-f12.tar.bz2 on your system.

The first command extracts the root filesystem to your current directory, which is the ROOTFS partition on the SD card. In the rootfs tarball, all of the files are located in the 'rootfs-f12' folder, so the second command moves all of the files out of the rootfs-f12 folder and into the base ROOTFS directory. Finally, the third command removes the unneeded 'rootfs-f12' folder.

Copy kernel modules to SD card

The BeagleBoard-xM comes with a pre-installed kernel image, but kernel modules and firmware are required for extra hardware such as the Real Time Clock. These modules need to be installed to /lib/modules on the ROOTFS partition. There are two ways to go about getting these modules: downloading them from the internet, or recovering them from the BeagleBoard's included validation image.

Download modules from internet

You can download modules.tgz from the Angstrom website. Once it's downloaded, navigate to the ROOTFS partition, and extract the modules using the command

su -c 'tar xvf /path/to/modules.tgz ./'

Replace /path/to/modules.tgz with the location of your downloaded modules.tgz file.

Extra settings

The Fedora 12 rootfs needs some additional configuration to do things like access the network. This section outlines some of the additional configuration changes that need to be made.

Networking

Fedora 12 defaults to the "eth0" network interface, but the BeagleBoard-xM's network interface is called usb0. To enable usb0, you need to set up the network configuration file. In the ROOTFS, open the file "etc/sysconfig/network-scripts/ifcfg-eth0" in a text editor. If you want a static IP address, edit to look like the following:

DEVICE=usb0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.1
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.1
TYPE=Ethernet
USERCTL=no

If you'd rather use DHCP to resolve an IP address, edit it to look like the following:

DEVICE=usb0
BOOTPROTO=dhcp
ONBOOT=yes

Change ONBOOT to no if you do not want to bring up the network on boot.

Filesystems

The Fedora 12 root filesystem is set up by default to mount a NFS share as the root partition. This can be corrected by changing /etc/fstab. In the ROOTFS partition, open the "etc/fstab" (note there is NO prepending slash) and change the first line to read:

/dev/mmcblk0p2        /           ext3    defaults     1 1

Set up u-boot

Mount the first partition if it hasn't been automatically mounted:

mkdir /media/BEAGLE
mount /dev/sdX1 /media/BEAGLE

Create a file fedora_boot_cmd with the following content:

setenv bootargs 'console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait'
mmc init
fatload mmc 0 0x80300000 uImage
bootm 0x80300000
boot

Process this file as follows (the mkimage program is available in the uboot-tools package):

mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n
"Beagleboard-xM boot script" -d fedora_boot_cmd boot.scr 

Copy boot.scr to the first partition on your SD card. If you ever want to restore the angstrom boot behavior just delete boot.scr from the first partition.

Unmount both partitions and flush filesystem data to the SD card:

umount /media/BEAGLE
umount /media/ROOTFS
sync

Wait for sync to complete before removing the SD card.

Insert the SD card into the BeagleBoard-xM's SD slot. Plug a serial cable into the BeagleBoard-xM's serial port, and open a serial terminal on your PC. Set the serial terminal to use the following settings:

  • Baudrate: 115200
  • Bits: 8
  • Parity: none
  • StopBits: 1

For example you can use cu available in the uucp package:

cu --line /dev/ttyX --speed 115200

Apply power to the BeagleBoard-xM, and you should see output on the serial terminal, and eventually it should enter a boot countdown and then proceed to load uImage, decompress Linux, discover hardware, and eventually bring up Fedora 12. At the login prompt, use the credentials:

  • Username: root
  • Password: fedoraarm

Note: The first boot may take quite some time, as fsck is being run over the filesystem. If you see no errors after the kernel output, and you see the SD card activity light on, wait a minute or two for init to start.

Note.png
The first few times I powered the board on, it failed to boot, whining that it could not find /boot/uImage. I copied /media/Narcisis.../boot/* on the original SD card to /media/ROOTFS/root/ on my SD card (note the fat-fingering) and then, magically, the board booted (go figure). When I looked in /boot there was a uImage file there as well as in /root. Now on every boot it a) whines about no /lib/modules/2.6.23/modules.dep file, b) the first time it booted it brought up eth0/usb0, but on every boot since it fails to bring up eth0/usb0 (I have to run dhclient usb0 manually, and c) runs an fsck on /dev/mmcblk0p2, although this is probably due to the system date/time being 0.