Subject: Re: Where to start...?
To: Andy Ball <ball@cyberspace.org>
From: Erik Anggard <erik.anggard@packetfront.com>
List: tech-embed
Date: 07/12/2002 10:08:54
Hi Andy,

I'm not aware of any how-to's for this but here are some pointers:

Well, if you want to get really minimalistic all you'll need is:
- A kernel (comment out all options and devices you don't need, in the 
config file before compiling it to reduce the size of the kernel).
- A root device: if you don't have a hardrive you can use a memory disk 
embeded in the kernel (like in the installation-kernel) or NFS.
- Your own statically linked /sbin/init on the root device. This is the 
only userland process started by the kernel so if your system only need 
to run one program call it init and place it in /sbin. (Your program 
might have to do some of the things that the original init does, e.g. if 
your program wants do console io you will need a /dev/console and your 
init will have to open that device and dup2 fd's 0, 1 and 2 to that fd). 
You can of course use the standard init and instead creat your own /etc/rc.

If you want dynamically linked programs you will also need a /usr/lib 
filled with the libraries your programs use (running ldd on a binary 
will list does) and /usr/libexec/ld.elf_so is also needed.

Some programs (like netstat) need to lookup data in the kernel and for 
that they need the kernel symbol table. Normally the symbol-table is 
read from /netbsd but if you use a memory disk embeded in the kernel you 
might not want to put a kernel there (since that would mean having a 
kernel inside the kernel). If that is the case you can use kvm_mkdb (8) 
to create a /var/db/kvm.db that will be used instead.

If you use existing programs you will of course need to lookup what 
libraries they need (if dynamically linked), what config files they use, 
other directories (e.g. they might want to put a log file in /var/log) 
and if they exec other programs.

That's all I can think of for the moment. You might want to search the 
netbsd mailing lists too, for example there was a post not long ago with 
some suggestions on how to reduce the size of libc (by using make 
defines to strip out stuff not normally not need by a small system).

Good luck,
Erik



Andy Ball wrote:

>Hello!                                               
>
>I'm planning to embed NetBSD into a few different pieces of
>kit.  The first will probably be a box with a bunch of       
>RAM, a CD-ROM drive and the appropriate I/O (it'll be a
>firewall).  Other projects on my drawing board feature more
>minimal hardware.
>
>I am wondering what processes people go through to embed  
>NetBSD.  I'd like to take 'ground up' approach, putting in   
>just those things I'm actually using.  The later projects
>will probably demand that kind of minimalism.  Is there a
>HOW-TO or some introductory documentation somewhere to
>help me get started?
>
>- Andy Ball.
>  
>