【智能路由器】新手openwrt平台搭建

【智能路由器】系列文章连接
http://blog.csdn.net/u012819339/article/category/5803489

从本篇文章开始,后续文章将会转为在openwrt上的开发,而不是一个单纯的linux内核上开发了,所以文章也多是基于openwrt的基础上进行实战。


最近业余时间主要精力放在openwrt和ffmpeg上。
手头一块MT7620的板子,上个图
【智能路由器】新手openwrt平台搭建_第1张图片

双频(2.4G and 5G)
8M FLASH
64M SRAM
CPU:MIPS24KEc
USB2.0
SD:SD-HC class10(32GB)

其他如:就不多介绍了,我看中了两点,SD接口和USB接口都印出来并焊接了卡座和USB母头,可插一个SD卡,用于存储一般数据、网页之类的够了,USB口只有一个,有点遗憾,不过我接了个USB一拖四,外面可挂载USB摄像头,移动硬盘。将摄像头数据推流到组播或者RTMP服务器,实现视频监控。移动硬盘则用来存放视频,挂接到web服务器下,做个界面,供局域网内用户观看硬盘内视频。

欢迎拍砖和提建议。


之前玩的都是MTK提供的SDK,里面只有一个Linux内核和几个MTK移植好的应用,功能弱爆了。

自此,本人私下开始折腾openwrt,并记录之。本系列文章保持【智能路由器】实战的风格,力争每篇文章都是实战后放出来。
【智能路由器】openwrt实战历程开始。


拿到mtksdk-openwrt-3.10.14-20150311-d021c937.tar的压缩包,这个SDK和openwrt的代码包没多大区别只是去掉了一些不相关的平台的代码而已,在fedora的环境下编译,当然还是虚拟机中。

在非root用户下(root 用户下条件检查是不通过的,已经试过):
解压后进入生成openwrt-3.10.14目录,进入,执行make defconfig,然后make menuconfig瞅了几眼,默认选上了MT7620的目标板,然后开始make V=99,编译不一会就出错了,提示一个软件版本过低,具体哪个软件就忘了,一条命令yum install -y xxx,就搞定了。

安装编译需要的组件如下,而我没有进行此步安装才出现上述问题,你也可以按此步骤先行安装或升级这些组件之后再编译:
Ubuntu下就是这些命令啦,(fedora、centos下就是yum install xxxx)
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install binutils
sudo apt-get install patch
sudo apt-get install bzip2
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install make
sudo apt-get install autoconf
sudo apt-get install gettext
sudo apt-get install texinfo
sudo apt-get install unzip
sudo apt-get install sharutils
sudo apt-get install subversion
sudo apt-get install libncurses5-dev
sudo apt-get install ncurses-term
sudo apt-get install zlib1g-dev
sudo apt-get install gawk
sudo apt-get install asciidoc
sudo apt-get install libz-dev

安装过程比较顺利,安装过程会自动从网上下载相应的元代码包,只是因为公司的网络太慢,整整花了7个小时才安装完毕!蛋碎了一地…

编译完毕后从/bin文件家下拿出固件openwrt-ramips-mt7620-uImage.bin,tftp导入到flash发现启动不起来,错误如下:

LINUX started...

 THIS IS ASIC
[    0.000000] Linux version 3.10.14 (cjpthree@F12) (gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 unknown) ) #3 Tue Jan 12 18:40:44 CST 2016
[    0.000000] 
[    0.000000]  The CPU feqenuce set to 580 MHz
[    0.000000] 
[    0.000000]  MIPS CPU sleep mode enabled.
[    0.000000]  PCIE: bypass PCIe DLL.

...

[    1.624000] spidrv_major = 217
[    1.632000] deice id : ef 40 17 0 0 (40170000)
[    1.640000] W25Q64BV(ef 40170000) (8192 Kbytes)
[    1.648000] mtd .name = raspi, .size = 0x00800000 (0M) .erasesize = 0x00000008 (0K) .numeraseregions = 65536
[    1.668000] Creating 5 MTD partitions on "raspi":
[    1.676000] 0x000000000000-0x000000800000 : "ALL"
[    1.688000] 0x000000000000-0x000000030000 : "Bootloader"
[    1.700000] 0x000000030000-0x000000040000 : "Config"
[    1.712000] 0x000000040000-0x000000050000 : "Factory"
[    1.724000] 0x000000050000-0x000000800000 : "firmware"
[    1.736000] 0x0000001b4812-0x000000800000 : "rootfs"
[    1.744000] mtd: partition "rootfs" must either start or end on erase block boundary or be smaller than an erase block -- forcing read-only
[    1.772000] mtdsplit: no squashfs found in "raspi"
[    1.784000] rdm_major = 253
[    1.788000] SMACCR1 -- : 0x0000000c
[    1.796000] SMACCR0 -- : 0x43762077
[    1.804000] Ralink APSoC Ethernet Driver Initilization. v3.1  256 rx/tx descriptors allocated, mtu = 1500!
[    1.820000] SMACCR1 -- : 0x0000000c
[    1.828000] SMACCR0 -- : 0x43762077
[    1.836000] PROC INIT OK!
[    1.844000] Ralink APSoC Hardware Watchdog Timer
[    1.852000] TCP: cubic registered
[    1.860000] NET: Registered protocol family 10
[    1.868000] NET: Registered protocol family 17
[    1.876000] 8021q: 802.1Q VLAN Support v1.8
[    1.908000] jffs2: Flash size not aligned to erasesize, reducing to 6400KiB
[    1.924000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000000: 0x9cfe instead
[    1.940000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000004: 0xdd04 instead
[    1.960000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000008: 0xad0f instead
[    1.980000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000000c: 0xfe65 instead
[    1.996000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000010: 0xf27e instead
[    2.016000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000014: 0x8f1d instead
[    2.036000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000018: 0x4f90 instead
[    2.056000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000001c: 0x09de instead
[    2.072000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000020: 0x0189 instead
[    2.092000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000024: 0x0838 instead
[    2.112000] jffs2: Further such events for this erase block will not be printed
[    2.172000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0001b7f0: 0x3d39 instead

...

[   16.672000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00630038: 0x5253 instead
[   16.692000] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00630044: 0x0001 instead
[   16.712000] jffs2: Further such events for this erase block will not be printed
[   16.748000] jffs2: Empty flash at 0x0063b7cc ends at 0x0063b7e4
[   16.764000] jffs2: Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes
[   16.780000] jffs2: empty_blocks 38, bad_blocks 0, c->nr_blocks 100
[   16.796000] VFS: Cannot open root device "mtdblock5" or unknown-block(31,5): error -5
[   16.808000] Please append a correct "root=" boot option; here are the available partitions:
[   16.828000] 1f00            8192 mtdblock0  (driver?)
[   16.836000] 1f01             192 mtdblock1  (driver?)
[   16.848000] 1f02              64 mtdblock2  (driver?)
[   16.856000] 1f03              64 mtdblock3  (driver?)
[   16.868000] 1f04            7872 mtdblock4  (driver?)
[   16.876000] 1f05            6445 mtdblock5  (driver?)
[   16.888000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,5)

重新浏览了一下编译最后部分的信息,发现如下内容:

...
cp -fpR /home/cjpthree/study/MTK_SDKopenwrt/openwrt-3.10.14/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620/openwrt-ramips-mt7620-mt7620-squashfs-sysupgrade.bin /home/cjpthree/study/MTK_SDKopenwrt/openwrt-3.10.14/bin/ramips/openwrt-ramips-mt7620-mt7620-squashfs-sysupgrade.bin;
...

这才发现弄错了固件,正确文件应该是是openwrt-ramips-mt7620-mt7620-squashfs-sysupgrade.bin。所以路由器启动时如果有打印 “jffs2: Flash size not aligned to erasesize, reducing to 6400KiB”错误的看看是不是固件下载错了。

openwrt正常启动,不管是命令行还是web界面,用起来都非常方便,得意于它的uci和luci管理。
除了usb接口不能正常使用外,其他都正常。下篇文章解决USB接口的问题。


好啦,本文到此结束,作者arvik,【智能路由器】系列文章见
http://blog.csdn.net/u012819339/article/category/5803489

你可能感兴趣的:(智能路由器,智能路由器)