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.
Compiling
Kernel
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
world
make TARGET_ARCH=arm TARGET_CPUTYPE=armv6 buildworld make TARGET_ARCH=arm TARGET_CPUTYPE=armv6 DESTDIR=/home/alek/beagle_rootfs SHAREOWN=alek SHAREGRP=wheel INSTALL=/home/alek/beagle-armv6/tools/install.sh installworld -DWITHOUT_SHAREDOCS -DWITHOUT_EXAMPLES -DWITHOUT_GAMES -DWITHOUT_HTML -DWITHOUT_INFO -DWITHOUT_MAN make distrib-dirs DESTDIR=/home/alek/beagle_rootfs make distribution DESTDIR=/home/alek/beagle_rootfs
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”
Running
u-boot with tftp
rootfs via nfs
debugging
kdb
j-tag and gdb
Porting FreeBSD to new boards
Let's see, how to port FreeBSD by example: BeagleBoard-xM. The port is using Flattened Device Tree for describing the software.
Config file
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
initarm()
Useful Links
* FreeBSD Architecture Handbook
* FreeBSD Developers' Handbook
* irc://irc.efnet.pl/#bsdmips - The IRC channel for FreeBSD on ARM, AVR32 and PowerPC!