OpenWRT and Compiling
Jump to navigation Jump to search

This article was written because of several aborted attempts to write and make sense of the OpenWRT build system. As of the first version of the article, it represents just tested cliff notes and will be expanded upon.

This article is based on several sources;

  • The below command will download / clone the 19.07 branch of OpenWRT to a specific directory.
    • git clone -b openwrt-19.07 ~/openwrt-19.07.3
  • cd openwrt-19.07.3
  • git checkout v19.07.3
  • Verify or Check what has occurred
    • git branch -a (shows all of the available branches of OpenWRT available with an * next to what has been downloaded and cloned)
    • git tag (shows different versions available to build)
  • Update the "feeds"* with the below command. *The documentation on "feeds" notes that "feeds" are 'additional packages'... Additional to what is a question that isn't answered. It is implied that the packages are in addition to other packages which are deemed essential to the operation of OpenWRT. And of course there's the question of 'package'. What is a package? See here:
    • ./scripts/feeds update -a
  • Install the feeds with the below command. Additional information can be found here:
    • ./scripts/feeds install -a (if there are any 'dependency errors', run the command again)
  • Just as a note, the following Entware command seems to accomplish the same thing (with a minor BASH error)
    • make package/symlinks (no need to actually run this, just noted as a comparison)
  • Prepare the OpenWRT build configuration file
    • make menuconfig (and select packages
    • changes, if saved are stored in the ~/openwrt-19.07.3/.config file and can be manually manipulated
  • Make the tools and toolchain for cross compiling (explicitly, as these commands will be run when the first make command is run)
    • make tools/install
    • make toolchain/install
  • Build a specific package
    • make package/nano/compile OR make package/utils/nano/compile (it will search for nano if the category isn't explicitly stated)
    • Skip the hash checking of a downloaded file, add this to the end of the command: PKG_HASH=skip
    • Outputting verbose information during compiling, add V=s to the end of the command
    • Speeding things up during compiling, add j=WhatEverNumberOfCPUs (note, the recommendation is to run make download to download any necessary files, however, when building only one specific package, this will take longer as all necessary files are downloaded for a build, so the default j=1 in this instance will work better)
  • Building NANO as an example
    • ~/openwrt-19.07.3/feeds/packages/utils/nano is the directory for the "receipt" to create NANO
    • ~/openwrt-19.07.3/bin is the directory where IPK packages will be stored.
    • make package/utils/nano/compile is the command to create an IPK file for nano
    • Use above noted options for modifying command line

INCLUDE_DIR = ./include OR ~/openwrt-19.07.3/include

On an interesting note, packages can be built for OpenWRT using the Entware build system (which is of course based on OpenWRT), and all of those files will be installed in the /opt directory, which makes it possible to use Entware compiled packages without interfering with OpenWRT. For instance, if the PATH variable contains /opt at the very end of it (and variations like /opt/bin, etc.), those locations will be used if no existing OpenWRT program exists. This assumes the full version of BASH is being used instead of the BusyBox version (opkg install bash)

  • PATH=$PATH:/opt/usr/sbin:/opt/usr/bin:/opt/sbin:/opt/bin (still stuff to work on here as dependencies must be in place too)

...on removing LuCI from an OpenWRT Image that accidentally does a great job of explaining the different methods of building OpenWRT:

Another article from the same author on a different subject also gives some great insight into other aspects of OpenWRT:

Creating a Custom Feed

  • edit the feeds.conf.default file (there are references to the old feeds.conf, but feeds.conf.default is the new file name), add the line:src-link custom /root/openwrt-19.07.3/feeds.custom
  • create a folder: ~/openwrt-19.07.3/feeds.custom
  • Add whatever custom feeds are desired, give them a unique name and edit the Makefile and any other files appropriately
  • ./scripts/feeds update -a
  • ./scripts/feeds install -a
  • There should now be references to the custom feeds in ~/openwrt-19.07.3/feeds directory
  • make menuconfig (Note, if there is a DEPENDS:= directive in the Makefile file then the item may not show up in the OpenWRT build utility, the .config file can be edited directly to allow for compiling, see next line)
  • CONFIG_PACKAGE_perlnetssleay=m (as an example)
  • make package/perlnetssleay/compile
  • ...see how it goes, other dependencies as noted in:, but that's a whole wormhole of other dependencies...