This bash script can be used to flash Onion Omega2(+) or Omega2S(+) factory state devices with custom firmware with no manual intervention except for connecting power and Ethernet.
The key is that the factory firmware of the Omega2(S) has IPv6 running on the ethernet by default, with a link local address derived from the Omega2's MAC. And as IPv6 easily allows to discover device's IPv6 on the local link (e.g. ping6 ff02::1%en7), the script can find the devices, send firmware via scp, and launch sysupgrade via ssh.
The script detects Omega2S from an early production batch which don't have a valid ethernet MAC programmed and automatically provisions the correct MAC address.
The script also allows to provision the uboot environment. This only works if the flashed custom firmware includes the fw_setenv utility and have a writable uboot environment partition.
As it is now, the script only programs one device at a time. It can be run in a loop, as it remembers programmed device's IPv6 to avoid programming the same device twice.
The script can also program Omega2 found on wireless network segments, however it can not automatically connect to Omega2 hotspots.
omega2flash <ethernet-if> <auto|wait|omega2_ipv6|list|ping> [<firmware.bin> [<uboot-env-file>] [<extra-conf-files-dir]]"
Where:
ifconfig
or ip link
for a list), on macos it's something like "en2" (use networksetup -listallhardwareports
for a list)/tmp/flashed_omega2_ipv6
) is used to record all IPv6 addresses of already programmed devices. In wait mode, the omega2flash script can be used in a loop to program batches of devices.etc/uci-defaults/...
and/or etc/config/...
files.Note: The script generates ANSI colored output when run from a terminal. Set NO_COLOR
environment variable to prevent colors, or set FORCE_COLOR
to output color even if stdout is not a terminal (e.g. to create logfiles with color included).
...are welcome! There's a lot that could be improved. Pull requests and comments can be posted on github
The omega2flash script is MIT licensed.
(c) 2017-2022 by plan44.ch/luz