How to Build OpenWrt

From FriendlyARM WiKi
Jump to: navigation, search

查看中文

1 Introduction

OpenWrt is a highly extensible GNU/Linux distribution for embedded devices.Unlike many other distributions for routers, OpenWrt is built from the ground up to be a full-featured, easily modifiable operating system for embedded devices. In practice, this means that you can have all the features you need with none of the bloat, powered by a modern Linux kernel. For more details you can refer to:OpenWrt Website

This Wiki pages mainly explains how to compile an OpenWrt system for FriendlyElec's ARM boards but doesn't have details about how to customize an OpenWrt system. OpenWrt is maintained by open source communities and its website has rich resources. If you want to customize an OpenWrt you can refer to: openwrt doc

2 H3 SoC

  • You need to compile an OpenWrt system as a non-root user.In our test we logged in and switched to a non-root user "fa" by running the following command:
$ su fa

All the following commands should be run as a non-root user.


  • For FriendlyElec's ARM boards OpenWrt's version 18.06.1. is integrated. Run the following commands to clone a branch:
$ cd /home/fa/
$ git clone https://github.com/friendlyarm/openwrt -b master-v18.06.1

After cloning is successful a "openwrt" directory will be generated.
Currently version 18.06.1 works with FriendlyElec's H3 based NanoPi NEO and NanoPi M1 Plus. You can make an OpenWrt system for other FriendlyElec's H3 based boards as well by using a config for NanoPi M1 Plus. Here are the steps to make an OpenWrt system for the NanoPi M1 Plus. Before proceed we highly recommend you to carefully read this document:openwrt buildsystem.


After you download the tar ball extract the ball and copy the whole "dl" directory to your OpenWrt's root directory:

$ cd /home/fa/
$ tar xzf openwrt-18.06.1_sunxi-cortexa7_prebuilt_YYYYMMDD.tar.gz -C ./
$ ls ./openwrt-18.06.1_sunxi-cortexa7_prebuilt
bin  dl

The "bin" directory will have all the image files generated after compiling an OpenWrt system. The "dl" directory has all the necessary packages needed for compilation:

$ cp -r ./openwrt-18.06.1_sunxi-cortexa7_prebuilt/dl /home/fa/openwrt/


  • Run the following commands to compile an OpenWrt system for FriendlyElec's H3 based boards(NanoPi NEO / NanoPi M1 Plus):
$ cd /home/fa/openwrt/friendlyelec
$ ./build.sh nanopi-h3

After compilation is done the following files will be generated:

$ tree bin/targets/sunxi/cortexa7/ -L 1
bin/targets/sunxi/cortexa7/
├── config.seed
├── openwrt-18.06.1-sunxi-cortexa7-device-sun8i-h3-nanopi-m1-plus.manifest
├── openwrt-18.06.1-sunxi-cortexa7.manifest
├── openwrt-18.06.1-sunxi-cortexa7-sun8i-h3-nanopi-m1-plus-ext4-sdcard.img.gz
├── openwrt-18.06.1-sunxi-cortexa7-sun8i-h3-nanopi-m1-plus-squashfs-sdcard.img.gz
├── openwrt-18.06.1-sunxi-cortexa7-sun8i-h3-nanopi-neo-ext4-sdcard.img.gz
├── openwrt-18.06.1-sunxi-cortexa7-sun8i-h3-nanopi-neo-squashfs-sdcard.img.gz
├── openwrt-imagebuilder-18.06.1-sunxi-cortexa7.Linux-x86_64.tar.xz
├── openwrt-sdk-18.06.1-sunxi-cortexa7_gcc-7.3.0_musl_eabi.Linux-x86_64.tar.xz
├── packages
└── sha256sums

openwrt-18.06.1-sunxi-cortexa7-sun8i-h3-nanopi-m1-plus-ext4-sdcard.img.gz is used to make a bootable TF card for the NanoPi M1 Plus.
openwrt-18.06.1-sunxi-cortexa7-sun8i-h3-nanopi-neo-ext4-sdcard.img.gz is used to make a bootable TF card for the NanoPi NEO.
These two are very typical OpenWrt system.


  • Notes:

OpenWrt is an all-in-one system that integrates U-boot, Linux Kernel, Rootfs utilities, package management utilities and etc.
When this WiKi was being written the U-boot(u-boot-2017.11.tar.bz2 under the "dl" directory) and Linux code(linux-4.14.63.tar.xz under the "dl" directory) for the OpenWrt version were maintained and supported by third party open source communities instead of FriendlyElec.
U-boot and Linux code that are maintained by open source communities are updated very frequently.Therefore if you want to use a stable OpenWrt with stable U-boot and Linux kernel you'd better use a FriendlyElec's version or generate an image by compiling a FriendlyElec's BSP. Here are two reference links:
1) Building U-boot and Linux for H5/H3/H2+, Compile FriendlyElec's U-boot and Linux kernel;
2) How to make your own SD-bootable ROM, Make a customized image following the steps verified by FriendlyElec. FriendlyElec's nanopi-r1_sd_openwrt_4.14_armhf_YYYYMMDD.img.zip is generated by following these steps;