Skip to content

Onion Omega

Allan Jude edited this page Feb 16, 2016 · 5 revisions

Running FreeBSD up on the Onion Omega

Introduction

The Onion Omega is an inexpensive IoT (Internet of Things) rapid-prototyping device

Hardware

The Onion Omega (https://onion.io/omega/) is an AR9330 based board with:

  • AR9330 Rev 1 SoC
  • 1x1 2GHz 802.11b/g/n support
  • 16MiB NOR flash
  • 64MiB RAM
  • 10/100 ethernet port
  • USB host port
  • RS232 console port
  • Lots of GPIO pins

The Omega combined with the standard expansion dock provides:

  • Power switch
  • GPIO Reset button
  • 3 LEDs controlled by GPIO 15-17
  • USB Host port
  • Power and RS232 console via mini-USB
  • 18 GPIO pins

A number of expansions are also available:

  • Ethernet Expansion: 1x 10/100mbps port (the SoC supports 2 ports, but only 1 expansion is supported)
  • Relay Expansion: 2 relays that support 120V AC or 24V DC (stack up to 8 expansions for 16 relays)
  • PWM Servo Expansion: Control up to 16 servos
  • 1" Monochrome OLED Expansion (128x64 pixels)

Building FreeBSD for the Omega

As root:

# pkg install lzma rsync perl5 uboot-mkimage git
# mkdir /tftpboot

As a regular user (just to be 100% sure no mips bits end up in your working OS):

# mkdir ~/omega
# cd ~/omega
# git clone https://github.com/freebsd/freebsd-wifi-build.git
# git clone https://github.com/freebsd/freebsd src
# cd src
# ../freebsd-wifi-build/build/bin/build onionomega

Copy the resulting image file to /tftpboot and configure tftpd

TFTP Booting FreeBSD on the Omega

  • Power the board via mini-USB and connect via the integrated serial (part of the mini-USB port)
  • Turn the power switch on
  • Press any key to interrupt the boot process:
*********************************************
*   U-Boot 1.1.4  (Sep 14 2015, 08:21:31)   *
*********************************************

AP121 (AR9331) U-Boot for Onion Omega

DRAM:   64 MB DDR2 16-bit
id read ox100000ff
FLASH: 16MCLOCKS: 400/400/200/20 MHz (CPU/RAM/AHB/SPI)

LED on during eth initialization...

Hit any key to stop autobooting:  2

Omega>
Omega> setenv ipaddr 192.168.13.10
Omega> setenv serverip 192.168.13.1
Omega> tftpboot 0x80600000 onionomega.factory.bin
Ethernet mode (duplex/speed): 1/100 Mbps

TFTP from IP: 192.168.13.1
      Our IP: 192.168.13.10
    Filename: 'onionomega.factory.bin'
Load address: 0x80600000
       Using: eth0

     Loading: ########################################
              ########################################

TFTP transfer complete!

Bytes transferred: 5846016 (0x593400)
Omega> bootm 0x80600000

And FreeBSD should boot to the mount root prompt. The image expects to find a root file system on the internal flash, and that still has linux, so you'd need to provide a root file system on a USB stick at this point. Or, you could go all in, and overwrite the OpenWRT install on the flash:

Burning FreeBSD into the flash

Omega> erase 0x9f020000 +0xf80000
Erase FLASH from 0x9F020000 to 0x9FF9FFFF in bank #1
Erasing: #######################################
         #######################################
         #######################################
         #######################################
         #######################################
         #########################

Erased sectors: 250
Omega> 
Omega> setenv ipaddr 192.168.13.10
Omega> setenv serverip 192.168.13.1
Omega> tftpboot 0x80020000 onionomega.factory.bin
Ethernet mode (duplex/speed): 1/100 Mbps

TFTP from IP: 192.168.13.1
      Our IP: 192.168.13.10
    Filename: 'onionomega.factory.bin'
Load address: 0x80020000
       Using: eth0

     Loading: ########################################
              ########################################

TFTP transfer complete!

Bytes transferred: 5846016 (0x593400)
Omega> cp.b 0x80020000 0x9f020000 $filesize
Copying to FLASH...
Writting at address: 0x9F020000

Done!
Omega> reset

And now it should boot FreeBSD

*********************************************
*   U-Boot 1.1.4  (Sep 14 2015, 08:21:31)   *
*********************************************

AP121 (AR9331) U-Boot for Onion Omega

DRAM:   64 MB DDR2 16-bit
id read ox100000ff
FLASH: 16MCLOCKS: 400/400/200/20 MHz (CPU/RAM/AHB/SPI)

LED on during eth initialization...

Hit any key to stop autobooting:  0

Booting image at: 0x9F020000

   Image name:   FreeBSD FreeBSD-HEAD
   Image type:   MIPS Linux Kernel Image (lzma compressed)
   Data size:    1375744 Bytes = 1.3 MB
   Load address: 0x80050000
   Entry point:  0x80050100

Uncompressing kernel image... OK!
Starting kernel...

CPU platform: Atheros AR9330 rev 1
CPU Frequency=400 MHz

...

FreeBSD/mips (freebsd-wifi) (ttyu0)

login: 

Controlling the Relay Expansion

The relay expansion can be used to switch up to 120V AC or 24V DC There are two relays on each expansion, numbered 0 and 1 To activate relay #0:

printf '\01' | i2c -a 0x27 -d w -o 0x09 -c 1

To activate relay #1, send \02, to activate both, send \03

The relay expansion is also stackable, up to 8 of them for a total of 16 relays. Each relay has a set of 3 dip switches on it that are used to control its address. The result is the relays will have I2C addresses ranging from 0x20 to 0x27

You can probe for the available I2C devices with this command:

i2c -s