Difference between revisions of "Template:OpenWrt1"

From FriendlyELEC WiKi
Jump to: navigation, search
(System Login)
(System Login)
Line 108: Line 108:
 
  | NanoPi-NEO-Plus2
 
  | NanoPi-NEO-Plus2
 
  | NanoPi-NEO2 =
 
  | NanoPi-NEO2 =
在本开发板的OpenWrt系统里,有线网络(eth0) 被配置为WAN功能。<br>
+
In FriendlyElec's OpenWrt system the Ethernet(eth0) is set to WAN.<br>
启动系统前,请先用网线连接板子的有线以太网口到一级路由器的LAN口,以便该以太网(eth0) 能通过DHCP获取到IP地址。<br>
+
Before you power on your board make sure your board is connected to a master router's LAN port via an Ethernet cable and an IP address will be allocated to this Ethernet(eth0) via DHCP.<br>
这里假设已经通过调试串口或者一级路由器确定板子的以太网(eth0) 的IP地址为192.168.1.163,执行下列命令通过SSH登录系统:
+
Suppose the IP address allocated to the Ethernet(eth0) is 192.168.1.163. You can login via SSH by running following command:
 
<syntaxhighlight lang="text">
 
<syntaxhighlight lang="text">
 
$ ssh root@192.168.1.163
 
$ ssh root@192.168.1.163
 
</syntaxhighlight>
 
</syntaxhighlight>
无需密码,直接就可以登录。
+
You will be able to login without a password.
 
| NanoPi-NEO-Air
 
| NanoPi-NEO-Air
 
| NanoPi-Duo2
 
| NanoPi-Duo2

Revision as of 13:31, 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

  • Login via Serial

When you do kernel development you'd better connect your board to a serial communication board and do your development in a command-line utility.
It is better to do development with a serial communication board. Here is a hardware setup:
After you connect your board to a serial communication board you can power on your board from either the board's MicroUSB port(if there is one) or the DC port on the serial communication board

You can use a USB to serial board to debug. Attention: you need to plug a 5V/2A power to the board's MicroUSB port.

By default you will automatically login as root without a password. You can set the "root" user's password by using the passwd command.
op_login
When your system boots for the first time it will automatically extend the TF card's file system to its max capacity:
resize_rootfs_userdata
Please wait patiently for the process to be completed.

  • Login via 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中。