FreeBSD/arm for Gateworks Avila board

No longer supported

Support for these boards have been removed. The last branch to support it is stable/11, but may need to go to previous stable branches for functional support. stable/9 is known to work.

Building and Booting Diskless

Build world

make TARGET_ARCH=armeb TARGET_CPUTYPE=xscale buildworld 

Setup an new NFS root

make TARGET=arm TARGET_CPUTYPE=xscale TARGET_ARCH=armeb DESTDIR=$ROOT installworld
make TARGET=arm TARGET_CPUTYPE=xscale TARGET_ARCH=armeb DESTDIR=$ROOT distribution
mergemaster -m $SRC/etc -D $ROOT -i -A arm

Note: mergemaster will fail if used to install HEAD on a RELENG_6 system unless /usr/share/mk on the host system has been updated w/ changes to the build infrastructure. Note: This will still fail to produce an NFS root image that can be logged in as root via control. You can add proper ssh keys and enable sshd in rc.conf and enable root logins via sshd_config to login.

Configure the NFS root for diskless use

Consult diskless(8).

Build and install a kernel

make TARGET=arm TARGET_ARCH=armeb KERNCONF=AVILA buildkernel

Note: the AVILA kernel is configured with the root filesystem mounted via NFS over the npe0 wired interface. You should now have an NFS-mountable root filesystem with a kernel. The final step is to setup network diskless booting from the board. It is assumed you have a DHCP server operating on your network and the server is configured to supply the necessary information in the DHCP lease. If you run the ISC DHCP server the following configuration information is an example of how to do this:

   option root-opts code 130 = string; # NFS / mount options
   host avila1 {
       hardware ethernet 00:d0:12:02:47:68;
       filename  "kernel-avila.nfs";
       option root-path "";
       option root-opts "nolockd";

Note: the root-opts item specifies the root filesystem should be mounted with the nolocked option; this just short-circuits file locking requests so you don't get complaints from programs that use the pidfile(3) routine (e.g. devd).

Move Kernel to TFTP area

Place the kernel in the TFTP area for booting from the prom monitor. If your TFTP server returns file from /tftpboot (default) then do something like:

   cp $ROOT/boot/kernel/kernel /tftpboot/kernel-avila.nfs 

Boot the kernel from redboot

Boot the kernel from redboot:

   RedBoot> ip -h -l
   IP: Gateway:
   Default server:
   RedBoot> load -b 0x200000 kernel-avila.nfs
   Using default protocol (TFTP)
   Address offset = 0x40000000
   Entry point: 0x00200100, address range: 0x00200000-0x004db2d4
   RedBoot> go 

Record the above commands

To record the above redboot script so that it's used every time the board is reset run the fconfig command at the redboot prompt and answer the questions.

Building with Nanobsd

The nanobsd(8) packaging system can be used to construct bootable compact flash images. This can even be done on a little-endian x86 system using makefs(8) To build an image for Avila boards use these steps:

Run nanobsd. There is an example packaging configuration for Avila boards in tools/tools/nanobsd/gateworks:

   cd tools/tools/nanobsd/gateworks
   sh ../ -c ./avila

Note this will cross-compile world and a kernel then construct the disk image. If you are not running as root this will fail after building world and kernel. To resume the operation as the super user you can just use the -b option; e.g.

   sudo ../ -b -c ./config

The file avila specifies the contents of the file system image and how to construct the disk image. This will likely need changing to suit local filesystem setup. The kernel configuration is located in the same directory and is named G2348. This too may be edited or replaced with an alternative configuration.

Nanobsd leaves the disk image in the /usr/obj/nanobsd.avila directory. You will need to transfer this data to a compact flash part. If you have a compact flash reader/writer on a FreeBSD machine then this is done with dd; e.g.

   dd if=_.disk.full of=/dev/da0 bs=32b

The block size is important; if the transfer size does not reflect the expected geometry then the image written will/may be corrupted. The block size used to construct the image is noted in comments at the bottom of the nanobsd log file named _.di.

To update a nanobsd image you can use command line options for the script. For example if you want to rebuild the kernel and update the image you might use:

   sudo ../ -w -n -c ./config

This will skip the buildworld stage then do a buildkernel with the -DNO_CLEAN option to reuse a previous build. If you want to update the image but not build anything (e.g. you have changed the custom steps used to construct the flash image) use:

   sudo ../ -b -c ./config

NOTE: At this time nanobsd does not know how to cross-build ports; the only way to add programs from the ports is to nfs mount a ports tree on a running Avila system and then build the programs. The results can be saved and copied to the compact flash image with nanobsd or installed directly on the running system (possibly after re-mounting the filesystem(s) read/write).

Boot kernel from CF

Past this you can setup a FreeBSD installation on compact flash and use RedBoot to load a second level bootstrap from the onboard flash that loads FreeBSD from compact flash. The running sytem then uses a file system written to compact flash. Note that this two-stage boot process is necessary because RedBoot does not understand how to load a file from a Unix File System (UFS)--the standard filesystem used by FreeBSD.

On the build machine:

Build a kernel configured to mount the file system from ad0. This is most easily done by copying the AVILA config file and stripping out the BOOTP* options.

Build the second level bootstrap program by entering the arm/xscale build environment and building sys/boot2/ixdp425:

   make TARGET_ARCH=arm TARGET_CPUTYPE=xscale TARGET_ARCH=armeb buildenv
   cd sys/boot/arm/ixp425/boot2/

Note that boot2 can be built to expect a BSD disklabel in the disk partition or not. The default build does not enable this because the bsdlabel program usually used to image disk labels is not endian-agonostic so is not usable on a little-endian machine to construct a filesystem for a big-endian ixp425 system. If you want to change how boot2 is built edit the Makefile or override the flags from the command line.

Once boot is built copy it to where tftp loads files from; e.g.

   cp boot2 /data/tftpboot/boot2.avila

On the target board

Download the boot2.avila file and write it to an image in the onboard flash (NB: we named the flash image boot2.freebsd

   RedBoot> load boot2.avila
   Using default protocol (TFTP)
   Entry point: 0x00180000, address range: 0x00180000-0x00183384
   RedBoot> fis create boot2.freebsd
   ... Erase from 0x50080000-0x500a0000: .
   ... Program from 0x00180000-0x00183384 at 0x50080000: .
   ... Unlock from 0x50fe0000-0x51000000: .
   ... Erase from 0x50fe0000-0x51000000: .
   ... Program from 0x03fe0000-0x04000000 at 0x50fe0000: .
   ... Lock from 0x50fe0000-0x51000000: .
   RedBoot> fis list
   Name              FLASH addr  Mem addr    Length      Entry point
   RedBoot           0x50000000  0x50000000  0x00080000  0x00000000
   boot2.freebsd     0x50080000  0x00180000  0x00020000  0x00180000
   FIS directory     0x50FE0000  0x50FE0000  0x0001F000  0x00000000
   RedBoot config    0x50FFF000  0x50FFF000  0x00001000  0x00000000

You are now ready to boot from compact flash. If you want to test operation you can do this manually:

   RedBoot> fis load boot2.freebsd
   RedBoot> go
   FreeBSD ARM (Avila) boot2 v0.2
   Default: /boot/kernel/kernel
   KDB: debugger backends: ddb
   KDB: current backend: ddb
   Copyright (c) 1992-2008 The FreeBSD Project.
   Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
           The Regents of the University of California. All rights reserved.
           FreeBSD is a registered trademark of The FreeBSD Foundation.
           FreeBSD 7.1-PRERELEASE #1: Fri Sep 26 14:37:41 PDT 2008

To set the default boot to happen from compact flash just change the RedBoot configuration to do the above steps automatically; e.g.

   RedBoot> fconfig
   Run script at boot: true
   Boot script:
   .. load -b 0x200000 kernel-avila.nfs.vap7
   .. go
   Enter script, terminate with empty line
   >> fis load boot2.freebsd
   >> go
   Boot script timeout (100ms resolution): 25
   Use BOOTP for network configuration: false
   Gateway IP address:
   Local IP address:
   Local IP address mask:
   Default server IP address:
   Console baud rate: 115200
   GDB connection port: 9000
   Force console for special debug messages: false
   Network debug at boot time: false
   Default network device: npe_eth0
   Update RedBoot non-volatile configuration - continue (y/n)? y
   ... Unlock from 0x50fe0000-0x51000000: .
   ... Erase from 0x50fe0000-0x51000000: .
   ... Program from 0x03fe0000-0x04000000 at 0x50fe0000: .
   ... Lock from 0x50fe0000-0x51000000: .

Now on reset you will boot from compact flash by default:

   Trying NPE-B...success. Using NPE-B with PHY 0.
   Ethernet eth0: MAC address 00:d0:12:02:47:68
   IP:, Gateway:
   Default server:

   RedBoot(tm) bootstrap and debug environment [ROM]
   Gateworks certified release, version 2.02 - built 05:22:19, Mar  3 2006

   Platform: Gateworks Avila GW234X (IXP42X 533MHz) BE
   Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
   Copyright (C) 2004, 2005 Gateworks Corporation

   RAM: 0x00000000-0x04000000, [0x000298b0-0x03fc1000] available
   FLASH: 0x50000000 - 0x51000000, 128 blocks of 0x00020000 bytes each.
   == Executing boot script in 2.500 seconds - enter ^C to abort
   RedBoot> fis load boot2.freebsd
   RedBoot> go
   FreeBSD ARM (Avila) boot2 v0.2
   Default: /boot/kernel/kernel
   KDB: debugger backends: ddb
   KDB: current backend: ddb
   Copyright (c) 1992-2008 The FreeBSD Project.
   Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
           The Regents of the University of California. All rights reserved.
   FreeBSD is a registered trademark of The FreeBSD Foundation.
   FreeBSD 7.1-PRERELEASE #1: Fri Sep 26 14:37:41 PDT 2008
   CPU: IXP425 533MHz rev 1 (ARMv5TE) (XScale core)
     DC enabled IC enabled WB enabled LABT branch prediction enabled
     32KB/32B 32-way Instruction cache
     32KB/32B 32-way write-back-locking Data cache
   real memory  = 67108864 (64 MB)
   avail memory = 58359808 (55 MB)
   ath_hal: (AR5210, AR5211, AR5212, AR5416, RF5111, RF5112, RF2413, RF5413, RF2133, RF2425, RF2417, REGOPS_FUNC)
   ixp0: <Intel IXP425> on motherboard
   pcib0: <IXP425 PCI Bus> on ixp0
   pci0: <PCI bus> on pcib0
   ath0: <Atheros 5413> irq 28 at device 1.0 on pci0
   ath0: [ITHREAD]
   ath0: WARNING: using obsoleted if_watchdog interface
   ath0: mac 10.4 phy 6.1 radio 6.3
   ath1: <Atheros 5413> irq 27 at device 2.0 on pci0
   ath1: [ITHREAD]
   ath1: WARNING: using obsoleted if_watchdog interface
   ath1: mac 10.5 phy 6.1 radio 6.3
   ixpclk0: <IXP425 Timer> on ixp0
   ixpiic0: <IXP425 GPIO-Based I2C Interface> on ixp0
   iicbb0: <I2C bit-banging driver> on ixpiic0
   iicbus0: <Philips I2C bus> on iicbb0 master-only
   iicbus0: <unknown card> at addr 0
   iic0: <I2C generic I/O> on iicbus0
   ad74180: <Analog Devices AD7418 ADC> at addr 0x50 on iicbus0
   ds16720: <Dallas Semiconductor DS1672 RTC> at addr 0xd0 on iicbus0
   ixpwdog0: <IXP425 Watchdog Timer> on ixp0
   uart0: <Non-standard ns8250 class UART with FIFOs> on ixp0
   uart0: [FILTER]
   uart0: console (115200,n,8,1)
   uart1: <Non-standard ns8250 class UART with FIFOs> on ixp0
   uart1: [FILTER]
   ixpqmgr0: <IXP425 Q-Manager> on ixp0
   ixpqmgr0: [ITHREAD]
   npe0: <IXP NPE-B> on ixp0
   npe0: [ITHREAD]
   npe0: remember to fix rx q setup
   miibus0: <MII bus> on npe0
   ukphy0: <Generic IEEE 802.3u media interface> PHY 0 on miibus0
   ukphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
   npe0: Ethernet address: 00:d0:12:02:47:68
   npe1: <IXP NPE-C> on ixp0
   npe1: [ITHREAD]
   npe1: remember to fix rx q setup
   miibus1: <MII bus> on npe1
   ukphy1: <Generic IEEE 802.3u media interface> PHY 1 on miibus1
   ukphy1:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
   npe1: Ethernet address: 00:d0:12:12:47:68
   ata_avila0: <Gateworks Avila IDE/CF Controller> on ixp0
   ata_avila0: [ITHREAD]
   ata0: <ATA channel 0> on ata_avila0
   ata0: [ITHREAD]
   led_avila0: <Gateworks Avila GPIO connected LED> on ixp0
   ixpclk0: [FILTER]
   Timecounter "IXP425 Timer" frequency 66666600 Hz quality 1000
   Timecounters tick every 10.000 msec
   ad0: 61MB <SanDisk SDCFB-64 Vdg 1.17> at ata0-master PIO1
   Trying to mount root from ufs:ad0s1
   cp: utimes: /var/var: No such file or directory
   cp: chown: /var/var: No such file or directory
   cp: chmod: /var/var: No such file or directory
   cp: chflags: /var/var: No such file or directory
   Loading configuration files.
   Entropy harvesting: kickstart.
   Starting file system checks:
   /dev/ad0s1: clean, 35625 free (1 frags, 4453 blocks, 0.0% fragmentation)
   /dev/ad0s3: clean, 1917 free (5 frags, 239 blocks, 0.3% fragmentation)
   Setting hostuuid: 8902ab18-8cef-11dd-b583-00026f3f9531.
   Setting hostid: 0x5cb2bb66.
   Mounting local file systems:.
   Setting hostname: avila.
   npe0: link state changed to UP
   Starting Network: lo0 npe0.
   ifconfig: npe0: bad value
   Additional routing options:.
   /etc/rc: WARNING: run_rc_command: cannot run /sbin/devd
   Generating host.conf.
   Additional IP options:.
   Mounting NFS file systems:.
   Creating and/or trimming log files:.
   Starting syslogd.
   ELF ldconfig path: /lib /usr/lib
   Initial arm initialization:.
   Additional ABI support:.
   NFS access cache time=60
   Clearing /tmp (X related).
   Starting local daemons:.
   Updating motd.
   Mounting late file systems:.
   Starting sshd.
   Starting cron.
   Local package initialization:.
   Starting background file system checks in 60 seconds.

   Sat Sep 27 23:54:08 UTC 2008

   FreeBSD/arm (avila) (ttyu0)


Multiple Partitions

If you use the boot2 program to boot from compact flash then it will automatically select the slice marked active. This makes it easy to partition a flash part with multiple slices that you can fallback to in case of a problem. If you use nanobsd to construct compact flash images the shell scripts updatep1 and updatep2 can be used to write new disk images to partition/slice 1 and 2, respectively and mark the MBR so that on reset boot2 boots from that slice.

FreeBSDAvila (last edited 2020-12-11T00:30:57+0000 by JohnMarkGurney)