John's research

From WirelessAfrica
Revision as of 18:35, 13 August 2008 by Jhay (talk | contribs) (Some more from my docs and part one of describing how the configs fit in)

Calling this research is probably a bit wild.

Here I'll try to capture the work done with our FreeBSD based wireless routers.

How the config files on our distro fit together

The idea was to try and leverage as much of FreeBSD's startup scripts and procedures as possible. This makes for less work and more testing, at least for the common parts. The standard FreeBSD startup scripts already cater for a diskless case, where /etc and /var are ramdisks and the rest can be read-only. That fits well with our case where we want the Compact Flash (CF) mostly read-only for reliability, but still needs things in /etc and /var to change during and after bootup. So we force this by creating the file /etc/diskless.

So maybe a description of the boot process is in order. I'll skip some detail that I think is not important to understand this. The kernel will at some stage get bored configuring RAM and probe for devices and look for something else to do. It will then load and run /sbin/init. Init will do some things and then run the /etc/rc script. And this is where the interesting stuff begins.

rc will try to determine if it is the diskless case. If so it will run /etc/rc.initdiskless, which will create a ramdisk over /etc and populate it from /conf/base/etc and then from /conf/default/etc. The idea being that you can have a standard /etc tree in /conf/base/ and your local changes in /conf/default/. So all the files that we change will be in /conf/default/. After that, rc.initdiskless will also create and populate a /var ramdisk. When finished, it will return to rc.

FreeBSD startup scripts reside in /etc/rc.d/ and /usr/local/etc/rc.d/ for packages. Now rc will use rcorder on those two directories to determine the dependencies and order they must be run in. /etc/rc.d/early.sh is one of the first to run. It will run /etc/rc.early if it exists. It does not exist by default.

Most startup scripts in rc.d/ can be enabled/disabled in /etc/rc.conf. Maybe that is a bit too simple. They will use a function called load_rc_config to load /etc/defaults/rc.conf, /etc/rc.conf and /etc/rc.conf.local, in that order.

So for our distro we install /etc/rc.early where the biggest chunk of our configuration will happen. A lot of it is just to put the right stuff in /etc/rc.conf and other app specific config files. Then the rest of the normal FreeBSD startup procedure, to run the startup scripts in rc.d/ will take care of the rest.

rc.conf - edited by auto script if auto_update_enable and _url set rc.conf.mesh - included early by rc.conf with defaults for the mesh rc.conf.local - overrides with partly manual conf

  1. conf directories

/etc - ramdisk with end results /conf/base/etc - original FreeBSD stuff /conf/default/etc - changed files, our and packages /usr/local/etc - a symlink to /etc/usr.local.etc

  1. The basic idea is that config overrides that is done manually, have
  2. to be done in /conf/default/etc/rc.conf.local because it is read last
  3. and so overrides previous settings.
  4. The startup scripts will create the ramdisk /etc, then recursively copy
  5. /conf/base/etc into it and then /conf/default/etc.
  6. The real /etc needs diskless rc fstab rc.initdiskless in it for this to
  7. work.
      1. files that will need to be twiddled by scripts on startup:

/etc/rc.conf - interface conf /usr/local/etc/olsrd.conf - interface, dns /usr/local/etc/dhcpd.conf - dhcpd /etc/resolv.conf - ? /usr/local/etc/dnsmasq.conf - dhcp + dns ?

What is there to tweak

Installing FreeBSD on a Avila/Pronghorn Metro ARM board

Gateworks Avila boards

Note! FreeBSD detects the mini-pci cards different from the labeled order on the PC board. It detects it in this order: J3, J1, J4, J2 So the card in J3 will be ath0...

ADI Pronghorn Metro boards

Note! FreeBSD detects the mini-pci cards in reverse order from the labeling on the PC board. So it will detect from PCI3, PCI2, PCI1 to PCI0. So the card in slot PCI3 will be ath0.


  • Redboot use 115200 baud, so use
  • > cu -l /dev/your-serial-dev -s 115200
  • Break RedBoot with ^C where it says you can. :-)
  • > ip -l 10.0.0.234/24 -h 10.0.0.1 # LAB C155
  • > ip -l 146.64.5.234/24 -h 146.64.5.1 # JHAY-LAB
  • > load boot2
  • On the ADI Pronghorn boards you might get an write error. They seem to lock the flash. Just unlock it. Look for the address in the error message and do something like this and do the fis create command again:
    • > fis free
    • > fis unlock -f 0x50060000 -l 0x20000
  • > fis create boot2
  • > fconfig
  • Change the "run script at boot" to true
  • Change the startup script to:
    • fis load boot2
    • go
  • Change the timeout to 3.
  • Change BOOTP enabled to false.
  • Enter a . on the next option to end fconfig. Choose y to save it.
  • > load -b 0x200000 kernel-avila
  • > go
  • Type <enter> at the shell prompt.
  • > ./writedisk disk-arm-7-20070315.tgz # Normally use the latest
  • > reboot
  • Reboot to make sure everything is working.

Installing a distro

Building a distro