小米路由核心支持包
第24行: | 第24行: | ||
<br><br> | <br><br> | ||
+ | |||
+ | == 使用 == | ||
+ | |||
+ | 以下在 Ubuntu 12.04 验证通过: | ||
+ | |||
+ | 1. 源码下载编译 | ||
+ | |||
+ | <source lang=bash> | ||
+ | $ sudo apt-get install lzma | ||
+ | $ git clone git://github.com/comcat/miwifi.git | ||
+ | $ cd miwifi/ | ||
+ | $ make | ||
+ | </source> | ||
+ | |||
+ | vmlinuz 为可直接被 CFE 加载的内核镜像(内含ramfs) | ||
+ | |||
+ | jarvis-rootfs.tgz 为 rootfs 包。用户 'root' 的默认密码为 'admin',WiFi 的SSID 为 Jarvis 和 Jarvis_5G,密码为 'qwer1234' | ||
+ | |||
+ | |||
+ | 2. 部署内核和文件系统 | ||
+ | |||
+ | 初次尝试建议使用 tftp 加载内核,挂载 NFS 文件系统,内核和rootfs都在PC上,不会改变原路由的结构,测试、调试方便 | ||
+ | |||
+ | |||
+ | 2.0 配置网络 | ||
+ | |||
+ | 我们在PC上部署 tftp server 和 NFS server,因此需要一根网线连接路由WAN口边上的LAN口到PC网口连接的HUB上,保证PC和路由在局域网内能通信 | ||
+ | |||
+ | 小米路由启动时,CFE (bootloader) 会检测 nvram 中的 flag_tftp_bootup 这个参数,如果其值为 on,其会首先尝试tftp加载 192.168.1.2:/tftpboot/vmlinuz 这个路径。因此我们要为 PC 配一个 192.168.1.2 的IP: | ||
+ | |||
+ | <source lang=bash> | ||
+ | $ sudo ifconfig eth0:0 192.168.1.2 | ||
+ | </source> | ||
+ | |||
+ | |||
+ | 另,路由启动后,其为LAN口配的地址为 192.168.31.1 ,为保证PC能访问其 web 配置界面,也为 PC | ||
+ | |||
+ | |||
+ | 2.1 安装配置 tftp 服务器 | ||
+ | |||
+ | <source lang=bash> | ||
+ | $ sudo apt-get install tftpd tftp | ||
+ | |||
+ | $ cat /etc/xinetd.d/tftp | ||
+ | service tftp | ||
+ | { | ||
+ | socket_type = dgram | ||
+ | protocol = udp | ||
+ | wait = yes | ||
+ | user = root | ||
+ | server = /usr/sbin/in.tftpd | ||
+ | server_args = -s /tftpboot | ||
+ | disable = no | ||
+ | per_source = 11 | ||
+ | cps = 100 2 | ||
+ | flags = IPv4 | ||
+ | } | ||
+ | |||
+ | $ sudo mkdir /tftpboot | ||
+ | $ sudo chmod 777 /tftpboot | ||
+ | |||
+ | $ sudo /etc/init.d/xinetd restart | ||
+ | </source> | ||
+ | |||
+ | |||
+ | 到此 tftp Server 安装成功,把编译好的内核 vmlinuz 拷到 /tftpboot 目录下: | ||
+ | |||
+ | <source lang=bash> | ||
+ | $ cp /path/to/miwifi/vmlinuz /tftpboot/ | ||
+ | </source> | ||
+ | |||
+ | |||
+ | 用 tftp 测试 tftp server 是否正常: | ||
+ | |||
+ | <source lang=bash> | ||
+ | $ tftp | ||
+ | > connect 192.168.31.1 | ||
+ | |||
<br><br> | <br><br> | ||
<br><br> | <br><br> | ||
<br><br> | <br><br> | ||
<br><br> | <br><br> | ||
+ | |||
+ | <source lang=bash> | ||
+ | |||
+ | </source> | ||
<br><br> | <br><br> |
2014年7月31日 (四) 19:19的版本
1 概述
5月底拿到带硬盘版的路由,想想也就放家里 7x24 搜集各种智能设备的数据合适。
对于一个好动手的极客,没有内核代码、不能定制、控制自己的路由器是不能容忍的。
手头有原来用perl写的用于服务传感器数据推送 (REST) 的进程,部署需要catalyst和MySql,很自然地想到内核源码搞定后,在原ROM系统里叠加一个Debian 核心系统还是很爽的
于是仔细分析了其硬件实现,借助社区公开的代码,修修改改,6月6日有了一个可启动的内核代码版本
然后断断续续完善到7月底,总算有了一个高度可用的版本
现有的核心支持包包括一个2.6的内核源码包,一个工具链和一个叠加了 Debian 核心系统的混合系统 (ROOT FS)
系统除支持原ROM的核心功能外,自带 Debian 核心环境,可用apt-get install 直接安装你想要的软件包,相当方便
核心包编译出的 rootfs 可直接部署在路由内硬盘的第四个分区上,亦可部署在 NFS server 上,详情参考源码目录的README
核心包源码置于个人的github帐号下: http://github.com/comcat/miwifi
2 使用
以下在 Ubuntu 12.04 验证通过:
1. 源码下载编译
$ sudo apt-get install lzma $ git clone git://github.com/comcat/miwifi.git $ cd miwifi/ $ make
vmlinuz 为可直接被 CFE 加载的内核镜像(内含ramfs)
jarvis-rootfs.tgz 为 rootfs 包。用户 'root' 的默认密码为 'admin',WiFi 的SSID 为 Jarvis 和 Jarvis_5G,密码为 'qwer1234'
2. 部署内核和文件系统
初次尝试建议使用 tftp 加载内核,挂载 NFS 文件系统,内核和rootfs都在PC上,不会改变原路由的结构,测试、调试方便
2.0 配置网络
我们在PC上部署 tftp server 和 NFS server,因此需要一根网线连接路由WAN口边上的LAN口到PC网口连接的HUB上,保证PC和路由在局域网内能通信
小米路由启动时,CFE (bootloader) 会检测 nvram 中的 flag_tftp_bootup 这个参数,如果其值为 on,其会首先尝试tftp加载 192.168.1.2:/tftpboot/vmlinuz 这个路径。因此我们要为 PC 配一个 192.168.1.2 的IP:
$ sudo ifconfig eth0:0 192.168.1.2
另,路由启动后,其为LAN口配的地址为 192.168.31.1 ,为保证PC能访问其 web 配置界面,也为 PC
2.1 安装配置 tftp 服务器
$ sudo apt-get install tftpd tftp $ cat /etc/xinetd.d/tftp service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4 } $ sudo mkdir /tftpboot $ sudo chmod 777 /tftpboot $ sudo /etc/init.d/xinetd restart
到此 tftp Server 安装成功,把编译好的内核 vmlinuz 拷到 /tftpboot 目录下:
$ cp /path/to/miwifi/vmlinuz /tftpboot/
用 tftp 测试 tftp server 是否正常:
$ tftp > connect 192.168.31.1 <br><br> <br><br> <br><br> <br><br> <source lang=bash>