Build and Flash OpenWrt for Raspberry Pi
OpenWrt is an open source project for
embedded operating system based on Linux, primarily used on embedded devices to
route network traffic. [1]
In this post, I will write about how to get the OpenWrt source, compile it for your Raspberry Pi board type and flash the SD card with the generated image.
First of all, you need a Linux build environment installed with the requirements needed to build the OpenWrt. I use Ubuntu 14.04.
In the market, there are 4 types of Raspberry Pi boards. Type 1, 2, 3 and Zero. OpenWrt's latest trunk branch supports all of these types. I will go through trunk.
Check out the source:
git clone git://github.com/openwrt/openwrt.git
This will create a directory called "openwrt" in your current directory. Go inside this directory and run make package/symlinks command.
msezgin@ubuntu:~/openwrt/make package/symlinks
Now, we need to do the configuration before starting the build.
msezgin@ubuntu:~/openwrt/make menuconfig
The configuration should be as below for the Raspberry Pi 3 support.
By default the luci package which is the
web interface of the OpenWrt is not enabled. To enable it, go to the
"LuCI" menuconfig option and under the "Collections"
section select the "luci" package. You will need the web interface to
configure the device easily.
Exit and Save the configuration and then
start the build with the make command.
The build will take sometime depending on
the CPU power of your build machine.
After the build, the final image will be
created under the bin/brcm2708 directory.
openwrt-brcm2708-bcm2710-rpi-3-ext4-sdcard.img
Our image is ready. The next step is to
flash this image to a microSD card. On Ubuntu machine, you can use the dd
command to write the image to your microSD card. When you mount the microSD
card to the Ubuntu machine, dmesg output will give you the microSD
card's device name, such as sdb, sdf or something else. Use that
name for the of= parameter.
dd
if=~/openwrt/bin/brcm2708/openwrt-brcm2708-bcm2710-rpi-3-ext4-sdcard.img
of=/dev/sdX bs=2M conv=fsync
If you want to use Windows or MacOS, you
can find other tools to flash the image to an SD card.
The popular one for MacOS is Etcher.
Our image is flashed now. The next step is to attached the card to the board, power it and connect the device via ssh or web interface. You need a ethernet cable to do this. The default IP address of the device is set to 192.168.1.1. You can directly connect your PC to the Pi or you can connect it to your router at home and access this IP address from your PC. Most of the routers' IP addresses are 192.168.1.1 by default, so you may need our router's IP address to another one to avoid the IP conflicts. [2].
That's it! Your Raspberry Pi 3 board is
ready to be used as an OpenWrt device. You can find several links and blogs on
the Internet about how to run a Raspberry Pi board as a router which is
installed with an OpenWrt image.
References:
[1] https://en.wikipedia.org/wiki/OpenWrt
[2] https://wiki.openwrt.org/toh/raspberry_pi_foundation/raspberry_pi
[2] https://wiki.openwrt.org/toh/raspberry_pi_foundation/raspberry_pi
Comments