Observations and Comparison with Linux Porting Efforts
Porting NetBSD to this SoC turned out to be a very straightforward
effort, with very few "potholes". I've done a few Linux ports before,
and the adaptation of NetBSD went at least as smoothly as any of the
Linux efforts. In fact, I found NetBSD to have several advantages that
made it substantially easier to port to a new platform than Linux,
especially for a "newbie" like myself with no previous NetBSD porting
experience.
- NetBSD
builds its own NetBSD-specific toolchain as part of the build process.
With Linux, you need to acquire or build yourself a toolchain that's
appropriate for the processor architecture and C library variant you're
using. While there are a number of nice aids for this process (e.g.,
Dan Kegel's crosstool), it can still be a significant pain - for
example, use the wrong binutils variant and things break in mysterious
ways. With
NetBSD, just run the included build script and the toolchain's there.
- The
NetBSD source includes the full system source - kernel and
applications. While this can reduce the flexibility somewhat (for
example, there's only one C library provided), it makes porting and
building much easier. With Linux, one of the main initial tasks is
pulling together the source for the components you want in your root
filesystem, and creating the build tree and scripts to create the
desired filesystem images. On the flip side, however, there are some
Linux distributions available (both free and commercial) that provide full system source and a
build environment - for example, the Snapgear distribution, or the
MontaVista offering - and one advantage these have is that they
generally provide a broad selection of library and application choices,
and tend to be more easily configurable than the standard NetBSD
distribution in selecting the components to be included.
However, NetBSD has a few drawbacks (some significant), particularly for use in embedded systems.
- There is at the time of this writing no Flash Translation Layer
or dedicated Flash filesystem that provides journaling or
wear-leveling to support Flash memory (NOR or NAND). You need to have
the root filesystem on a disk or embedded as a RAM filesystem in the
kernel image (or mounted via NFS). Since the embedded space is extremely
Flash-centric, this is a significant hole. There are apparently efforts
to correct this, but in early 2007 it's not there yet. (With the recent
release of Apple's iPhone, which runs OSX, whose kernel, Darwin, is
BSD-based, and which uses Flash as its storage medium, it looks like
there is some solution that exists, but whether this is open-source at
this point I don't know.)
- The NetBSD kernel doesn't provide the option to build itself
as a
self-extracting compressed image (a zImage in Linux parlance). The
kernel image can be built as a compressed image, but it relies on the
bootloader to be able to uncompress it. However, NetBSD does provide a
utility called gzboot, which decompresses a gzipped kernel to RAM and
jumps to its entry point. This provides essentially the same
functionality as the Linux zImage. (Thanks to Allen Briggs for the
gzboot tip.)
Both Linux and NetBSD benefit tremendously from being open-source
systems. As noted in the introduction, it's because of the
work of others, and their openness in sharing it, that NetBSD and Linux
and most other
open-source systems are quite straightforward to adapt to new
platforms. And there's nothing quite so satisfying as finally seeing
on your console (debug messages and warts and all):
NetBSD/evbarm (Vx115 VEP) booting...
physmemory: 3840 pages at 0x24100000 -> 0x24ffffff
Allocating page tables
freestart = 0x24100000, free_pages = 512 (0x00000200)
IRQ stack: p0x242f2000 v0xc01f2000
ABT stack: p0x242f1000 v0xc01f1000
UND stack: p0x242f0000 v0xc01f0000
SVC stack: p0x242ee000 v0xc01ee000
Creating L1 page table at 0x242fc000
Mapping kernel
pmap_map_chunk: pa=0x24300000 va=0xc0200000 size=0x183000 resid=0x183000 prot=0x3 cache=1
SLLLLLLLLPPP
pmap_map_chunk: pa=0x24483000 va=0xc0383000 size=0x56d000 resid=0x56d000 prot=0x3 cache=1
PPPPPPPPPPPPPLLLLLLLSSSSLLLLLLLLLLLLLLL
Constructing L2 page tables
pmap_map_chunk: pa=0x242f2000 va=0xc01f2000 size=0x1000 resid=0x1000 prot=0x3 cache=1
P
pmap_map_chunk: pa=0x242f1000 va=0xc01f1000 size=0x1000 resid=0x1000 prot=0x3 cache=1
P
pmap_map_chunk: pa=0x242f0000 va=0xc01f0000 size=0x1000 resid=0x1000 prot=0x3 cache=1
P
pmap_map_chunk: pa=0x242ee000 va=0xc01ee000 size=0x2000 resid=0x2000 prot=0x3 cache=1
PP
pmap_map_chunk: pa=0x242fc000 va=0xc01fc000 size=0x4000 resid=0x4000 prot=0x3 cache=2
PPPP
pmap_map_chunk: pa=0x242fb000 va=0xc01fb000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x242fa000 va=0xc01fa000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x242f9000 va=0xc01f9000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x242f8000 va=0xc01f8000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x242f7000 va=0xc01f7000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x242f6000 va=0xc01f6000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x242f5000 va=0xc01f5000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
pmap_map_chunk: pa=0x242f4000 va=0xc01f4000 size=0x1000 resid=0x1000 prot=0x3 cache=2
P
devmap: 70000000 -> 700fffff @ fd000000
pmap_map_chunk: pa=0x70000000 va=0xfd000000 size=0x100000 resid=0x100000 prot=0x3 cache=0
S
devmap: fc000000 -> fc1fffff @ fc000000
pmap_map_chunk: pa=0xfc000000 va=0xfc000000 size=0x200000 resid=0x200000 prot=0x3 cache=0
SS
freestart = 0x249f0000, free_pages = 1552 (0x610)
switching to new L1 page table @0x242fc000...done!
bootstrap done.
init subsystems: stacks vectors undefined page pmap done.
Loaded initial symtab at 0xc038b3f4, strtab at 0xc03b81b0, # entries 11404
abcdefg
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
The NetBSD Foundation, Inc. All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
pmap_postinit: Allocated 35 static L1 descriptor tables
NetBSD 3.0.1 (VX115_VEP) #8: Tue Jan 2 19:17:21 EST 2007
root@localhost.localdomain:/home/agere/vx115_netbsd/build/usr/src/sys/arch/evbarm/compile/obj/VX115_VEP
total memory = 15360 KB
avail memory = 5404 KB
mainbus0 (root)
cpu0 at mainbus0: ARM926EJ-S rev 5 (ARM9E-S core)
cpu0: WB enabled EABT
cpu0: 16KB/32B 4-way Instruction cache
cpu0: 16KB/32B 4-way write-back-locking-C Data cache
vx115_ahb0 at mainbus0
vx115_apb0 at mainbus0
vx115_clk0 at vx115_apb0 addr 0x700c5000-0x700c5067 intr 9
vx115_pic0 at vx115_apb0 addr 0x700c1000-0x700c114b
vx115_com0 at vx115_apb0 addr 0x700e2000-0x700e207b intr 19
vx115_com0: major = 110: console
md0: internal 5000 KB image area
boot device: <unknown>
root on md0a dumps on md0b
mountroot: trying msdos...
mountroot: trying ffs...
root file system type: ffs
WARNING: CHECK AND RESET THE DATE!
init: copying out flags `-s' 3
init: copying out path `/sbin/init' 11
Jan 3 00:17:46 init: /etc/pwd.db: No such file or directory
Enter pathname of shell or RETURN for /bin/sh:
# ls
bin dev etc lib libexec sbin usr
# ps
ps: warning: /var/run/dev.db: No such file or directory
PID TTY STAT TIME COMMAND
5 ? Ss 0:00.13 -sh
7 ? R+ 0:00.02 ps
#
Comments/questions: jsevy@cs.drexel.edu