Buildroot basics: Building for a real target (PandaBoard)


Publicerad av Kenneth Andersson
PandaBoard ES is a community supported development platform based on the Texas Instrument OMAP4460 system-on-chip.
It is fairly low cost compared to other available platforms with lots of features.
Since it is based on an ARM Cortex A9 (Dual core) it has enough power to do most anything for small scale prototyping.
The PandaBoard ES has been around for some time now and are not the latest chicken in the market but still is one of my favourites.

As before we start out with setting up a separate  directory for our project and use the same buildroot directory as before.
Se previous posts on how to do this.

Buildroot version used is 2013-02.

Then it is time to configure buildroot for our target.
Buildroot takes care of the whole crosstools environment in a very smooth way to let you concentrate on the final goal: getting a system that runs on target.
The specs for PandaBoard ES can be found at http://pandaboard.org along with distros and other docuemnts.
Further good sources of information are 
http://omappedia.org/wiki/PandaBoard_Minimal-FS_SD_Configuration and http://elinux.org/PandaBoard.

The following configurations should be made:

Target Architecture – ARM (little endian)
 Enable NEON's SIMD extension support
Target Architecture Variant – cortex-A9
 Toolchain 
   Enable large file (files > 2 GB) support
   GCC 4.6.x -- Should already be set
 System Configuration
   System hostname -- Set it to what ever you'd like. Mine is "myPanda"
  /dev management -- Dynamic using devtmpfs only
  Port to run getty - ttyO2

  



When using qemu we didn't need to think about bootloaders but on a real target we do.
There are several bootloader to use such as grub, LILO, APEX and many more if you search for it.
One of the mostly used bootloader is the Universal Bootloader or U-boot.
The U-boot package has a configuration for the pandaboard called omap4_panda.
Enter the menu Bootloaders and set the following options:

Bootloaders
  Enable u-boot
     U-boot board name – omap4_panda
     U-boot binary format – u-boot.img
     Enable U-boot SPL support
     U-boot SPL target name – MLO

U-boot configuration

Just like the U-boot, the linux kernel also comes with a configuration file for the pandaboard named omap2plus.
Other than that we don't change anything.

Kernel
  Enable Linux Kernel
    Kernel Version– default (3.7.8)
    Defconfig name -- omap2plus

..and the most important thing: Save configuration

Now we are ready to start the download and building process.

make O=${PWD} -C ../myLinux/

Buildroot might complain about unsatisfied dependencies that you need to install, such as g++, flex or other tools.

When the build stops our images and rootfs will be in the ./images/ directory.


To simplify formating of the SD-card we will use a script found at one of the sources mentioned at the top.
#!/bin/bash
if [ ! "$1" = "/dev/sda" ] ; then
	unset LANG
	DRIVE=$1
	if [ -b "$DRIVE" ] ; then
		dd if=/dev/zero of=$DRIVE bs=1024 count=1024
		SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
		echo DISK SIZE - $SIZE bytes
		CYLINDERS=`echo $SIZE/255/63/512 | bc`
		echo CYLINDERS - $CYLINDERS
		{
		echo ,9,0x0C,*
		echo ,,,-
		} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
		mkfs.vfat -F 32 -n "boot" ${DRIVE}1
		mke2fs -j -L "rootfs" ${DRIVE}2
	fi 
fi
What it does is to format the SD-card into two partitions called boot and rootfs.
Input parameter is the device path for the card, such as in my case /dev/sdb.

$mkfs.sh /dev/sdb
 
Mount your two partitions to gain access:
mkdir /mnt/boot /mnt/rootfs
mount /dev/sdb1 /mnt/boot
mount /dev/sdb2 /mnt/rootfs
Copy the following files from ./images/ to the boot partition:

 boot:MLO
 uboot.imgu
  image
  
Unpack the rootfs into the rootfs partition:
   tar xvf rootfs.tar /mnt/rootfs
Unmount the card and we are ready to test it.

Hook up the serial port to your host and connect minicom to gain access to the target.
In my case, I use a serial to usb which will show up as /dev/ttyUSB0.
Insert the SD-card into the slot on the pandaboard and power up.

 

Log on using user root, no password, and try out your own linux system.