User Tools

Site Tools


openwrt_bpi-r1

Building OpenWRT for a BPI-R1

There are pre-built OpenWRT images available for the BPI-R1, at lot more than the 2 i linked here. But, the OpenWRT BuildRoot makes building your own release very easy.

Introduction

This document discusses possible strategies of building a custom version of OpenWRT to use on the BPI-R1 Banana Pi Router Board. Not all tasks done here are explicitly explained, for example, setting up a Linux VM for building is far beyond the scope of this document. Also, the Banana Pi Router Board seems to be referred to by a lot of names. The ones i've found so far include: BPI-R1, Banana Pi Router Board and Lamobo R1. The official Website for the Banana Pi Router Board BPI-R1 can be found here.

Disclaimer

The contents of this document and all linked documents are subject to revision without notice due to continued progress in methodology, design, and manufacturing. The author shall have no liability for any error or damages of any kind resulting from the use of this document. There is no warranty; not even for merchantability or fitness for a particular purpose.

The information contained in these documents is supplied for domestic and private use only and is not intended as a substitute for appropriate professional advice or guidance. You shall not use this information in any unlawful manner, for any unlawful purposes. You shall not use the information to transmit any material that is defamatory, offensive or otherwise objectionable.

Preparation

You'll want to install the OpenWRT BuildRoot on a supported system to continue. I went on using Ubuntu Linux in a VM for building. They say OSX is supported, but only after some pretty heavy tweaking, which i would not recommend doing on a system you need to work. In the end, you'll need:

  • a recent Linux system, preferrably Debian or Ubuntu
  • build directory location mustn't have spaces
  • all necessary packages (Debian: sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core libssl-dev unzip)
  • If you're using a VM, ssh access is preferred over 'vm console access'. Also see here for a couple of tips.

Details on what exactly to install can be found in the OpenWRT documentation.

Getting the sources

The HEAD revision sources can be fetched via git:

# git clone https://github.com/openwrt/openwrt

To fetch a specific release then do this:

# git checkout openwrt-19.07

Or just get _only_ that in the first place:

# git clone --single-branch -b openwrt-19.07 git@github.com:openwrt/openwrt.git

Updating and enabling the package feeds

To make the standard packages as well as your custom feed available in make menuconfig, you'll want to do this:

# cd ~/openwrt
# ./scripts/feeds update -a
# ./scripts/feeds install -a

Configuring the build

Now its time to start the fun part! We'll now configure OpenWRT to match our needs.

# make menuconfig

Adding V=s to any make statement will turn up verbosity and tell you whats wrong. If all went well, you'll see a screen quite similar to the Linux kernel make menuconfig. To establish support for the BPI-R1, you have to set at least these options:

Target System -> 'Allwinner A1x/A20/A3x'
Target Profile -> 'Lamobo R1'

Anything else can be customized to fit your special needs. Take your time to study all the available options.

Some hints

When selecting [M] for a package in the OpenWRT BuildRoot make menuconfig, this package will be built as an opkg package file for later installation. When selecting [*], it will additionally be installed in the final image. Use the 'm', 'y' (for *) and 'n' (to deselect) keys.

Injecting files into image

If you want to inject some config files (or whatever) into the final image, create a files folder under ~/openwrt/openwrt, consider files as being the / of the image. For example, to add an /etc/hostname file:

# mkdir ~/openwrt/files
# cd ~/openwrt/files
# mkdir etc
# echo "routerboard" > ./etc/hostname

Building OpenWRT

Although there are other howtos hinting to use make with the -j parameter to establish parallelism (i.e. make -j5), i wouldn't recommend it. I ran into some things which i considered to be race conditions while experimenting with -j for the OpenWRT buildroot. Not using -j did not produce any strange errors. Besides, theres an option in make menuconfig to 'build certain packages in parallel', so i suspect there could be issues. The time this would have saved is in the minutes range anyways - we're hopefully building on modern hardware!

Otherwise than that, building OpenWRT is just a matter of running

# cd ~/openwrt
# make

and then walking away to have a couple of coffees. As above, fix any errors. Use make -j1 V=s as a parameter to increase verbosity. While this might look strange when just 2 paragraphs above i discourage the use of -j for make, but this way you can disable aforementioned make menuconfig option to 'build certain packages in parallel' (thus get useful console output).

Obtaining the final OpenWRT image

The result of the build process is in ~/openwrt/openwrt/bin/sunxi. The image file is named something along the lines of openwrt-sunxi-Lamobo_R1-sdcard-vfat-ext4.img. Write this image to your sdcard like so:

# cd ~/openwrt/openwrt/bin/sunxi
# dd if=./openwrt-sunxi-Lamobo_R1-sdcard-vfat-ext4.img of=/dev/your_sd_reader bs=1m conv=sync status=progress

See the OPKG technical reference for details on how to make use of the packages.

Et voila, we're done! :-)

Sources for the document

openwrt_bpi-r1.txt · Last modified: 2020/09/10 13:20 by flo