Difference between revisions of "APITestPage"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
(144 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[How to build FriendlyELEC FriendlyWRT|English]]
 
  
==FriendlyWRT简介==
+
{{BurnLinuxToExtDrive-Rockchip/zh|NanoPC-T4}}
TODO <br />
+
{{BurnLinuxToExtDrive-Rockchip|NanoPC-T4}}
==下载体验版固件==
+
TODO <br />
+
解压后用 dd 或者 win32image 烧写到 SD 卡。
+
==帐户与密码==
+
用户名: root<br />
+
密码: fa<br />
+
<br />
+
==获取项目源代码==
+
===安装 repo 工具===
+
首先需要安装 repo 工具:
+
<syntaxhighlight lang="bash">
+
git clone https://github.com/friendlyarm/repo
+
cp repo/repo /usr/bin/
+
</syntaxhighlight>
+
===下载项目源代码===
+
有以下两种途径获取项目源代码,中国大陆用户建议使用方法1的途径下载:
+
====方法一:使用网盘里的repo压缩包====
+
网盘下载地址: [http://download.friendlyarm.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}} 点击进入]<br />
+
文件位于网盘的以下路径:sources/friendlywrt-YYYYMMDD.tar (YYYYMMDD表示打包的日期)<br />
+
从网盘中获取的 repo 压缩包在解压之后,需要执行一下以下命令做一次解包动作:
+
<syntaxhighlight lang="bash">
+
tar xvf /path/to/netdisk/sources/friendlywrt-YYYYMMDD.tar
+
cd friendlywrt
+
repo sync -l
+
</syntaxhighlight>
+
用此方法得到的源代码版本是repo打包时的版本,如果想拉取到官方最新的版本,可以去掉 -l 参数,执行一次 repo sync, 例如:
+
<syntaxhighlight lang="bash">
+
cd friendlywrt
+
repo sync
+
</syntaxhighlight>
+
====方法二:从github下载====
+
<syntaxhighlight lang="bash">
+
mkdir friendlywrt
+
cd friendlywrt
+
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master -m h3.xml --repo-url=https://github.com/friendlyarm/repo
+
repo sync -c
+
</syntaxhighlight>
+
====同步项目到最新版本====
+
<syntaxhighlight lang="bash">
+
cd friendlywrt
+
repo sync -c
+
</syntaxhighlight>
+
同步过程中,由于网络原因出现中断,可以使用下面脚本同步代码:
+
<syntaxhighlight lang="bash">
+
#! /bin/bash
+
repo sync -c
+
while [ $? -ne 0 ];
+
do 
+
    repo sync -c
+
done
+
</syntaxhighlight>
+
 
+
==如何编译==
+
===搭建编译环境===
+
在PC的Ubuntu系统下,执下以下命令安装所需的软件:
+
<syntaxhighlight lang="bash">
+
sudo apt-get install repo git-core gitk git-gui gcc-arm-linux-gnueabihf u-boot-tools device-tree-
+
compiler gcc-aarch64-linux-gnu mtools parted libudev-dev libusb-1.0-0-dev python-linaro-image-
+
tools linaro-image-tools autoconf autotools-dev libsigsegv2 m4 intltool libdrm-dev curl sed make
+
binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio python unzip rsync file bc wget
+
libncurses5 libqt4-dev libglib2.0-dev libgtk2.0-dev libglade2-dev cvs git mercurial rsync openssh-
+
client subversion asciidoc w3m dblatex graphviz python-matplotlib libc6:i386 libssl-dev texinfo
+
liblz4-tool genext2fs lib32stdc++6 swig python-dev python3-dev exfat-fuse exfat-utils
+
</syntaxhighlight>
+
 
+
===查看帮助===
+
不带参数执行 build.sh,默认是打印帮助信息:
+
<syntaxhighlight lang="bash">
+
./build.sh
+
</syntaxhighlight>
+
显示的帮助信息如下:
+
<syntaxhighlight lang="bash">
+
USAGE: ./build.sh <parameter>
+
 
+
# 选择目标的硬件平台:
+
  ./build.sh friendlyelec_h3_series.mk
+
 
+
# 编译各个模块:
+
  ./build.sh all                -编译所有组件
+
  ./build.sh uboot              -单独编译uboot
+
  ./build.sh kernel            -单独编译kernel
+
  ./build.sh friendlywrt        -单独编译friendlywrt
+
  ./build.sh sd-img            -生成sd启动的镜像文件
+
  ./build.sh emmc-img          -生成用于安装到emmc的镜像文件 (镜像文件需要dd到sd卡,通过sd卡启动安装程序)
+
# 清理:
+
  ./build.sh cleanall
+
</syntaxhighlight>
+
===全自动方式编译===
+
初次编译,需要选择目标的硬件平台,当前只有H3可用,后续会加入更多的硬件支持:
+
<syntaxhighlight lang="bash">
+
./build.sh friendlyelec_h3_series.mk
+
</syntaxhighlight>
+
执行上述命令,会自动编译所有组件,其中包括u-boot, kernel 和 friendlywrt,并生成sd启动的烧写镜像文件。
+
===编译单独的模块===
+
====kernel====
+
<syntaxhighlight lang="bash">
+
./build.sh kernel
+
</syntaxhighlight>
+
====u-boot====
+
<syntaxhighlight lang="bash">
+
./build.sh uboot
+
</syntaxhighlight>
+
====friendlywrt====
+
<syntaxhighlight lang="bash">
+
./build.sh friendlywrt
+
</syntaxhighlight>
+
===生成sdcard固件===
+
<syntaxhighlight lang="bash">
+
sudo ./build.sh sd-img
+
</syntaxhighlight>
+
===生成emmc (eflasher) 固件===
+
<syntaxhighlight lang="bash">
+
sudo ./build.sh emmc-img
+
</syntaxhighlight>
+
 
+
==friendlywrt定制与开发==
+
===源代码目录结构===
+
<syntaxhighlight lang="bash">
+
├── friendlywrt
+
│  ├── friendlywrt -> friendlywrt源代码
+
|   └── configs -> 保存预设好的friendlywrt defconfig文件
+
│  ├── build.sh -> 全自动编译脚本
+
│  ├── device/friendlyelec -> 用于适配友善电子开发板的相关文件
+
│  ├── kernel -> 内核
+
│  └── u-boot -> u-boot
+
│  └── scripts -> 打包img的相关脚本
+
</syntaxhighlight>
+
===配置friendlywrt的软件包===
+
* 使用make menuconfig更改配置
+
<syntaxhighlight lang="bash">
+
cd friendlywrt
+
make menuconfig
+
</syntaxhighlight>
+
* 保存你的friendlywrt配置
+
<syntaxhighlight lang="bash">
+
make menuconfig
+
./scripts/diffconfig.sh > ../configs/my_config
+
</syntaxhighlight>
+
* 让以后的编译使用你的friendlywrt配置
+
编辑以下文件:
+
<syntaxhighlight lang="bash">
+
device/friendlyelec/h3/friendlyelec_h3_series.mk
+
</syntaxhighlight>
+
将TARGET_FRIENDLYWRT_CONFIG的值改为你的配置。
+
* 重新编译friendlywrt并制成sd启动镜像
+
<syntaxhighlight lang="bash">
+
./build.sh friendlywrt
+
./build.sh sd-img
+
</syntaxhighlight>
+
===预装文件到friendlywrt===
+
将文件或目录放入以下目录即可,打包img时会把它们都打包进去:
+
<syntaxhighlight lang="bash">
+
device/friendlyelec/h3/common-files
+
</syntaxhighlight>
+
也可以放在新建的目录里,然后编辑以下文件:
+
<syntaxhighlight lang="bash">
+
device/friendlyelec/h3/friendlyelec_h3_series.mk
+
</syntaxhighlight>
+
在文件中新增一行 (XXX替换为你的目录名):
+
<syntaxhighlight lang="bash">
+
FRIENDLYWRT_FILES+=(device/friendlyelec/h3/XXX)
+
</syntaxhighlight>
+
===更改friendlywrt系统的默认配置(如网络、防火墙等)===
+
进入如下目录:
+
<syntaxhighlight lang="bash">
+
device/friendlyelec/h3/default-settings/files/root/board
+
</syntaxhighlight>
+
编辑你所用的开发板目录所在的配置文件即可。
+
===更改u-boot和kernel配置===
+
同样是编辑如下文件:
+
<syntaxhighlight lang="bash">
+
device/friendlyelec/h3/friendlyelec_h3_series.mk
+
</syntaxhighlight>
+
可通过以下设置,将uboot的配置改为你自已的:
+
<syntaxhighlight lang="bash">
+
TARGET_UBOOT_CONFIG=nanopi_h3_defconfig
+
</syntaxhighlight>
+
可通过以下设置,将kernel的配置改为你自已的:
+
<syntaxhighlight lang="bash">
+
TARGET_KERNEL_CONFIG=sunxi_defconfig
+
</syntaxhighlight>
+
===更换其他源代码===
+
编辑如下 xml 文件,即可替换 kernel 和 uboot 的源代码:
+
<syntaxhighlight lang="bash">
+
.repo/manifests/h3.xml
+
</syntaxhighlight>
+
编辑完成后,需要用 repo 命令同步一下,比如更换了 kernel 的源代码,用以下命令同步一次:
+
<syntaxhighlight lang="bash">
+
repo sync --force-sync kernel
+
</syntaxhighlight>
+
同步后单独重新内核即可:
+
<syntaxhighlight lang="bash">
+
./build.sh kernel
+
</syntaxhighlight>
+

Latest revision as of 09:58, 29 October 2024

1 安装系统到M.2或USB硬盘

可以通过使用TF卡启动eFlasher系统,将引导和系统分别安装到不同存储设备,但是由于CPU不支持直接从M.2和USB设备引导,所以虽然系统可以安装到M.2和USB设备,但是引导仍然需要安装到eMMC或者TF卡。
操作步骤如下:

  • 准备一张32G或以上容量的TF卡;
  • 访问此处的下载地址下载文件名为XXXX-eflasher-multiple-os-YYYYMMDD-30g.img.gz的固件(位于"01_系统固件/02_SD卡刷机固件(SD-to-eMMC)"目录);
  • 将固件写入TF卡,在NanoPC-T4上连接好存储设备,插入TF卡上电开机,接下来要在界面上操作,如果没有显示设备,可以使用VNC代替,请参考使用VNC操作eFlasher;
  • 在eFlasher界面上,首先选择要安装的OS,然后选择引导安装的目的地 (通常选eMMC),以及选择系统安装的目的地(可以选eMMC,M.2硬盘,USB存储设备等),如下图所示:

Eflasher-select-boot-and-system-device.png

  • 没有eMMC时可使用TF卡作为引导,方法是将另一个TF卡通过USB读卡器插入USB端口,然后选择USB设备作为引导安装目的地,从而实现从TF卡引导,但系统存放在M.2或USB硬盘的目的;
  • 烧写完成后,从NanoPC-T4弹出SD卡,引导在eMMC的情况下,NanoPC-T4会自动重启至你刚刚烧写的系统,如果引导安装在TF卡,则需要拨掉电源,插入TF引导卡再上电开机;
  • 更详细的安装指南请参考此处;

2 Installing the System to M.2 or USB Drive

You can use a TF card to boot the eFlasher system, allowing the boot and system to be installed on different storage devices. However, since the CPU doesn’t support booting directly from M.2 and USB devices, the system can be installed on M.2 and USB devices, but the boot must still be installed on eMMC or a TF card.
Steps are as follows:

  • Prepare a TF card with a capacity of 32GB or larger.
  • Visit [the download link here](http://download.friendlyelec.com/APITestPage) to download the firmware file named XXXX-eflasher-multiple-os-YYYYMMDD-30g.img.gz (located in the “01_Official images/02_SD-to-eMMC images” directory).
  • Flash the firmware to the TF card, connect the storage device you intend to use on NanoPC-T4, insert the TF card and power on, we need to perform the operations in the eFlasher GUI. If your NanoPC-T4 does not have a display interface, you can use VNC; refer to Using VNC to Operate eFlasher.
  • In the eFlasher GUI, select the OS to install, and in the OS settings interface, choose the destination for boot installation (typically eMMC), then choose the destination for system installation (options include eMMC, M.2 hard drive, USB storage, etc.), as shown below:

Eflasher-select-boot-and-system-device.png

  • If no eMMC is available, the TF card can serve as the boot by inserting another TF card into the USB port via a USB card reader and selecting it as the boot destination, enabling booting from the TF card with the system stored on the M.2 or USB drive.
  • After flashing, eject the SD card from NanoPC-T4. If booting from eMMC, NanoPC-T4 will automatically restart into the newly flashed system. If boot installation is on a TF card, power off, insert the boot TF card, and power on again.
  • For a more detailed installation guide, please refer to this link.