Difference between revisions of "Template:OpenWrt1"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
Line 1: Line 1:
==Work with OpenWrt==
+
==OpenWrt的使用==
===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:[https://openwrt.org/ OpenWrt Website].
+
OpenWrt是适合于嵌入式设备的一个Linux发行版,它不是一个单一、静态的固件,而是提供了一个可添加软件包的可写的文件系统。
 +
这使用户可以自由的选择应用程序和配置,而不必受设备提供商的限制,并且可以使用一些适合某方面应用的软件包来定制你的设备。
 +
对于开发者来说,OpenWrt是一个框架,开发者不必麻烦地构建整个固件就能得到想要的应用程序;对于用户来说,这意味着完全定制的能力,与以往不同的方式使用设备,OPKG包含超过3500个软件。
 +
更详细的介绍请参考[https://openwrt.org/ OpenWrt官网]
  
===System Login===
+
===登录系统===
* Login via Serial Communication
+
* <strong>串口登录</strong>
 +
<!-- copy frome FriendlyCoreGeneral-zh.txt -->
 +
如果您需要进行内核开发,最好选购一个串口配件,连接了串口,则可以通过串口终端对开发板进行操作。<br />
 
{{#switch: {{{1}}}
 
{{#switch: {{{1}}}
| NanoPC-T4 =
 
| NanoPi-M4 =
 
| NanoPi-NEO4 =
 
 
  | NanoPi-NEO2 =
 
  | NanoPi-NEO2 =
allow you to operate the board via a serial terminal.Here is a setup where we connect a board to a PC via the PSU-ONECOM and you can power on your board from either the PSU-ONECOM or its MicroUSB:
+
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电:<br />
 
[[File:PSU-ONECOM-NEO2.jpg|frameless|400px]]<br>
 
[[File:PSU-ONECOM-NEO2.jpg|frameless|400px]]<br>
 
  | NanoPi-NEO =
 
  | NanoPi-NEO =
allow you to operate the board via a serial terminal.Here is a setup where we connect a board to a PC via the PSU-ONECOM and you can power on your board from either the PSU-ONECOM or its MicroUSB:
+
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电:<br />
 
[[File:PSU-ONECOM-NEO.jpg|frameless|400px]]<br>
 
[[File:PSU-ONECOM-NEO.jpg|frameless|400px]]<br>
 
  | NanoPi-NEO-Plus2 =
 
  | NanoPi-NEO-Plus2 =
allow you to operate the board via a serial terminal.Here is a setup where we connect a board to a PC via the PSU-ONECOM and you can power on your board from either the PSU-ONECOM or its MicroUSB:
+
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电:<br />
 
[[File:PSU-ONECOM-NEO-Plus2.jpg|frameless|400px]]<br>
 
[[File:PSU-ONECOM-NEO-Plus2.jpg|frameless|400px]]<br>
 
  | NanoPi-NEO-Core =
 
  | NanoPi-NEO-Core =
allow you to operate the board via a serial terminal.Here is a setup where we connect a board to a PC via the PSU-ONECOM and you can power on your board from either the PSU-ONECOM or its MicroUSB:
+
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电:<br />
 
[[File:PSU-ONECOM-NEO-Core.jpg|frameless|400px]]<br>
 
[[File:PSU-ONECOM-NEO-Core.jpg|frameless|400px]]<br>
 
  | NanoPi-M1 =
 
  | NanoPi-M1 =
allow you to operate the board via a serial terminal.Here is a setup where we connect a board to a PC via the PSU-ONECOM and you can power on your board from either the PSU-ONECOM or its MicroUSB:
+
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电:<br />
 
[[File:PSU-ONECOM-M1.jpg|frameless|400px]]<br>
 
[[File:PSU-ONECOM-M1.jpg|frameless|400px]]<br>
 
  | NanoPi-M1-Plus =
 
  | NanoPi-M1-Plus =
allow you to operate the board via a serial terminal.Here is a setup where we connect a board to a PC via the PSU-ONECOM and you can power on your board from either the PSU-ONECOM or its MicroUSB:
+
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电:<br />
 
[[File:PSU-ONECOM-NanoPi-M1-Plus.jpg|frameless|400px]]<br>
 
[[File:PSU-ONECOM-NanoPi-M1-Plus.jpg|frameless|400px]]<br>
 
  | NanoPi-A64 =
 
  | NanoPi-A64 =
allow you to operate the board via a serial terminal.Here is a setup where we connect a board to a PC via the PSU-ONECOM and you can power on your board from either the PSU-ONECOM or its MicroUSB:
+
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电:<br />
 
[[File:PSU-ONECOM-A64.jpg|frameless|400px]]<br>
 
[[File:PSU-ONECOM-A64.jpg|frameless|400px]]<br>
 
  | NanoPi-NEO-Air =
 
  | NanoPi-NEO-Air =
allow you to operate the board via a serial terminal.Here is a setup where we connect a board to a PC via the PSU-ONECOM and you can power on your board from either the PSU-ONECOM or its MicroUSB:
+
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电:<br />
 
[[File:PSU-ONECOM-AIR.jpg|frameless|400px]]<br>
 
[[File:PSU-ONECOM-AIR.jpg|frameless|400px]]<br>
 +
| NanoPi-R1 =
 +
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,请注意串口模块的DC口和NanoPi-R1的MicroUSB口都需要供电:<br />
 +
[[File:PSU-ONECOM-R1.jpg|frameless|500px]]<br>
 
  | NanoPi-Duo =
 
  | NanoPi-Duo =
 
  | NanoPi-Duo2 =
 
  | NanoPi-Duo2 =
 
     <!-- Duox not support ONECOM -->
 
     <!-- Duox not support ONECOM -->
 
  | #default =
 
  | #default =
For example, NanoPi-M1:<br>[[File:PSU-ONECOM-M1.jpg|frameless|400px]]<br>
+
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:<br>
 +
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电。
 
}}
 
}}
  
By default you will login as root without a password. You can set your password by commanding "passwd".<br />
+
{{#switch: {{{1}}}
[[File:R1-login.jpg|frameless|500px|R1-login]]<br>
+
| NanoPC-T4 =
When your board loads OS for the first time the TF card's rootfs system in your board will be automatically partitioned to its max capacity:<br>
+
{{{1}}}需要使用USB转串口模块,连接方法如下图所示:<br>[[File:T4usb2serialport.jpg|frameless|500px]]<br>
[[File:resize_rootfs.png|frameless|500px|resize_rootfs]]<br>
+
| NanoPi-M4 =
Be patient for this process to be done.
+
{{{1}}}需要使用USB转串口模块,连接方法如下图所示:<br>[[File:m4usb2serialport.jpg|frameless|500px]]<br>
 +
| NanoPi-NEO4 =
 +
{{{1}}}需要使用USB转串口模块,连接方法如下图所示:<br>[[File:neo4usb2serialport.jpg|frameless|500px]]<br>
 +
| NanoPi-NEO2 =
 +
也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:USB2UART-NEO2.jpg|frameless|400px]]<br>
 +
| NanoPi-NEO-Core =
 +
也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:USB2UART-NEO-Core.jpg|frameless|400px]]<br>
 +
| NanoPi-M1 =
 +
也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:USB2UART-M1.jpg|frameless|400px]]<br>
 +
| NanoPi-M1-Plus =
 +
也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:USB2UART-M1-Plus.jpg|frameless|400px]]<br>
 +
| NanoPi-Duo =
 +
使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:USB2UART-Duo.jpg|frameless|400px]]<br>
 +
| NanoPi-Duo2 =
 +
使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:USB2UART-Duo2.jpg|frameless|400px]]<br>
 +
| NanoPi-NEO-Plus2 =
 +
也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:USB2UART-NEO-Plus2.jpg|frameless|400px]]<br>
 +
| NanoPi-NEO =
 +
也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:Matrix-USB2UART_nanopi_NEO.jpg|frameless|400px]]<br>
 +
| NanoPi-NEO-Air =
 +
也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:Matrix-USB2UART_NEO_Air.jpg|frameless|500px]]<br>
 +
| NanoPi-R1 =
 +
也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电:<br>
 +
[[File:Matrix-USB2UART_nanopi_R1.jpg|frameless|500px]]<br>
 +
| #default =
 +
也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电。
 +
}}
  
* Login via SSH
+
默认会以 root 用户自动登录,并且没有设置root用户的密码,你可以使用 passwd 命令来设置 root 用户的密码。<br />
Make sure you connect your board to the internet and your board's eth0 is set to WAN and wlan0 is set to LAN.<br>
+
[[File:op_login.jpg|frameless|500px|op_login]]<br>
Before you proceed make sure you connect your board to a master router's LAN and your board can get an IP address via DHCP.<br>
+
第一次运行系统时,系统会自动拓展TF卡上文件系统分区到最大可用空间:<br>
<!--
+
[[File:resize_rootfs_userdata.png|frameless|500px|resize_rootfs_userdata]]<br>
[[File:r1_lan_connected.png|frameless|500px|r1_lan_connected]]<br>
+
请耐心等待文件系统扩展完成。
-->
+
 
We assume the board's (eth0) IP address is 192.168.1.163. You can login via SSH by running the following command:
+
* <strong>SSH登录</strong>
 +
{{#switch: {{{1}}}
 +
| NanoPi-R1
 +
| NanoPi-M1-Plus
 +
| NanoPi-M1
 +
| NanoPi-NEO
 +
| NanoPi-NEO-Core
 +
| NanoPi-K1-Plus
 +
| NanoPi-NEO-Core2
 +
| NanoPi-NEO-Plus2
 +
| NanoPi-NEO2 =
 +
在本开发板的OpenWrt系统里,有线网络(eth0) 被配置为WAN功能。<br>
 +
启动系统前,请先用网线连接板子的有线以太网口到一级路由器的LAN口,以便该以太网(eth0) 能通过DHCP获取到IP地址。<br>
 +
这里假设已经通过调试串口或者一级路由器确定板子的以太网(eth0) 的IP地址为192.168.1.163,执行下列命令通过SSH登录系统:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ ssh root@192.168.1.163
 
$ ssh root@192.168.1.163
 
</syntaxhighlight>
 
</syntaxhighlight>
By default you will login as root without a password.
+
无需密码,直接就可以登录。
 +
| NanoPi-NEO-Air
 +
| NanoPi-Duo2
 +
| NanoPi-Duo =
 +
本开发板的OpenWrt系统默认的WiFi AP热点名称类似为“OpenWrt-10:d0:7a:de:3d:92”,网段为192.168.2.x,没有密码,可用手机或者PC机连接该热点,然后执行下列命令SSH登录系统:
 +
<syntaxhighlight lang="text">
 +
$ ssh root@192.168.2.1
 +
</syntaxhighlight>
 +
无需密码,直接就可以登录。
 +
}}
  
* Login via Web
+
* <strong>Web登录</strong>
 
+
OpenWrt系统支持通过LuCI Web界面进行访问和配置。<br>
OpenWrt supports web login via the LuCI Web GUI. Configure your system following the steps in <Login via SSH>. In our test the board's IP address was 192.168.1.163. Type your IP address in a browser and you will be able to load the OpenWrt-LuCI page:<br>
+
{{#switch: {{{1}}}
 +
| NanoPi-R1
 +
| NanoPi-M1-Plus
 +
| NanoPi-M1
 +
| NanoPi-NEO
 +
| NanoPi-NEO-Core
 +
| NanoPi-K1-Plus
 +
| NanoPi-NEO-Core2
 +
| NanoPi-NEO-Plus2
 +
| NanoPi-NEO2 =
 +
在已完成 <SSH登录> 章节里的设置的基础上,假设板子的有线以太网的IP地址为192.168.1.163,在浏览器中输入该IP地址就可以登录OpenWrt-LuCI界面了:<br>
 
[[File:R1-OpenWrt-LuCI.jpg|frameless|600px|R1-OpenWrt-LuCI]]<br>
 
[[File:R1-OpenWrt-LuCI.jpg|frameless|600px|R1-OpenWrt-LuCI]]<br>
By default you will login as root without a password. After click on "Login" you will sign in.
+
| NanoPi-NEO-Air
 
+
| NanoPi-Duo2
===Connect to WiFi Hotspot from Smart Phone===
+
| NanoPi-Duo =  
* Make sure you install a WiFi antenna on your board.
+
在已完成<SSH登录>章节里的设置的基础上,在浏览器中输入 192.168.2.1 就可以登录OpenWrt-LuCI界面了:<br>
* By default the board with OpenWrt is configured as a secondary router and its WiFi module AP6212 is set to AP mode. The default WiFi AP hotspot's name is like "OpenWrt-10:d0:7a:de:3d:92" and it doesn't have a password. You can connect a smart phone or PC to it.<br>
+
[[File:OpenWrt-LuCI_wlan0.jpg|frameless|600px|OpenWrt-LuCI_wlan0]]<br>
* The board's WiFi hotspot IP address falls into 192.168.2.x. Open a browser in your phone or PC, type 192.168.2.1 in the address bar and you will be able to visit the LuCI GUI:<br>
+
}}
[[File:phone_luci.png|frameless|300px|phone_luci]] <br>
+
默认用户名为root,无需密码,直接点击"Login"按键即可登录。
* After your phone is successfully connected to the board's WiFi hotspot, load the LuCI page, go to "Netwrok ---> Wireless" and you will see all connected devices:<br>
+
[[File:openwrt_wifiap_connected.png|frameless|600px|openwrt_wifiap_connected]] <br>
+
  
===Manage Software Packages===
+
===软件包管理===
OpenWrt has a package management utility: opkg. You can get its details by running the following command:
+
OpenWrt使用opkg工具来管理软件包,执行如下命令可以获取opkg的帮助信息:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg
 
$ opkg
Line 98: Line 178:
 
...
 
...
 
</syntaxhighlight>
 
</syntaxhighlight>
These are just part of the manual. Here are some popular opkg commands.
+
上面只截取了部分帮助信息,请自行查阅完整的帮助信息,下面会描述几个常用的opkg命令。
  
* Update Package List
+
* 更新可用软件包列表
Before you install a package you'd better update the package list:
+
第一次安装软件前,建议先更新可用软件包列表:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg update
 
$ opkg update
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* Check Available Packages
+
* 查看可安装的软件包:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg list
 
$ opkg list
 
</syntaxhighlight>
 
</syntaxhighlight>
At the time of writing there are 3241 packages available.
+
本WiKi编写时,可安装的软件包共有3241个。
  
* Check Installed Packages:
+
* 查看已安装的软件:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg list-installed
 
$ opkg list-installed
 
</syntaxhighlight>
 
</syntaxhighlight>
At the time of writing 124 packages have been installed.
+
本WiKi编写时,已安装的软件包共有124个。
  
* Install/Delete Packages:
+
* 安装/删除软件:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg install <pkgs>
 
$ opkg install <pkgs>
Line 124: Line 204:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* Check Files Contained in Installed Packages:
+
* 查看已安装的软件包含什么文件:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg files <pkg>
 
$ opkg files <pkg>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* Install Chinese Language Package for LuCI
+
* 安装LuCI中文语言包:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg install luci-i18n-base-zh-cn
 
$ opkg install luci-i18n-base-zh-cn
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* Check Changed Files:
+
* 查看当前系统中哪些配置文件被修改过:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg list-changed-conffiles
 
$ opkg list-changed-conffiles
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* Reference Links:
+
* 相关参考:
 
** [https://openwrt.org/docs/guide-user/additional-software/opkg openwrt opkg]
 
** [https://openwrt.org/docs/guide-user/additional-software/opkg openwrt opkg]
  
===Check System Status===
+
===查看系统状态===
* Check CPU Temperature & Frequency:
+
* <strong>命令行查看CPU温度和频率</strong>
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
$ cpu_freq
+
$ cpu_freq  
CPU0 online=1 temp=26581 governor=ondemand cur_freq=480000
+
Aavailable frequency(KHz):
CPU1 online=1 temp=26581 governor=ondemand cur_freq=480000
+
        480000 624000 816000 1008000
CPU2 online=1 temp=26581 governor=ondemand cur_freq=480000
+
Current frequency(KHz):
CPU3 online=1 temp=26581 governor=ondemand cur_freq=480000
+
        CPU0 online=1 temp=26548C governor=ondemand freq=624000KHz
 +
        CPU1 online=1 temp=26548C governor=ondemand freq=624000KHz
 +
        CPU2 online=1 temp=26548C governor=ondemand freq=624000KHz
 +
        CPU3 online=1 temp=26548C governor=ondemand freq=624000KHz
 
</syntaxhighlight>
 
</syntaxhighlight>
These messages mean four CPU cores are working online. Each core's temperature is 26.5 degrees. Each core's governor is on demand and the frequency is 480 MHz.
+
上述信息表示当前有4个CPU核在线, 温度均约为26.5摄氏度, 运行的策略均为根据需求来决定运行频率, 当前的运行频率均为624MHz,设置频率的命令如下:
 +
<syntaxhighlight lang="text">
 +
$ cpu_freq -s 1008000
 +
Aavailable frequency(KHz):
 +
        480000 624000 816000 1008000
 +
Current frequency(KHz):
 +
        CPU0 online=1 temp=36702C governor=userspace freq=1008000KHz
 +
        CPU1 online=1 temp=36702C governor=userspace freq=1008000KHz
 +
        CPU2 online=1 temp=36702C governor=userspace freq=1008000KHz
 +
        CPU3 online=1 temp=36702C governor=userspace freq=1008000KHz
 +
</syntaxhighlight>
 +
上述命令将4个CPU核的频率设置为1008MHz。<br>
  
* Check System Status on OpenWrt-LuCI Web Page:
+
* <strong>OpenWrt-LuCI Web界面查看系统状态</strong>
After you load the OpenWrt-LuCI page, click on "Statistics ---> Graphs" and you will be able to check all the statistics:<br>
+
登录OpenWrt-LuCI界面后,点击顶部的 Statistics ---> Graphs,可以查看系统的各种软硬件状态信息(即statistics),例如:<br>
1) System Load:<br>
+
1) 系统负载:<br>
 
[[File:statistics_system_load.png|frameless|600px|statistics_system_load]] <br>
 
[[File:statistics_system_load.png|frameless|600px|statistics_system_load]] <br>
2) RAM:<br>
+
2) 内存:<br>
 
[[File:statistics_memory.png|frameless|600px|statistics_memory]] <br>
 
[[File:statistics_memory.png|frameless|600px|statistics_memory]] <br>
3) CPU Temperature:<br>
+
3) CPU温度:<br>
 
[[File:statistics_thermal.png|frameless|600px|statistics_thermal]] <br>
 
[[File:statistics_thermal.png|frameless|600px|statistics_thermal]] <br>
"Statistics" is collected by the luci-app-statistics package. The luci-app-statistics package uses the Collectd utility to collect statistics and presents them using the RRDtool utility.<br>
+
Statistics界面对应软件包luci-app-statistics,luci-app-statistics软件包用Collectd工具收集状态数据并且用RRDtool工具将数据渲染为图表。<br>
If you want to get more statistics you can install various collectd-mod-* packages.  
+
你可以通过安装额外的collectd-mod-*软件包去使能更多的statistics.
 
<!--
 
<!--
 
The statistics package uses Collectd to gather data and RRDtool to render diagram images.
 
The statistics package uses Collectd to gather data and RRDtool to render diagram images.
 
You can install additional collectd-mod-* plugins to enable more statistics.
 
You can install additional collectd-mod-* plugins to enable more statistics.
 
-->
 
-->
All collectd-mod-* packages use the same configuration file: /etc/config/luci_statistics.
+
所有的collectd-mod-*软件包对应同一个配置文件: /etc/config/luci_statistics。
  
* Reference Links:
+
* 相关参考:
 
** [https://openwrt.org/docs/guide-user/luci/luci_app_statistics openwrt luci_app_statistics]
 
** [https://openwrt.org/docs/guide-user/luci/luci_app_statistics openwrt luci_app_statistics]
 
** [https://openwrt.org/docs/guide-user/luci/statistics.chart.public openwrt statistics.chart.public]
 
** [https://openwrt.org/docs/guide-user/luci/statistics.chart.public openwrt statistics.chart.public]
 
** [https://openwrt.org/docs/guide-user/perf_and_log/statistic.custom openwrt statistic.custom]
 
** [https://openwrt.org/docs/guide-user/perf_and_log/statistic.custom openwrt statistic.custom]
  
===Check Network->Interfaces Configurations===
+
===查看Network->Interfaces的配置===
* Login OpenWrt-LuCI, go to "Network ---> Interfaces" and you will see all the configurations: <br>
+
* 登录OpenWrt-LuCI界面后,点击顶部的 Network ---> Interfaces ,可以查看当前的网络设置: <br>
[[File:R1_Interfaces.png|frameless|600px|R1_Interfaces]] <br>
+
{{#switch: {{{1}}}
The Ethernet eth0 is configured as WAN and wlan0 is configured as LAN.<br>
+
| NanoPi-R1
* You can set WAN or LAN by clicking on "WAN" or "LAN".<br>
+
| NanoPi-M1-Plus
[[File:R1_Interfaces_WAN.jpg|frameless|600px|R1_Interfaces_WAN]]  [[File:R1_Interfaces_LAN.jpg|frameless|600px|R1_Interfaces_LAN]]<br>
+
| NanoPi-NEO-Plus2
* All the configurations on the Network->Interfaces page will be saved in the "/etc/config/network" file.<br>
+
| NanoPi-Duo2
 +
| NanoPi-Duo
 +
| NanoPi-K1-Plus =
 +
[[File:op_interface_eth0_br.png|frameless|600px|op_interface_eth0_br]] <br>
 +
| NanoPi-M1
 +
| NanoPi-NEO
 +
| NanoPi-NEO-Core
 +
| NanoPi-NEO-Core2
 +
| NanoPi-NEO2 =
 +
[[File:op_interface_eth0.png|frameless|600px|op_interface_eth0]] <br>
 +
| NanoPi-NEO-Air =
 +
  [[File:op_interface_br.png|frameless|600px|op_interface_br]] <br>
 +
}}
 +
* Network->Interfaces界面的配置保存在/etc/config/network中。<br>
  
===Check Netwrok->Wireless Configurations===
+
{{#switch: {{{1}}}
* Login OpenWrt-LuCI, go to "Network ---> Wireless" and you will see all the WiFi hotspot configurations:<br>
+
| NanoPi-R1
[[File:R1-Wireless1.jpg|frameless|600px|R1-Wireless]]<br>
+
| NanoPi-M1-Plus
By default the WiFi AP's hotspot name is like "OpenWrt-10:d0:7a:de:3d:92" without a password. You can connect a smart phone to the WiFi hotspot.<br>
+
| NanoPi-NEO-Plus2
* Click on "Edit", type a new name in Interface Configuration ---> General Setup ---> ESSID and click on Save & Apply.<br>
+
| NanoPi-Duo2
[[File:R1-Wireless-ESSID.jpg|frameless|600px|R1-Wireless-ESSID]]<br>
+
| NanoPi-Duo
* You can set a new encryption in Interface Configuration ---> Wireless Security, a new password in Key and click on Save & Apply.<br>
+
| NanoPi-NEO-Air =
[[File:R1-Wireless-Key.jpg|frameless|600px|R1-Wireless-Key]]<br>
+
===查看Netwrok->Wireless的配置===
* You can see all the connected devices in Associated Stations on the Network ---> Wireless page.<br>
+
* 登录OpenWrt-LuCI界面后,点击顶部的 Network ---> Wireless,可以查看WiFi 热点的设置界面:<br>
[[File:R1-Wireless-Associated_Stations.jpg|frameless|600px|R1-Wireless-Associated Stations]]<br>
+
[[File:op_wireless.jpg|frameless|600px|op_wireless]]<br>
* All the configurations on the Network->Wireless page will be saved in the /etc/config/wireless file.<br>
+
默认的WiFi AP热点名称类似为“OpenWrt-10:d0:7a:de:3d:92”,没有密码,手机可以直接连接该热点然后访问互联网。<br>
 +
* Network->Wireless界面的配置保存在/etc/config/wireless中。<br>
 +
}}

Revision as of 09:03, 5 May 2019

1 OpenWrt的使用

1.1 介绍

OpenWrt是适合于嵌入式设备的一个Linux发行版,它不是一个单一、静态的固件,而是提供了一个可添加软件包的可写的文件系统。 这使用户可以自由的选择应用程序和配置,而不必受设备提供商的限制,并且可以使用一些适合某方面应用的软件包来定制你的设备。 对于开发者来说,OpenWrt是一个框架,开发者不必麻烦地构建整个固件就能得到想要的应用程序;对于用户来说,这意味着完全定制的能力,与以往不同的方式使用设备,OPKG包含超过3500个软件。 更详细的介绍请参考OpenWrt官网

1.2 登录系统

  • 串口登录

如果您需要进行内核开发,最好选购一个串口配件,连接了串口,则可以通过串口终端对开发板进行操作。
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:
接上串口后,您可以选择从串口模块的DC口或者从MicroUSB口 (如果有) 进行供电。

也可以使用USB转串口模块调试,请注意需要使用5V/2A电源给开发板MicroUSB供电。

默认会以 root 用户自动登录,并且没有设置root用户的密码,你可以使用 passwd 命令来设置 root 用户的密码。
op_login
第一次运行系统时,系统会自动拓展TF卡上文件系统分区到最大可用空间:
resize_rootfs_userdata
请耐心等待文件系统扩展完成。

  • SSH登录


  • Web登录

OpenWrt系统支持通过LuCI Web界面进行访问和配置。

默认用户名为root,无需密码,直接点击"Login"按键即可登录。

1.3 软件包管理

OpenWrt使用opkg工具来管理软件包,执行如下命令可以获取opkg的帮助信息:

$ opkg
Package Manipulation:
        update                  Update list of available packages
        upgrade <pkgs>          Upgrade packages
        install <pkgs>          Install package(s)
        configure <pkgs>        Configure unpacked package(s)
        remove <pkgs|regexp>    Remove package(s)
        flag <flag> <pkgs>      Flag package(s)
         <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation)
 
Informational Commands:
        list                    List available packages
        list-installed          List installed packages
        list-upgradable         List installed and upgradable packages
        list-changed-conffiles  List user modified configuration files
        files <pkg>             List files belonging to <pkg>
        search <file|regexp>    List package providing <file>
        find <regexp>           List packages whose name or description matches <regexp>
        info [pkg|regexp]       Display all info for <pkg>
        status [pkg|regexp]     Display all status for <pkg>
        download <pkg>          Download <pkg> to current directory
...

上面只截取了部分帮助信息,请自行查阅完整的帮助信息,下面会描述几个常用的opkg命令。

  • 更新可用软件包列表

第一次安装软件前,建议先更新可用软件包列表:

$ opkg update
  • 查看可安装的软件包:
$ opkg list

本WiKi编写时,可安装的软件包共有3241个。

  • 查看已安装的软件:
$ opkg list-installed

本WiKi编写时,已安装的软件包共有124个。

  • 安装/删除软件:
$ opkg install <pkgs>
$ opkg remove <pkgs>
  • 查看已安装的软件包含什么文件:
$ opkg files <pkg>
  • 安装LuCI中文语言包:
$ opkg install luci-i18n-base-zh-cn
  • 查看当前系统中哪些配置文件被修改过:
$ opkg list-changed-conffiles

1.4 查看系统状态

  • 命令行查看CPU温度和频率
$ cpu_freq 
Aavailable frequency(KHz):
        480000 624000 816000 1008000
Current frequency(KHz):
        CPU0 online=1 temp=26548C governor=ondemand freq=624000KHz
        CPU1 online=1 temp=26548C governor=ondemand freq=624000KHz
        CPU2 online=1 temp=26548C governor=ondemand freq=624000KHz
        CPU3 online=1 temp=26548C governor=ondemand freq=624000KHz

上述信息表示当前有4个CPU核在线, 温度均约为26.5摄氏度, 运行的策略均为根据需求来决定运行频率, 当前的运行频率均为624MHz,设置频率的命令如下:

$ cpu_freq -s 1008000
Aavailable frequency(KHz):
        480000 624000 816000 1008000
Current frequency(KHz):
        CPU0 online=1 temp=36702C governor=userspace freq=1008000KHz
        CPU1 online=1 temp=36702C governor=userspace freq=1008000KHz
        CPU2 online=1 temp=36702C governor=userspace freq=1008000KHz
        CPU3 online=1 temp=36702C governor=userspace freq=1008000KHz

上述命令将4个CPU核的频率设置为1008MHz。

  • OpenWrt-LuCI Web界面查看系统状态

登录OpenWrt-LuCI界面后,点击顶部的 Statistics ---> Graphs,可以查看系统的各种软硬件状态信息(即statistics),例如:
1) 系统负载:
statistics_system_load
2) 内存:
statistics_memory
3) CPU温度:
statistics_thermal
Statistics界面对应软件包luci-app-statistics,luci-app-statistics软件包用Collectd工具收集状态数据并且用RRDtool工具将数据渲染为图表。
你可以通过安装额外的collectd-mod-*软件包去使能更多的statistics. 所有的collectd-mod-*软件包对应同一个配置文件: /etc/config/luci_statistics。

1.5 查看Network->Interfaces的配置

  • 登录OpenWrt-LuCI界面后,点击顶部的 Network ---> Interfaces ,可以查看当前的网络设置:
  • Network->Interfaces界面的配置保存在/etc/config/network中。