openwrt启动过程中

来源:互联网 发布:网站阿里云备案要多久 编辑:程序博客网 时间:2024/06/05 17:58

在openwrt启动过程中,向串口的输出主要有四个部分(如下所示):U-Boot 的输出,kernel的输出,文件系统启动过程中的输出(也是kernel输出的一部分,但是打印语句在系统的配置文件中),系统输出。

[cpp] view plaincopy
  1. U-Boot 1.1.4 (Aug 27 2011 - 10:39:39)  
  2. >  
  3. AP121-2MB (ar9330) U-boot  
  4. >  
  5. DRAM:  32 MB  
  6. led turning on for 1s...  
  7. id read 0x100000ff  
  8. flash size 4194304, sector count = 64  
  9. Flash:  4 MB  
  10. Using default environment  
  11. >  
  12. In:    serial  
  13. Out:   serial  
  14. Err:   serial  
  15. Net:   ag7240_enet_initialize...  
  16. No valid address in Flash. Using fixed address  
  17. No valid address in Flash. Using fixed address  
  18. : cfg1 0x5 cfg2 0x7114  
  19. eth0: 00:03:7f:09:0b:ad  
  20. ag7240_phy_setup  
  21. eth0 up  
  22. : cfg1 0xf cfg2 0x7214  
  23. eth1: 00:03:7f:09:0b:ad  
  24. athrs26_reg_init_lan  
  25. ATHRS26: resetting s26  
  26. ATHRS26: s26 reset done  
  27. ag7240_phy_setup  
  28. eth1 up  
  29. eth0, eth1  
  30. Autobooting in 1 seconds  
  31. ## Booting image at 9f020000 ...  
  32.    Uncompressing Kernel Image ... OK  
  33. >  
  34. Starting kernel ...  

(以上为U-Boot打印)

[cpp] view plaincopy
  1. 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  
  2. bootconsole [early0] enabled  
  3. CPU revision is: 00019374 (MIPS 24Kc)  
  4. SoC: Atheros AR9330 rev 1  
  5. Clocks: CPU:400.000MHz, DDR:400.000MHz, AHB:200.000MHz, Ref:25.000MHz  
  6. Determined physical RAM map:  
  7.  memory: 02000000 @ 00000000 (usable)  
  8. Initrd not found or empty - disabling initrd  
  9. Zone PFN ranges:  
  10.   Normal   0x00000000 -> 0x00002000  
  11. Movable zone start PFN for each node  
  12. early_node_map[1] active PFN ranges  
  13.     0: 0x00000000 -> 0x00002000  
  14. Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 8128  
  15. Kernel command line:  board=TL-WR703N console=ttyATH0,115200 rootfstype=squashfs,jffs2 noinitrd  
  16. PID hash table entries: 128 (order: -3, 512 bytes)  
  17. Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)  
  18. Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)  
  19. Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.  
  20. Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes  
  21. Writing ErrCtl register=00000000  
  22. Readback ErrCtl register=00000000  
  23. Memory: 29376k/32768k available (2009k kernel code, 3392k reserved, 386k data, 180k init, 0k highmem)  
  24. SLUB: Genslabs=9, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1  
  25. NR_IRQS:80  
  26. Calibrating delay loop... 265.42 BogoMIPS (lpj=1327104)  
  27. pid_max: default: 32768 minimum: 301  
  28. Mount-cache hash table entries: 512  
  29. NET: Registered protocol family 16  
  30. MIPS: machine is TP-LINK TL-WR703N v1  
  31. bio: create slab  at 0  
  32. Switching to clocksource MIPS  
  33. NET: Registered protocol family 2  
  34. IP route cache hash table entries: 1024 (order: 0, 4096 bytes)  
  35. TCP established hash table entries: 1024 (order: 1, 8192 bytes)  
  36. TCP bind hash table entries: 1024 (order: 0, 4096 bytes)  
  37. TCP: Hash tables configured (established 1024 bind 1024)  
  38. TCP reno registered  
  39. UDP hash table entries: 256 (order: 0, 4096 bytes)  
  40. UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)  
  41. NET: Registered protocol family 1  
  42. squashfs: version 4.0 (2009/01/31) Phillip Lougher  
  43. JFFS2 version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.  
  44. msgmni has been set to 57  
  45. io scheduler noop registered  
  46. io scheduler deadline registered (default)  
  47. Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled  
  48. ar933x-uart: ttyATH0 at MMIO 0x18020000 (irq = 11) is a AR933X UART  
  49. console [ttyATH0] enabled, bootconsole disabled  
  50. console [ttyATH0] enabled, bootconsole disabled  
  51. Atheros AR71xx SPI Controller driver version 0.2.4  
  52. m25p80 spi0.0: found s25sl032a, expected m25p80  
  53. m25p80 spi0.0: s25sl032a (4096 Kbytes)  
  54. Searching for RedBoot partition table in spi0.0 at offset 0x3e0000  
  55. Searching for RedBoot partition table in spi0.0 at offset 0x3f0000  
  56. No RedBoot partition table detected in spi0.0  
  57. spi0.0: no WRT160NL signature found  
  58. Creating 5 MTD partitions on "spi0.0":  
  59. 0x000000000000-0x000000020000 : "u-boot"  
  60. 0x000000020000-0x000000120000 : "kernel"  
  61. 0x000000120000-0x0000003f0000 : "rootfs"  
  62. mtd: partition "rootfs" set to be root filesystem  
  63. mtd: partition "rootfs_data" created automatically, ofs=2A0000, len=150000  
  64. 0x0000002a0000-0x0000003f0000 : "rootfs_data"  
  65. 0x0000003f0000-0x000000400000 : "art"  
  66. 0x000000020000-0x0000003f0000 : "firmware"  
  67. ag71xx_mdio: probed  
  68. eth0: Atheros AG71xx at 0xb9000000, irq 4  
  69. Atheros AR71xx hardware watchdog driver version 0.1.0  
  70. TCP westwood registered  
  71. NET: Registered protocol family 17  
  72. 802.1Q VLAN Support v1.8 Ben Greear   
  73. All bugs added by David S. Miller   
  74. VFS: Mounted root (squashfs filesystem) readonly on device 31:2.  
  75. Freeing unused kernel memory: 180k freed  
  76. linput: gpio-keys-polled as /devices/platform/gpio-keys-polled/input/input0  
  77. Button Hotplug driver version 0.4.1  

(以上为kernel输出)

[cpp] view plaincopy
  1. - preinit -  
  2. Press the [f] key and hit [enter] to enter failsafe mode  
  3. eth0: link up (100Mbps/Full duplex)  
  4. - regular preinit -  
  5. JFFS2 notice: (371) jffs2_build_xattr_subsystem: complete building xattr subsystem, 17 of xdatum (0 unchecked, 16 orphan) and 30 of xref (0 dead,  
  6.  16 orphan) found.  
  7. switching to jffs2  
  8. - init -  

(以上部分是文件系统输出)

[cpp] view plaincopy
  1. BusyBox v1.18.5 (2011-09-17 19:36:07 CEST) built-in shell (ash)  
  2. Enter 'help' for a list of built-in commands.  
  3. >  
  4.   _______                     ________        __  
  5.  |       |.-----.-----.-----.|  |  |  |.----.|  |_  
  6.  |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|  
  7.  |_______||   __|_____|__|__||________||__|  |____|  
  8.           |__| W I R E L E S S   F R E E D O M  
  9.  ATTITUDE ADJUSTMENT (bleeding edge, r28258) ----------  
  10.   * 1/4 oz Vodka      Pour all ingredients into mixing  
  11.   * 1/4 oz Gin        tin with ice, strain into glass.  
  12.   * 1/4 oz Amaretto  
  13.   * 1/4 oz Triple sec  
  14.   * 1/4 oz Peach schnapps  
  15.   * 1/4 oz Sour mix  
  16.   * 1 splash Cranberry juice  
  17.  -----------------------------------------------------  
  18. 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:
[cpp] view plaincopy
  1. echo 0 > /proc/sys/kernel/printk  
  2. cat /proc/sys/kernel/printk  
  3. 0   4   1   7  

或者在/etc/config/system下添加
[cpp] view plaincopy
  1. option 'conloglevel' '1'  
  2. option 'kconloglevel' '1'  

如果使用了后面的设置,前面的printk中的第一个值会被强制设置为system中的值。


3)还有一种方案是在u-boot中取消console设置,例如:
[cpp] view plaincopy
  1. U-Boot 1.1.2 (Dec 14 2005 - 12:12:14)  
  2. U-Boot code: 21F00000 -> 21F1666C BSS: -> 21F1AC44  
  3. RAM Configuration:  
  4. Bank #0: 20000000 32 MB  
  5. Flash: 16 MB  
  6. In: serial  
  7. Out: serial  
  8. Err: serial  
  9. Hit any key to stop autoboot: 0  
  10. U-Boot> setenv bootargs console=none root=/dev/ram  
  11. U-Boot> saveenv  
  12. Saving Environment to Flash...  
  13. Un-Protected 1 sectors  
  14. Erasing Flash...  
  15. . done  
  16. Erased 1 sectors  
  17. 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修改:
[cpp] view plaincopy
  1. static struct mtd_partition tl_wr1043nd_partitions[] = {  
  2.   {  
  3.     .name   = "u-boot",  
  4.     .offset   = 0,  
  5.     .size   = 0x020000,  
  6.     .mask_flags = MTD_WRITEABLE,  
  7.   } , {  
  8.     .name   = "kernel",  
  9.     .offset   = 0x020000,  
  10.     .size   = 0x140000,  
  11.   } , {  
  12.     .name   = "rootfs",  
  13.     .offset   = 0x160000,  
  14.     .size   = 0x690000,  
  15.   } , {  
  16.     .name   = "art",  
  17.     .offset   = 0x7f0000,  
  18.     .size   = 0x010000,  
  19.     .mask_flags = MTD_WRITEABLE,  
  20.   } , {  
  21.     .name   = "firmware",  
  22.     .offset   = 0x020000,  
  23.     .size   = 0x7d0000,  
  24.   }  
  25. };  

去掉“u-boot”块中的“.mask_flags = MTD_WRITEABLE”,并重新编译镜像。


3。 取消文件系统的输出。
在这个阶段没有找到很好的取消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 ***”

然后重新编译镜像。


4. U-Boot打印部分(没有测试完全)
找到一份可编译的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里操作:(这些命令一般是可行的,有些数据地址可能会随着硬件的不同而不同)
[cpp] view plaincopy
  1. setenv ipaddr 192.168.1.1  
  2. setenv serverip 192.168.1.2  
  3. tftpboot 0x80000000 openwrt-xxx-generic-xxx-squashfs-factory.bin  
  4. erase 0x9f020000 +0x332004  
  5. cp.b 0x80000000 0x9f020000 0x332004  
  6. boot.m 0x9f020000  

2. 更新u-Boot(更新有风险,需谨慎操作)
将编译好的u-boot和一个安装shell文件放在/tmp/目录下,执行shell文件后重新启动即可。shell文件内容如下:
[cpp] view plaincopy
  1. #! /bin/sh  
  2.   
  3.   
  4. UBOOT_NAME=/tmp/tuboot.bin  
  5. RAW_UBOOT_LEN=`wc -c $UBOOT_NAME | awk '{print $1 }'`  
  6. NEED_PAD_LEN=$((0x1fc00-$RAW_UBOOT_LEN))  
  7. #Generate a file used as pad ...  
  8. dd if=/dev/zero of=/tmp/pad.bin bs=1 count=$NEED_PAD_LEN  
  9.   
  10.   
  11. cat $UBOOT_NAME /tmp/pad.bin >/tmp/tuboot_0x1fc00.bin  
  12.   
  13.   
  14. echo "Backup some config first,just like MAC address ..."  
  15. dd if=/dev/mtd0 of=/tmp/config.bin bs=1 skip=$((0x1fc00))  
  16.   
  17.   
  18. cat /tmp/tuboot_0x1fc00.bin /tmp/config.bin >uboot.bin  
  19.   
  20.   
  21. cat uboot.bin >/dev/mtdblock0  
  22.   
  23.   
  24. sync  


3. tftp 工具:http://download.csdn.net/detail/wonengxing/5851839

[cpp] view plaincopy
  1. <p></p>  

版权声明:本文为博主原创文章,未经博主允许不得转载。

0 0
原创粉丝点击