Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| zh:docs:guide-developer:adding_new_device [2018/08/10 07:08] – [/target/linux/<arch_name>/base-files/sbin] miroky | zh:docs:guide-developer:adding_new_device [2020/09/09 02:44] – [从设备获取数据] star_twinkling | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== 为新设备添加OpenWrt支持 ====== | ====== 为新设备添加OpenWrt支持 ====== | ||
| - | 为了全面了解如何添加新设备支持,我们建议您查看一台新设备相关的最新的commit,摸清楚哪些文件发生了修改和如何修改它们。这些文件尽可能不言自明,大多数时候只是打开它们就足以理解它们的功能。(先机器翻译一次,后面再来修改,“海涵”) | + | 为了全面了解如何添加新设备支持,我们建议您查看一台新设备相关的最新的commit,摸清楚哪些文件发生了修改和如何修改它们。这些文件非常方便理解,我们只需要去打开查看就能理解。 |
| ===== 通过实例进行学习 ===== | ===== 通过实例进行学习 ===== | ||
| Line 42: | Line 41: | ||
| ==== / | ==== / | ||
| - | 该文件夹下的文件夹和文件对应固件中的/ | + | 该文件夹下的文件夹和文件对应固件中的/ |
| 它的子文件夹和文件有: | 它的子文件夹和文件有: | ||
| Line 56: | Line 55: | ||
| ==== / | ==== / | ||
| - | Device tree source files, | + | 设备树源文件(Device tree source files, |
| ==== / | ==== / | ||
| - | Configuration needed to build device-specific flashable images. | + | 用于构建写入用镜像的设置文件。 |
| ==== / | ==== / | ||
| - | Board-specific configuration. | + | 设备专用的设置文件 |
| ==== / | ==== / | ||
| - | Arch-specific | + | __menuconfig__中使用的架构专用(Arch-specific)配置文件 |
| - | ==== Making new device appear in make menuconfig ==== | + | ==== 使新设备出现在make menuconfig中 ==== |
| - | After edit the files above, you need to touch the makefiles | + | 在编辑了上述的文件后, 你需要对Makefile使用touch命令 |
| touch target/ | touch target/ | ||
| - | ===== Patches | + | ===== 补丁 |
| - | The patches-* subdirectories contain the kernel patches applied for every target.\\ | + | 子目录 |
| - | All patches should be named 'NNN-lowercase_shortname.patch' | + | 它包含的文件名('3个数字-全小写字母的简介.patch' |
| - | **0xx** - upstream backports\\ | + | **0xx** - 上游需要回退的内容补丁\\ |
| - | **1xx** - code awaiting upstream merge\\ | + | **1xx** - 等待上游合并的代码补丁\\ |
| - | **2xx** - kernel build / config / header patches\\ | + | **2xx** - 内核构建、配置和头文件的补丁\\ |
| - | **3xx** - architecture specific patches\\ | + | **3xx** - 用于特定体系结构的补丁\\ |
| - | **4xx** - mtd related patches (subsystem and drivers)\\ | + | **4xx** - MTD相关的补丁(系统和设备方面)\\ |
| - | **5xx** - filesystem related patches\\ | + | **5xx** - 文件系统相关的补丁\\ |
| - | **6xx** - generic network patches\\ | + | **6xx** - 网络通用补丁\\ |
| - | **7xx** - network / phy driver patches\\ | + | **7xx** - 网络物理层驱动补丁\\ |
| - | **8xx** - other drivers\\ | + | **8xx** - 其他设备补丁\\ |
| - | **9xx** - uncategorized other patches\\ | + | **9xx** - 未分类的其他补丁\\ |
| <WRAP center round tip 80%> | <WRAP center round tip 80%> | ||
| - | All patches must be written in a way that they are potentially upstreamable, | + | 所有的补丁发布都必须具有相比现阶段潜在的优势,如: |
| - | - they must contain a proper subject\\ | + | - 补丁必须具有**合适明确的主题**\\ |
| - | - they must contain a proper | + | - 必须有一个**明确清晰的commit信息**来解析补丁作出了什么样的改变\\ |
| - | - they must contain a valid Signed-off-by line\\ | + | - 补丁必须包含**一个签署人**\\ |
| </ | </ | ||
| - | ===== Testing images | + | ===== 镜像测试 |
| - | Test firmware images without writing them to flash by using ramdisk | + | 测试镜像固件通过ramdisk镜像而不通过烧写到Flash。\\ |
| - | In **make menuconfig** | + | 在**make menuconfig**配置中选择**Target Images**,然后再选择**ramdisk**选项。\\ |
| - | This will create an image with kernel + initramfs, that will have **initramfs** | + | 这样将会编译生成一个kernel+inittramfs(内核加上内存根文件系统)的镜像文件,它的名字中将会包含**initramfs**。通过BootLoader的tftp功能可以将这个镜像文件导入到设备,这样可以在不需要flash文件系统的支持下进行启动。 |
| - | ===== Tips and tricks | + | ===== 小窍门 |
| - | ==== Getting a shell on the target device | + | ==== 使用目标设备中的shell ==== |
| - | In order to collect relevant data for a port of LEDE to the device of interest one wants shell access. Most devices though do not offer a way to get a shell with telnet | + | 为了获取到某个你感兴趣的OpenWrt设备的端口的相关数据,需要进行shell访问。但是大多数设备都没有提供使用telnet或者ssh连接shell的方法。 |
| - | With [[https://wiki.openwrt.org/toh/netgear/ | + | ==== 通过PING或者NTP功能进入shell ==== |
| - | When such means cannot be used, one could try to flash an image build from the sources published by the vendor with telnetd | + | 某些路由器提供ping测试或NTP服务器配置,并且可能无法正确清理用户输入。尝试输入shell脚本,看看您是否幸运。您可能需要一些JavaScript知识才能禁用客户端输入验证。 |
| + | == 使用telnetd == | ||
| + | <code bash> | ||
| + | $( /bin/busybox telnetd -l/bin/sh -p23 & ) | ||
| + | </code> | ||
| + | == 如果需要远程登录,请使用HTTP获取密码哈希或使用“sed”删除/ | ||
| + | <code bash> | ||
| + | $( cp /etc/shadow /www ) | ||
| + | $( cp /etc/passwd /www ) | ||
| + | </ | ||
| + | 然后尝试将他们下载到您的电脑并且破解哈希密码。 | ||
| + | == 降级固件 == | ||
| + | 某些路由器可能会在启动之初尝试从特定的专用IP下载固件文件(例如TP-Link Archer C2 AC750),从而允许用户降级到较旧的固件。 | ||
| + | == HTTP服务器漏洞 == | ||
| + | 一些路由器可能正在运行过时/ | ||
| + | == 网件 == | ||
| + | 使用 [[toh: | ||
| - | With [[https:// | + | 通过 |
| + | ==== 收集相关数据 ==== | ||
| + | 在[[https:// | ||
| - | ==== Collecting relevant data ==== | + | 通常可以使用以下的命令: |
| - | On [[https:// | + | <code bash> |
| - | + | ||
| - | Typically one can use the following commands: | + | |
| dmesg # log buffer might be to small, see note 1. | dmesg # log buffer might be to small, see note 1. | ||
| cat / | cat / | ||
| Line 131: | Line 145: | ||
| ls / | ls / | ||
| brctl show | brctl show | ||
| - | + | | |
| - | Note 1: Often the log buffer is to small and the earliest messages may be missing from the information retrieved with '' | + | </ |
| + | |||
| + | **注意1**:通过**dmesg**检索时,如果日志的缓存区太小,就会丢失掉最早的信息。如果从供应商发布的资源中构建库存及镜像文件,则可以在内核配置中设置更大的缓冲区大小。 | ||
| + | |||
| + | **注意2**: | ||
| + | |||
| + | 获取设置LED信息的另一个有用的工具是[[https:// | ||
| + | |||
| + | |||
| + | ==== 从设备获取数据 ==== | ||
| + | 由于空间有限,常见的文件传输实用程序(例如rsync/ | ||
| + | |||
| + | 假设路由器ip为192.168.0.123,要传输的文件位于/ | ||
| + | |||
| + | === HTTP通过" | ||
| + | |||
| + | 如果从/ | ||
| + | |||
| + | == Sender == | ||
| + | <code bash> | ||
| + | mount -o bind /tmp /www | ||
| + | </ | ||
| + | |||
| + | == Receiver == | ||
| + | <code bash> | ||
| + | wget http:// | ||
| + | </ | ||
| + | |||
| + | === FTP通过“busybox ftpput” === | ||
| + | == Receiver == | ||
| + | 设置一个FTP服务器,添加一个具有写权限的匿名账号。 | ||
| + | <code bash> | ||
| + | python -m pyftpdlib -w -p 21 | ||
| + | </ | ||
| + | |||
| + | |||
| + | == Sender == | ||
| + | <code bash> | ||
| + | busybox ftpput 192.168.0.123 important-data.txt / | ||
| + | </ | ||
| + | |||
| + | === netcat通过“buxybox nc” === | ||
| + | == Receiver == | ||
| + | <code bash> | ||
| + | busybox nc -l -p 12345 > important-data.txt | ||
| + | </ | ||
| + | |||
| + | == Sender == | ||
| + | <code bash> | ||
| + | cat / | ||
| + | </ | ||
| - | Note 2: http:// | + | === TFTP通过“busybox tftp” === |
| + | == Receiver == | ||
| + | Setup a tftp server | ||
| - | Another useful tool for getting information for setting LEDs might be [[https://github.com/ | + | == Sender == |
| + | <code bash> | ||
| + | busybox tftp -p -l /tmp/important-data.txt -r important-data.txt 192.168.0.123 | ||
| + | </ | ||
| - | ==== Getting collected data from a device ==== | + | === 通过终端(terminal)复制 |
| - | Sometimes no normal means such as scp or ftp are available for retrieving files from a device. Still one could use httpd and busybox its mount command to do so. How? | + | 如果上述所有工具/小工具都不可用,则可以从telnet终端进行复制,但不适用于二进制文件 |
| - | Assume the files with relevant data on the device with IP address '' | + | |
| - | On the device do: | + | |
| - | cp important-data.txt /tmp | + | |
| - | mount -o bind /tmp /www | + | |
| - | After that the data on the host connected to the device do: | + | |
| - | wget http:// | + | |
| | | ||