This is an old revision of the document!


Embedded Handbook

This Handbook is dedicated for all kernel developer beginners. It provides useful snippets of code and use-cases for begginers. This will not cover the theory of FreeBSD's kernel architecture. Please, read the handbooks, given in links section.

Environment variables for arm, when building kernel/world:

ARCH=arm
TARGET_ARCH=arm
TARGET_CPUTYPE=armv6
MAKEOBJDIRPREFIX=/home/aleek/obj

Basic usage of make: (invoke head -n 40 Makefile for all options)

export MAKEOBJDIRPREFIX=/home/aleek/obj
make ARCH=arm TARGET_ARCH=arm kernel-toolchain
make ARCH=arm TARGET_ARCH=arm buildkernel KERNCONF=BEAGLEBOARD-XM
make TARGET_ARCH=arm TARGET_CPUTYPE=armv6 buildworld

All object files will be written to MAKEOBJDIRPREFIX directory. Kernel config files are stored in sys/$ARCH/conf

Compiler kernel is stored in $MAKEOBJDIRPREFIX/$TARGET_ARCH.$ARCH/usr/$MAKEOBJDIRPREFIX/sys/$KERNCONF/ i.e. /home/aleek/obj/arm.arm/usr/home/aleek/armv6/sys/BEAGLEBOARD-XM. You are interested in 3 of them:

$ file kernel
kernel: ELF 32-bit LSB executable, ARM, version 1 (FreeBSD), dynamically linked (uses shared libs), not stripped
$ file kernel.bin     // raw kernel
kernel.bin: data
$ file kernel.debug   // kernel with debugging symbols, useful for gdb 
kernel.debug: ELF 32-bit LSB executable, ARM, version 1 (FreeBSD), dynamically linked (uses shared libs), not stripped
make xdev XDEV=arm XDEV_ARCH=arm

make developer's toolchain instead of regular.

/usr/ports/devel/arm-rtems-gdb

gdb for arm

make installworld DESTDIR=/home/aleek/panda_dest
make installkernel DESTDIR=/home/aleek/panda_dest KERNCONF=PANDABOARD INSTALL_NODEBUG=t

As you can see, freebsd's makefile supports DESTDIR variable :)

make distrib-dirs DESTDIR=/home/aleek/panda_dest
make distribution DESTDIR=/home/aleek/panda_dest

distrib-dirs makes dirs for rootfs (var, etc, usr ), and distribution “populates DESTDIR with various configuration files and scripts, obviously mostly etc, but it will add some files to rootdir, var and probably somewhere else as well”

Let's see, how to port FreeBSD by example: BeagleBoard-xM. The port is using Flattened Device Tree for describing the software.

Useful options during development:

makeoptions     DEBUG=-g                #Build kernel with gdb(1) debug symbols
options         BREAK_TO_DEBUGGER       #also ALT_BREAK_TO_DEBUGGER
options         VERBOSE_SYSINIT         #Enable verbose sysinit messages
options         KDB
options         DDB                     #Enable the kernel debugger
options         INVARIANTS              #Enable calls of extra sanity checking
options         INVARIANT_SUPPORT       #Extra sanity checks of internal structures, required by INVARIANTS
options         WITNESS                 #Enable checks to detect deadlocks and cycles
options         WITNESS_SKIPSPIN        #Don't run witness on spinlocks for speed
options         DIAGNOSTIC
options         DEBUG

* FreeBSD Architecture Handbook

* FreeBSD Developers' Handbook

* irc://irc.efnet.pl/#bsdmips - The IRC channel for FreeBSD on ARM, AVR32 and PowerPC!

  • embeddedhandbook.1340376973.txt.gz
  • Last modified: 2012/06/22 14:56
  • by AleksanderDutkowski