Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== 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 ====== Environment variables for building kernel/world: <code> ARCH=arm TARGET_ARCH=arm MAKEOBJDIRPREFIX=/home/aleek/obj </code> ===== Kernel ===== <code> export MAKEOBJDIRPREFIX=/home/aleek/obj export ARCH=arm export TARGET_ARCH=arm make kernel-toolchain (not necessary, when building world before kernel) make buildkernel KERNCONF=BEAGLEBOARD-XM make buildworld </code> 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: <code> $ 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 </code> You can make developer's toolchain, instead of regular: <code> make xdev XDEV=arm XDEV_ARCH=arm </code> RTEMS provides set of GNU debuggers for a couple of architectures: <code> # cd /usr/ports; make search name=rtems-gdb Port: arm-rtems-gdb-7.2 Path: /usr/ports/devel/arm-rtems-gdb Info: GNU gdb port for cross-target development Maint: ports@FreeBSD.org Port: i386-rtems-gdb-7.2 Path: /usr/ports/devel/i386-rtems-gdb Info: GNU gdb port for cross-target development Maint: ports@FreeBSD.org Port: m68k-rtems-gdb-7.2 Path: /usr/ports/devel/m68k-rtems-gdb Info: GNU gdb port for cross-target development Maint: ports@FreeBSD.org Port: mips-rtems-gdb-7.2 Path: /usr/ports/devel/mips-rtems-gdb Info: GNU gdb port for cross-target development Maint: ports@FreeBSD.org Port: powerpc-rtems-gdb-7.2 Path: /usr/ports/devel/powerpc-rtems-gdb Info: GNU gdb port for cross-target development Maint: ports@FreeBSD.org Port: sh-rtems-gdb-7.2 Path: /usr/ports/devel/sh-rtems-gdb Info: GNU gdb port for cross-target development Maint: ports@FreeBSD.org Port: sparc-rtems-gdb-7.2 Path: /usr/ports/devel/sparc-rtems-gdb Info: GNU gdb port for cross-target development Maint: ports@FreeBSD.org </code> ===== world ===== <code> 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 </code> ''%%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 [[FlattenedDeviceTree|Flattened Device Tree]] for describing the software. ===== Config file ===== Useful options during development: <code> 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 </code> ===== initarm() ===== ====== Useful Links ====== * [[http://www.freebsd.org/doc/en/books/arch-handbook/|FreeBSD Architecture Handbook]] * [[http://www.freebsd.org/doc/en/books/developers-handbook/|FreeBSD Developers' Handbook]] * [[irc://irc.efnet.pl/#bsdmips]] - The IRC channel for %%FreeBSD%% on ARM, AVR32 and %%PowerPC%%! ---- {{tag>HowTo}} embeddedhandbook.txt Last modified: 2018/05/26 00:05by MateuszPiotrowski