Introduction

As the EdgeRouter doesn't seem to get any love (QoS) on the FreeBSD project I decided to have a look at other software solutions and as I've previously have good experience with OpenWRT I decided go with it a try. Information is pretty sparse at the moment but I decided to write a few lines on how you write a bootable USB flash stick on FreeBSD. This actually fits within 128M but as I have no USB flash drives that small I ended up grabbing the smallest one I could find which was a 8Gb thumb drive. Do note that this does not need any modification of u-boot.

Prerequisites

  • USB Flash drive (128Mbyte minimum)
  • OpenWRT image (openwrt-octeon-erlite-sysupgrade.tar)

Instructions

  • Plug in the drive and run dmesg, at the end you'll see something like this
ugen3.2: <Verbatim> at usbus3
umass0: <Verbatim STORE N GO, class 0/0, rev 2.00/1.00, addr 2> on usbus3
umass0:  SCSI over Bulk-Only; quirks = 0xc100
umass0:10:0: Attached to scbus10
da8 at umass-sim0 bus 0 scbus10 target 0 lun 0
da8: <Verbatim STORE N GO 1.00> Removable Direct Access SCSI-2 device
da8: Serial Number 1226000000009999
da8: 40.000MB/s transfers
da8: 7645MB (15656960 512 byte sectors: 255H 63S/T 974C)
da8: quirks=0x2<NO_6_BYTE>
  • Let's have a look at the partition layout on da8
    gpart show /dev/da8
=>       1  15656959  da8  MBR  (7.5G)
         1        31       - free -  (16K)
        32  15656928    1  fat32  (7.5G)
  • Delete the FAT32 partition which has ID 1 (hence 1 before the filesystem)
    gpart delete -i 1 /dev/da8
  • Verify that it's deleted
    gpart show /dev/da8
=>       1  15656959  da8  MBR  (7.5G)
         1  15656959       - free -  (7.5G)
  • Delete the partition table
    gpart destroy /dev/da8
  • Create a new MBR partition table
    gpart create -s MBR /dev/da8
    da8 created
  • Create a 32Mbyte large partition for the kernel and align it to 1M
    Note: I don't think it matters in this case in terms of performance but why not since we have the space.
    gpart add -a 1M -t fat32 -s 32M /dev/da8
    da8s1 added
  • Just to be sure, make it active (bootable)
    gpart set -a active -i 1 /dev/da8
    active set on da8s1
  • Create a partition for the root filesystem, in this case 256Mbyte but you'll be fine with 64Mbyte if you have space constraints.
    gpart add -a 1M -t linux-data -s 256M /dev/da8
    da8s2 added
  • Generate (format) the FAT partition
    newfs_msdos /dev/da8s1
newfs_msdos: trim 16 sectors to adjust to a multiple of 63
/dev/da8s1: 65416 sectors in 8177 FAT16 clusters (4096 bytes/cluster)
BytesPerSec=512 SecPerClust=8 ResSectors=1 FATs=2 RootDirEnts=512 Sectors=65520 Media=0xf0 FATsecs=32 SecPerTrack=63 Heads=255 HiddenSecs=0
  • Extract firmware
    tar xf openwrt-octeon-erlite-sysupgrade.tar
  • Mount the FAT partiton
    mount -t msdosfs /dev/da8s1 /mnt
  • Copy kernel to the FAT partition, you also need to rename it to vmlinux.64
    cp ./sysupgrade-erlite/kernel /mnt/vmlinux.64
  • Unmount the FAT partition
    umount /mnt
  • Write the root filesystem the second partition
    dd if=./sysupgrade-erlite/root of=/dev/da8s2 bs=1M
48+0 records in
48+0 records out
50331648 bytes transferred in 7.267285 secs (6925784 bytes/sec)

All set, just plug it in the EdgeRouter