Difference between revisions of "How to Build FriendlyWrt"

From FriendlyELEC WiKi
Jump to: navigation, search
(Introduction)
Line 8: Line 8:
 
OpenWrt is maintained by open source communities and its website has rich resources. If you want to customize an OpenWrt you can refer to: [https://openwrt.org/docs/start openwrt doc]。
 
OpenWrt is maintained by open source communities and its website has rich resources. If you want to customize an OpenWrt you can refer to: [https://openwrt.org/docs/start openwrt doc]。
  
==H3 平台==
+
==H3 SoC==
* 首先,OpenWrt必须切换到普通用户才能正常编译,假设你的PC机的普通用户为fa,执行下列命令切换为该普通用户:
+
* 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:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ su fa
 
$ su fa
 
</syntaxhighlight>
 
</syntaxhighlight>
接下来的所有操作请务必在普通用户的环境下进行。
+
All the following commands should be run as a non-root user.
  
 
<br>
 
<br>
* FriendlyElec使用的OpenWrt基于18.06.1版本,执行下列命令克隆源码并切换分支:
+
* For FriendlyElec's ARM boards OpenWrt's version 18.06.1. is integrated. Run the following commands to clone a branch:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ cd /home/fa/
 
$ cd /home/fa/
 
$ git clone https://github.com/friendlyarm/openwrt -b master-v18.06.1
 
$ git clone https://github.com/friendlyarm/openwrt -b master-v18.06.1
 
</syntaxhighlight>
 
</syntaxhighlight>
克隆完毕后,会得到一个名"openwrt"的目录。<br>
+
After cloning is successful a "openwrt" directory will be generated.<br>
虽然该版本的OpenWrt目前仅支持为两款FriendlyElec H3开发板(NanoPi NEO / NanoPi M1 Plus)制作系统映像,但是由于FriendlyElec H3开发板都比较兼容和类似,所以我们完全可以基于NanoPi M1 Plus的config,为其他FriendlyElec H3开发板制作OpenWrt系统映像。
+
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.
下面将以NanoPi M1 Plus为例,描述如何编译制作OpenWrt系统映像。在开始编译制作OpenWrt系统映像前,请务必先阅读OpenWrt官方编写的编译文档[https://openwrt.org/docs/guide-developer/build-system/use-buildsystem openwrt buildsystem],下面将不再赘述每一步编译操作的作用。<br>
+
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:[https://openwrt.org/docs/guide-developer/build-system/use-buildsystem openwrt buildsystem].<br>
  
 
<br>
 
<br>
* 由于OpenWrt编译前需要下载许多的软件包,为了避免网络不稳定的问题,建议使用FriendlyElec预先下载好的软件包目录:[http://download.friendlyarm.com/nanopir1 prebuilt/openwrt-18.06.1-prebuilt_YYYYMMDD.tar.gz]。<br>
+
* To compile an OpenWrt system it needs various software packages. To make a compilation process more quickly and smoothly we suggest you download these packages before you start compilation. Here is a link to the tar ball of all necessary packages:[http://download.friendlyarm.com/nanopir1 prebuilt/openwrt-18.06.1-prebuilt_YYYYMMDD.tar.gz]。<br>
下载成功后,解压并拷贝dl目录到OpenWrt源码的根目录:
+
After you download the tar ball extract the ball and copy the whole "dl" directory to your OpenWrt's root directory:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ cd /home/fa/
 
$ cd /home/fa/
Line 34: Line 34:
 
bin  dl
 
bin  dl
 
</syntaxhighlight>
 
</syntaxhighlight>
其中,bin目录里包含的文件为FriendlyElec编译OpenWrt后产生的系统映像等文件,dl目录则为FriendlyElec预先下载好的软件包目录,将dl目录拷贝到OpenWrt源码的根目录:
+
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:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ cp -r openwrt-18.06.1-prebuilt/dl /home/fa/openwrt/
 
$ cp -r openwrt-18.06.1-prebuilt/dl /home/fa/openwrt/
Line 40: Line 40:
  
 
<br>
 
<br>
* 执行下列命令为FriendlyElec H3开发板(NanoPi NEO / NanoPi M1 Plus)编译并制作OpenWrt系统映像:
+
* Run the following commands to compile an OpenWrt system for FriendlyElec's H3 based boards(NanoPi NEO / NanoPi M1 Plus):
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ cd /home/fa/openwrt/friendlyelec
 
$ cd /home/fa/openwrt/friendlyelec

Revision as of 02:30, 15 January 2019

查看中文

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.


  • To compile an OpenWrt system it needs various software packages. To make a compilation process more quickly and smoothly we suggest you download these packages before you start compilation. Here is a link to the tar ball of all necessary packages:prebuilt/openwrt-18.06.1-prebuilt_YYYYMMDD.tar.gz

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 openwrt-18.06.1-prebuilt_YYYMMDD.tar.gz ./
$ ls openwrt-18.06.1-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-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

编译完成后,会生成下列文件:

$ 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可以用于烧写到TF卡并放在NanoPi M1 PLus上运行。
openwrt-18.06.1-sunxi-cortexa7-sun8i-h3-nanopi-neo-ext4-sdcard.img.gz可以烧写到TF卡并放在NanoPi NEO上运行。
这两个系统映像都是最原汁原味的OpenWrt系统。


  • 注意事项

OpenWrt作为一个一体化的嵌入式系统制作方案,它集成了编译U-boot、Linux Kernel、Rootfs制作、软件源码包管理的功能。
本WiKi编写时,对于FriendlyElec H3系列的开发板,OpenWrt官方使用的U-boot和Linux源码均为第三方开源社区维护的u-boot-2017.11.tar.bz2和linux-4.14.63.tar.xz(均位于dl目录下),而非FriendlyElec官方维护的版本。
开源社区维护的源码版本迭代较快并且变化较多,如果您想使用FriendlyElec官方维护的稳定版U-boot和Linux内核,请使用FriendlyElec定制过的系统映像,或者自行编译FriendlyElec提供的BSP源码并制作系统映像,相关参考如下:
1) Building U-boot and Linux for H5/H3/H2+,编译FriendlyElec维护的U-boot和Linux内核;
2) How to make your own SD-bootable ROM,以FriendlyElec的方式制作系统映像,FriendlyElec提供的nanopi-r1_sd_openwrt_4.14_armhf_YYYYMMDD.img.zip就是通过这种方式制作出来的;