Loading...
 

Build From Source - OpenWrt

In this page, we will go over downloading necessary sources and building OpenWrt binaries 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.

Pre-built OpenWrt images can be downloaded from our Tech Spec page, Software table.

Prerequisites

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:

  • subversion
  • build-essential
  • libncurses5-dev
  • zlib1g-dev
  • gawk
  • git
  • ccache
  • gettext
  • libssl-dev
  • xsltproc
  • file

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.

Bootloader

 IMPORTANT
In order to provide the full device functionality for the OpenWrt distribution, you will have to re-flash the U-Boot version to match the version of the OpenWrt release you are planning to use. For example:


U-Boot 2017.03-armada-17.10.1-00489-ge7c0ff4 should be used for the OpenWrt 17.10. release
ESPRESSObin U-Boot binaries for 17.06 and 17.10 branches are available on our Tech Spec page, Software table under Bootloader. The bootloader can be re-flashed using instructions covered in Update the Bootloader page.


To check the current version of U-boot on your ESPRESSObin, connect the device over serial port and power on the board. You should see the relevant information in the first few lines:

TIM-1.0
WTMI-armada-17.10.1-b90dbf0
ENTER init_ddrgen
DDR_TOPOLOGY is 2 :DDR3, 2CS 512M + 512M
WTMI_CLOCK=2

Fill memory before self refresh...done

Fill memory before self refresh...done

Now in Self-refresh Mode
Restore CAS Read and Write Latency
Restore termination values to original values
Exited self-refresh ...

DLL TUNING
==============
   DLL 0xc0001050[21:16]: [0,27,13]
   DLL 0xc0001050[29:24]: [4,38,1e]
   DLL 0xc0001054[21:16]: [2,2d,17]
   DLL 0xc0001054[29:24]: [b,38,21]
   DLL 0xc0001074[21:16]: [0,3f,1f]
   DLL 0xc0001074NOTICE:  Booting Trusted Firmware
NOTICE:  BL1: v1.3(release):armada-17.10.3:a3306ab
NOTICE:  BL1: Built : 18:22:33, Jan 29 2NOTICE:  BL2: v1.3(release):armada-17.10.3:a3306ab
NOTICE:  BL2: Built : 18:22:35, Jan 29 2018NOTICE:  BL31: v1.3(release):armada-17.10.3:a3306ab
NOTICE:  BL31:

U-Boot 2017.03-armada-17.10.1-gaee49fc (Jan 29 2018 - 18:21:49 +0800)

Model: Marvell Armada 3720 Community Board ESPRESSOBin
       CPU    @ 1000 [MHz]
       L2     @ 800 [MHz]
       TClock @ 200 [MHz]
       DDR    @ 800 [MHz]
DRAM:  1 GiB
...

Alternatively, press any key to stop the booting procedure, and type version in the U-Boot prompt:

Marvell>> version

U-Boot 2017.03-armada-17.10.1-gaee49fc (Jan 29 2018 - 18:21:49 +0800)
aarch64-linux-gnu-gcc (Linaro GCC 5.2-2015.11-2) 5.2.1 20151005
GNU ld (GNU Binutils) 2.25.0 Linaro 2015_10

Build Environment

In most cases, the (stable) GNU/Linux distribution of your choice should be sufficient for building the OpenWrt image. Using testing repositories, bleeding-edge distros or latest/unstable development packages could result in 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 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).

Kernel

There are three Marvell LSP kernel versions (with OpenWrt patches on top) available for the ESPRESSObin: 17.02, 17.06 and 17.10. The location where we will download the kernel source to is /opt/kernel/openwrt-kernel, so create the directory and position into it:

$ mkdir -p /opt/kernel/ && cd /opt/kernel/

From here clone the kernel source and checkout the desired version:

  • for 17.02:
$ git clone https://github.com/MarvellEmbeddedProcessors/openwrt-kernel.git -b openwrt_17.02_release
  • for 17.06:
$ git clone https://github.com/MarvellEmbeddedProcessors/openwrt-kernel.git -b openwrt_17.06_release
  • for 17.10:
$ git clone https://github.com/MarvellEmbeddedProcessors/openwrt-kernel.git -b openwrt_17.10_release

OpenWrt

OpenWrt version supported for ESPRESSObin is Designated Driver (DD), with additional patches for the boards. We will download OpenWrt to /opt/openwrt/openwrt-dd so create the directory and position there:

$ mkdir -p /opt/openwrt/openwrt-dd && cd /opt/openwrt/openwrt-dd

Depending on your chosen Marvell LSP kernel version, checkout the respective OpenWrt branch:

  • for 17.02:
$ git clone https://github.com/MarvellEmbeddedProcessors/openwrt-dd.git -b openwrt_17.02_release
  • for 17.06:
$ git clone https://github.com/MarvellEmbeddedProcessors/openwrt-dd.git -b openwrt_17.06_release
  • for 17.10:
$ git clone https://github.com/MarvellEmbeddedProcessors/openwrt-dd.git -b openwrt_17.10_release

 Note
It is also needed to set the right permissions for working directories:

$ sudo chown -R $(whoami):$(id -gn) /opt/kernel/
$ sudo chown -R $(whoami):$(id -gn) /opt/openwrt/openwrt-dd/
 Note
Make sure to regularly update both kernel and OpenWrt sources before configuring and building OpenWrt firmware.

Image configuration

After we have downloaded necessary repositories, from our OpenWrt directory ( /opt/openwrt/openwrt-dd ) we update and index the feeds with:

$ ./scripts/feeds update -a
$ ./scripts/feeds install -a

Now invoke OpenWrt's image configuration dialog:

$ make menuconfig

in the menu 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

 

 Note
If you have setup a different kernel path, make sure to replace it when defining external kernel tree variable.

Save your configuration and exit the menuconfig interface. Build the image with the make command. To speed up the build process, you can utilize multiple cores with the following command:

$ 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. Binaries have the same file name irregardless of the chosen version.

To see how to flash these files onto a USB device or SD card, see Boot from MicroSD card/USB stick - OpenWrt.

OpenWrt 18.06

For downloading and booting OpenWrt 18.06 stable release, see Boot from removable storage - OpenWrt.