January 17, 2013
OpenWRT #1
Aphirak Jansang, D.Eng. http://www.cpe.ku.ac.th/~aphirak IWING Lab, Department of Computer Engineering, Faculty of Engineering, Kasetsart University
1 01204428 Wireless Embedded Systems Outline
Linksys WRT54GL OpenWRT firmware Cross-compiling software for OpenWRT
2 01204428 Wireless Embedded Systems Linksys WRT54G series
Wireless Residual gateway from Linksys First release in December 2002 Support IEEE 802.11b/g: Wireless LANs Ethernet 802.3: Internet and LANs
3 01204428 Wireless Embedded Systems WRT54GL
Released in 2005 To support third-party firmware based on Linux operating system
Version CPU RAM Flash Memory S/N Prefix 1.0 Broadcom 16 MB 4 MB CL7A BCM5352 @ 200 MHz 1.1 Broadcom 16 MB 4 MB CL7B BCM5352 @ CL7C 200 MHz CF7C
4 01204428 Wireless Embedded Systems WRT54GL
http://home.cisco.com/en-apac/products/routers/WRT54GL
5 01204428 Wireless Embedded Systems Stock Firmware
original firmware, pre-installed from factory including basic features and non-void device warrantee For WRT54GL http://homesupport.cisco.com/en-apac/support/routers/WRT54GL
6 01204428 Wireless Embedded Systems Firmware Release Notes
Firmware history details: fixing bugs, new features, new supported devices, … e.g. WRT54GL
7 01204428 Wireless Embedded Systems Custom Firmware
modified firmware code from the original firmware adding more applications/services removing unnecessary applications/services tuning the firmware parameters to work more effective adding support for new devices fixing the old bugs …
CyanogenMod is an aftermarket firmware for a number of cell phones based on the open-source Android operating system. It offers features not found in the official Android based firmwares of vendors of these cell phones.
8 01204428 Wireless Embedded Systems Third-party firmware for WRT54GL
OpenWRT based firmware Coova – OpenWrt based with focus on Wireless Hotspot functionality. Freifunk – OpenWrt-based, German software supports wireless mesh networks with OLSR and B.A.T.M.A.N. DD-WRT – Based on OpenWrt code. Paid and free versions available. USE IT AT YOUR OWN RISK! HyperWRT based firmware Tomato – advanced QoS TomatoUSB – based on Tomato; adds support to newer routers HyperWRT Thibor – based on stock WRT54GS firmware
http://en.wikipedia.org/wiki/List_of_wireless_router_firmware_projects
9 01204428 Wireless Embedded Systems Outline
Linksys WRT54GL OpenWRT Cross-compiling software for OpenWRT
10 01204428 Wireless Embedded Systems OpenWRT
http://www.openwrt.org Based on Linux kernel Free and open source, licensed under GPL Easy and free access Community driven
11 01204428 Wireless Embedded Systems OpenWRT Project
Tweetster Twitter display ASUS Wireless Router WL-520-GU Sparkfun serial LCD
http://www.slashgear.com/tweetster-twitter-display-2750394/
12 01204428 Wireless Embedded Systems OpenWRT Project
WiFi Robot Network camera WRT54GL Controller Batteries
http://www.jbprojects.net/projects/wifirobot/
13 01204428 Wireless Embedded Systems OpenWRT Project
LinkMeter Heatmeter WRT54GL
http://tvwbb.com/showthread.php?22136-LinkMeter-v2-Homebrew-BBQ-Controller-Part-1
14 01204428 Wireless Embedded Systems OpenWRT Project
RASS: RFID Access control with Air Support IWING Lab, CPE, KU
http://iwing.cpe.ku.ac.th/th/node/414
15 01204428 Wireless Embedded Systems OpenWRT Project
CATs: Class Attendance System with Real-time Report via WLAN IWING Lab, CPE, KU
http://iwing.cpe.ku.ac.th/en/node/415
16 01204428 Wireless Embedded Systems OpenWRT basic
Supported devices Supported platform Firmware version
17 01204428 Wireless Embedded Systems OpenWRT supported devices
Supported devices are listed in Table of Hardware (ToH) http://wiki.openwrt.org/toh/start
18 01204428 Wireless Embedded Systems OpenWRT supported platform
https://dev.openwrt.org/wiki/platforms
19 01204428 Wireless Embedded Systems WRT54GL
Information of WRT54GL on OpenWRT website http://wiki.openwrt.org/toh/linksys/wrt54g
20 01204428 Wireless Embedded Systems WRT54GL Board
http://wiki.openwrt.org/toh/linksys/wrt54g Serial port: ttyS0, ttyS1
21 01204428 Wireless Embedded Systems WRT54GL Dual Serial Port and SD Card Mods
Modification details http://www.jbprojects.net/articles/wrt54gl_mods/
22 01204428 Wireless Embedded Systems WRT54GL Internal Architecture
23 01204428 Wireless Embedded Systems OpenWRT basic
Supported devices Supported platform Firmware version
24 01204428 Wireless Embedded Systems Firmware version
http://wiki.openwrt.org/about/history Current stable version: Backfire 10.03.1
25 01204428 Wireless Embedded Systems OpenWRT development history
26 01204428 Wireless Embedded Systems Pre-compiled OpenWRT firmware
http://downloads.openwrt.org/
27 01204428 Wireless Embedded Systems http://downloads.openwrt.org/backfire/10.03.1/
28 01204428 Wireless Embedded Systems MIPs emulator
QEMU (short for "Quick EMUlator") a generic and open source machine emulator and virtualizer Support platform x86 x86_64 embedded PowerPC S390
29 01204428 Wireless Embedded Systems OpenWRT on QEMU
PC, x86/x86_64 Ubuntu
QEMU MIPS OpenWRT
30 01204428 Wireless Embedded Systems OpenWRT image for QEMU
Must compile firmware with the following detail platform: malta MIPS Malta CoreLV board (qemu)
https://dev.openwrt.org/browser/trunk/target/linux/malta/README
31 01204428 Wireless Embedded Systems Running OpenWRT in QEMU
Installing QEMU package sudo aptitude install qemu-kvm-extras -y
Running OpenWRT image (openwrt-*-vmlinux.elf) qemu- system-mips -kernel bin/malta/openwrt-malta-be-vmlinux.elf -nographic -m 64
Getting IP address udhcpc -i br-lan Copy file from outside to /tmp
scp userid@my-outside-server-ip:/tmp/test.img /tmp
To quite QEMU CTRL+A c, then type quit
http://fosiao.com/content/running-openwrt-under-qemu 32 01204428 Wireless Embedded Systems
OpenWRT Configuration
Unified Configuration Interface (UCI) Location of configuration file: /etc/config How to configure OpenWRT, please refer to http://wiki.openwrt.org/doc/uci
OpenWRT PacKaGe (OPKG) an ipkg fork similar to apt-get, aptitude, pacman, yum tutorial for opkg usage: http://wiki.openwrt.org/doc/techref/opkg
33 01204428 Wireless Embedded Systems Outline
Linksys WRT54gl OpenWRT Cross-compiling software for OpenWRT
34 01204428 Wireless Embedded Systems Why we need Cross-compile?
required program does not including in software repository no a binary program compiled for your CPU
35 01204428 Wireless Embedded Systems Cross-compiling concept
Host VS. Target the computer the compiler runs on is called the host the computer the new programs run on is called the target
Native Compiler VS. Cross Compiler the host and target are the same type of machine: native compiler the host and target are different: cross compiler
http://people.mech.kuleuven.be/~mklotzbucher/ecs-assignments/ecs.html
36 01204428 Wireless Embedded Systems Uses of cross compilers
embedded computers where a device has extremely limited resources compiling for multiple machines compiling on a server farm bootstrapping to a new platform
37 01204428 Wireless Embedded Systems Cross-compiler for OpenWRT
SDK (Software Development Kit) set of programs to build software package Toolchain set of programming tools that are used to create a binary program may be used in a chain
http://xathrya.web.id/blog/2012/10/22/beginning-c-the-language-compiler-code-structure/
38 01204428 Wireless Embedded Systems Cross-compiling process
Preparing HOST system Compiling code for target platform (On HOST machine) Transferring binary file to target platform
39 01204428 Wireless Embedded Systems How to get SDK?
Based on OpenWRT Download from http://downloads.openwrt.org http://downloads.openwrt.org/
40 01204428 Wireless Embedded Systems Setup HOST Toolchain for Cross-compilation
create directory for toolchain (e.g. ~/toolchain) mkdir ~/toolchain cd ~/toolchain
download SDK for your target platform (e.g. backfire, ar71xx) wget http://downloads.openwrt.org/backfire/10.03.1/ar71xx/OpenWrt -SDK-ar71xx-for-Linux-i686-gcc-4.3.3%2bcs_uClibc-0.9.30.1.tar.bz2
extract file OpenWrt-SDK-ar71xx-for-Linux-i686-gcc-4.3.3%2bcs_uClibc-0.9.30.1.tar.bz2
tar jxvf OpenWrt-SDK-ar71xx-for-Linux-i686-gcc-4.3.3%2bcs_uClibc-0.9.30.1.tar.bz2
41 01204428 Wireless Embedded Systems Setup HOST Toolchain for Cross-compilation
locate the toolchain binaries in staging_dir/toolchain-architecture_gcc-compilerver_uClibc-libcver/usr/bin/
add the toolchain directory to the PATH variable PATH=$PATH:(your toolchain directory here) export PATH
set the STAGING_DIR environment variable STAGING_DIR=(your staging directory here) export STAGING_DIR
42 01204428 Wireless Embedded Systems Cross-compiling process
Preparing HOST system Compiling code for target platform (On HOST machine) Transferring binary file to target platform
43 01204428 Wireless Embedded Systems Compiling code for target platform (On HOST machine)
On HOST machine, create file: hello.c #include
44 01204428 Wireless Embedded Systems
Cross-compiling process
Preparing HOST system Compiling code for target platform (On HOST machine) Transferring binary file to target platform
45 01204428 Wireless Embedded Systems Transferring to OpenWRT
Assume: running OpenWRT on QEMU root@OpenWrt :/# uname -a Linux OpenWrt 3.3.8 #1 SMP Wed Jan 16 23:02:29 ICT 2013 mips GNU/Linux
root@OpenWrt:/# udhcpc -i br-lan udhcpc (v1.19.4) started Sending discover... Sending select for 10.0.2.15... Lease of 10.0.2.15 obtained, lease time 86400 udhcpc : ifconfig br-lan 10.0.2.15 netmask 255.255.255.0 broadcast + udhcpc: setting default routers: 10.0.2.2
root@OpenWrt:/# scp [email protected]:/home/aphirak/toolchain/hello . [email protected]'s password: hello 0% 5088 5.0KB/s 00:00 root@OpenWrt:/# ./hello Hello World!
46 01204428 Wireless Embedded Systems Summary
Linksys WRT54GL device Stock VS. Custom firmware OpenWRT concept Cross-compiling concept Cross-compiling process Preparing HOST system Compiling code for target platform (On HOST machine) Transferring binary file to target platform
47 01204428 Wireless Embedded Systems References/Resources
Linksys WRT54G Ultimate Hacking by Paul Asadoorian and Larry Pesce http://en.wikipedia.org/wiki/Linksys_WRT54G_series https://sites.google.com/site/wangjihowto/home/running- openwrt-dd-wrt-mips-in-qemu http://wiki.acemonstertoys.org/Tp-link_router http://en.wikipedia.org/wiki/Cross_compiler
48 01204428 Wireless Embedded Systems