Skip to main content

FreeBSD ARM

Posted in

1. Prerequisites

1.1. Hardware

  • PandaBoard Rev 0.3
  • USB-to-RS232 adapter
  • SD card

1.2. Software

  • minicom (or cu)
  • u-boot
  • FreeBSD source code (can be found here)

2. Getting started

2.1. Load driver for USB-to-RS232 cable

Plug in you adapter and see what dmesg tells you about it. My cable has FTDI chip as seend from dmesg:

$ dmesg
...
ugen1.2: <FTDI> at usbus1
...

Load the driver:

$ sudo kldload uftdi

Some of USB-to-RS232 cable may have Prolific chips. If your cable is oe of those, the you need to load another driver:

$ sudo kldload uplcom

Make sure the cable is recognized properly. New device uftdi0 appears.

$ dmesg
...
uftdi0: <USB Serial Converter> on usbus1
...

Now you should see cuaU0 and ttyU0 devices under /dev.

2.2. Setup minicom

Plug in USB-to-RS232 adapter and run the following command:

$ sudo minicom -s ttyU0

  • Go to Serial port setup.
  • Set proper serial device to /dev/ttyU0.
  • Set Bps/Par/Bits to "115200 8N1".
  • Go to Save setup as ttyU0.

You may omit -s flag next you run minicom. So just do:

$ sudo minicom ttyU0

Important: But make sure the speed is set to 115200.

3. Building kernel

$ git clone git://gitorious.org/+freebsd-omap-team/freebsd/freebsd-omap.git
$ cd freebsd-omap
$ git checkout -b bengray-wip remotes/origin/bengray-wip

Make sure sys/conf/options.arm contains these two lines:

SOC_OMAP3           opt_global.h
SOC_OMAP4           opt_global.h

If you find SOC_OMAP3530 and SOC_OMAP4430 in it, just replace with SOC_OMAP3 and SOC_OMAP4 correspondingly.

$ setenv MAKEOBJDIRPREFIX `pwd`
$ setenv KERNSRCDIR `pwd`/sys
$ make kernel-toolchain KERNCONF=PANDABOARD TARGET=arm MACHINE_ARCH=arm TARGET_CPUTYPE=cortex-a9 WERROR=
$ make buildkernel KERNCONF=PANDABOARD TARGET=arm MACHINE_ARCH=arm WERROR=

4. Booting

4.1. From SD/MMC

Modify the kernel so that u-boot understands it:

$ mkimage -A arm -O netbsd -T kernel -C none -a 80200000 -e 802000e0 -n "FreeBSD" -d path/to/kernel.bin ukernel

Prepare SD card:
First you need to create 2 partitions (slices) on your SD card. The first one should be FAT, the second one UFS. We will use sysinstall to create slices.

$ sudo sysinstall

  • Go to Configure.
  • Go to Fdisk.
  • Choose mmcsd0.
  • Set the correct geometry. Otherwise, sysinstall will core dump. Most likely, that you will see this geometry:
    DISK Geometry:  0 cyls/0 heads/0 sectors = 0 sectors (0MB)

    You need to set a proper geometry.
    Solution 1:
    Run fdisk for SD card and get the geometry from its output.

    $ fdisk /dev/mmcsd0
    ******* Working on device /dev/mmcsd0 *******
    parameters extracted from in-core disklabel are:
    cylinders=1961 heads=255 sectors/track=63 (16065 blks/cyl)
    ...

    This means that the geometry should be set to 1961/255/63.

    Solution 2:
    Calculate the number of cylinders. Take the volume of SD card in bytes, let it be Vb. The number of cylinders will be equal to (int)(Vb / 255 / 63 / 512).

  • Create 1st slice with partition type (sysid) 12 (FAT). I allocated 50MB for this slice.
  • Create 2nd slice with partition type 165 (UFS). I allocated the rest of available space.
  • $ sudo newfs_msdos /dev/mmcsd0s1
  • $ sudo newfs /dev/mmcsd0s2

Put the following files to the root directory of the first partition of SD card:

The root of the first FAT partition will be scaned for MLO, which is x-loader. It gets loaded and the control is passed to it.
MLO in its turn scans the same first FAT partition for the u-boot binary, i.e. u-boot.bin, and loads it.
At last, the control is passed to u-boot. At this point it show the prompt and waits for your commands.

Panda # mmc init
Panda # fatload mmc 0:1 81000000 ukernel
reading ukernel
 
3484724 bytes read
Panda # bootm 81000000
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   FreeBSD
   Image Type:   ARM NetBSD Kernel Image (uncompressed)
   Data Size:    3484660 Bytes = 3.3 MiB
   Load Address: 80200000
   Entry Point:  802000e0
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK
## Transferring control to NetBSD stage-2 loader (at address 802000e0) ...

4.2. Over USB

For booting kernel over usb we will need omap4loader utility which can be found here. If you are unable to compile it with the Makefile available through the link then probably you have libusb in your base system and you should try this instead:

gcc -L/usr/lib -lusb -o omap4loader omap4loader.c

We also need the second version of aboot.bin, the one that is precompiled for 0x80200000 value.

Now that we have everything ready run the ompa4loader as:

sudo ./omap4loader aboot_0x80200000.bin kernel.bin

and then reboot PandaBoard.

5. Troubleshooting

5.1. Stuck at stage-2 loader

You may observer the following problem.

Panda # mmc init ; fatload mmc 0:1 81000000 ukernel ; bootm 81000000
reading ukernel
 
3563380 bytes read
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   FreeBSD
   Image Type:   ARM NetBSD Kernel Image (uncompressed)
   Data Size:    3563316 Bytes = 3.4 MiB
   Load Address: 80200000
   Entry Point:  802000e0
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK
## Transferring control to NetBSD stage-2 loader (at address 802000e0) ...
...<nothing happens after this>...

5.2. ERROR: booting os 'Unknown OS' (3) is not supported

Most probabl you passed "-O freebsd" flag when running mkimage. Use "-O netbsd" instead.

  1. http://omappedia.org/wiki/Bootloader_Project
  2. http://code.google.com/p/beagleboard-freebsd/w/list
  3. http://web.me.com/dmarion/omap4loader