Difference between revisions of "APITestPage"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
(146 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[EFlasher|English]]
 
  
== eFlasher介绍 ==
+
{{RockchipUnbrick|NanoPC-T4}}
eFlasher (eMMC-flasher) 是FriendlyElec官方发布的工具,让用户能方便和轻松地将系统安装到板载的eMMC上运行,甚至可以抛开电脑,就能让你在多个系统中,选择并安装上你想要的系统。
+
<br /><br />
+
eFlasher同时为量产提供了灵活的设置选项,以方便工厂量产时安装定制系统。 <br />
+
<br />
+
eFlasher为方便使用,提供了图形界面与命令行两个版本,为方便描述,这里为它们分别命名为: eflasher-gui 和 eflasher-console:<br />
+
1) eflasher-gui: 有图形界面的eFlasher,推荐有LCD屏或者HDMI显示的用户使用,可以使用触摸屏操作,没有触摸屏时也可以使用鼠标操作;<br />
+
2) eflasher-console: 命令行版本的eFlasher,可在串口终端或者ssh命令行上使用;<br />
+
<br />
+
 
+
== eFlasher 的安装 ==
+
 
+
* 第一步: 下载包含eflasher工具的固件 <br />
+
到你所购买的板子相关WiKi页面,找到下载固件的章节,下载固件文件名为:XXXX-eflasher-YYYYMMDD-full.img.7z 的固件(其中XXXX替换为板子所在的平台型号, YYYYMMDD是该固件发布的日期), <br />
+
这个固件内已经包含了所属平台的所有官方系统映象,包括最新版本的 Debian, Android5, Android4.4和Ubuntu core 系统 (不同的平台提供的系统有所不同);<br />
+
将 XXXX-eflasher-YYYYMMDD-full.img.7z 下载到电脑上,在Windows下制作SD卡,还需要下载Windows下的烧写工具: win32diskimager.rar;<br />
+
* 第二步: 用eflasher固件制作SD启动卡 <br />
+
将固件用7z软件解压,得到.img结尾的文件,在Windows下插入SDHC卡(限4G及以上的卡),以管理员身份运行Win32DiskImager,选择 Image File载入固件,选择你的SD卡盘符,点 Write 即开始写Image到SD卡;<br />
+
如果你的电脑用的是Linux系统,你也可以用 dd 命令将解压后得到的 .img 文件直接写入SD卡完成启动卡的制作;<br />
+
* 第三步: 启动eFlasher工具
+
将制作好的SD卡插入开发板, 按住标住有“BOOT”字样的按键,上电,如你有HDMI、LCD或者USB2LCD,可以在上电之前先连接好。
+
 
+
== 更新 eflasher 到最新版本 ==
+
在开发板上执行以下命令:
+
<syntaxhighlight lang="bash">
+
git clone https://github.com/friendlyarm/eflasher-updater
+
cd eflasher-updater/
+
./update.sh
+
</syntaxhighlight>
+
 
+
== eFlasher系统的登录 ==
+
在命令行模式下使用以下帐号登录:<br />
+
用户名: root<br />
+
密码: fa<br />
+
如果通过ssh登录,eFlasher系统的IP地址默认为 192.168.1.231<br />
+
 
+
== 启动图形界面版本的eFlasher ==
+
系统启动时,图形界面版本的eFlasher会随系统自动启动,如你有连接HDMI或者LCD,应该会看到如下所示的界面: <br />
+
::[[File:Eflasher-gui-ui.png| frameless|500px|Eflasher-gui]]
+
 
+
点击触摸屏,或者用鼠标选择你需要烧写到eMMC的系统即可。<br />
+
 
+
<!--
+
== 通过VNC远程控制eFlasher烧写 ==
+
<b>* 注意:仅 2018/07/21 之后的ROM支持此功能</b><br /><br />
+
eFlasher支持使用VNC来远程控制,在没有LCD和HDMI屏幕的情况下,可以通过手机或者电脑上的VNC客户端来操作eFlasher。<br />
+
VNC客户端属于免费软件,可以到官方去下载,多个平台的下载链接:<br />
+
https://www.realvnc.com/en/connect/download/vnc/<br />
+
<br />
+
<b>使用方法:</b>
+
开发板需要连接网线开机,你可以登录你的路由器后台管理页面,获悉开发板的IP地址。<br />
+
在VNC客户端创建一个新设备,在地址栏上填写:  <开发板IP地址>:5900,然后点击 Connect 即可。<br />
+
<br />
+
<b>示例:以下图片演示了在 iPhone 上通过VNC 为T3 Plus更新系统:</b>
+
::[[File:Eflasher-vnc.png| frameless|800px]]
+
<br />
+
-->
+
 
+
== 启动命令行版本的eFlasher ==
+
如果板子没有连接显示设备,可以通过串口或ssh登录开发板,在命令行终端下输入命令 eflasher也可以进入eflasher的命令行交互界面,命令行交互界面如下图所示: <br />
+
<pre>
+
----------------------------------------------------------------------
+
  EFlasher v1.2 b190111 running on NanoPC-T4
+
    Doc: http://wiki.friendlyarm.com/wiki/index.php/EFlasher
+
    eMMC: 14.56 GB
+
----------------------------------------------------------------------
+
  # Select an OS to install:
+
    1) Android 8
+
 
+
  # Select your backup target device:
+
    tf) [*] TF card  (/dev/mmcblk0p1 - 4.27 GB free - 5.67 GB total - fuseblk)
+
    usb) [ ] USB disk  (<none>)
+
 
+
  # Backup eMMC flash to TF card:
+
    Not enough free disk space on your TF card
+
 
+
  # Restore eMMC flash from backup file:
+
    No backup files found
+
 
+
  # Configure automatic job:
+
    aui) Automatic installing (Curr:Off)
+
    aur) Automatic restoring (Curr:Off)
+
 
+
  # Format drive
+
    ftf) Format TF card back to original size
+
----------------------------------------------------------------------
+
>>> Enter an option (1/tf/usb/aui/aur/ftf) :
+
</pre>
+
 
+
== 开机自动烧写指定的系统 ==
+
有三种途径可以进行配置:<br />
+
* 方法1:在图形界面上,选择你要烧写的系统,在Ready to Go预览界面上,在屏幕下方钩选 "Start automatically at startup" 。<br />
+
* 方法2:  将SD卡挂载到Windows电脑上,用notepad+文本编辑器在SD卡的Fat分区上新建一个名为eflasher.conf文件 (如果已存在就直接编辑即可),例如,要开机自动烧写debian系统,其内容如下:<br />
+
<syntaxhighlight lang="bash">
+
[General]
+
autoStart=/mnt/sdcard/friendlycore-xenial
+
</syntaxhighlight>
+
其中,autoStart字段所保存的路径,是你要烧写的系统的rom路径,本例是 Fat分区的 debian 目录。
+
* 方法3:  开发板运行状态下,通过串口终端,用vi编辑文件:/mnt/sdcard/eflasher.conf,文件不存在就新增一个,内容同上面的方法2。<br />
+
 
+
== 烧写或恢复系统完成后做些其他事情 ==
+
在量产时,你可能会希望在烧写系统完成后做一些额外的事情,比如点亮某个LED,你可以修改 /opt/run-eflasher.sh 脚本,在 "./eflasher-gui" 开头这一行的后面加入代码,例如下面的示例,在烧写完成后,设置某个GPIO针脚:
+
<syntaxhighlight lang="bash">
+
./eflasher-gui -qws >/dev/null 2>&1
+
echo 13 > /sys/class/gpio/export
+
echo out > /sys/class/gpio/gpio13/direction
+
echo 0 > /sys/class/gpio/gpio13/value
+
echo 13 > /sys/class/gpio/unexport
+
</syntaxhighlight>
+
要让上面的脚本正常运作,我们还需要设置让 eflasher-gui 在烧写完成后自动退出,需要做以下设置:<br />
+
用notepad+文本编辑器在SD卡的Fat分区上编辑并新建一个名为eflasher.conf文件,将AutoExit字段设置为True:<br />
+
<syntaxhighlight lang="bash">
+
[General]
+
autoStart=/mnt/sdcard/friendlycore-xenial
+
autoExit=true
+
</syntaxhighlight>
+
<br />
+
 
+
== eMMC Flash的备份和恢复 ==
+
 
+
这个功能类拟于电脑上面的 ghost 软件,可以将整个 eMMC Flash 的数据备份到 U盘 或 移动硬盘,或者从 U盘 恢复系统到 eMMC Flash,恢复系统时,可以恢复到 同一个开发板,也可以恢复到 同型号同规格的其他开发板。<br /><br />
+
<b>为产品量产提供的便利</b>:<br />
+
在一块开发板上做好定制,比如预装好软件和设置,然后备份一份出来,恢复到其他开发板上,以达到量产的目的,由于是对eMMC Flash进行祼读和祼写,所以支持包括 Android和Linux 在内的所有系统及数据。<br />
+
<br />
+
功能要求:<br />
+
此功能要求你有一个容易大过 eMMC Flash 大小的U盘,或者移动硬盘,并且里面没有重要的数据,最好事先格式化为exFat或者ntfs格式,在必要时,EFlasher可能会对你磁盘进行重新分区及格式化 (会事先询问)。
+
<br />
+
 
+
=== 图形界面上执行备份和恢复 ===
+
 
+
在 EFlasher 界面上点击 Backup and Restore 进入备份菜单,根据提示操作即可,如下图所示:<br />
+
::[[File:Eflasher-backup-restore.jpg| frameless|800px|Eflasher-console]]<br />
+
<br />
+
 
+
===命令行进行备份和恢复  ===
+
在命令行终端执行以下命令启动命令行EFlasher,命令行终端可以是ssh或者串口终端:
+
<syntaxhighlight lang="bash">
+
# eflasher
+
</syntaxhighlight>
+
 
+
然后你会看到如下功能菜单项:
+
<pre>
+
----------------------------------------------------------------------
+
  EFlasher v1.2 b190111 running on NanoPC-T4
+
    Doc: http://wiki.friendlyarm.com/wiki/index.php/EFlasher
+
    eMMC: 14.56 GB
+
----------------------------------------------------------------------
+
  # Select an OS to install:
+
    1) Android 8
+
 
+
  # Select your backup target device:
+
    tf) [*] TF card  (/dev/mmcblk0p1 - 4.27 GB free - 5.67 GB total - fuseblk)
+
    usb) [ ] USB disk  (<none>)
+
 
+
  # Backup eMMC flash to TF card:
+
    Not enough free disk space on your TF card
+
 
+
  # Restore eMMC flash from backup file:
+
    No backup files found
+
 
+
  # Configure automatic job:
+
    aui) Automatic installing (Curr:Off)
+
    aur) Automatic restoring (Curr:Off)
+
 
+
  # Format drive
+
    ftf) Format TF card back to original size
+
----------------------------------------------------------------------
+
>>> Enter an option (1/tf/usb/aui/aur/ftf) :
+
</pre>
+
 
+
===选择备份文件的存储位置===
+
可以将备份文件放在 TF 卡,或者USB存储设备,用 tf 和 usb 命令进行切换。
+
====备份到TF卡====
+
你的TF卡的大小应该大于或等于两倍的eMMC大小,例如eMMC是8G,则你应该准备一张16G的TF card。<br />
+
默认情况下,8G以上的 TF 卡在 eFlasher 系统下并没有利用上所有的空间,需要做一次格式化,使用菜单上的 ftf 命令即可。<br />
+
====备份到USB存储设备====
+
USB存储设备最好是 ext4/exfat/ntfs 格式的,如果不是,可以使用菜单上的 fud 对USB存储设备进行一次格式化,注意,此操作会丢失所有数据。
+
====开始备份====
+
根椐菜单项前面插号的指示, 输入bk并按回车启动备份,在命令行模式下,EFlasher会立即开始备份,存储为扩展名为raw的文件,如下图所示:<br />
+
<syntaxhighlight lang="bash">
+
----------------------------------------------------------------------
+
  Backing up eMMC to /mnt/udisk/nanopc-t3-emmc.raw
+
----------------------------------------------------------------------
+
  Speed: 15.01 MB/s
+
  Remaining Time: 00:12:53
+
  [===========_______________________________________]  22%
+
----------------------------------------------------------------------
+
  >>>If you want to cancel, input "c" then press <Enter> key.
+
</syntaxhighlight>
+
 
+
===扩展功能  ===
+
 
+
EFlasher允许你编写一些 Linux shell 脚本,来对 eMMC 的 boot分区或者根文件系统分区进行内容更改,比如:<br />
+
1)增加个性化的开机LOGO<br />
+
2)为板子分配静态的IP地址,或者MAC地址<br />
+
3)通过网络更新数据,软件<br />
+
4)  等等<br />
+
EFlasher在完成对 eMMC 的恢复操作之后,自动执行你的脚本。<br />
+
你的脚本需要放在一个单独的目录下,这个目录需要与备份文件同级,目录名称的命令规则是: 备份文件名+.d,例如 备份文件名是 xxxx.raw,则脚本目录名应为 xxxx.raw.d。<br/>
+
EFlasher 在默认情况下,会为你的备份文件生成一个清理脚本,其作用是对文件系统做一些常规的清理工作,例如清理 tmp 目录下的临时文件、var目录下的log等等。<br />
+
你可以通过参考 EFlasher 生成的清理脚本来了解应该如何访问 eMMC 的boot分区和根分区。<br />
+
<syntaxhighlight lang="bash">
+
root@NanoPC-T3:/mnt/udisk/nanopc-t3-emmc.raw.d# tree
+
.
+
|-- cleanup.sh
+
`-- README.txt
+
 
+
0 directories, 2 files
+
root@NanoPC-T3:/mnt/udisk/nanopc-t3-emmc.raw.d#
+
</syntaxhighlight>
+
 
+
(注: 使用开机自动还原功能时,此特性不起作用)
+
 
+
=== 开机自动恢复指定的备份 ===
+
有三种途径可以进行配置:<br />
+
* 方法1:在图形界面上,进入Backup and restore界面,先选择备份文件所在的存储设备,可选择TF card或者USB disk,选择 Turn on "Automatic restoring" ,然后选择要恢复的文件即可。<br />
+
* 方法2:  将存放有备份文件的设备(TF卡或U盘)挂载到电脑上,用notepad+文本编辑器在根目录新建一个名为eflasher.conf文件 (如果已存在就直接编辑即可),示例内容如下:<br />
+
<syntaxhighlight lang="bash">
+
[General]
+
autoRestore=/mnt/sdcard/nanopct3-backup-20190101.raw
+
</syntaxhighlight>
+
其中,/mnt/sdcard/代表TF card,/mnt/udisk代表USB磁盘.
+
* 方法3:  开发板运行状态下,通过串口终端,如果备份文件位于TF卡,用vi编辑文件:/mnt/sdcard/eflasher.conf, 如果备份文件位于 USB存储设备,用vi编辑文件:/mnt/udisk/eflasher.conf,文件不存在就新增一个,内容同上面的方法2。<br />
+
 
+
== 针对量产用户的定制选项==
+
 
+
=== EFlasher对系统映象的管理 ===
+
 
+
EFlasher会从SD卡的Fat分区读取系统映象文件,将SD卡插入Windows的电脑,你可以直接管理这些映象文件。<br />
+
在SD卡的Fat分区,根目录下的每一个子目录,代表一个OS,目录名称可随意命令(但不能是中文), <br />
+
如果SD卡的Fat分区空间不够用,你也可以在一个U盘中存放这些系统文件,目录结构与SD卡的相同。<br />
+
<br />
+
例如Fat分区有下面4个目录: <br />
+
[[File:Eflasher-folder.png| frameless|400px|Eflasher-folder]]<br />
+
对应以下4个可安装的系统: <br />
+
[[File:Eflasher-oslist.png| frameless|400px|Eflasher-oslist]]<br />
+
<br />
+
每个目录下的文件,分别说明如下:<br />
+
烧写配置文件:<br />
+
::{| class="wikitable"
+
|-
+
| env.conf    || 用于设置uboot环境变量,内核启动参数
+
|-
+
| info.conf    || 用于个性化烧写程序界面上的名称、图标以及定义该系统所属的硬件平台,示例说明: <br />
+
title=Android 5 ---> 系统名称显示为Android5<br />
+
require-board=s5p4418  ---> 所属平台 s5p4418, 可选的值还有 s5p6818, h3, a64 等<br />
+
version=2016-11-17  ---> 该rom的版本 (或制作的日期) <br />
+
icon=androidos.png  ---> 图标 <br />
+
上面的定义对应的显示所下:<br />[[File:Eflasher-infoconf.png| frameless|200px|Eflasher-infoconf]]<br />
+
|-
+
|}
+
 
+
系统映象文件, 不同的系统可能不同:<br />
+
::{| class="wikitable"
+
|-
+
| 2ndboot.bin    || Second Boot
+
|-
+
| boot.img    || boot分区映象文件
+
|-
+
| bootloader    || U-Boot
+
|-
+
| cache.img    || Android Cache分区映象
+
|-
+
| system.img    || 系统分区的映象
+
|-
+
| userdata.img    || 数据分区的映象
+
|-
+
| partmap.txt    || 分区描述文件
+
|-
+
|}
+
 
+
以上映象文件默认已经预装在eFlasher的固件中,不过你也可以到指定板子的下载地址下载它们,进入官方的下载地址指向的网盘目录,这些系统映象放在一个名为 images-for-eflasher 的目录下,以下是S5P6818开发板的网盘目录:<br />
+
::[[File:Images-for-eflasher.png| frameless|800px|EImages-for-eflasher.png]] <br />
+
 
+
可以下载这个目录下的文件然后解压到SD卡的Fat分区或者U盘即可。
+
 
+
 
+
=== 制作自已的量产Eflasher烧写卡 ===
+
请参考 [[How to make your own SD-bootable ROM/zh]]
+
 
+
=== 在EFlasher系统中连接WiFi ===
+
写入如下内容到配置文件:/etc/wpa_supplicant/wpa_supplicant.conf,其中,SSID和PASSWORD请替换为路由器的SSID和密码:
+
<syntaxhighlight lang="bash">
+
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
+
update_config=1
+
country=CN
+
network={
+
  ssid="SSID"
+
  psk="PASSWORD"
+
  key_mgmt=WPA-PSK
+
}
+
</syntaxhighlight>
+
如果WiFi路由并没有设置密码,请将key_mgmt设置为NONE, 删除psk=这一行。
+
 
+
=== 更改IP地址为动态获取 ===
+
For faster startup speed, we set the eflasher to  static ip address: 192.168.1.231, <br />
+
<br />
+
If you want to change to dhcp, you can modify this file:<br />
+
/etc/network/interfaces.d/eth0<br />
+
<br />
+
Change the contents of this file to:<br />
+
<syntaxhighlight lang="bash">
+
    auto eth0
+
    iface eth0 inet dhcp
+
</syntaxhighlight>
+

Latest revision as of 09:23, 4 June 2024

1 Unbricking Method

If the ROM is not installed correctly, causing the development board to become bricked, and you might not have the opportunity to reinstall the ROM via an SD card, you need to enter Maskrom mode to unbrick it by erasing the storage device.

1.1 Windows Users

1.1.1 Download Required Files

  • Get the necessary tools: Visit here, find RKDevTool_v3.19_for_window.zip and DriverAssitant_v5.12.zip in the 05_Tools directory, and download them to your local machine.
  • Install Rockchip USB driver and RKDevTool: Extract DriverAssitant_v5.12.zip to install the Rockchip USB driver, and extract RKDevTool_v3.19_for_window.zip to obtain the Rockchip flashing tool RKDevTool.
  • Get the loader: Visit here, enter the tools directory corresponding to your CPU model, and download MiniLoaderAll.bin.

1.1.2 Enter Maskrom Mode to Erase the Storage Device

  • Connect NanoPC-T4 to your computer using a USB data cable.
  • Start RKDevTool on your computer.
  • Disconnect the power from NanoPC-T4, hold down the MASK button, connect the power, and release the button when you see Found One MASKROM Device displayed at the bottom of the interface, as shown below:

Rkdevtool found one maskrom device.png

  • Click the Advanced Function tab in the RKDevTool interface.
  • In the Boot text box, select MiniLoaderAll.bin, then click the Download button.
  • Select EMMC, click Switch Storage, then click the EraseAll button to erase the eMMC.

Rkdevtool erase emmc.png

  • At this point, NanoPC-T4 is restored to its initial state and can be normally booted via SD card or eMMC.

1.2 Linux/Mac Users

1.2.1 Download the Required Files

  • Get the necessary tools: Visit here and find upgrade_tool_v2.30_for_linux.tgz (or for Mac users, select upgrade_tool_v2.25_for_mac.tgz) in the 05_Tools directory and download it locally.
  • Get the loader: Visit here, enter the tools directory corresponding to your CPU model, and download MiniLoaderAll.bin.

1.2.2 Installation for upgrade_tool

The following commands are for Linux, with only slight differences in file and directory names for Mac users:

tar xzf upgrade_tool_v2.30_for_linux.tgz
cd upgrade_tool_v2.30_for_linux
sudo cp upgrade_tool /usr/local/sbin/
sudo chmod 755 /usr/local/sbin/upgrade_tool

1.2.3 Enter Maskrom Mode to Erase the Storage Device

  • Connect NanoPC-T4 to the computer using a USB data cable.
  • Disconnect the power from NanoPC-T4, hold down the MASK button, connect the power, and release the button after 4 seconds.
  • Check the connection with the following command:
upgrade_tool LD

A result similar to "DevNo=1 Vid=0x2207,Pid=0x350b,LocationID=13 Mode=Maskrom SerialNo=" indicates that the device has been detected.

  • Erase the eMMC with the following command:
upgrade_tool EF MiniLoaderAll.bin
  • At this point, NanoPC-T4 has been restored to its initial state and can boot the system normally via SD card or eMMC.