Generating my own OpenWRT Custom Firmware

Recently after I upgraded my firmware to the latest kernel in my post , I noticed I had significantly a lot less disk space available. (When you have less than 3MB to play with, it’s a real big concern).

Note: This is using my TP-LINK TL-WR703N v1 with an Atheros AR9330 chipset, this may or may not work for you. Note the version number of my TP-Link device (this is important as newer versions have had some issues, check the OpenWRT wiki for further information; it’s very detailed). I’m using the arch ar71xx, check your own the downloads.openwrt.org folder hierarchy and steps should be the same.

A quick list of installed packages, I found the web interface was now packaged in the default firmware. Uninstalling it didn’t free up any space, it actually used more space. This is because the packages are inbuilt to the squashfs filesystem. So after a bit of research (unfortunately OpenWRT documentation is a bit all over the place, although things are SUPER easy once you put the pieces to together).

I did this on my Fedora 18 laptop within less than 15 minutes. I packaged my kmod packages so my USB Wireless adapter would work straight after install without having to install any other components. It also saves on disk space.

wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2  
tar -xvjf OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2  
cd OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64

# Get List of Pre-defined profiles (TLWR703)
make info

nano include/target.mk  
    # Removed ppp pppoe from default_packages section

make image PROFILE=TLWR703 PACKAGES="kmod-rt2800-lib kmod-rt2800-usb kmod-rt2x00-lib kmod-rt2x00-usb -liblua -libubus-lua -libuci-lua -luci-app-firewall -luci-i18n-english -luci-lib-ipkg -luci-lib-lmo -luci-lib-sys -luci-proto-core -luci-proto-ppp -luci-sgi-cgi -luci-theme-base -luci-theme-openwrt"

cd bin/ar71xx  
scp openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin [email protected]:/tmp  
md5sum openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin  

And there we go, our images are generated :)
Taking a look inside the bin/ar71xx folder there’ll be a whole list of images

md5sums  
openwrt-ar71xx-generic-rootfs.tar.gz  
openwrt-ar71xx-generic-root.jffs2-128k  
openwrt-ar71xx-generic-root.jffs2-256k  
openwrt-ar71xx-generic-root.jffs2-64k  
openwrt-ar71xx-generic-root.squashfs  
openwrt-ar71xx-generic-root.squashfs-64k  
openwrt-ar71xx-generic-tl-wr703n-v1-jffs2-factory.bin  
openwrt-ar71xx-generic-tl-wr703n-v1-jffs2-sysupgrade.bin  
openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin  
openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-sysupgrade.bin  
openwrt-ar71xx-generic-uImage-gzip.bin  
openwrt-ar71xx-generic-uImage-lzma.bin  
openwrt-ar71xx-generic-vmlinux.bin  
openwrt-ar71xx-generic-vmlinux.elf  
openwrt-ar71xx-generic-vmlinux.gz  
openwrt-ar71xx-generic-vmlinux.lzma  
openwrt-ar71xx-generic-vmlinux-lzma.elf  

Now to installing the firmware.

[email protected]:/tmp# md5sum openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory  
.bin 
11eadb03ef4fcd59084fe11793725a24  openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin  
[email protected]:/tmp# mtd -r write /tmp/openwrt-ar71xx-generic-tl-wr703n-v1-squas  
hfs-factory.bin firmware  
Unlocking firmware ...

Writing from /tmp/openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin to firmware ...  
Rebooting ...  

And we’re done, after installing my USB Kernel Modules I still have 1.2M available.

[email protected]:~# df -h  
Filesystem                Size      Used Available Use% Mounted on  
rootfs                    1.4M    224.0K      1.2M  16% /  
/dev/root                 1.5M      1.5M         0 100% /rom
tmpfs                    14.1M     88.0K     14.1M   1% /tmp  
tmpfs                   512.0K         0    512.0K   0% /dev  
/dev/mtdblock3            1.4M    224.0K      1.2M  16% /overlay
overlayfs:/overlay        1.4M    224.0K      1.2M  16% /  

Other/External References:
- http://wiki.openwrt.org/doc/howto/obtain.firmware.generate - http://wiki.openwrt.org/toh/tp-link/tl-wr703n - http://wiki.openwrt.org/doc/howto/generic.sysupgrade

comments powered by Disqus