Difference between revisions of "How to Build FriendlyWrt"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
(63 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[How to Build OpenWrt/zh|查看中文]]
+
[[How to Build FriendlyWrt/zh|查看中文]]
  
==简介==
+
==Introduction to FriendlyWrt==
OpenWrt是适合于嵌入式设备的一个Linux发行版,它不是一个单一、静态的固件,而是提供了一个可添加软件包的可写的文件系统。
+
FriendlyWrt is a customized OpenWrt system developed by FriendlyElec. It is open source and suitable for applications in IoT, NAS and etc.<br />
这使用户可以自由的选择应用程序和配置,而不必受设备提供商的限制,并且可以使用一些适合某方面应用的软件包来定制你的设备。
+
对于开发者来说,OpenWrt是一个框架,开发者不必麻烦地构建整个固件就能得到想要的应用程序;对于用户来说,这意味着完全定制的能力,与以往不同的方式使用设备,OPKG包含超过3500个软件。
+
更详细的介绍请参考: [https://openwrt.org/ OpenWrt官网]。<br>
+
<br>
+
本Wiki页面的主要用于介绍如何为FriendlyElec发行的开发板编译OpenWrt,并不涉及太多对OpenWrt的定制和研究。
+
OpenWrt是由开源组织维护的开源项目,其官网上已经有丰富的用户文档和开发者文档,如果您需要对OpenWrt进行定制开发,请自行查看OpenWrt官方提供的文档: [https://openwrt.org/docs/start openwrt doc]。
+
  
 +
==User Name & Password==
 +
No password set default, please configure a root password to protect the web interface and enable SSH.
  
==H3 平台==
+
==Supported FriendlyElec Boards==
* 首先,OpenWrt必须切换到普通用户才能正常编译,假设你的PC机的普通用户为fa,执行下列命令切换为该普通用户:
+
{| class="wikitable"
<syntaxhighlight lang="text">
+
|-
$ su fa
+
  | '''OS'''
 +
  | '''Version'''
 +
  | '''Supported Board Types'''
 +
  | '''Image File'''
 +
  | '''Download Link'''
 +
|-
 +
  | FriendlyWrt for H3
 +
  | 19.07.1
 +
  | NanoPi-R1S, NanoPi-R1, NanoPi-NEO, NanoPi-NEO-Air,  <br />NanoPi-M1, ZeroPi, NanoPi-NEO-S,  <br />NanoPi-NEO-Core, NanoPi-M1-Plus, NanoPi-Duo2
 +
  | nanopi-r1_sd_friendlywrt_4.14_armhf_YYYYMMDD.img.zip
 +
  | [http://download.friendlyelec.com/nanopir1 H3 Download Link]
 +
|-
 +
  | FriendlyWrt for H5
 +
  | 19.07-snapshot
 +
  | NanoPi-NEO2,NanoPi-K1-Plus,NanoPi-NEO-Core2
 +
  | nanopi-neo-core2_sd_friendlywrt_4.14_arm64_YYYYMMDD.img.zip
 +
  | [http://download.friendlyelec.com/nanopineocore2 H5 Download Link]
 +
|-
 +
  | FriendlyWrt for S5P4418
 +
  | 19.07-snapshot
 +
  | NanoPi-Fire2A, NanoPC-T2, NanoPi-S2,  <br />NanoPi-M2A, Smart4418
 +
  | s5p4418-sd-friendlywrt-4.4-YYYYMMDD.img.zip
 +
  | [http://download.friendlyelec.com/nanopct2 S5P4418 Download Link]
 +
|-
 +
  | FriendlyWrt for S5P6818
 +
  | 19.07-snapshot
 +
  | NanoPi-Fire3, NanoPC-T3, Smart6818
 +
  | s5p6818-sd-friendlywrt-4.4-YYYYMMDD.img.zip
 +
  | [http://download.friendlyelec.com/nanopct3 S5P6818 Download Link]
 +
|-
 +
  | FriendlyWrt for RK3399
 +
  | 21.02.5 / 23.05
 +
  | All FriendlyElec's RK3399 based boards, including NanoPi-M4v2, NanoPi-M4B, Som-RK3399
 +
  | rk3399-sd-friendlywrtNN-6.1-YYYYMMDD.img.zip
 +
  | [http://download.friendlyelec.com/nanopct4 RK3399 Download Link]
 +
|-
 +
  | FriendlyWrt for RK3328
 +
  | 21.02.5 / 23.05
 +
  | NanoPi-R2S, NanoPi-R2C, NanoPi-R2C-Plus
 +
  | rk3328-sd-friendlywrtNN-6.1-YYYYMMDD.img.zip
 +
  | [http://download.friendlyelec.com/nanopir2s RK3328 Download Lin]
 +
|-
 +
  | FriendlyWrt for RK3568
 +
  | 21.02.5 / 23.05
 +
  | NanoPi-R5S
 +
  | rk3568-sd-friendlywrtNN-6.1-YYYYMMDD.img.zip
 +
  | [http://download.friendlyelec.com/nanopir5s RK3568下载链接]
 +
|-
 +
  | FriendlyWrt for RK3588
 +
  | 21.02.5 / 23.05
 +
  | NanoPi-R6S
 +
  | rk3588-sd-friendlywrtNN-6.1-YYYYMMDD.img.zip
 +
  | [http://download.friendlyelec.com/nanopir6s RK3588下载链接]
 +
|}
 +
How to test the image: extract the image file, use the "dd" command under Linux or the win32image utility under Windows to flash the image to an SD card.
 +
 
 +
==Get Source Code==
 +
===Install repo===
 +
Firstly you need to install the repo utility:
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/repo --depth 1
 +
sudo cp repo/repo /usr/bin/
 
</syntaxhighlight>
 
</syntaxhighlight>
接下来的所有操作请务必在普通用户的环境下进行。
 
  
<br>
+
===Download Source Code===
* FriendlyElec使用的OpenWrt基于18.06.1版本,执行下列命令克隆源码并切换分支:
+
There are two ways to obtain the source code. For mainland Chinese users the first is recommended:
<syntaxhighlight lang="text">
+
====One: Use Repo Package from FriendlyElec's Cloud Storage====
$ cd /home/fa/
+
The source files are located at the "sources/friendlywrt-CPU-YYYYMMDD.tar" directory in FriendlyElec's cloud storage. "CPU" stands for an SoC model and YYYYMMDD stands for date(the year, month and day) in which the package is packed.<br />
$ git clone https://github.com/friendlyarm/openwrt -b master-v18.06.1
+
After you get a repo package run the following command to extract it. Let's take an image for Allwinner H3 based boards as an example:
 +
<syntaxhighlight lang="bash">
 +
tar xvf /path/to/netdisk/sources/friendlywrt-h3-20190101.tar
 +
cd friendlywrt-h3
 +
repo sync -l --no-clone-bundle
 +
</syntaxhighlight>
 +
Now you have had the full source code for generating an image. The last number digits in the file name stand for the packing date. If you want to obtain the latest official release, remove "-l" and do "repo sync" again:
 +
<syntaxhighlight lang="bash">
 +
cd friendlywrt-h3
 +
repo sync --no-clone-bundle
 
</syntaxhighlight>
 
</syntaxhighlight>
克隆完毕后,会得到一个名"openwrt"的目录。<br>
 
虽然该版本的OpenWrt目前仅支持为两款FriendlyElec H3开发板(NanoPi NEO / NanoPi M1 Plus)制作系统映像,但是由于FriendlyElec H3开发板都比较兼容和类似,所以我们完全可以基于NanoPi M1 Plus的config,为其他FriendlyElec H3开发板制作OpenWrt系统映像。
 
下面将以NanoPi M1 Plus为例,描述如何编译制作OpenWrt系统映像。在开始编译制作OpenWrt系统映像前,请务必先阅读OpenWrt官方编写的编译文档[https://openwrt.org/docs/guide-developer/build-system/use-buildsystem openwrt buildsystem],下面将不再赘述每一步编译操作的作用。<br>
 
  
<br>
+
====Two: Get Source Code from Github====
* 由于OpenWrt编译前需要下载许多的软件包,为了避免网络不稳定的问题,建议使用FriendlyElec预先下载好的软件包目录:[http://download.friendlyarm.com/nanopir1 prebuilt/openwrt-18.06.1-prebuilt_YYYYMMDD.tar.gz]。<br>
+
=====H3 Based Boards=====
下载成功后,解压并拷贝dl目录到OpenWrt源码的根目录:
+
<syntaxhighlight lang="bash">
<syntaxhighlight lang="text">
+
mkdir friendlywrt-h3
$ cd /home/fa/
+
cd friendlywrt-h3
$ tar openwrt-18.06.1-prebuilt_YYYMMDD.tar.gz ./
+
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v19.07.1 -m h3.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
$ ls openwrt-18.06.1-prebuilt
+
repo sync -c --no-clone-bundle
bin dl
+
 
</syntaxhighlight>
 
</syntaxhighlight>
其中,bin目录里包含的文件为FriendlyElec编译OpenWrt后产生的系统映像等文件,dl目录则为FriendlyElec预先下载好的软件包目录,将dl目录拷贝到OpenWrt源码的根目录:
+
=====H5 Based Boards=====
<syntaxhighlight lang="text">
+
<syntaxhighlight lang="bash">
$ cp -r openwrt-18.06.1-prebuilt/dl /home/fa/openwrt/
+
mkdir friendlywrt-h5
 +
cd friendlywrt-h5
 +
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master \
 +
        -m h5.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
 +
repo sync -c  --no-clone-bundle
 +
</syntaxhighlight>
 +
=====S5P4418 Based Boards=====
 +
<syntaxhighlight lang="bash">
 +
mkdir friendlywrt-s5p4418
 +
cd friendlywrt-s5p4418
 +
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master \
 +
        -m s5p4418.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
 +
repo sync -c  --no-clone-bundle
 +
</syntaxhighlight>
 +
=====S5P6818 Based Boards=====
 +
<syntaxhighlight lang="bash">
 +
mkdir friendlywrt-s5p6818
 +
cd friendlywrt-s5p6818
 +
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master \
 +
        -m s5p6818.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
 +
repo sync -c  --no-clone-bundle
 +
</syntaxhighlight>
 +
=====RK3399 Based Boards=====
 +
<syntaxhighlight lang="bash">
 +
mkdir friendlywrt23-rk3399
 +
cd friendlywrt23-rk3399
 +
git clone https://github.com/friendlyarm/repo --depth 1 tools
 +
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \
 +
        -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
 +
tools/repo sync -c  --no-clone-bundle
 +
</syntaxhighlight>
 +
=====RK3328 Based Boards=====
 +
<syntaxhighlight lang="bash">
 +
mkdir friendlywrt23-rk3328
 +
cd friendlywrt23-rk3328
 +
git clone https://github.com/friendlyarm/repo --depth 1 tools
 +
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \
 +
        -m rk3328.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
 +
tools/repo sync -c  --no-clone-bundle
 +
</syntaxhighlight>
 +
=====RK3568 Based Boards=====
 +
<syntaxhighlight lang="bash">
 +
mkdir friendlywrt23-rk3568
 +
cd friendlywrt23-rk3568
 +
git clone https://github.com/friendlyarm/repo --depth 1 tools
 +
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \
 +
        -m rk3568.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
 +
tools/repo sync -c  --no-clone-bundle
 +
</syntaxhighlight>
 +
=====RK3588 Based Boards=====
 +
<syntaxhighlight lang="bash">
 +
mkdir friendlywrt23-rk3588
 +
cd friendlywrt23-rk3588
 +
git clone https://github.com/friendlyarm/repo --depth 1 tools
 +
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \
 +
        -m rk3588.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
 +
tools/repo sync -c  --no-clone-bundle
 +
</syntaxhighlight>
 +
====Get Latest Release With "Sync"====
 +
<syntaxhighlight lang="bash">
 +
repo sync -c --no-clone-bundle
 +
</syntaxhighlight>
 +
If synchronization is interrupted you can run the following script to do sync again:
 +
<syntaxhighlight lang="bash">
 +
#! /bin/bash
 +
repo sync -c --no-clone-bundle
 +
while [ $? -ne 0 ];
 +
do 
 +
    repo sync -c --no-clone-bundle
 +
done
 
</syntaxhighlight>
 
</syntaxhighlight>
  
<br>
+
====Swtich To Different Platform====
* 执行下列命令为FriendlyElec H3开发板(NanoPi NEO / NanoPi M1 Plus)编译并制作OpenWrt系统映像:
+
If you have been working on the source code for Allwinner H3's boards and want to swtich to the source code for Allwinner H5's boards you can do it this way:
<syntaxhighlight lang="text">
+
<syntaxhighlight lang="bash">
$ cd /home/fa/openwrt/friendlyelec
+
cp -af friendlywrt-h3 friendlywrt-h5
$ ./build.sh nanopi-h3
+
cd friendlywrt-h5
 +
repo init -m h5.xml
 +
repo sync --force-sync
 
</syntaxhighlight>
 
</syntaxhighlight>
编译完成后,会生成下列文件:
+
 
<syntaxhighlight lang="text">
+
==Compile Source Code==
$ tree bin/targets/sunxi/cortexa7/ -L 1
+
===Setup Development Environment===
bin/targets/sunxi/cortexa7/
+
You need a host PC running a 64-bit Ubuntu 20.04 system and run the following command on the PC:
├── config.seed
+
<syntaxhighlight lang="bash">
├── openwrt-18.06.1-sunxi-cortexa7-device-sun8i-h3-nanopi-m1-plus.manifest
+
wget -O - https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh | bash
├── 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
+
 
</syntaxhighlight>
 
</syntaxhighlight>
openwrt-18.06.1-sunxi-cortexa7-sun8i-h3-nanopi-m1-plus-ext4-sdcard.img.gz可以用于烧写到TF卡并放在NanoPi M1 PLus上运行。<br>
 
openwrt-18.06.1-sunxi-cortexa7-sun8i-h3-nanopi-neo-ext4-sdcard.img.gz可以烧写到TF卡并放在NanoPi NEO上运行。<br>
 
这两个系统映像都是最原汁原味的OpenWrt系统。
 
  
<br>
+
===Build buildroot in Docker container===
* 注意事项
+
Please use the Docker image provided by this link, for details, please refer to the README document:<br />
OpenWrt作为一个一体化的嵌入式系统制作方案,它集成了编译U-boot、Linux Kernel、Rootfs制作、软件源码包管理的功能。<br>
+
https://github.com/friendlyarm/docker-cross-compiler-novnc<br />
本WiKi编写时,对于FriendlyElec H3系列的开发板,OpenWrt官方使用的U-boot和Linux源码均为第三方开源社区维护的u-boot-2017.11.tar.bz2和linux-4.14.63.tar.xz(均位于dl目录下),而非FriendlyElec官方维护的版本。<br>
+
 
开源社区维护的源码版本迭代较快并且变化较多,如果您想使用FriendlyElec官方维护的稳定版U-boot和Linux内核,请使用FriendlyElec定制过的系统映像,或者自行编译FriendlyElec提供的BSP源码并制作系统映像,相关参考如下:<br>  
+
===Get Help Info===
1) [[Building U-boot and Linux for H5/H3/H2+]],编译FriendlyElec维护的U-boot和Linux内核;<br>
+
Run the build.sh script without any options it will print the help information:
2) [[How to make your own SD-bootable ROM]],以FriendlyElec的方式制作系统映像,FriendlyElec提供的nanopi-r1_sd_openwrt_4.14_armhf_YYYYMMDD.img.zip就是通过这种方式制作出来的;
+
<syntaxhighlight lang="bash">
 +
./build.sh
 +
</syntaxhighlight>
 +
Let's take Allwinner H3 as an example, the help information will be presented as follows:
 +
<syntaxhighlight lang="bash">
 +
USAGE: ./build.sh <parameter>
 +
 
 +
# Select Board Type:
 +
  ./build.sh nanopi_r1.mk
 +
  ./build.sh nanopi_duo.mk
 +
  ./build.sh nanopi_neo_core.mk
 +
  ./build.sh nanopi_neo.mk
 +
  ./build.sh nanopi_neo_s.mk
 +
  ./build.sh nanopi_m1_plus.mk
 +
  ./build.sh nanopi_m1.mk
 +
  ./build.sh nanopi_neo_air.mk
 +
 
 +
# Select Module:
 +
  ./build.sh all                -compile all
 +
  ./build.sh uboot              -compile uboot
 +
  ./build.sh kernel            -compile kernel
 +
  ./build.sh friendlywrt        -compile friendlywrt
 +
  ./build.sh sd-img            -generate an image for an sd card
 +
  ./build.sh emmc-img          -generate an image for emmc (the generated image should be flased to an SD card and then flashed to emm with this SD card)
 +
# Clean:
 +
  ./build.sh cleanall
 +
</syntaxhighlight>
 +
 
 +
===Auto Compile===
 +
For a first time compilation you need to select an SoC platform. Let's take the NanoPi R1(Allwinner H3) as an example:
 +
<syntaxhighlight lang="bash">
 +
./build.sh nanopi_r1.mk
 +
</syntaxhighlight>
 +
After the script is done successfully all components including a u-boot, a kernel and a friendlywrt will be compiled, and an image file will be generated.
 +
 
 +
===Compile Individual Component===
 +
====kernel====
 +
<syntaxhighlight lang="bash">
 +
./build.sh kernel
 +
</syntaxhighlight>
 +
====u-boot====
 +
<syntaxhighlight lang="bash">
 +
./build.sh uboot
 +
</syntaxhighlight>
 +
====FriendlyWrt====
 +
method 1:
 +
<syntaxhighlight lang="bash">
 +
./build.sh friendlywrt
 +
</syntaxhighlight>
 +
method 2:
 +
<syntaxhighlight lang="bash">
 +
cd friendlywrt
 +
./scripts/feeds update -a
 +
./scripts/feeds install -a
 +
cp ../configs/config_XXXX .config
 +
make defconfig
 +
make download -j8
 +
make -j8
 +
</syntaxhighlight>
 +
===Generate Image for SD Card===
 +
<syntaxhighlight lang="bash">
 +
sudo ./build.sh sd-img
 +
</syntaxhighlight>
 +
If an img file is generated successfully you will see the following messages. You can use the "dd" command to flash the img file to an SD card. Note: you will need to replace "/dev/sdX" with the actual device name which your system recognizes the device as:<br />
 +
<syntaxhighlight lang="bash">
 +
Run the following for sdcard install:
 +
    sudo dd if=out/FriendlyWrt_20190828_NanoPi-R1_armhf_sd.img bs=1M of=/dev/sdX
 +
</syntaxhighlight>
 +
===Generate emmc (eflasher) Image===
 +
<syntaxhighlight lang="bash">
 +
sudo ./build.sh emmc-img
 +
</syntaxhighlight>
 +
If an img file is generated successfully you will see the following messages. You can use the "dd" command to flash the img file to an SD card. Note: you will need to replace "/dev/sdX" with the actual device name which your system recognizes the device as:<br />
 +
<syntaxhighlight lang="bash">
 +
Run the following for sdcard install:
 +
    sudo dd if=out/FriendlyWrt_20190828_NanoPi-R1_armhf_eflasher.img bs=1M of=/dev/sdX
 +
</syntaxhighlight>
 +
Use this SD card to boot the eflasher system and run eflasher commands to install an OS to emmc. After installation is done, take off the SD card of the board and boot your system friendlywrt will load from eMMC.
 +
 
 +
==Make Your Own Friendlywrt==
 +
===Structure of Source Code Directories===
 +
<syntaxhighlight lang="bash">
 +
├── friendlywrt
 +
│  ├── friendlywrt -> friendlywrt's source code
 +
│  └── configs -> save the "friendlywrt defconfig" file
 +
│  └── toolchain -> cross-compiler, used for compiling a u-boot and kernel
 +
│  ├── build.sh -> script for auto-compile
 +
│  ├── device/friendlyelec -> configuration file for friendlyelec boards
 +
│  ├── kernel -> kernel
 +
│  └── u-boot -> u-boot
 +
│  └── scripts -> script files for generating an img
 +
</syntaxhighlight>
 +
 
 +
===Configure friendlywrt Components===
 +
* Configure by Using Make Menuconfig(H3)
 +
<syntaxhighlight lang="bash">
 +
cd friendlywrt-h3/friendlywrt
 +
make menuconfig
 +
</syntaxhighlight>
 +
* Save Your Configurations
 +
<syntaxhighlight lang="bash">
 +
make menuconfig
 +
./scripts/diffconfig.sh > ../configs/my_config
 +
</syntaxhighlight>
 +
* Set Your Configurations As Default
 +
Let's take the NanoPi-R1 as an example and edit the following file:
 +
<syntaxhighlight lang="bash">
 +
device/friendlyelec/h3/nanopi_r1.mk
 +
</syntaxhighlight>
 +
Set TARGET_FRIENDLYWRT_CONFIG to your configurations.
 +
* Recompile Friendlywrt and Generate Image for SD Card
 +
<syntaxhighlight lang="bash">
 +
./build.sh friendlywrt
 +
./build.sh sd-img
 +
</syntaxhighlight>
 +
 
 +
===Put Your Add-on Features to Friendlywrt===
 +
Let's take H3 as an example. Put your files and directories to the following directory and they will be compiled to an img file.
 +
<syntaxhighlight lang="bash">
 +
device/friendlyelec/h3/common-files
 +
</syntaxhighlight>
 +
Or you can put your files and directories in a new directory. Let's take the NanoPi-R1 as an example and edit the following file:
 +
<syntaxhighlight lang="bash">
 +
device/friendlyelec/h3/nanopi_r1.mk
 +
</syntaxhighlight>
 +
Open the file and add a new line(replace "XXX" with your directory):
 +
<syntaxhighlight lang="bash">
 +
FRIENDLYWRT_FILES+=(device/friendlyelec/h3/XXX)
 +
</syntaxhighlight>
 +
 
 +
===Change Friendlywrt's Default Configurations(Network, Firewall Etc)===
 +
Open and edit the following files:
 +
<syntaxhighlight lang="bash">
 +
device/friendlyelec/h3/default-settings/files
 +
friendlywrt/package/base-files/files
 +
</syntaxhighlight>
 +
 
 +
===Change U-boot and Kernel's Configurations(H3)===
 +
Open and edit the following file:
 +
<syntaxhighlight lang="bash">
 +
device/friendlyelec/h3/nanopi_r1.mk
 +
</syntaxhighlight>
 +
Change uboot's settings to your own by making the following changes:
 +
<syntaxhighlight lang="bash">
 +
TARGET_UBOOT_CONFIG=nanopi_h3_defconfig
 +
</syntaxhighlight>
 +
Change kernel's settings to your own by making the following changes:
 +
<syntaxhighlight lang="bash">
 +
TARGET_KERNEL_CONFIG=sunxi_defconfig
 +
</syntaxhighlight>
 +
 
 +
===Change Other COnfigurations===
 +
Open and edit the following xml file and you can replace the source code of kernel, uboot and friendlywrt yo your own code:
 +
<syntaxhighlight lang="bash">
 +
.repo/manifests/h3.xml
 +
</syntaxhighlight>
 +
For more details about what each item in the xml file means, refer to:[https://gerrit.googlesource.com/git-repo/+/refs/heads/master/docs/manifest-format.md repo Manifest Format]<br />
 +
After you make your changes you need to do "repo" to sync and make the changes effective. For example after you change the kernel's source code you need to run the following command to sync:
 +
<syntaxhighlight lang="bash">
 +
repo sync --force-sync kernel
 +
</syntaxhighlight>
 +
After synchronization you just need to recompile the kernel's source code:
 +
<syntaxhighlight lang="bash">
 +
./build.sh kernel
 +
</syntaxhighlight>
 +
===Repacking firmware after editing===
 +
After compiling FriendlyWrt, you can get a copy of the filesystem contents (directory named rootfs) with the following command:
 +
<syntaxhighlight lang="bash">
 +
export KEEP_CACHE=1
 +
./build.sh sd-img
 +
cd scripts/sd-fuse
 +
rm -rf ./rootfs
 +
cp -r out/rootfs.* ./rootfs
 +
</syntaxhighlight>
 +
Repacking firmware after editing:
 +
<syntaxhighlight lang="bash">
 +
./build-rootfs-img.sh $PWD/rootfs friendlywrt
 +
./mk-sd-image.sh friendlywrt
 +
</syntaxhighlight>
 +
 
 +
== Tips ==
 +
===Visit FriendlyWrt management page===
 +
Enter http://friendlywrt/ or the IP address on the computer browser to enter the FriendlyWrt management page. By default, the IP address of the LAN port is 192.168.2.1, and the WAN will dynamically obtain an IP address from your main router.
 +
<!--
 +
==Enable swap===
 +
<syntaxhighlight lang="bash">
 +
/etc/enable-swap.sh
 +
reboot
 +
</syntaxhighlight>
 +
-->
 +
 
 +
===mount smbfs resource===
 +
<syntaxhighlight lang="bash">
 +
mount -t cifs //192.168.1.10/shared /movie -o username=xxx,password=yyy,file_mode=0644
 +
</syntaxhighlight>
 +
 
 +
==Common Issues and Tips==
 +
* When you compile a source code under Ubuntu you cannot do it as root and you need to do it as a non-root user
 +
* Compilation in VNC may not succeed
 +
 
 +
==Resources==
 +
[https://source.android.com/setup/develop/repo repo guidance]<br />
 +
 
 +
==Report bug==
 +
Please mail-to:techsupport@friendlyarm.com<br />
 +
 
 +
==Update Log==
 +
===2023-10-25===
 +
* Rockchip platform: upgrade FriendlyWrt to 23.05
 +
===2021-10-29===
 +
* RK33xx platform: upgrade FriendlyWrt to 21.02.1, features are basically the same as 19.07.5, support docker, usb wifi, etc.
 +
===2021-08-31===
 +
* Add a high-speed 5G USB WiFi support, the network card model is Comfast CF-WU782AC V2, the chip model is MediaTek MT7662
 +
* Improved USB WiFi compatibility
 +
* Improved PWM fan support (RK3399 platform), fan controlled by kernel drive, temperature control support(Please search for "PWM fans" on the R4S WiKi page for details)
 +
* Improved stability on first boot (previous version, bpfilter error occurred in some cases on first boot)
 +
===2021-01-14===
 +
====RK3328 FriendlyWrt:====
 +
* RK3328 FriendlyWrt has been updated to the official stable version 19.07.5
 +
===2020-12-24===
 +
* RK3399 FriendlyWrt has been updated to the official stable version 19.07.5, which provides two versions of the kernel:
 +
** Mainline kernel-5.10 for NanoPi-R4S, NanoPC-T4, NanoPC-M4v1, NanoPi-NEO4
 +
** Rockchip kernel-4.19 for All FriendlyElec's RK3399 based boards
 +
===2020-02-20===
 +
* Optimized openssl performance<br />
 +
* Added support for PWM fan, support fan speed control (platform: rk33xx)<br />
 +
===2019-09-06===
 +
* Released English version

Latest revision as of 16:33, 26 October 2023

查看中文

1 Introduction to FriendlyWrt

FriendlyWrt is a customized OpenWrt system developed by FriendlyElec. It is open source and suitable for applications in IoT, NAS and etc.

2 User Name & Password

No password set default, please configure a root password to protect the web interface and enable SSH.

3 Supported FriendlyElec Boards

OS Version Supported Board Types Image File Download Link
FriendlyWrt for H3 19.07.1 NanoPi-R1S, NanoPi-R1, NanoPi-NEO, NanoPi-NEO-Air,
NanoPi-M1, ZeroPi, NanoPi-NEO-S,
NanoPi-NEO-Core, NanoPi-M1-Plus, NanoPi-Duo2
nanopi-r1_sd_friendlywrt_4.14_armhf_YYYYMMDD.img.zip H3 Download Link
FriendlyWrt for H5 19.07-snapshot NanoPi-NEO2,NanoPi-K1-Plus,NanoPi-NEO-Core2 nanopi-neo-core2_sd_friendlywrt_4.14_arm64_YYYYMMDD.img.zip H5 Download Link
FriendlyWrt for S5P4418 19.07-snapshot NanoPi-Fire2A, NanoPC-T2, NanoPi-S2,
NanoPi-M2A, Smart4418
s5p4418-sd-friendlywrt-4.4-YYYYMMDD.img.zip S5P4418 Download Link
FriendlyWrt for S5P6818 19.07-snapshot NanoPi-Fire3, NanoPC-T3, Smart6818 s5p6818-sd-friendlywrt-4.4-YYYYMMDD.img.zip S5P6818 Download Link
FriendlyWrt for RK3399 21.02.5 / 23.05 All FriendlyElec's RK3399 based boards, including NanoPi-M4v2, NanoPi-M4B, Som-RK3399 rk3399-sd-friendlywrtNN-6.1-YYYYMMDD.img.zip RK3399 Download Link
FriendlyWrt for RK3328 21.02.5 / 23.05 NanoPi-R2S, NanoPi-R2C, NanoPi-R2C-Plus rk3328-sd-friendlywrtNN-6.1-YYYYMMDD.img.zip RK3328 Download Lin
FriendlyWrt for RK3568 21.02.5 / 23.05 NanoPi-R5S rk3568-sd-friendlywrtNN-6.1-YYYYMMDD.img.zip RK3568下载链接
FriendlyWrt for RK3588 21.02.5 / 23.05 NanoPi-R6S rk3588-sd-friendlywrtNN-6.1-YYYYMMDD.img.zip RK3588下载链接

How to test the image: extract the image file, use the "dd" command under Linux or the win32image utility under Windows to flash the image to an SD card.

4 Get Source Code

4.1 Install repo

Firstly you need to install the repo utility:

git clone https://github.com/friendlyarm/repo --depth 1
sudo cp repo/repo /usr/bin/

4.2 Download Source Code

There are two ways to obtain the source code. For mainland Chinese users the first is recommended:

4.2.1 One: Use Repo Package from FriendlyElec's Cloud Storage

The source files are located at the "sources/friendlywrt-CPU-YYYYMMDD.tar" directory in FriendlyElec's cloud storage. "CPU" stands for an SoC model and YYYYMMDD stands for date(the year, month and day) in which the package is packed.
After you get a repo package run the following command to extract it. Let's take an image for Allwinner H3 based boards as an example:

tar xvf /path/to/netdisk/sources/friendlywrt-h3-20190101.tar
cd friendlywrt-h3
repo sync -l --no-clone-bundle

Now you have had the full source code for generating an image. The last number digits in the file name stand for the packing date. If you want to obtain the latest official release, remove "-l" and do "repo sync" again:

cd friendlywrt-h3
repo sync --no-clone-bundle

4.2.2 Two: Get Source Code from Github

4.2.2.1 H3 Based Boards
mkdir friendlywrt-h3
cd friendlywrt-h3
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v19.07.1 -m h3.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
repo sync -c  --no-clone-bundle
4.2.2.2 H5 Based Boards
mkdir friendlywrt-h5
cd friendlywrt-h5
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master \
        -m h5.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
repo sync -c  --no-clone-bundle
4.2.2.3 S5P4418 Based Boards
mkdir friendlywrt-s5p4418
cd friendlywrt-s5p4418
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master \
        -m s5p4418.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
repo sync -c  --no-clone-bundle
4.2.2.4 S5P6818 Based Boards
mkdir friendlywrt-s5p6818
cd friendlywrt-s5p6818
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master \
        -m s5p6818.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
repo sync -c  --no-clone-bundle
4.2.2.5 RK3399 Based Boards
mkdir friendlywrt23-rk3399
cd friendlywrt23-rk3399
git clone https://github.com/friendlyarm/repo --depth 1 tools
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \
        -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
tools/repo sync -c  --no-clone-bundle
4.2.2.6 RK3328 Based Boards
mkdir friendlywrt23-rk3328
cd friendlywrt23-rk3328
git clone https://github.com/friendlyarm/repo --depth 1 tools
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \
        -m rk3328.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
tools/repo sync -c  --no-clone-bundle
4.2.2.7 RK3568 Based Boards
mkdir friendlywrt23-rk3568
cd friendlywrt23-rk3568
git clone https://github.com/friendlyarm/repo --depth 1 tools
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \
        -m rk3568.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
tools/repo sync -c  --no-clone-bundle
4.2.2.8 RK3588 Based Boards
mkdir friendlywrt23-rk3588
cd friendlywrt23-rk3588
git clone https://github.com/friendlyarm/repo --depth 1 tools
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \
        -m rk3588.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
tools/repo sync -c  --no-clone-bundle

4.2.3 Get Latest Release With "Sync"

repo sync -c --no-clone-bundle

If synchronization is interrupted you can run the following script to do sync again:

#! /bin/bash
repo sync -c --no-clone-bundle
while [ $? -ne 0 ]; 
do  
    repo sync -c --no-clone-bundle
done

4.2.4 Swtich To Different Platform

If you have been working on the source code for Allwinner H3's boards and want to swtich to the source code for Allwinner H5's boards you can do it this way:

cp -af friendlywrt-h3 friendlywrt-h5
cd friendlywrt-h5
repo init -m h5.xml
repo sync --force-sync

5 Compile Source Code

5.1 Setup Development Environment

You need a host PC running a 64-bit Ubuntu 20.04 system and run the following command on the PC:

wget -O - https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh | bash

5.2 Build buildroot in Docker container

Please use the Docker image provided by this link, for details, please refer to the README document:
https://github.com/friendlyarm/docker-cross-compiler-novnc

5.3 Get Help Info

Run the build.sh script without any options it will print the help information:

./build.sh

Let's take Allwinner H3 as an example, the help information will be presented as follows:

USAGE: ./build.sh <parameter>
 
# Select Board Type:
  ./build.sh nanopi_r1.mk
  ./build.sh nanopi_duo.mk
  ./build.sh nanopi_neo_core.mk
  ./build.sh nanopi_neo.mk
  ./build.sh nanopi_neo_s.mk
  ./build.sh nanopi_m1_plus.mk
  ./build.sh nanopi_m1.mk
  ./build.sh nanopi_neo_air.mk
 
# Select Module:
  ./build.sh all                -compile all
  ./build.sh uboot              -compile uboot
  ./build.sh kernel             -compile kernel
  ./build.sh friendlywrt        -compile friendlywrt
  ./build.sh sd-img             -generate an image for an sd card
  ./build.sh emmc-img           -generate an image for emmc (the generated image should be flased to an SD card and then flashed to emm with this SD card)
# Clean:
  ./build.sh cleanall

5.4 Auto Compile

For a first time compilation you need to select an SoC platform. Let's take the NanoPi R1(Allwinner H3) as an example:

./build.sh nanopi_r1.mk

After the script is done successfully all components including a u-boot, a kernel and a friendlywrt will be compiled, and an image file will be generated.

5.5 Compile Individual Component

5.5.1 kernel

./build.sh kernel

5.5.2 u-boot

./build.sh uboot

5.5.3 FriendlyWrt

method 1:

./build.sh friendlywrt

method 2:

cd friendlywrt
./scripts/feeds update -a 
./scripts/feeds install -a 
cp ../configs/config_XXXX .config
make defconfig
make download -j8
make -j8

5.6 Generate Image for SD Card

sudo ./build.sh sd-img

If an img file is generated successfully you will see the following messages. You can use the "dd" command to flash the img file to an SD card. Note: you will need to replace "/dev/sdX" with the actual device name which your system recognizes the device as:

Run the following for sdcard install:
    sudo dd if=out/FriendlyWrt_20190828_NanoPi-R1_armhf_sd.img bs=1M of=/dev/sdX

5.7 Generate emmc (eflasher) Image

sudo ./build.sh emmc-img

If an img file is generated successfully you will see the following messages. You can use the "dd" command to flash the img file to an SD card. Note: you will need to replace "/dev/sdX" with the actual device name which your system recognizes the device as:

Run the following for sdcard install:
    sudo dd if=out/FriendlyWrt_20190828_NanoPi-R1_armhf_eflasher.img bs=1M of=/dev/sdX

Use this SD card to boot the eflasher system and run eflasher commands to install an OS to emmc. After installation is done, take off the SD card of the board and boot your system friendlywrt will load from eMMC.

6 Make Your Own Friendlywrt

6.1 Structure of Source Code Directories

├── friendlywrt
│   ├── friendlywrt -> friendlywrt's source code
│   └── configs -> save the "friendlywrt defconfig" file
│   └── toolchain -> cross-compiler, used for compiling a u-boot and kernel
│   ├── build.sh -> script for auto-compile
│   ├── device/friendlyelec -> configuration file for friendlyelec boards
│   ├── kernel -> kernel
│   └── u-boot -> u-boot
│   └── scripts -> script files for generating an img

6.2 Configure friendlywrt Components

  • Configure by Using Make Menuconfig(H3)
cd friendlywrt-h3/friendlywrt
make menuconfig
  • Save Your Configurations
make menuconfig
./scripts/diffconfig.sh > ../configs/my_config
  • Set Your Configurations As Default

Let's take the NanoPi-R1 as an example and edit the following file:

device/friendlyelec/h3/nanopi_r1.mk

Set TARGET_FRIENDLYWRT_CONFIG to your configurations.

  • Recompile Friendlywrt and Generate Image for SD Card
./build.sh friendlywrt
./build.sh sd-img

6.3 Put Your Add-on Features to Friendlywrt

Let's take H3 as an example. Put your files and directories to the following directory and they will be compiled to an img file.

device/friendlyelec/h3/common-files

Or you can put your files and directories in a new directory. Let's take the NanoPi-R1 as an example and edit the following file:

device/friendlyelec/h3/nanopi_r1.mk

Open the file and add a new line(replace "XXX" with your directory):

FRIENDLYWRT_FILES+=(device/friendlyelec/h3/XXX)

6.4 Change Friendlywrt's Default Configurations(Network, Firewall Etc)

Open and edit the following files:

device/friendlyelec/h3/default-settings/files
friendlywrt/package/base-files/files

6.5 Change U-boot and Kernel's Configurations(H3)

Open and edit the following file:

device/friendlyelec/h3/nanopi_r1.mk

Change uboot's settings to your own by making the following changes:

TARGET_UBOOT_CONFIG=nanopi_h3_defconfig

Change kernel's settings to your own by making the following changes:

TARGET_KERNEL_CONFIG=sunxi_defconfig

6.6 Change Other COnfigurations

Open and edit the following xml file and you can replace the source code of kernel, uboot and friendlywrt yo your own code:

.repo/manifests/h3.xml

For more details about what each item in the xml file means, refer to:repo Manifest Format
After you make your changes you need to do "repo" to sync and make the changes effective. For example after you change the kernel's source code you need to run the following command to sync:

repo sync --force-sync kernel

After synchronization you just need to recompile the kernel's source code:

./build.sh kernel

6.7 Repacking firmware after editing

After compiling FriendlyWrt, you can get a copy of the filesystem contents (directory named rootfs) with the following command:

export KEEP_CACHE=1
./build.sh sd-img
cd scripts/sd-fuse
rm -rf ./rootfs
cp -r out/rootfs.* ./rootfs

Repacking firmware after editing:

./build-rootfs-img.sh $PWD/rootfs friendlywrt
./mk-sd-image.sh friendlywrt

7 Tips

7.1 Visit FriendlyWrt management page

Enter http://friendlywrt/ or the IP address on the computer browser to enter the FriendlyWrt management page. By default, the IP address of the LAN port is 192.168.2.1, and the WAN will dynamically obtain an IP address from your main router.

7.2 mount smbfs resource

mount -t cifs //192.168.1.10/shared /movie -o username=xxx,password=yyy,file_mode=0644

8 Common Issues and Tips

  • When you compile a source code under Ubuntu you cannot do it as root and you need to do it as a non-root user
  • Compilation in VNC may not succeed

9 Resources

repo guidance

10 Report bug

Please mail-to:techsupport@friendlyarm.com

11 Update Log

11.1 2023-10-25

  • Rockchip platform: upgrade FriendlyWrt to 23.05

11.2 2021-10-29

  • RK33xx platform: upgrade FriendlyWrt to 21.02.1, features are basically the same as 19.07.5, support docker, usb wifi, etc.

11.3 2021-08-31

  • Add a high-speed 5G USB WiFi support, the network card model is Comfast CF-WU782AC V2, the chip model is MediaTek MT7662
  • Improved USB WiFi compatibility
  • Improved PWM fan support (RK3399 platform), fan controlled by kernel drive, temperature control support(Please search for "PWM fans" on the R4S WiKi page for details)
  • Improved stability on first boot (previous version, bpfilter error occurred in some cases on first boot)

11.4 2021-01-14

11.4.1 RK3328 FriendlyWrt:

  • RK3328 FriendlyWrt has been updated to the official stable version 19.07.5

11.5 2020-12-24

  • RK3399 FriendlyWrt has been updated to the official stable version 19.07.5, which provides two versions of the kernel:
    • Mainline kernel-5.10 for NanoPi-R4S, NanoPC-T4, NanoPC-M4v1, NanoPi-NEO4
    • Rockchip kernel-4.19 for All FriendlyElec's RK3399 based boards

11.6 2020-02-20

  • Optimized openssl performance
  • Added support for PWM fan, support fan speed control (platform: rk33xx)

11.7 2019-09-06

  • Released English version