Views
OpenFlow on OpenWrt: Prerequisites
From OpenFlow Wiki
NOTE : This page is deprecated, look here for up-to-date instructions.
It is a good idea to exercise building a Vanilla OpenWrt image for your platform before adding OpenFlow support to it. This document will walk you through the details.
If you are familiar with the basics of OpenWrt, please proceed to the OpenFlow on OpenWrt page.
Contents |
Installing OpenWrt via TFTP(Assuming you still have a working bootloader)
Warning: before you start, please take a moment to go through the section 1 below. It is gonna be very useful in case you brick your device.
Although you can install the firmware through more traditional means (via webpage), there are reasons to install via TFTP. This is NOT a requirement, simply a damned good idea if you use self compiled firmware images; if anything goes wrong you can just TFTP the old firmware back.
When the device boots it runs a bootloader. It's the responsibility of this bootloader to perform basic system initialization along with validating and loading the actual firmware; think of it as the BIOS of the device before control is passed over to the operating system. Should the firmware fail to pass a CRC check, the bootloader will presume the firmware is corrupt and wait for a new firmware to be uploaded over the network. The type of the preinstalled bootloader depends on your router model. Broadcom based routers use CFE - Common Firmware Environment (older system boards use PMON), Texas Instruments based routers use ADAM2.
The basic procedure of using a tftp client to upload a new firmware to your router:
* unplug the power to your router
* start your tftp client
o give it the router's address (usually 192.168.1.1)
o set mode to octet/binary
o tell the client to resend the file, until it succeeds.
o put the file
* plug your router, while having the tftp client running and constantly probing for a connection
* the tftp client will receive an ack from the bootloader and starts sending the firmware
Please be patient, the reflashing occurs AFTER the firmware has been transferred. DO NOT unplug the router, it will automatically reboot into the new firmware.
Note that the nvram IP address will not be used by the bootloader: instead, the router will revert to the factory default, which is usually 192.168.1.1
Putting a hub or switch between the WRT device and the computer where the TFTP client runs will make sure that the local computer link is up before the boot_wait period is passed. This is a requirement to make TFTP work on computers where the local link is brought up too slow.
On routers with a DMZ LED, OpenWrt will light the DMZ LED while booting, after the bootup scripts are finished it will turn off the DMZ LED. Sometimes automatic rebooting does not work, so you can safely reboot (power cycle) after waiting 6 minutes.
The TFTP commands vary across different implementations. Here are some examples:
tftp 192.168.1.1 binary rexmt 1 timeout 60 trace Packet tracing on. tftp> put openwrt-xxx-x.x-xxx.bin
Building OpenWrt Kamikaze from source
1. install packages required by the OpenWrt Kamikaze buildsystem
aptitude install build-essential binutils flex bison autoconf gettext texinfo sharutils subversion libncurses5-dev ncurses-term zlib1g-dev gawk
2. checkout and prepare Kamikaze and the packages
Currently OpenFlow works with Kamikaze 8.09.1 or earlier. Use the following commands instead of checking out from svn and go to step 2.1.
cd ${WORKING_DIR}
wget http://kamikaze.openwrt.org/8.09.1/kamikaze_8.09.1_source.tar.bz2
tar xvfj kamikaze_8.09.1_source.tar.bz2
mv kamikaze_8.09.1 trunk
cd ./trunk
./scripts/feeds update -a
./scripts/feeds install -a
Skip these commands and go to 2.1
cd ${WORKING_DIR}
svn co svn://svn.openwrt.org/openwrt/trunk/
cd ./trunk/
./scripts/feeds update -a
./scripts/feeds install -a
2.1 Configure Kamikaze (select target system) and the packages (a full build with all packages selected requires about 9GB of free disk space)
make menuconfig
2.2 If you select extra packages it's a good idea to check if you have all prerequisites installed. Check with:
make prereq
2.3 Finally build Kamikaze (to download all packages at once use 'make download world')
make world
3. After the build finished, ready to use images can be found in $(TOPDIR)/bin
Targets for 'make'
download
download all source tarballs (from the selected packages and it's dependencies) at once before starting the build
prereq
checks if you have all prerequisites installed on the host-system for building the selected packages
world
build everything
tools/install toolchain/install
only build the tools and the toolchain
clean
cleans the packages (NOT the tools and toolchain)
distclean
cleans up everything expect $(TOPDIR)/.config and $(TOPDIR)/dl/
package/<package_name>/{clean,compile}
rebuild a single package
package/index
updates $(TOPDIR)/bin/packages/Packages
V=99
turns on debugging
make kernel_menuconfig
If you want, you can also modify the kernel config for the selected target system. Simply run
make kernel_menuconfig
and the build system will unpack the kernel sources (if necessary), run menuconfig inside of the kernel tree, and then copy the kernel config to target/linux/<platform>/config so that it is preserved over "make clean" call.
Load Image to OpenWRT Devices
OpenWrt image with OpenFlow support:
From WebGui
Open your web browser and use the firmware upgrade page on your device to upload the OpenWrt firmware.
Both vendor provided WebGUI or OpenWRT WebGUI(WebIF or WebIF^2 or LuCI) should work.
From CLI
If the OpenWrt supports the sysupgrade command, please use:
sysupgrade -n <link to the image>
it will automatically reboot your device (not in rescue mode)!
Otherwise use:
cd /tmp wget -O /tmp/linux.trx <link to the image> mtd unlock linux mtd write /tmp/linux.trx linux reboot
TFTP
Same as Installing OpenWrt via TFTP(Assuming you still have a working bootloader)
