Subject: Re: NetBSD for embedded i386 apps
To: Paul Taylor <ptaylor@ashdown-electronics.co.uk>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: netbsd-advocacy
Date: 07/31/2003 21:42:12
> Things are slightly different for NetBSD, but conceptually it's
> similar.  Have a peruse through /usr/src/distrib/i386 to see how
> the boot floppies/cdroms are built.  It's along the lines of:

I did that recently. As there is not much documentation about this
topic, the actual options and command will help a lot...

>         - build a kernel with space reserved for an in-built "ramdisk"

Here are the kernel options:
MEMORY_DISK_HOOKS
MEMORY_DISK_IS_ROOT
MEMORY_DISK_ROOT_SIZE=size

And of course pseudo-device md

>         - build your applications (usually, "crunched" to save space)

That one is easy: just use crunchgen

>         - build an ffs file system containing the OS image and your
>           applications

dd if=/dev/zero of=ramdisk.fs bs=1024k count=whatever
vnconfig vnd0 ramdisk.fs
disklabel -I -e vnd0
newfs /dev/vnd0a
mount /devv/vnd0a /mnt

>         - stuff that ffs image into the kernel
>         - munge the kernel to boot on your chosen media (provide
>           a bootloader, etc)

Use "mdsetimage netbsd ramdisk.fs" to fold ramdisk.fs into the kernel.
If it fails, it's probably that you don't have the proper options in
your kernel (MEMORY_DISK_HOOKS and friends).

Before using mdsetimage, you'll umount /mnt and vnconfig -u vnd0. But
there is a bug in the vnd driver, changes will not be flushed to
ramdisk.fs imediatly (kern/18116). Workaround: do it twice
umount /mnt
vnconfig -u vnd0
vnconfig vnd0 ramdisk.fs
vnconfig -u vnd0

-- 
Emmanuel Dreyfus
Il y a 10 sortes de personnes dans le monde: ceux qui comprennent 
le binaire et ceux qui ne le comprennent pas.
manu@netbsd.org