在openwrt启动过程中,向串口的输出主要有四个部分(如下所示):U-Boot 的输出,kernel的输出,文件系统启动过程中的输出(也是kernel输出的一部分,但是打印语句在系统的配置文件中),系统输出。
- U-Boot 1.1.4 (Aug 27 2011 - 10:39:39)
- >
- AP121-2MB (ar9330) U-boot
- >
- DRAM: 32 MB
- led turning on for 1s...
- id read 0x100000ff
- flash size 4194304, sector count = 64
- Flash: 4 MB
- Using default environment
- >
- In: serial
- Out: serial
- Err: serial
- Net: ag7240_enet_initialize...
- No valid address in Flash. Using fixed address
- No valid address in Flash. Using fixed address
- : cfg1 0x5 cfg2 0x7114
- eth0: 00:03:7f:09:0b:ad
- ag7240_phy_setup
- eth0 up
- : cfg1 0xf cfg2 0x7214
- eth1: 00:03:7f:09:0b:ad
- athrs26_reg_init_lan
- ATHRS26: resetting s26
- ATHRS26: s26 reset done
- ag7240_phy_setup
- eth1 up
- eth0, eth1
- Autobooting in 1 seconds
- ## Booting image at 9f020000 ...
- Uncompressing Kernel Image ... OK
- >
- Starting kernel ...
(以上为U-Boot打印)
- Linux version 2.6.39.4 (juhosg@idared) (gcc version 4.5.4 20110808 (prerelease) (Linaro GCC 4.5-2011.08) ) #1 Tue Sep 20 14:44:37 CEST 2011
- bootconsole [early0] enabled
- CPU revision is: 00019374 (MIPS 24Kc)
- SoC: Atheros AR9330 rev 1
- Clocks: CPU:400.000MHz, DDR:400.000MHz, AHB:200.000MHz, Ref:25.000MHz
- Determined physical RAM map:
- memory: 02000000 @ 00000000 (usable)
- Initrd not found or empty - disabling initrd
- Zone PFN ranges:
- Normal 0x00000000 -> 0x00002000
- Movable zone start PFN for each node
- early_node_map[1] active PFN ranges
- 0: 0x00000000 -> 0x00002000
- Built 1 zonelists in Zone order, mobility grouping on. Total pages: 8128
- Kernel command line: board=TL-WR703N console=ttyATH0,115200 rootfstype=squashfs,jffs2 noinitrd
- PID hash table entries: 128 (order: -3, 512 bytes)
- Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
- Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
- Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
- Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
- Writing ErrCtl register=00000000
- Readback ErrCtl register=00000000
- Memory: 29376k/32768k available (2009k kernel code, 3392k reserved, 386k data, 180k init, 0k highmem)
- SLUB: Genslabs=9, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
- NR_IRQS:80
- Calibrating delay loop... 265.42 BogoMIPS (lpj=1327104)
- pid_max: default: 32768 minimum: 301
- Mount-cache hash table entries: 512
- NET: Registered protocol family 16
- MIPS: machine is TP-LINK TL-WR703N v1
- bio: create slab at 0
- Switching to clocksource MIPS
- NET: Registered protocol family 2
- IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
- TCP established hash table entries: 1024 (order: 1, 8192 bytes)
- TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
- TCP: Hash tables configured (established 1024 bind 1024)
- TCP reno registered
- UDP hash table entries: 256 (order: 0, 4096 bytes)
- UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
- NET: Registered protocol family 1
- squashfs: version 4.0 (2009/01/31) Phillip Lougher
- JFFS2 version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
- msgmni has been set to 57
- io scheduler noop registered
- io scheduler deadline registered (default)
- Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
- ar933x-uart: ttyATH0 at MMIO 0x18020000 (irq = 11) is a AR933X UART
- console [ttyATH0] enabled, bootconsole disabled
- console [ttyATH0] enabled, bootconsole disabled
- Atheros AR71xx SPI Controller driver version 0.2.4
- m25p80 spi0.0: found s25sl032a, expected m25p80
- m25p80 spi0.0: s25sl032a (4096 Kbytes)
- Searching for RedBoot partition table in spi0.0 at offset 0x3e0000
- Searching for RedBoot partition table in spi0.0 at offset 0x3f0000
- No RedBoot partition table detected in spi0.0
- spi0.0: no WRT160NL signature found
- Creating 5 MTD partitions on "spi0.0":
- 0x000000000000-0x000000020000 : "u-boot"
- 0x000000020000-0x000000120000 : "kernel"
- 0x000000120000-0x0000003f0000 : "rootfs"
- mtd: partition "rootfs" set to be root filesystem
- mtd: partition "rootfs_data" created automatically, ofs=2A0000, len=150000
- 0x0000002a0000-0x0000003f0000 : "rootfs_data"
- 0x0000003f0000-0x000000400000 : "art"
- 0x000000020000-0x0000003f0000 : "firmware"
- ag71xx_mdio: probed
- eth0: Atheros AG71xx at 0xb9000000, irq 4
- Atheros AR71xx hardware watchdog driver version 0.1.0
- TCP westwood registered
- NET: Registered protocol family 17
- 802.1Q VLAN Support v1.8 Ben Greear
- All bugs added by David S. Miller
- VFS: Mounted root (squashfs filesystem) readonly on device 31:2.
- Freeing unused kernel memory: 180k freed
- linput: gpio-keys-polled as /devices/platform/gpio-keys-polled/input/input0
- Button Hotplug driver version 0.4.1
(以上为kernel输出)
- - preinit -
- Press the [f] key and hit [enter] to enter failsafe mode
- eth0: link up (100Mbps/Full duplex)
- - regular preinit -
- JFFS2 notice: (371) jffs2_build_xattr_subsystem: complete building xattr subsystem, 17 of xdatum (0 unchecked, 16 orphan) and 30 of xref (0 dead,
- 16 orphan) found.
- switching to jffs2
- - init -
(以上部分是文件系统输出)
- BusyBox v1.18.5 (2011-09-17 19:36:07 CEST) built-in shell (ash)
- Enter 'help' for a list of built-in commands.
- >
- _______ ________ __
- | |.-----.-----.-----.| | | |.----.| |_
- | - || _ | -__| || | | || _|| _|
- |_______|| __|_____|__|__||________||__| |____|
- |__| W I R E L E S S F R E E D O M
- ATTITUDE ADJUSTMENT (bleeding edge, r28258) ----------
- * 1/4 oz Vodka Pour all ingredients into mixing
- * 1/4 oz Gin tin with ice, strain into glass.
- * 1/4 oz Amaretto
- * 1/4 oz Triple sec
- * 1/4 oz Peach schnapps
- * 1/4 oz Sour mix
- * 1 splash Cranberry juice
- -----------------------------------------------------
- root@OpenWrt:/#
(最后部分是系统输出)
1. 首先,取消系统输出。
注释掉/etc/inittab中的ttyATH0::askfirst:/bin/ash --login
2. 首先,禁止kernel的输出较简单,重新编译镜像前,在make kernel_menuconfig时,选择Kernel hacking ----> 找到Early printk,将其取消选中,保存设置,make编译镜像即可。 http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:debug:early_printk
其他方法(在wr703n中均测试失败,网络上有人测试成功):
1)在编译目录下找到./target/linux/<对应的平台>/config-3.3,找到文件中的CONFIG_CMDLINE去掉console=ttyATH0,115200,或者改成console=none,然后重新编译镜像。
2)因为kernel的message都是printk打印的,可以提高console的message打印级别,将/proc/sys/kernel/printk中第一个值改成0或者1:
- echo 0 > /proc/sys/kernel/printk
- cat /proc/sys/kernel/printk
- 0 4 1 7
或者在/etc/config/system下添加
- option 'conloglevel' '1'
- option 'kconloglevel' '1'
如果使用了后面的设置,前面的printk中的第一个值会被强制设置为system中的值。
- U-Boot 1.1.2 (Dec 14 2005 - 12:12:14)
- U-Boot code: 21F00000 -> 21F1666C BSS: -> 21F1AC44
- RAM Configuration:
- Bank #0: 20000000 32 MB
- Flash: 16 MB
- In: serial
- Out: serial
- Err: serial
- Hit any key to stop autoboot: 0
- U-Boot> setenv bootargs console=none root=/dev/ram
- U-Boot> saveenv
- Saving Environment to Flash...
- Un-Protected 1 sectors
- Erasing Flash...
- . done
- Erased 1 sectors
- Writing to Flash...\done
不同的硬件进入U-Boot的方式不同,像tp的wr703是在出现"Autobooting in 1 seconds"后快速输入tpl。
这种方案可能在某些支持saveenv 的U-Boot中使用,像wr703是不能这样处理的,因为它没有saveenv命令。
如果想使用U-Boot永久性的改变这些环境变量,需要重新编译镜像使得U-Boot所处的flash可写。
在target/linux/ar71xx/files/drivers/mtd/tplinkpart.c修改:
- static struct mtd_partition tl_wr1043nd_partitions[] = {
- {
- .name = "u-boot",
- .offset = 0,
- .size = 0x020000,
- .mask_flags = MTD_WRITEABLE,
- } , {
- .name = "kernel",
- .offset = 0x020000,
- .size = 0x140000,
- } , {
- .name = "rootfs",
- .offset = 0x160000,
- .size = 0x690000,
- } , {
- .name = "art",
- .offset = 0x7f0000,
- .size = 0x010000,
- .mask_flags = MTD_WRITEABLE,
- } , {
- .name = "firmware",
- .offset = 0x020000,
- .size = 0x7d0000,
- }
- };
去掉“u-boot”块中的“.mask_flags = MTD_WRITEABLE”,并重新编译镜像。
在这个阶段没有找到很好的取消serial console输出的方法。需要找到输出文件,挨个取消。
这些配置文件虽然在系统中存在,但是不能修改文件系统的配置,需要在源码中修改并重新编译镜像。
需要修改的一共有6个文件,7个函数。具体列表如下:
1)10_indicate_preinit: preinit_echo和pi_indicate_preinit
2)20_check_jffs2_ready:mount_no_jffs2
3) 30_failsafe_wait:fs_wait_for_key
4) 40_merge_overlay_hooks:merge_overlay_hooks
5) 50_indicate_regular_preinit:indicate_regular_preinit
6) 70_pivot_jffs2_root:rootfs_pivot
具体修改方法如下:
在源码根目录下建立一个新的目录files/lib/preinit/;
在该目录下分别建立包含需重定义函数的文件的副本(注意文件名的数字部分要大于原来的文件):
1)15_indicate_preinit
2)25_check_jffs2_ready
3) 35_failsafe_wait
4) 45_merge_overlay_hooks
5) 55_indicate_regular_preinit
6) 75_pivot_jffs2_root
每个副本中的函数去掉其中的打印语句部分-“echo ***”
然后重新编译镜像。
找到一份可编译的U-Boot源码,这里我使用的是https://code.google.com/p/wr703n-uboot-with-web-failsafe/提供的一个针对wr703n的U-Boot源码。
在代码中找到./u-boot/include/configs/<对应平台> .h,(wr703n对应ar7240.h)定义一个宏: #define CONFIG_SILENT_CONSOLE 1;重新编译U-Boot。
在启动后通过设置U-Boot的环境变量silent=1,再重新启动后即可消除U-Boot的输出。(由于wr703n没有saveenv命令,不能保存环境变量,故而没有测试成功,可以尝试在源码中直接设定silent的值)此种方法同样需要U-Boot可写,方式同2中所述。
介绍详情见:https://github.com/linux-sunxi/u-boot-sunxi 和 U-Boot源码中的/u-boot/doc/README.silent。
附:
1. 用u-boot更新镜像步骤:
1)将pc的IP设定为192.168.1.2, 子网掩码255.255.255.0;并安装tftp服务器,将需要安装的镜像放置在tftp根目录下;
2)用网线将路由器和pc连接起来;在u-boot里操作:(这些命令一般是可行的,有些数据地址可能会随着硬件的不同而不同)
- setenv ipaddr 192.168.1.1
- setenv serverip 192.168.1.2
- tftpboot 0x80000000 openwrt-xxx-generic-xxx-squashfs-factory.bin
- erase 0x9f020000 +0x332004
- cp.b 0x80000000 0x9f020000 0x332004
- boot.m 0x9f020000
2. 更新u-Boot(更新有风险,需谨慎操作)
将编译好的u-boot和一个安装shell文件放在/tmp/目录下,执行shell文件后重新启动即可。shell文件内容如下:
- #! /bin/sh
- UBOOT_NAME=/tmp/tuboot.bin
- RAW_UBOOT_LEN=`wc -c $UBOOT_NAME | awk '{print $1 }'`
- NEED_PAD_LEN=$((0x1fc00-$RAW_UBOOT_LEN))
- #Generate a file used as pad ...
- dd if=/dev/zero of=/tmp/pad.bin bs=1 count=$NEED_PAD_LEN
- cat $UBOOT_NAME /tmp/pad.bin >/tmp/tuboot_0x1fc00.bin
- echo "Backup some config first,just like MAC address ..."
- dd if=/dev/mtd0 of=/tmp/config.bin bs=1 skip=$((0x1fc00))
- cat /tmp/tuboot_0x1fc00.bin /tmp/config.bin >uboot.bin
- cat uboot.bin >/dev/mtdblock0
- sync
3. tftp 工具:http://download.csdn.net/detail/wonengxing/5851839
- <p></p>
版权声明:本文为博主原创文章,未经博主允许不得转载。