Installing Your Own Package into OpenWRT By Using ‘menuconfig’

Once you finish successfully building the OpenWRT image following this tutorial you’ll be able to add your own custom packages to the OpenWRT image using the menuconfig tool.

Let’s start by cloning two example Git Repositories I’ve made for this article into the openwrt/package/utils directory

$ cd openwrt/package/utils
$ git clone http://github.com/fpfaffendorf/helloworld-c.git
$ git clone http://github.com/fpfaffendorf/helloworld-python.git


Those two repositories are hello-world-like applications written in C and Python along with their own makefiles. The two git clone commands will create two directories with all necessary files to cross-compile the examples and include the packages into the OpenWRT image binary file.

Inside the makefile (lowercase) files placed in the src directory you’ll find all necessary instructions to build the C and Python applications.

Hello World C Application makefile
Hello World Python Application makefile

Outside each repository root directory there is a Makefile (this time with capital ‘M’) files that has all necessary information, in almost human readable format, to compile, install and make the application appear in the menuconfig tool.

Hello World C Application Makefile
Hello World Python Application Makefile

Take a look at the define Package/helloworld/install and define Package/helloworldpython/install code where you’ll find the instructions we give to the make process to copy the application binaries to the /bin directory of the OpenWRT.

Now that we have all the files we need let’s continue by updating the feeds and asking the makemenu tool to install our two applications into the OpenWRT image.

In the openwrt root directory we execute the following commands:

$ ./scripts/feeds update -a
$ ./scripts/feeds install –a
$ make menuconfig

Once in the menuconfig tool navigate to the “Utilities” menu and mark with <*> the helloworld and helloworldpython packages. Exit saving the changes and run the make again. This time it will be much faster since most of the OpenWRT files are already made in the previous tutorial.

$ make 2>&1 | tee output.txt

Once the make process finish the OpenWRT binary image file including both applications can be found in the openwrt/bin directory.

Credits:

Build and package your own software for OpenWRT

Leave a Reply

Your email address will not be published. Required fields are marked *