Difference between revisions of "Template:OpenWrt1"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
Line 1: Line 1:
==OpenWrt的使用==
+
==Work with OpenWrt==
===介绍===
+
===Introduction===
OpenWrt是适合于嵌入式设备的一个Linux发行版,它不是一个单一、静态的固件,而是提供了一个可添加软件包的可写的文件系统。
+
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是一个框架,开发者不必麻烦地构建整个固件就能得到想要的应用程序;对于用户来说,这意味着完全定制的能力,与以往不同的方式使用设备,OPKG包含超过3500个软件。
+
更详细的介绍请参考[https://openwrt.org/ OpenWrt官网]
+
  
===登录系统===
+
===System Login===
 
* <strong>串口登录</strong>
 
* <strong>串口登录</strong>
 
<!-- copy frome FriendlyCoreGeneral-zh.txt -->
 
<!-- copy frome FriendlyCoreGeneral-zh.txt -->
Line 152: Line 149:
 
默认用户名为root,无需密码,直接点击"Login"按键即可登录。
 
默认用户名为root,无需密码,直接点击"Login"按键即可登录。
  
===软件包管理===
+
===Manage Software Packages===
OpenWrt使用opkg工具来管理软件包,执行如下命令可以获取opkg的帮助信息:
+
OpenWrt has a package management utility: opkg. You can get its details by running the following command:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg
 
$ opkg
Line 178: Line 175:
 
...
 
...
 
</syntaxhighlight>
 
</syntaxhighlight>
上面只截取了部分帮助信息,请自行查阅完整的帮助信息,下面会描述几个常用的opkg命令。
+
These are just part of the manual. Here are some popular opkg commands.
  
* 更新可用软件包列表
+
* 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>
本WiKi编写时,可安装的软件包共有3241个。
+
At the time of writing there are 3241 packages available.
  
* 查看已安装的软件:
+
* Check Installed Packages:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg list-installed
 
$ opkg list-installed
 
</syntaxhighlight>
 
</syntaxhighlight>
本WiKi编写时,已安装的软件包共有124个。
+
At the time of writing 124 packages have been installed.
  
* 安装/删除软件:
+
* Install/Delete Packages:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg install <pkgs>
 
$ opkg install <pkgs>
Line 204: Line 201:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* 查看已安装的软件包含什么文件:
+
* Check Files Contained in Installed Packages:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ opkg files <pkg>
 
$ opkg files <pkg>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* 安装LuCI中文语言包:
+
* Install Chinese Language Package for 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]
  
Line 245: Line 242:
 
         CPU3 online=1 temp=36702C governor=userspace freq=1008000KHz
 
         CPU3 online=1 temp=36702C governor=userspace freq=1008000KHz
 
</syntaxhighlight>
 
</syntaxhighlight>
上述命令将4个CPU核的频率设置为1008MHz。<br>
+
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.
  
 
* <strong>OpenWrt-LuCI Web界面查看系统状态</strong>
 
* <strong>OpenWrt-LuCI Web界面查看系统状态</strong>
 
登录OpenWrt-LuCI界面后,点击顶部的 Statistics ---> Graphs,可以查看系统的各种软硬件状态信息(即statistics),例如:<br>
 
登录OpenWrt-LuCI界面后,点击顶部的 Statistics ---> Graphs,可以查看系统的各种软硬件状态信息(即statistics),例如:<br>
1) 系统负载:<br>
+
1) System Load:<br>
 
[[File:statistics_system_load.png|frameless|600px|statistics_system_load]] <br>
 
[[File:statistics_system_load.png|frameless|600px|statistics_system_load]] <br>
2) 内存:<br>
+
2) RAM:<br>
 
[[File:statistics_memory.png|frameless|600px|statistics_memory]] <br>
 
[[File:statistics_memory.png|frameless|600px|statistics_memory]] <br>
3) CPU温度:<br>
+
3) CPU Temperature:<br>
 
[[File:statistics_thermal.png|frameless|600px|statistics_thermal]] <br>
 
[[File:statistics_thermal.png|frameless|600px|statistics_thermal]] <br>
 
Statistics界面对应软件包luci-app-statistics,luci-app-statistics软件包用Collectd工具收集状态数据并且用RRDtool工具将数据渲染为图表。<br>
 
Statistics界面对应软件包luci-app-statistics,luci-app-statistics软件包用Collectd工具收集状态数据并且用RRDtool工具将数据渲染为图表。<br>
Line 261: Line 258:
 
You can install additional collectd-mod-* plugins to enable more statistics.
 
You can install additional collectd-mod-* plugins to enable more statistics.
 
-->
 
-->
所有的collectd-mod-*软件包对应同一个配置文件: /etc/config/luci_statistics。
+
All collectd-mod-* packages use the same configuration file: /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]
Line 301: Line 298:
 
默认的WiFi AP热点名称类似为“OpenWrt-10:d0:7a:de:3d:92”,没有密码,手机可以直接连接该热点然后访问互联网。<br>
 
默认的WiFi AP热点名称类似为“OpenWrt-10:d0:7a:de:3d:92”,没有密码,手机可以直接连接该热点然后访问互联网。<br>
 
* Network->Wireless界面的配置保存在/etc/config/wireless中。<br>
 
* Network->Wireless界面的配置保存在/etc/config/wireless中。<br>
 +
}}
 +
 +
{{#switch: {{{1}}}
 +
| NanoPi-R1
 +
===Check LED Configuration===
 +
* After login OpenWrt-LuCI and click on "System" ---> "LED Configuration" you will see the LED configuration:<br>
 +
[[File:R1_openwrt_led.png|frameless|600px|R1_openwrt_led]] <br>
 +
* By default the LED configuration is as follows:
 +
::{| class="wikitable"
 +
|-
 +
|LED1 || heartbeat LED. If it doesn't blink it means the system is dead and you need to reboot the system.<br>
 +
|-
 +
|LED2 || Status LED for Gbps Ethernet(eth0) WAN port. If WAN works it will be on otherwise it will be off. You can check the "Transmit" / "Receive" box to set it to blink when WAN transmits/receives data.<br>
 +
|-
 +
|LED3 || Status LED for Fast Ethernet(eth1) LAN port. If LAN works it will be on otherwise it will be off. You can check the "Transmit" / "Receive" box to set it to blink when LAN transmits/receives data.<br>
 +
|-
 +
|}
 +
* Reference Link:
 +
** [https://openwrt.org/docs/guide-user/base-system/led_configuration openwrt led_configuration]
 +
}}
 +
 +
{{#switch: {{{1}}}
 +
| NanoPi-R1
 +
===Check BUTTON Configuration===
 +
FriendlyElec's OpenWrt uses the triggerhappy utility to configure buttons. By default if a button is pressed it will trigger the system to reboot.If the system needs to be rebooted to recover from some errors it is recommended to press the button to reboot the system instead of directly powering off the system.<br>
 +
The triggerhappy utility uses the "/etc/triggerhappy/triggers.d/example.conf" configuration file.
 +
 +
* Reference Link:
 +
** [https://openwrt.org/docs/guide-user/hardware/hardware.button openwrt hardware.button]
 
}}
 
}}

Revision as of 09:32, 5 May 2019

1 Work with OpenWrt

1.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.

1.2 System Login

  • 串口登录

如果您需要进行内核开发,最好选购一个串口配件,连接了串口,则可以通过串口终端对开发板进行操作。
使用串口模块能有效地提升开发效率,以下是串口模块的连接方法:
接上串口后,您可以选择从串口模块的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 Manage Software Packages

OpenWrt has a package management utility: opkg. You can get its details by running the following command:

$ 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
...

These are just part of the manual. Here are some popular opkg commands.

  • Update Package List

Before you install a package you'd better update the package list:

$ opkg update
  • Check Available Packages
$ opkg list

At the time of writing there are 3241 packages available.

  • Check Installed Packages:
$ opkg list-installed

At the time of writing 124 packages have been installed.

  • Install/Delete Packages:
$ opkg install <pkgs>
$ opkg remove <pkgs>
  • Check Files Contained in Installed Packages:
$ opkg files <pkg>
  • Install Chinese Language Package for LuCI
$ opkg install luci-i18n-base-zh-cn
  • Check Changed Files:
$ 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

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.

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

登录OpenWrt-LuCI界面后,点击顶部的 Statistics ---> Graphs,可以查看系统的各种软硬件状态信息(即statistics),例如:
1) System Load:
statistics_system_load
2) RAM:
statistics_memory
3) CPU Temperature:
statistics_thermal
Statistics界面对应软件包luci-app-statistics,luci-app-statistics软件包用Collectd工具收集状态数据并且用RRDtool工具将数据渲染为图表。
你可以通过安装额外的collectd-mod-*软件包去使能更多的statistics. All collectd-mod-* packages use the same configuration file: /etc/config/luci_statistics.

1.5 查看Network->Interfaces的配置

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


}

NanoPi-R1

1.6 Check BUTTON Configuration

FriendlyElec's OpenWrt uses the triggerhappy utility to configure buttons. By default if a button is pressed it will trigger the system to reboot.If the system needs to be rebooted to recover from some errors it is recommended to press the button to reboot the system instead of directly powering off the system.
The triggerhappy utility uses the "/etc/triggerhappy/triggers.d/example.conf" configuration file.