OpenWrt is an open source operating system based on Linux especially designed for embedded & networking devices. This OS is well known for its lightweight footprint, standardized configuration approach (using LUCI interface), easy to build images, as opkg packages. At the core of OpenWrt is a writable root file system, where the users can add and/or remove packages, modify configs etc…. without having to re-flash the entire firmware/operating system. This is achieved by overlaying a read-only compressed SquashFS file system with a writable JFFS2 filesystem using OverlayFS. You can install pre-built packages from OpenWrt repo (which contains approximately 3500 packages) using opkg package manager.
The Build Process
Below steps cover the required pre-build environment and how to build OpenWrt from the source tree for Raspberry Pi board. Even though OpenWrt recommends Debian for the build machine, I built it successfully on Ubuntu 18.04 Desktop.
Setup Build Environment
1 2 3 4 5 6 7 |
sudo apt-get update sudo apt-get install git-core subversion mercurial build-essential libssl-dev libncurses5-dev unzip gawk zlib1g-dev unset SED unset GREP_OPTIONS export GREP_OPTIONS= export PATH=$PATH:~/openwrt/openwrt/staging_dir/host/bin export PATH=$PATH:~/openwrt/openwrt/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.16 |
Build OpenWrt
Fetch the source tree from Openwrt git repo
1 |
git clone https://github.com/openwrt/openwrt.git |
Move to OpenWRT source tree and execute the following commands:
1 2 3 4 |
cd openwrt ./scripts/feeds update -a ./scripts/feeds install -a make menuconfig |
Make menuconfig will bring a GUI to select various parameters before initiating the build process such as –
- Target build system & subsystem
- Packages required to be part of the build – Base packages, packages required for system administration, development packages & extra packages.
- Firmware for various (wireless) chips/modules
- Kernel modules
- Option to enable support for various programming languages & libraries
The below build instructions are for building Openwrt for RPi B+, and the Target System will remain the same (BCM27XX) for other Raspberry Pi boards as highlighted in the screenshot below.
The Subtarget will be BCM2708 for the original Raspberry Pi boards and Pi Zero variants, while, the second option is preferred for Raspberry Pi 2B (BCM2709), Raspberry Pi 3B (BCM2710), and Raspberry Pi 4 (BCM2711) as highlighted below.
Once the necessary modifications been added and saved you can exit from the GUI and can start the actual build process by executing the following command.
1 |
make |
This process may take from several minutes up to a few hours. Once the build process is completed successfully you will be able to see the compiled images and packages at “/openwrt/bin/targets/brcm2708/bcm2708”.
If the build fails with some errors, it’s better to recompile by using the following command to get more details of the error:
1 |
make -j1 V=s |
Customizations
Netdata is part of the build system
We can install Netdata performance and system health monitoring easily as the required components (Packages, MakeFile and custom configuration files) are already part of OpenWrt Source tree in openwrt/feeds/packages/admin. We can enable the specific package with “make menuconfig” and netdata will compile at the time of source tree build.
Post compilation and build process, the ipk of netdata will be available in “openwrt/bin/targets/brcm2708/bcm2708/packages” folder.
Add a custom pre-login message
You can modify the file “banner” in “openwrt/package/base-files/files/etc” folder so that your image shows a custom pre-login message at boot time.
FIGlet Linux utility can create ASCII art from the text using the command line. Simply install it, and create ASCII art using the commands below.
1 2 |
$ sudo apt-get install figlet $ figlet "Ants OS" > ~/banner.txt |
The ASCII artwork will be generated and saved in banner.txt in your home folder. There are also some other online tools available to generate ASCII art from text.
An Entrepreneur, an Opensource Enthusiast and Researcher in the domain of Embedded Systems, Wireless and IoT – Has over 16+ years of experience in managing and contributing enterprise Research Projects, in Embedded Systems, Software Technologies, Product Conceptualizations and development, Telecommunication, Media and Entertainment and Consumer Electronics.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
Not sure why anyone would use -j1. On my system i want to use all cores. so I use -j16
You probably didn’t read the comment above this line, it said “If the build fails with some errors, it’s better …“. And that’s right, retrying only the last faulty steps without parallelism is generally better to read error messages, we all do this.
>retrying only the last faulty steps without parallelism is generally >better to read error messages, we all do this. Personally I don’t do that. I use the find function in my terminal to look for the error that stopped the build. The key point is to configure your terminal emulator to have unlimited or a lot of scrollback buffer so that the error doesn’t leave the buffer before the build fails. The problem with running the build again is that you might have an issue the only happens on the first pass (i.e. your dependencies aren’t correct so it fails… Read more »
This case is rare, but it indeed happens on software that do not support parallel build. I do have 50k lines of history in my terminal, which is often enough for debugging. But sometimes when you see lines interleaved like “foo.c:” then “bar.h” etc it becomes hard to figure which one included what and what error triggers in which file.
because sometimes build system has bugs and fails, and you dont have time/want to debug it. and if -j1 works, you just move on
It can help if you’re low on RAM, such as when compiling on most ARM platforms.
Perfect, RPi is often used as a hardcore router.
If I wouldn’t face jail and deportation I would want some of what you’re on Jerry old chum.
We shouldn’t downvote Jerry, he made the funniest joke of the year and we’re only on 13th of January!
with an wan 100mbit port addon (over spi) it’s can be a very powerfull gateway and self hosting server.
Long term support also possible unlike many chinese router that change their hardware every month!
Yeah, can’t wait to use an SPI connected 100BT port for my 500/500 fiber connection.
i don’t care about your theoric 500mbps cloud link, i live in country within best link are in the range of 1mbps-40mbps with a shitty ISP firewall for speed load regulation.
have fun with your hispeed link but don’t be hungry
Even my cheap vps don’t have a real 100mbps link đŸ˜‰
The only throughput number I found for the combination of RPi and SPI Ethernet was 3Mbps (no numbers wrt latency/jitter though). Kinda impressive…
I don’t think that’s going to be enough for Bob’s 1-40Mbps.
I’m not sure which SPI Ethernet chip you were looking at but the microchip one has a lot of issues–two buffers, IRQ latency issues, etc. You end up losing a lot of packets even if you keep on top of it–and that’s for a microcontroller attached to it paying close attention. Add the latency of an IRQ on a low end ARM SoC running a non-real time Linux kernel and good luck!
Looks like some of the Wiznet chips can do a bit better and are better architected. I’m half tempted to try to pick up a few modules and see how they perform.
this page show 15-20mbps link with this spi W5500 controler 3-4$ on aliexpress.
Offcourse it’s not fast but bob it’s fine to link to my vps đŸ˜‰
https://www.blaess.fr/christophe/2019/12/20/un-port-ethernet-supplementaire-sur-raspberry-pi/
15mbps at 31,25 MHz spi , maybe rpi4 can setup spi highter (<80mhz) and get better speed.
But feel free to use USB gigabit ethernet and use an usb port
> I’m not sure which SPI Ethernet chip you were looking at
None specific but all the search hits talked about ENC28J60. The Wiznet W5500 the came up here looks more interesting though. But I still wonder what the benefits might be compared to using an el cheapo USB attached RTL8152b (if there’s a free USB port of course).
Even the GbE RTL8153 dongles are now down to less than 5 bucks on Aliexpress these days… and driver support in every major OS today means they’re simply plug&play…
i agree usb gigabit is very cheap now, but it’s good to see better low speed ethernet for embedded soc like esp32 or small risk-v wo usb or real hw mac onboard.
Security a new chalenge face to wild internet, closed source sdk and ipv6
Considering iot like esp32 can host easily an sdcard, low power it’s can be a new storage ressource for mesh application without the administration effort at the community user level. Sorry i like dumb nodes, basic routers and some good intelligent servers to share every good thing on the www
I am building a web interface ala Ubuntu PPA to build and host your own OpenWRT packages.
It should be ready for Fosdem.
BTW OpenWRT new release is out, probably worth a new article:
https://openwrt.org/releases/19.07/notes-19.07.0
I’m confused with OpenWrt releases numbering. 19 must be the year, but what is 07? Before it was 18.06, and 17.01.
As far as I know the version numbers contains the ‘timestamp’ when the current development build was branched off to become release candidate of the next stable version for end users: https://openwrt.org/releases/start
It is the same like in Ubuntu or OpenSCAD or many more. First the year, than the month. In case of OpenWrt the date is based on the branching day, like tkaiser wrote.