Compiling custom OpenWRT firmware / packages

OpenWRT is a nifty thing. However, if you want to test some custom or self written programs it can be tricky.

For most instances, e.g. on a Raspberry or other embedded device, you can install a compile toolchain to just configure and make your project. Due to space constraints this is often not necessary. Cross-compiling for these embedded devices (for instance WR703N is MIPS32) is quite tricky. The easiest way therefore is to use the OpenWRT build root to compile these packages (and complete OpenWrt firmares).

I will not go into detail how to get, configure and build OpenWRT, you can find detailled instructions at the OpenWRT Wiki, and in addition how you can compile only a single package.

Assuming you have configured your OpenWRT install, you can build and include custom packages by editing the corresponding Makefiles.
For instance rtl-sdr you can find in the feeds directory:
openwrt/package/feeds/packages/rtl-sdr
Or the hamlib
openwrt/package/feeds/packages/hamlib

Everytime you install and compile the package, the source files will be downloaded newly from the internet and compiled. Therefore the easiest way is to provide a repository and commit where is the newer version.

So for instance, replacing the rtl-sdr/Makefile with this content can receive my custom version of rtl-sdr.

#
# Copyright (C) 2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.

include $(TOPDIR)/rules.mk

PKG_NAME:=rtl-sdr
PKG_VERSION:=2014-10-21
PKG_RELEASE:=$(PKG_SOURCE_VERSION)

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=git://github.com/satnogs/rtl-sdr.git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=b72ab8fc83efbc2ec112154b9d1cbe2d85b1e258
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
CMAKE_INSTALL:=1