在合众达板子上,进入合众达提供的内核源码树目录下执行如下命令,配置内核为合众达出厂配置(这是一种考虑尽量多兼容性的配置) $make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- SEED_DIM3517_defconfig 用如下命令编译出默认内核 $make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage 现在你可以试用一下默认内核感受一下内核的启动速度 如果你觉得内核的启动速度已经可以接受,则可以跳过下面的内容。 如果你认为速度还需要进一步改善,请接着往下看。 这时打开内核的printktimes选项。按下面两个图操作始可
重新生成uImage, 并用新的uImage文件启动。 按照在7楼的说法得到内核中各个模块启动时间如下。 [975.592071 < 0.035187 >] bio: create slab <bio-0> at 0 [975.594665 < 0.002594 >] SCSI subsystem initialized [975.596405 < 0.001740 >] usbcore: registered new interface driver usbfs [975.596893 < 0.000488 >] usbcore: registered new interface driver hub [975.597229 < 0.000336 >] usbcore: registered new device driver usb [975.598419 < 0.001190 >] i2c_omap i2c_omap.1: bus 1 rev3.12 at 400 kHz [975.600860 < 0.002441 >] regulator: VDCDC1: 1200 mV normal [975.601531 < 0.000671 >] regulator: VDCDC2: 3300 mV normal [975.602111 < 0.000580 >] regulator: VDCDC3: 1800 mV normal [975.602691 < 0.000580 >] regulator: LDO1: 1800 mV normal [975.603302 < 0.000611 >] regulator: LDO2: 3300 mV normal [975.603790 < 0.000488 >] i2c_omap i2c_omap.2: bus 2 rev3.12 at 400 kHz [975.615753 < 0.011963 >] pca953x 2-0021: failed reading register [975.615814 < 0.000061 >] pca953x: probe of 2-0021 failed with error -5 [975.631347 < 0.015533 >] i2c_omap i2c_omap.3: bus 3 rev3.12 at 400 kHz [975.646972 < 0.015625 >] tca6416-keypad 3-0020: failed reading register [975.647003 < 0.000031 >] tca6416-keypad: probe of 3-0020 failed with error -5 [975.647369 < 0.000366 >] pca953x 3-0021: failed reading register [975.647399 < 0.000030 >] pca953x: probe of 3-0021 failed with error -5 [975.649597 < 0.002198 >] Switching to clocksource 32k_counter [975.652587 < 0.002990 >] musb_hdrc: version 6.0, cppi4.1-dma, otg (peripheral+host), debug=0 [975.673583 < 0.020996 >] AM3517 OTG revision 4ea41001, PHY f0036a2, control 00 [975.673980 < 0.000397 >] musb_hdrc: ConfigData=0x1e (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn) [975.674011 < 0.000031 >] musb_hdrc: MHDRC RTL version 1.900 [975.674041 < 0.000030 >] musb_hdrc: setup fifo_mode 4 [975.674072 < 0.000031 >] musb_hdrc: 28/31 max ep, 16384/32768 memory [975.674133 < 0.000061 >] musb_hdrc: USB OTG mode controller at c8810000 using DMA, IRQ 71 [975.674957 < 0.000824 >] NET: Registered protocol family 2 [975.675170 < 0.000213 >] IP route cache hash table entries: 1024 (order: 0, 4096 bytes) [975.675750 < 0.000580 >] TCP established hash table entries: 4096 (order: 3, 32768 bytes) [975.675903 < 0.000153 >] TCP bind hash table entries: 4096 (order: 2, 16384 bytes) [975.675994 < 0.000091 >] TCP: Hash tables configured (established 4096 bind 4096) [975.676025 < 0.000031 >] TCP reno registered [975.676025 < 0.000000 >] UDP hash table entries: 256 (order: 0, 4096 bytes) [975.676086 < 0.000061 >] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes) [975.676300 < 0.000214 >] NET: Registered protocol family 1 [975.676757 < 0.000457 >] RPC: Registered udp transport module. [975.676757 < 0.000000 >] RPC: Registered tcp transport module. [975.676788 < 0.000031 >] RPC: Registered tcp NFSv4.1 backchannel transport module. [975.677612 < 0.000824 >] AM3517 Linux PSP version 03.00.01.06 (AM3517EVM) [975.677642 < 0.000030 >] NetWinder Floating Point Emulator V0.97 (double precision) [975.679718 < 0.002076 >] VFS: Disk quotas dquot_6.5.2 [975.679809 < 0.000091 >] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) [975.681152 < 0.001343 >] Installing knfsd (copyright (C) 1996 okir@monad.swb.de). [975.681915 < 0.000763 >] JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc. [975.682556 < 0.000641 >] yaffs Jul 21 2011 23:38:33 Installing. [975.682647 < 0.000091 >] msgmni has been set to 234 [975.684478 < 0.001831 >] alg: No test for stdrng (krng) [975.684570 < 0.000092 >] io scheduler noop registered [975.684600 < 0.000030 >] io scheduler deadline registered [975.684783 < 0.000183 >] io scheduler cfq registered (default) [975.743713 < 0.058930 >] OMAP DSS rev 2.0 [975.743774 < 0.000061 >] OMAP DISPC rev 3.0 [975.743835 < 0.000061 >] OMAP VENC rev 2 [975.744262 < 0.000427 >] OMAP DSI rev 1.0 [976.093170 < 0.348908 >] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled [976.115844 < 0.022674 >] serial8250.0: ttyS0 at MMIO 0x4806a000 (irq = 72) is a ST16654 [976.136901 < 0.021057 >] serial8250.1: ttyS1 at MMIO 0x4806c000 (irq = 73) is a ST16654 [976.157775 < 0.020874 >] serial8250.2: ttyS2 at MMIO 0x49020000 (irq = 74) is a ST16654 [976.640075 < 0.482300 >] console [ttyS2] enabled [976.655975 < 0.015900 >] brd: module loaded [976.665496 < 0.009521 >] loop: module loaded [976.669799 < 0.004303 >] omap2-nand driver initializing [976.674407 < 0.004608 >] NAND device: Manufacturer ID: 0xec, Chip ID: 0xdc (Samsung NAND 512MiB 3,3V 8-bit) [976.683166 < 0.008759 >] Creating 5 MTD partitions on "omap2-nand.0": [976.688537 < 0.005371 >] 0x000000000000-0x000000080000 : "xloader-nand" [976.696075 < 0.007538 >] 0x000000080000-0x000000240000 : "uboot-nand" [976.703582 < 0.007507 >] 0x000000240000-0x000000280000 : "params-nand" [976.710388 < 0.006806 >] 0x000000280000-0x000000780000 : "linux-nand" [976.719055 < 0.008667 >] 0x000000780000-0x000020000000 : "jffs2-nand" [976.934783 < 0.215728 >] vcan: Virtual CAN interface driver [976.939331 < 0.004548 >] CAN device driver interface [976.943206 < 0.003875 >] TI High End CAN Controller Driver 0.7 [976.948028 < 0.004822 >] failed to get can_stb [976.952362 < 0.004334 >] ti_hecc ti_hecc.1: device registered (reg_base=c8870000, irq=24) [976.960357 < 0.007995 >] usbcore: registered new interface driver hwa-rc [976.966766 < 0.006409 >] usbmon: debugfs is not available [976.971130 < 0.004364 >] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [976.977783 < 0.006653 >] ~~~~~~~~~~~~~~~~~~~~~0!!!!!!!!!!!~~~~~~~~~` [976.983093 < 0.005310 >] ~~~~~~~~~~~~~~~~~~~~~1!!!!!!!!!!!~~~~~~~~~` [976.988555 < 0.005462 >] ehci-omap ehci-omap.0: OMAP-EHCI Host Controller [976.994445 < 0.005890 >] ehci-omap ehci-omap.0: new USB bus registered, assigned bus number 1 [977.002136 < 0.007691 >] ehci-omap ehci-omap.0: irq 77, io mem 0x48064800 [977.016937 < 0.014801 >] ehci-omap ehci-omap.0: USB 2.0 started, EHCI 1.00 [977.023925 < 0.006988 >] hub 1-0:1.0: USB hub found [977.027801 < 0.003876 >] hub 1-0:1.0: 3 ports detected [977.056243 < 0.028442 >] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [977.062957 < 0.006714 >] usbcore: registered new interface driver hwa-hc [977.069000 < 0.006043 >] usbcore: registered new interface driver wusb-cbaf [977.074920 < 0.005920 >] Initializing USB Mass Storage driver... [977.080230 < 0.005310 >] usbcore: registered new interface driver usb-storage [977.086273 < 0.006043 >] USB Mass Storage support registered. [977.091033 < 0.004760 >] g_ether gadget: using random self ethernet address [977.096954 < 0.005921 >] g_ether gadget: using random host ethernet address [977.103607 < 0.006653 >] usb0: MAC 2a:eb:77:58:8e:fb [977.107482 < 0.003875 >] usb0: HOST MAC 8e:c8:d7:06:a7:9f [977.111907 < 0.004425 >] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008 [977.118591 < 0.006684 >] g_ether gadget: g_ether ready [977.122650 < 0.004059 >] musb_hdrc musb_hdrc: MUSB HDRC host driver [977.127929 < 0.005279 >] musb_hdrc musb_hdrc: new USB bus registered, assigned bus number 2 [977.136474 < 0.008545 >] hub 2-0:1.0: USB hub found [977.140289 < 0.003815 >] hub 2-0:1.0: 1 port detected [977.145568 < 0.005279 >] mice: PS/2 mouse device common for all mice [977.151184 < 0.005616 >] tsc2003 init [977.153900 < 0.002716 >] tsc2003 probe [977.156585 < 0.002685 >] mux: Setting signal mcspi1_cs2.gpio176 0x0114 -> 0x011c [977.156616 < 0.000031 >] tsc2003 begin [977.159454 < 0.002838 >] GPIO176 irqqq :336 [977.162963 < 0.003509 >] input: tsc2003 as /class/input/input0 [977.212280 < 0.049317 >] tsc2003 x:-5 y:-5 z:-5 bate:-5 [977.419555 < 0.207275 >] rtc-s35390a 1-0030: error resetting chip [977.426361 < 0.006806 >] rtc-s35390a: probe of 1-0030 failed with error -5 [977.432525 < 0.006164 >] Linux video capture interface: v2.00 [977.437622 < 0.005097 >] vpfe_init [977.440124 < 0.002502 >] vpfe-capture vpfe-capture: v4l2 device registered [977.446350 < 0.006226 >] vpfe-capture vpfe-capture: video device registered [977.452911 < 0.006561 >] tvp514x 3-005c: tvp514x 3-005c decoder driver registered !! [977.459655 < 0.006744 >] vpfe-capture vpfe-capture: v4l2 sub device tvp5146 registered [977.466827 < 0.007172 >] vpfe_register_ccdc_device: DM6446 CCDC [977.471832 < 0.005005 >] DM6446 CCDC is registered with vpfe. [977.477508 < 0.005676 >] OMAP Watchdog Timer Rev 0x31: initial timeout 60 sec [977.484954 < 0.007446 >] mmci-omap-hs mmci-omap-hs.1: err -16 configuring card detect [977.493164 < 0.008210 >] usbcore: registered new interface driver usbhid [977.498840 < 0.005676 >] usbhid: USB HID core driver [977.503112 < 0.004272 >] Advanced Linux Sound Architecture Driver Version 1.0.21. [977.512542 < 0.009430 >] No device for DAI AD73311 [977.516479 < 0.003937 >] Asahi Kasei AK4104 ALSA SoC Codec Driver [977.521820 < 0.005341 >] No device for DAI AK4535 [977.526000 < 0.004180 >] Cirrus Logic CS4270 ALSA SoC Codec Driver [977.531311 < 0.005311 >] No device for DAI PCM3008 HiFi [977.536804 < 0.005493 >] No device for DAI SSM2602 [977.540588 < 0.003784 >] No device for DAI tlv320aic23 [977.657623 < 0.117035 >] mmc0: new high speed SD card at address 6919 [977.663635 < 0.006012 >] mmcblk0: mmc0:6919 SD02G 1.83 GiB [977.668487 < 0.004852 >] mmcblk0: p1 p2 [977.993530 < 0.325043 >] No device for DAI tlv320aic3x [977.998107 < 0.004577 >] No device for DAI UDA134X [978.002105 < 0.003998 >] No device for DAI WM8510 HiFi [978.007354 < 0.005249 >] No device for DAI WM8728 [978.011505 < 0.004151 >] No device for DAI WM8750 [978.016510 < 0.005005 >] No device for DAI WM8971 [978.021636 < 0.005126 >] No device for DAI WM8990 ADC/DAC Primary [978.027679 < 0.006043 >] No device for DAI omap-mcbsp-dai-0 [978.032135 < 0.004456 >] No device for DAI omap-mcbsp-dai-1 [978.036712 < 0.004577 >] No device for DAI omap-mcbsp-dai-2 [978.041229 < 0.004517 >] No device for DAI omap-mcbsp-dai-3 [978.045684 < 0.004455 >] No device for DAI omap-mcbsp-dai-4 [978.050170 < 0.004486 >] OMAP3517 / AM3517 EVM SoC init [978.056335 < 0.006165 >] asoc: tlv320aic3x <-> omap-mcbsp-dai-0 mapping ok [978.063140 < 0.006805 >] Failed to add route IN1L->LINE1L [978.067504 < 0.004364 >] dapm: tlv320aic3x: configuring unknown pin Line Out [978.080322 < 0.012818 >] ALSA device list: [978.083312 < 0.002990 >] #0: am3517evm (tlv320aic3x) [978.087646 < 0.004334 >] TCP cubic registered [978.090911 < 0.003265 >] NET: Registered protocol family 17 [978.095458 < 0.004547 >] NET: Registered protocol family 15 [978.099975 < 0.004517 >] can: controller area network core (rev 20090105 abi 8) [978.106353 < 0.006378 >] NET: Registered protocol family 29 [978.110931 < 0.004578 >] can: raw protocol (rev 20090105) [978.115203 < 0.004272 >] can: broadcast manager protocol (rev 20090105 t) [978.121582 < 0.006379 >] Power Management for TI OMAP3. [978.125976 < 0.004394 >] Disabling unused clock "emac_fck" [978.125976 < 0.000000 >] Disabling unused clock "emac_ick" [978.126007 < 0.000031 >] Disabling unused clock "mcbsp_fck" [978.126037 < 0.000030 >] Disabling unused clock "mcbsp_fck" [978.126037 < 0.000000 >] Disabling unused clock "mcbsp_fck" [978.126068 < 0.000031 >] Disabling unused clock "mcbsp_ick" [978.126098 < 0.000030 >] Disabling unused clock "mcbsp_ick" [978.126098 < 0.000000 >] Disabling unused clock "mcbsp_ick" [978.126129 < 0.000031 >] Disabling unused clock "gpt2_ick" [978.126129 < 0.000000 >] Disabling unused clock "gpt3_ick" [978.126159 < 0.000030 >] Disabling unused clock "gpt4_ick" [978.126159 < 0.000000 >] Disabling unused clock "gpt5_ick" [978.126190 < 0.000031 >] Disabling unused clock "gpt6_ick" [978.126220 < 0.000030 >] Disabling unused clock "gpt7_ick" [978.126220 < 0.000000 >] Disabling unused clock "gpt8_ick" [978.126251 < 0.000031 >] Disabling unused clock "gpt9_ick" [978.126251 < 0.000000 >] Disabling unused clock "wdt3_ick" [978.126281 < 0.000030 >] Disabling unused clock "wdt3_fck" [978.126342 < 0.000061 >] Disabling unused clock "gpio2_dbck" [978.126373 < 0.000031 >] Disabling unused clock "gpio3_dbck" [978.126373 < 0.000000 >] Disabling unused clock "gpio4_dbck" [978.126403 < 0.000030 >] Disabling unused clock "gpio5_dbck" [978.126403 < 0.000000 >] Disabling unused clock "gpio6_dbck" [978.126434 < 0.000031 >] Disabling unused clock "gpt9_fck" [978.126464 < 0.000030 >] Disabling unused clock "gpt8_fck" [978.126464 < 0.000000 >] Disabling unused clock "gpt7_fck" [978.126495 < 0.000031 >] Disabling unused clock "gpt6_fck" [978.126495 < 0.000000 >] Disabling unused clock "gpt5_fck" [978.126525 < 0.000030 >] Disabling unused clock "gpt4_fck" [978.126525 < 0.000000 >] Disabling unused clock "gpt3_fck" [978.126556 < 0.000031 >] Disabling unused clock "gpt2_fck" [978.126556 < 0.000000 >] Disabling unused clock "gpt12_ick" [978.126586 < 0.000030 >] Disabling unused clock "wdt1_ick" [978.126617 < 0.000031 >] Disabling unused clock "gpio1_dbck" [978.126617 < 0.000000 >] Disabling unused clock "mcbsp_ick" [978.126647 < 0.000030 >] Disabling unused clock "mcbsp_ick" [978.126678 < 0.000031 >] Disabling unused clock "gpt10_ick" [978.126678 < 0.000000 >] Disabling unused clock "gpt11_ick" [978.126708 < 0.000030 >] Disabling unused clock "mcspi_ick" [978.126708 < 0.000000 >] Disabling unused clock "mcspi_ick" [978.126739 < 0.000031 >] Disabling unused clock "mcspi_ick" [978.126770 < 0.000031 >] Disabling unused clock "mcspi_ick" [978.126770 < 0.000000 >] Disabling unused clock "hdq_ick" [978.126800 < 0.000030 >] Disabling unused clock "hdq_fck" [978.126800 < 0.000000 >] Disabling unused clock "mcspi_fck" [978.126831 < 0.000031 >] Disabling unused clock "mcspi_fck" [978.126831 < 0.000000 >] Disabling unused clock "mcspi_fck" [978.126861 < 0.000030 >] Disabling unused clock "mcspi_fck" [978.126861 < 0.000000 >] Disabling unused clock "mcbsp_fck" [978.126892 < 0.000031 >] Disabling unused clock "mcbsp_fck" [978.126922 < 0.000030 >] Disabling unused clock "gpt11_fck" [978.126922 < 0.000000 >] Disabling unused clock "gpt10_fck" [978.126953 < 0.000031 >] Disabling unused clock "dpll4_m6x2_ck" [978.126983 < 0.000030 >] Disabling unused clock "dpll4_m5x2_ck" [978.126983 < 0.000000 >] Disabling unused clock "dpll3_m3x2_ck" [978.127014 < 0.000031 >] Disabling unused clock "sys_clkout1" [978.127593 < 0.000579 >] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 1 [978.151489 < 0.023896 >] Console: switching to colour frame buffer device 100x30 [978.239227 < 0.087738 >] omapdss DPI: Could not find exact pixel clock. Requested 35087 kHz, got 35086 kHz [978.250549 < 0.011322 >] davinci_emac_probe: using random MAC addr: 4e:14:cb:c5:2f:c9 [978.260040 < 0.009491 >] emac-mii: probed [978.263214 < 0.003174 >] drivers/rtc/hctosys.c: unable to open rtc device (rtc0) [978.269744 < 0.006530 >] omapdss DPI error: display already enabled [978.274932 < 0.005188 >] omap_vout omap_vout: 'lcd' Display already enabled [978.280822 < 0.005890 >] omapdss DPI error: display already enabled [978.286010 < 0.005188 >] omap_vout omap_vout: 'lcd' Display already enabled [978.291931 < 0.005921 >] omap_vout omap_vout: Buffer Size = 3686400 [978.298675 < 0.006744 >] omap_vout omap_vout: : registered and initialized video device 1 [978.305816 < 0.007141 >] omap_vout omap_vout: Buffer Size = 3686400 [978.312561 < 0.006745 >] omap_vout omap_vout: : registered and initialized video device 2 [978.823852 < 0.511291 >] eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=ffffffff:00, id=221613) [979.837310 < 1.013458 >] Sending DHCP and RARP requests ...... timed out! [1054.362609 < 74.525299 >] IP-Config: Reopening network devices... [1054.869781 < 0.507172 >] eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=ffffffff:00, id=221613) [1055.884124 < 1.014343 >] Sending DHCP and RARP requests ...... timed out! [1131.878112 < 75.993988 >] IP-Config: Auto-configuration of network failed. [1134.965942 < 3.087830 >] Empty flash at 0x00c5f3e4 ends at 0x00c5f800 [1137.241119 < 2.275177 >] Empty flash at 0x1ae5d108 ends at 0x1ae5d800 [1137.671966 < 0.430847 >] VFS: Mounted root (jffs2 filesystem) on device 31:4. [1137.678161 < 0.006195 >] Freeing init memory: 168K [1139.638549 < 1.960388 >] JFFS2 notice: (596) check_node_data: wrong data CRC in data node at 0x1ae5cfac: read 0x2efd2e64, calculated 0x5fa9cf47. [1143.775421 < 4.136872 >] yaffs: dev is 187695104 name is "mmcblk0" [1143.780517 < 0.005096 >] yaffs: passed flags "" [1143.783996 < 0.003479 >] yaffs: Attempting MTD mount on 179.0, "mmcblk0" [1143.938781 < 0.154785 >] yaffs: dev is 187695104 name is "mmcblk0" [1143.944000 < 0.005219 >] yaffs: passed flags "" [1143.947448 < 0.003448 >] yaffs: Attempting MTD mount on 179.0, "mmcblk0" [1145.161468 < 1.214020 >] EXT2-fs (mmcblk0p2): warning: mounting ext3 filesystem as ext2 [1145.168579 < 0.007111 >] EXT2-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsck is recommended 首先我们发现最浪费时间的在试图动态获得网络IP那一块。然后第二多的就是各种文件系统初始化花费的时间。 作为一款Cortex-A8产品,TI的AM3517在基本的代码运行方面可以说表现得非常出色。不需要做太多的优化。 那前面提到的IP获取那一块,及文件系统方面问题怎么解决呢。 网络,请在内核配置里关掉相关的动态获取IP的选择,对于嵌入式产品通常这是用不到的,而这里的慢,也正是因为实质上没有提供DHCP服务器。 当然,如果能进一步优化一下网络PHY那一块的代码,使得驱动只汇报有一个PHY, 也会快不少。 eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=ffffffff:00, id=221613) (这是合众达优化前检测PHY的地址,导致系统后面按照32个PHY去做DHCP请求,显然会是超慢的) eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=1:00, id=221613 (这是合众达优化后的情况,系统正确的识别了只有一个PHY,这样后面的检测自然会快很多) 文件系统,只保留你用得到的,其它的都关掉吧。比如上面的同时启用Flash的JFFS2和YAFFS2, 实际的产品中是不可能同时使用两种文件系统的,除非板子上即用了Nor Flash又使用了NAND Flash 这是内核方面的问题。 后面我们将继续讲述,UBoot加载内核时发生的情况。