In this page we will go over building OpenWrt for ESPRESSObin on your Linux machine.
OpenWrt is an open source firmware designed for embedded devices that is highly extensible and enables both users and customers to install a powerful, highly customizable variant of Linux on their routers.
Generating an installable OpenWrt firmware requires:
- ca. 200MB of hard disk space for OpenWrt build system
- ca. 300MB of hard disk space for OpenWrt build system + OpenWrt feeds
- ca. 2.1 GB of hard disk space for source packages downloaded during build from OpenWrt feeds
- ca. 3-4 GB or available hard disk space to build (i.e. cross-compile) OpenWrt and build the firmware image.
- ca. 1-4GB of RAM to build OpenWrt (building x86 images requires 4GB RAM)
Before proceeding, make sure to install all prerequisites for building OpenWrt:
These packages should be available for installation using your default distribution package manager. A complete list of dependencies and prerequisites can be found on OpenWrt's official Wiki pages.
In most cases, the (stable) GNU/Linux distribution of your choice should be sufficient for building the OpenWrt image. Just take care to do everything as non-root user.
However, if you are using testing repositories, bleeding-edge distros or latest/unstable development packages, you could encounter problems with building OpenWrt's cross-toolchain and/or compiler.
In these cases, we advise the use of Docker container with one of the stable images, e.g. Ubuntu 16.04. Setting up a running Docker image is outside of the scope of this tutorial.
Whichever method you require/prefer, take care of the following guidelines:
- Do everything as non-root user!
- Issue all OpenWrt build system commands in <buildroot_dir> directory.
- Make sure to issue all OpenWrt commands in the directory where you have cloned OpenWrt, or in our case this will be the opt/openwrt/openwrt-dd/ directory.
- Changing ownership for working directories to other than root user (this will be covered a little later).
First we will need to download Marvell's LSP kernel version 17.02 with OpenWrt's patches on top of it. Download the kernel sources to your Linux machine; the location for the kernel we will use is /opt/kernel/openwrt-kernel:
user@laptop:~$ mkdir -p /opt/kernel/ && cd /opt/kernel/ user@laptop:/opt/kernel$ git clone https://github.com/MarvellEmbeddedProcessors/openwrt-kernel.git -b openwrt_17.02_release
OpenWrt version supported for ESPRESSObin is Designated Driver (DD), with additional patches for the boards. We will download OpenWrt to /opt/openwrt/openwrt-dd:
user@laptop:~$ mkdir -p /opt/openwrt/ && cd /opt/openwrt/ user@laptop:~$ git clone https://github.com/MarvellEmbeddedProcessors/openwrt-dd.git -b openwrt_17.02_release
NoteIt is also needed to set the right permissions for working directories:
user@laptop:~$ sudo chown -R $(whoami):$(id -gn) /opt/kernel/
user@laptop:~$ sudo chown -R $(whoami):$(id -gn) /opt/openwrt/openwrt-dd/
NoteMake sure to regularly update both kernel and OpenWrt sources before configuring and building OpenWrt firmware.
After we have downloaded necessary repositories, we head to the OpenWrt directory (in our case /opt/openwrt/openwrt-dd):
user@laptop:~$ cd /opt/openwrt/openwrt-dd/
and there we update and index the feeds with:
user@laptop:/opt/openwrt/openwrt-dd$ ./scripts/feeds update -a user@laptop:/opt/openwrt/openwrt-dd$ ./scripts/feeds install -a
Now we invoke OpenWrt's image configuration dialog:
user@laptop:/opt/openwrt/openwrt-dd$ make menuconfig
and in the menu, we select the following:
Target System ---> Marvell 64b Boards Target Profile ---> ESPRESSObin (Marvell Armada 3700 Community Board) Target Images ---> [x] ramdisk ---> * Root filesystem archives * [x] tar.gz * Root filesystem images * [x] ext4 ---> [x] Advanced configuration options (for developers) ---> (/opt/kernel/openwrt-kernel) Use external kernel tree
NoteIf you have setup a different kernel path, make sure to replace it when defining external kernel tree variable.
Save your configuration and exit the make menuconfig interface. Build the image with the make command, e.g.:
user@laptop:/opt/openwrt/openwrt-dd$ make -j5
To speed up the build process, you can utilize multiple cores with the following command:
user@laptop:/opt/openwrt/openwrt-dd$ make -j$(($(nproc)+1))
When the build process finishes, the binaries will be generated 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.
To see how to flash these files onto a USB device or SD card, see Boot from MicroSD card/USB stick - OpenWrt.