This HOW-TO will help you easily set up a PogoPlug to run NetBSD without
needing to disassemble the device and solder on a serial adapter. When
you're done, your PogoPlug will still be able to be booted into GNU/Linux
but will automatically boot into NetBSD using the SD card slot as the root
filesystem.

You can choose to use a serial port, if you prefer. If you won't be using
a serial port, skip the next part.

Pins on the PogoPlug (Mobile and Series 4) are numbered one through four
immediately behind the SD card (where behind means towards the rear where
the plugs are). One is farthest back and four is closest to the SD card
slot. TxD is really transmit and RxD, receive. Connect at 115200 baud.

1: power (3.3 volts)
2: TxD
3: RxD
4: ground

If you're not using a serial connection, you'll have to create an account
at http://my.pogoplug.com/, activate the device at
https://my.pogoplug.com/activate/, then navigate to Settings (starting
with the tiny gear icon in the top right of the web interface), select
Security, then enable ssh for your PogoPlug. Choose your own ssh password.
Then, ssh as user root to the IP of your PogoPlug.

Connect ethernet to a network where the PogoPlug can get a DHCP lease and
access to the Internet. Either with a serial console or via ssh, you're at
a root prompt. Paste in these lines to get tools and the NetBSD kernel.

cd /tmp
wget http://download.doozan.com/uboot/nandwrite
wget http://download.doozan.com/uboot/flash_erase
wget http://ftp.netbsd.org/pub/NetBSD/misc/jklos/netbsd.pogo.ub
chmod +x nandwrite flash_erase

If you like, you can get nanddump (via wget
http://download.doozan.com/uboot/nanddump) and back up mtd3 before
overwriting and scp it somewhere else. Something like this would work:

/nanddump -f pogov4mtd3.dump -o /dev/mtd3

Now we flash the actual NetBSD kernel. mtd3 is labeled "failsafe" in the
mtd map and is 8 megs from the start of flash and 8 megs long. The block
size on the PogoPlug is 131072 bytes, so 64 blocks of 128k each works out
to 8 megs. The "-p" option of nandwrite is to pad the kernel to fit whole
blocks.

Note that at this point we begin running commands which write to the
internal flash. A mistake here could brick your PogoPlug, so proceed with
caution!

/flash_erase /dev/mtd3 0 64
/nandwrite -p /dev/mtd3 netbsd.pogo.ub

Next, we write the environment variable bootcmd. Note that the mw commands
in init_mmc are necessary so that NetBSD can use the SD card slot (many
thanks to Lwazi for that). Enter the following as continuous lines (keep
spaces where it wraps):

/usr/local/cloudengines/bin/blparam bootcmd='if ping 192.168.58.254; then
run boot_nand; fi; run boot_bsd'
/usr/local/cloudengines/bin/blparam boot_bsd='run init_mmc; nand read.e
0x800000 0x800000 0x500000; bootm 0x800000'
/usr/local/cloudengines/bin/blparam init_mmc='mw f1010004 11113311; mw
f1010008 551111'

For PogoPlug Pink, the beginning of mtd3 is 0x2500000, so use:

/usr/local/cloudengines/bin/blparam bootcmd='if ping 192.168.58.254; then
run boot_nand; fi; nand read.e 0x800000 0x2500000 0x500000; bootm
0x800000'

Note that the kernel's current size is 4379904 bytes (but it may change,
so please check), or 0x42d500 in hex, so we can round up to 0x500000 in
the nand read.e command like so. If you make a custom kernel, be sure to
make sure the read.e command loads the entire kernel.

nand read.e 0x800000 0x800000 0x500000

We decide whether to boot NetBSD or GNU/Linux based on whether the
PogoPlug can ping a machine on the local network. This gives us the option
to flash a new kernel using GNU/Linux, if we like, without a serial
console. In order to have the PogoPlug boot into GNU/Linux, create an IP
alias at address 192.168.58.254 on any other machine on the same network.
An example would be:

ifconfig usmsc0 inet 192.168.58.254 netmask 0xffffff00 alias

Once back in GNU/Linux, you can rerun the above but with a new kernel or
your own custom kernel. Just copy and paste the wget of nandwrite and
flash_erase, chmod them, wget or scp your own kernel, then flash_erase and
nandwrite your kernel.

A sample kernel configuration file for NetBSD-current is here:

http://ftp.netbsd.org/pub/NetBSD/misc/jklos/POGO

These notes can also be found here:

http://ftp.netbsd.org/pub/NetBSD/misc/jklos/pogoplug_notes

You can use another NetBSD machine to install NetBSD to an SD card and the
kernel you just installed will use that as the root filesystem. A link for
a quick NetBSD installation how-to will come soon.