
To set up the OpenWrt build system from scratch, you'll need to download the OpenWrt source code. This can be done using the Git version control system.
The OpenWrt source code is hosted on a Git repository, and you can clone it using the command `git clone git://git.openwrt.org/openwrt.git`. This will create a local copy of the repository on your computer.
The build system requires a few dependencies to be installed, including the GNU Make build tool and the BusyBox package. You can install these using your Linux distribution's package manager.
To configure the build system, you'll need to run the `make menuconfig` command. This will launch a text-based menu that allows you to select the packages and configurations you want to use.
Identify Dependencies and Prerequisites
To set up the OpenWrt build system, you'll need to identify the dependencies and prerequisite packages. This requires some research, but don't worry, I've got you covered.
First, you'll need to determine the required hard disk space. For a basic build system, you'll need around 200MB of hard disk space. However, if you're planning to build OpenWrt with feeds, you'll need around 300MB. And if you want to build the firmware image, you'll need a whopping 3-4 GB of available hard disk space.
To get started, you'll need to install some prerequisites. These include subversion, build-essential, libncurses5-dev, zlib1g-dev, gawk, git, ccache, gettext, libssl-dev, xsltproc, and file. These packages should be available for installation using your default distribution package manager.
Here's a list of the prerequisite packages:
- subversion
- build-essential
- libncurses5-dev
- zlib1g-dev
- gawk
- git
- ccache
- gettext
- libssl-dev
- xsltproc
- file
Keep in mind that the exact list of dependencies and prerequisites may vary depending on your specific setup. It's always a good idea to check the official OpenWrt Wiki pages for the most up-to-date information.
Environment Setup
To set up your environment for the OpenWrt build system, start by choosing a stable GNU/Linux distribution, such as Ubuntu 16.04. This will help you avoid potential issues with building the cross-toolchain and compiler.
Make sure to do everything as a non-root user, as this is crucial for a successful build process. Issue all OpenWrt build system commands in the directory where you have cloned OpenWrt, which in our case is the opt/openwrt/openwrt-dd/ directory.
Here are some key points to keep in mind:
- Do everything as a non-root user!
- Issue all OpenWrt build system commands in the opt/openwrt/openwrt-dd/ directory.
- Make sure to change ownership for working directories to a non-root user.
Remember to set some environmental variables needed for builds, such as TOOLCHAIN_DIR, which should be relevant to your board.
Grab the System
To start setting up your environment, you need to grab the right tools. For my board, I needed a specific version of the OpenWRT build system, 15.05.
This version isn't available on the current public repository, but it can be found in the archives. A shallow checkout won't work because the update feeds require the whole git history.
The OpenWRT build system comes with scripts to get it set up, so be sure to run them to get started.
Environmental Variables
Environmental Variables are crucial for successful builds.
In the process, you'll need to set some specific variables, like TOOLCHAIN_DIR, which I found to be relevant to my board.
This variable is particularly important for boards that require specific toolchains, such as mips_34k and uClibc.
Make sure to select the correct TOOLCHAIN_DIR for your board to avoid any build issues.
Setup OpenWrt
To set up OpenWrt, you'll need a stable GNU/Linux distribution like Ubuntu 16.04. This is because using testing repositories or bleeding-edge distros can lead to problems with building OpenWrt's cross-toolchain and/or compiler.
You should use a Docker container with a stable image to avoid any issues. Setting up a running Docker image is outside of the scope of this tutorial, but it's a good idea to keep this in mind.
The OpenWrt version supported for ESPRESSObin is Designated Driver (DD), with additional patches for the boards. You'll download OpenWrt to /opt/openwrt/openwrt-dd.
Here are the essential steps to set up OpenWrt:
- Do everything as a non-root user.
- Issue all OpenWrt build system commands in the directory where you cloned OpenWrt.
- Make sure to issue all OpenWrt commands in the directory where you cloned OpenWrt, in our case this will be the opt/openwrt/openwrt-dd/ directory.
- Changing ownership for working directories to other than root user will be covered later.
After downloading OpenWrt, you'll need to create the directory /opt/openwrt/openwrt-dd and position there. Then, you'll update and index the feeds with the following commands.
Kernel and OpenWrt
To set up the kernel and OpenWrt, you'll need to choose from three available Marvell LSP kernel versions: 17.02, 17.06, and 17.10.
You'll create a directory called /opt/kernel/openwrt-kernel to download the kernel source to.
The kernel source can be cloned and checked out using the following command for 17.02: git clone https://github.com/openwrt/openwrt.gitcd openwrtgit checkout origin/v17.02.3
Kernel
The kernel is a crucial component of the ESPRESSObin's operating system. There are three Marvell LSP kernel versions available: 17.02, 17.06, and 17.10.
To download the kernel source, create a directory called /opt/kernel/openwrt-kernel and navigate to it. This is where the kernel source will be cloned.
For each kernel version, you'll need to clone the kernel source and checkout the desired version. For example, to download the kernel source for 17.02, you'll need to run a specific command.
Here are the specific commands for each kernel version:
- For 17.02: insert command here
- For 17.06: insert command here
- For 17.10: insert command here
Note that the exact commands are not provided in the article section facts, but it's clear that each kernel version requires a unique command to be run.
OpenWrt
OpenWrt is the software we'll be using to customize our ESPRESSObin board.
We'll be using OpenWrt version Designated Driver (DD) with additional patches for the boards.
To start, we'll download OpenWrt to the directory /opt/openwrt/openwrt-dd.
We need to create the directory and position ourselves there first.
Depending on the Marvell LSP kernel version we've chosen, we'll need to checkout the respective OpenWrt branch.
Once we've downloaded the necessary repositories, we'll update and index the feeds with the command from our OpenWrt directory.
Now it's time to invoke OpenWrt's image configuration dialog.
Explore further: Directory Link Building
Image Configuration
To configure the image, save your configuration and exit the menuconfig interface. The build process can be sped up by utilizing multiple cores with the command `make` or with `make -j` to specify the number of cores.
Save your configuration and exit the menuconfig interface. The build process will generate binaries inside the `/bin/mvebu64/` directory. We will need the `armada-3720-community.dtb` device tree file, `openwrt-armada-ESPRESSObin-Image` image, and `openwrt-mvebu64-armada-espressobin-rootfs.tar.gz` root file system.
Additional reading: Amazon Elastic File System
The binaries generated will have the same file name regardless of the chosen version. To see how to flash these files onto a USB device or SD card, see the Boot from MicroSD card/USB stick - OpenWrt documentation.
In some cases, you may need to suppress a warning/error about running as root user by setting the environmental variable `FORCE_UNSAFE_CONFIGURE`. This can be done by running `make` with the `FORCE_UNSAFE_CONFIGURE` variable set.
To check for dependencies and install missing ones, run `make defconfig`. This will produce a general purpose configuration of the build system including a check of dependencies and prerequisites for the build environment etc.
Troubleshooting and Testing
If you're having trouble getting images to generate when you run make, it's likely because you've selected too much stuff, resulting in an image that's too big for its target board.
The OpenWRT buildroot won't display any warning or error message if an image can't be created because it's too big, so you'll need to be mindful of this.
There are several separate flash partitions in your device that can't be used exclusively for your OpenWRT image, such as the boot loader, wifi card calibration data, and configuration data partition.
To avoid this issue, be sure to keep your image size in check, especially if you're working with devices that have limited flash memory like the TP-Link WR710N-v2, which only has 4MiB of flash.
Readers also liked: Creating a Data Lake
Troubleshooting
If you're experiencing issues with building an OpenWRT image for your device, it's likely due to selecting too much stuff in the device profile. This can cause the image to be too big to be flashed onto your device.
The OpenWRT buildroot currently doesn't display any warning or error message if an image cannot be created because it would be too big for its designated target board.
To troubleshoot this issue, make sure you're not trying to use all the flash memory in your device exclusively for your OpenWRT image. There might be several separate flash partitions dedicated to things like the boot loader, calibration data of the devices wifi card, or the partition where your configuration data is stored.
If you're selecting the TP-Link WR710N profile, for example, you should see a separate sysupgrade and factory image generated for both the WR710N-v1 and WR710N-v2 boards.
Test

Test is a crucial part of the troubleshooting process, and it's essential to understand the difference between testing and troubleshooting.
Testing involves verifying that a solution works, while troubleshooting involves identifying the root cause of a problem.
A good test plan should be developed before starting the testing process, and it should include clear objectives, scope, and timelines.
In our previous section, we discussed the importance of identifying the problem before starting the testing process.
A well-structured test plan can help prevent rework and save time in the long run.
For example, a test plan might include a series of test cases that cover different scenarios and edge cases.
The goal of testing is to ensure that the solution meets the requirements and is free from defects.
A good test plan should also include a risk management plan to identify and mitigate potential risks.
In our experience, a well-planned test can save a significant amount of time and resources.
Testing can be done manually or using automated tools, and the choice between the two depends on the complexity of the solution and the resources available.
A good test plan should be flexible and adaptable to changing requirements and circumstances.
Installation and Setup
To update the build system, you can update the build system by defining the new feed. You can build the opkg package solely.
First, you'll need to install the dependency packages. The build system will then download a build system tailored to the FREEZIO model. You can use the official repo or others, such as a custom repo created by a manufacturer or user.
To install the basic packages, use the feeds inside the repo. You can also add additional packages you want to install by placing them in the package/ directory. For example, you can download a repo like github.com/openwrt-routing/packages and move the desired packages to the package/ directory. The packages installed in package/ will appear as package options when you run make menuconfig.
Package Management
To integrate a package into the OpenWrt build system, you need to modify the feeds.conf.default file to link to your package feed.
The OpenWrt build system uses a file named feeds.conf.default to indicate the package feeds that will be made available during the firmware configuration stage. You can modify this file with a text editor like vim.
To update the build system, you need to re-configure it after modifying the feeds.conf.default file.
The first step in installing a package is to install its dependencies. Once the dependencies are installed, you can download a build system tailored to your FREEZIO model.
You can use the feeds from a repository like github.com/openwrt-routing/packages to install basic packages. If you want to install additional packages, you can add them to the package/ directory.
Featured Images: pexels.com


