Building a wireless hub

In the course of meandering around the web looking at computer hardware, I stumbled across this board from PC Engines. It looked like it could form the basis of a wireless hub, but with sufficient grunt to handle the web server (and other services such as DNS, DHCPD, mail etc). Why was this interesting? In the home environment, I have three boxes consuming electricity; the VDSL router (Draytek Vigor 2860), the web server (IBM T42 laptop running FreeBSD) and a wireless hub in the sitting room, which is connected to the router by a CAT5 cable dropped through two ceilings. If I could build a wireless router based on the APU.1D4 board, I could eliminate one humming box, i.e. the T42 laptop.

From a local supplier, I bought:

The only difficult bit about the assembly was making sure the thermal pads were applied as instructed. I could have sworn I had a 9pin serial console cable lying around, but I couldn't find it. Installation of the OS would have to wait a couple of days until the one I ordered arrived.

I had initially thought about installing OpenBSD on the device, but it didn't support the Atheros (AR9580) wireless card I'd purchased. I did start to look at what would be required to add support in OpenBSD, but quickly realised it would take more time and skill than I had, so I went with FreeBSD.

It was the first time I'd had a chance to play with multiple ethernet ports (and the wireless card of course), but it turned out to be remarkably easy to create a bridge device for the hub. Here's the /etc/rc.conf setup:

   wlans_ath0="wlan0"
   create_args_wlan0="wlanmode hostap"
   cloned_interfaces="bridge0"
   ifconfig_bridge0="inet 192.168.0.4 netmask 255.255.255.0 addm re0 \
                      addm re1 addm re2 addm wlan0 up"
   ifconfig_re0="up"
   ifconfig_re1="up"
   ifconfig_re2="up"
   # -bgscan and -powersave may help prevent timeouts
   # channel 2 seems to help prevent beacon issues
   ifconfig_wlan0="ssid hydrus mode 11g up channel 2 -bgscan -powersave"
 

You'll note from the comments in the /etc/rc.conf file, that the wireless access point was experiencing beacon misses and timeouts (resulting in messages regarding stubbed routines in the Atheros driver). The settings specified above minimise the problems, but they are not eliminated.

I'm also running hostapd, which provide WPA security. The configuration file (/etc/hostapd.conf) is likewise fairly simple:

  interface=wlan0
  dump_file=/tmp/hostapd.dump
  ctrl_interface=/var/run/hostapd
  ctrl_interface_group=wheel
  wpa=2
  wpa_passphrase=[REDACTED]
  wpa_key_mgmt=WPA-PSK
  wpa_pairwise=CCMP TKIP

The device is warm to the touch, due to the (non-fan) heat dissipation mechanism. The CPU temperature runs at about 59 degrees Celsius. When under load (e.g. compiling FreeBSD), it rises to around 76 degrees. Suggested maximum temperature for the AMD T40E CPU is 90 degrees, so should be OK.

Dmesg below:

  Copyright (c) 1992-2016 The FreeBSD Project.
  Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
      The Regents of the University of California. All rights reserved.
  FreeBSD is a registered trademark of The FreeBSD Foundation.
  FreeBSD 10.3-RELEASE-p1 #0 r298770: Fri Apr 29 16:22:54 BST 2016
      root@opal:/usr/obj/usr/src/sys/GENERIC amd64
  FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
  CPU: AMD G-T40E Processor (1000.02-MHz K8-class CPU)
    Origin="AuthenticAMD"  Id=0x500f20  Family=0x14  Model=0x2  Stepping=0
    Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
    Features2=0x802209<SSE3,MON,SSSE3,CX16,POPCNT>
    AMD Features=0x2e500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM>
    AMD Features2=0x35ff<LAHF,CMP,SVM,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,IBS,SKINIT,WDT>
    SVM: NP,NRIP,NAsids=8
    TSC: P-state invariant, performance statistics
  real memory  = 4815060992 (4592 MB)
  avail memory = 4085374976 (3896 MB)
  Event timer "LAPIC" quality 400
  ACPI APIC Table: <CORE   COREBOOT>
  FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
  FreeBSD/SMP: 1 package(s) x 2 core(s)
   cpu0 (BSP): APIC ID:  0
   cpu1 (AP): APIC ID:  1
  random: <Software, Yarrow> initialized
  ioapic0 <Version 2.1> irqs 0-23 on motherboard
  module_register_init: MOD_LOAD (vesa, 0xffffffff80dc6500, 0) error 19
  kbd0 at kbdmux0
  acpi0: <CORE COREBOOT> on motherboard
  acpi0: Power Button (fixed)
  cpu0: <ACPI CPU> on acpi0
  cpu1: <ACPI CPU> on acpi0
  atrtc0: <AT realtime clock> port 0x70-0x71 irq 8 on acpi0
  Event timer "RTC" frequency 32768 Hz quality 0
  attimer0: <AT timer> port 0x40-0x43 irq 0 on acpi0
  Timecounter "i8254" frequency 1193182 Hz quality 0
  Event timer "i8254" frequency 1193182 Hz quality 100
  Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
  acpi_timer0: <32-bit timer at 3.579545MHz> port 0x808-0x80b on acpi0
  hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0
  Timecounter "HPET" frequency 14318180 Hz quality 950
  Event timer "HPET" frequency 14318180 Hz quality 550
  Event timer "HPET1" frequency 14318180 Hz quality 450
  pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
  pci0: <ACPI PCI bus> on pcib0
  pcib1: <ACPI PCI-PCI bridge> irq 16 at device 4.0 on pci0
  pci1: <ACPI PCI bus> on pcib1
  re0: <RealTek 8168/8111 B/C/CP/D/DP/E/F/G PCIe Gigabit Ethernet> port 0x1000-0x10ff mem 0xf7900000-0xf7900fff,0xf7800000-0xf7803fff irq 16 at device 0.0 on pci1
  re0: Using 1 MSI-X message
  re0: ASPM disabled
  re0: Chip rev. 0x2c000000
  re0: MAC rev. 0x00200000
  miibus0: <MII bus> on re0
  rgephy0: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 1 on miibus0
  rgephy0:  none, 10baseT, 10baseT-FDX, 10baseT-FDX-flow, 100baseTX, 100baseTX-FDX, 100baseTX-FDX-flow, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, 1000baseT-FDX-flow, 1000baseT-FDX-flow-master, auto, auto-flow
  re0: Using defaults for TSO: 65518/35/2048
  re0: Ethernet address: 00:0d:b9:40:3e:68
  pcib2: <ACPI PCI-PCI bridge> irq 17 at device 5.0 on pci0
  pci2: <ACPI PCI bus> on pcib2
  re1: <RealTek 8168/8111 B/C/CP/D/DP/E/F/G PCIe Gigabit Ethernet> port 0x2000-0x20ff mem 0xf7b00000-0xf7b00fff,0xf7a00000-0xf7a03fff irq 17 at device 0.0 on pci2
  re1: Using 1 MSI-X message
  re1: ASPM disabled
  re1: Chip rev. 0x2c000000
  re1: MAC rev. 0x00200000
  miibus1: <MII bus> on re1
  rgephy1: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 1 on miibus1
  rgephy1:  none, 10baseT, 10baseT-FDX, 10baseT-FDX-flow, 100baseTX, 100baseTX-FDX, 100baseTX-FDX-flow, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, 1000baseT-FDX-flow, 1000baseT-FDX-flow-master, auto, auto-flow
  re1: Using defaults for TSO: 65518/35/2048
  re1: Ethernet address: 00:0d:b9:40:3e:69
  pcib3: <ACPI PCI-PCI bridge> irq 18 at device 6.0 on pci0
  pci3: <ACPI PCI bus> on pcib3
  re2: <RealTek 8168/8111 B/C/CP/D/DP/E/F/G PCIe Gigabit Ethernet> port 0x3000-0x30ff mem 0xf7d00000-0xf7d00fff,0xf7c00000-0xf7c03fff irq 18 at device 0.0 on pci3
  re2: Using 1 MSI-X message
  re2: ASPM disabled
  re2: Chip rev. 0x2c000000
  re2: MAC rev. 0x00200000
  miibus2: <MII bus> on re2
  rgephy2: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 1 on miibus2
  rgephy2:  none, 10baseT, 10baseT-FDX, 10baseT-FDX-flow, 100baseTX, 100baseTX-FDX, 100baseTX-FDX-flow, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, 1000baseT-FDX-flow, 1000baseT-FDX-flow-master, auto, auto-flow
  re2: Using defaults for TSO: 65518/35/2048
  re2: Ethernet address: 00:0d:b9:40:3e:6a
  ahci0: <AMD SB7x0/SB8x0/SB9x0 AHCI SATA controller> port 0x4010-0x4017,0x4020-0x4023,0x4018-0x401f,0x4024-0x4027,0x4000-0x400f mem 0xf7f04000-0xf7f043ff irq 19 at device 17.0 on pci0
  ahci0: AHCI v1.20 with 6 6Gbps ports, Port Multiplier supported
  ahci0: quirks=0x22000<ATI_PMP_BUG,1MSI>
  ahcich0: <AHCI channel> at channel 0 on ahci0
  ahcich1: <AHCI channel> at channel 1 on ahci0
  ahcich2: <AHCI channel> at channel 2 on ahci0
  ahcich3: <AHCI channel> at channel 3 on ahci0
  ahcich4: <AHCI channel> at channel 4 on ahci0
  ahcich5: <AHCI channel> at channel 5 on ahci0
  ohci0: <AMD SB7x0/SB8x0/SB9x0 USB controller> mem 0xf7f00000-0xf7f00fff irq 18 at device 18.0 on pci0
  usbus0 on ohci0
  ehci0: <AMD SB7x0/SB8x0/SB9x0 USB 2.0 controller> mem 0xf7f04400-0xf7f044ff irq 17 at device 18.2 on pci0
  usbus1: EHCI version 1.0
  usbus1 on ehci0
  ohci1: <AMD SB7x0/SB8x0/SB9x0 USB controller> mem 0xf7f01000-0xf7f01fff irq 18 at device 19.0 on pci0
  usbus2 on ohci1
  ehci1: <AMD SB7x0/SB8x0/SB9x0 USB 2.0 controller> mem 0xf7f04500-0xf7f045ff irq 17 at device 19.2 on pci0
  usbus3: EHCI version 1.0
  usbus3 on ehci1
  isab0: <PCI-ISA bridge> at device 20.3 on pci0
  isa0: <ISA bus> on isab0
  pcib4: <ACPI PCI-PCI bridge> at device 20.4 on pci0
  pci4: <ACPI PCI bus> on pcib4
  ohci2: <AMD SB7x0/SB8x0/SB9x0 USB controller> mem 0xf7f02000-0xf7f02fff irq 18 at device 20.5 on pci0
  usbus4 on ohci2
  pcib5: <ACPI PCI-PCI bridge> at device 21.0 on pci0
  pci5: <ACPI PCI bus> on pcib5
  ath0: <Atheros AR9580> mem 0xf7e00000-0xf7e1ffff irq 16 at device 0.0 on pci5
  ar9300_set_stub_functions: setting stub functions
  ar9300_set_stub_functions: setting stub functions
  ar9300_attach: calling ar9300_hw_attach
  ar9300_hw_attach: calling ar9300_eeprom_attach
  ar9300_flash_map: unimplemented for now
  Restoring Cal data from DRAM
  Restoring Cal data from EEPROM
  Restoring Cal data from Flash
  Restoring Cal data from Flash
  Restoring Cal data from OTP
  ar9300_hw_attach: ar9300_eeprom_attach returned 0
  ath0: RX status length: 48
  ath0: RX buffer size: 4096
  ath0: TX descriptor length: 128
  ath0: TX status length: 36
  ath0: TX buffers per descriptor: 4
  ar9300_freebsd_setup_x_tx_desc: called, 0x0/0, 0x0/0, 0x0/0
  ath0: ath_edma_setup_rxfifo: type=0, FIFO depth = 16 entries
  ath0: ath_edma_setup_rxfifo: type=1, FIFO depth = 128 entries
  ath0: [HT] enabling HT modes
  ath0: [HT] enabling short-GI in 20MHz mode
  ath0: [HT] 1 stream STBC receive enabled
  ath0: [HT] 1 stream STBC transmit enabled
  ath0: [HT] 2 RX streams; 2 TX streams
  ath0: AR9580 mac 448.4 RF5110 phy 0.0
  ath0: 2GHz radio: 0x0000; 5GHz radio: 0x0000
  ohci3: <AMD SB7x0/SB8x0/SB9x0 USB controller> mem 0xf7f03000-0xf7f03fff at device 22.0 on pci0
  usbus5 on ohci3
  ehci2: <AMD SB7x0/SB8x0/SB9x0 USB 2.0 controller> mem 0xf7f04600-0xf7f046ff at device 22.2 on pci0
  usbus6: EHCI version 1.0
  usbus6 on ehci2
  amdtemp0: <AMD CPU On-Die Thermal Sensors> on hostb4
  acpi_button0: <Power Button> on acpi0
  orm0: <ISA Option ROM> at iomem 0xee800-0xeffff on isa0
  ppc0: cannot reserve I/O port range
  uart0: <16550 or compatible> at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
  uart0: console (115200,n,8,1)
  uart1: <16550 or compatible> at port 0x2f8-0x2ff irq 3 on isa0
  random: unblocking device.
  usbus0: 12Mbps Full Speed USB v1.0
  Timecounters tick every 1.000 msec
  usbus1: 480Mbps High Speed USB v2.0
  usbus2: 12Mbps Full Speed USB v1.0
  usbus3: 480Mbps High Speed USB v2.0
  ugen0.1: <ATI> at usbus0
  uhub0: <ATI OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0
  ugen1.1: <ATI> at usbus1
  uhub1: <ATI EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
  ugen2.1: <ATI> at usbus2
  uhub2: <ATI OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus2
  ugen3.1: <ATI> at usbus3
  uhub3: <ATI EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus3
  usbus4: 12Mbps Full Speed USB v1.0
  usbus5: 12Mbps Full Speed USB v1.0
  usbus6: 480Mbps High Speed USB v2.0
  ugen4.1: <ATI> at usbus4
  uhub4: <ATI OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus4
  ugen5.1: <ATI> at usbus5
  uhub5: <ATI OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus5
  ugen6.1: <ATI> at usbus6
  uhub6: <ATI EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus6
  ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
  ada0: <Crucial CT250MX200SSD3 MU03> ACS-3 ATA SATA 3.x device
  ada0: Serial Number 160911EEFB13
  ada0: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 8192bytes)
  ada0: Command Queueing enabled
  ada0: 238475MB (488397168 512 byte sectors)
  ada0: Previously was known as ad4
  uhub4: 2 ports with 2 removable, self powered
  uhub0: 5 ports with 5 removable, self powered
  SMP: AP CPU #1 Launched!
  Timecounter "TSC" frequency 1000022733 Hz quality 800
  Root mount waiting for: usbus6 usbus5 usbus3 usbus2 usbus1
  uhub2: 5 ports with 5 removable, self powered
  uhub5: 4 ports with 4 removable, self powered
  Root mount waiting for: usbus6 usbus3 usbus1
  uhub6: 4 ports with 4 removable, self powered
  uhub3: 5 ports with 5 removable, self powered
  uhub1: 5 ports with 5 removable, self powered
  Root mount waiting for: usbus6
  ugen6.2: <Generic> at usbus6
  umass0: <Generic Flash Card ReaderWriter, class 0/0, rev 2.01/1.00, addr 2> on usbus6
  umass0:  SCSI over Bulk-Only; quirks = 0x4001
  umass0:6:0:-1: Attached to scbus6
  Trying to mount root from ufs:/dev/ada0p2 [rw]...
  da0 at umass-sim0 bus 0 scbus6 target 0 lun 0
  da0: <Multiple Card  Reader 1.00> Removable Direct Access SPC-2 SCSI device
  da0: Serial Number 058F63666485
  da0: 40.000MB/s transfers
  da0: Attempt to query device size failed: NOT READY, Medium not present
  da0: quirks=0x2<NO_6_BYTE>