根据log信息解读内核(linux-2.6.32.24)的启动流程

目录

概述

1 从bootloader 到内核部分

2 初始化cache和CPU时钟

3 获取cache和memory信息

4 初始化cache、电源管理和中断

5 初始化USB和I2C

6 网络协议初始化

7 挂载JFFS2文件系统和初始化IO

8 初始化外围device

9 Nand Flash资源分配

10 初始化网络接口

11 注册USB Devices

12 初始化触摸屏驱动

13 RTC、watchdog,sd初始化

14 初始化声卡设备

15 注册网络设备和初始化文件系统

16 挂载根文件系统和进入控制台

17 完整log文件


概述

笔者已经移植该内核到板卡mini2440中,现在该内核已经在mini2440上能正常启动,控制台上也能输入命令,输出log。本文主要以linux-2.6.32.24内核为基础,分析内核在mini2440板卡终端输出的log,分析其启动过程中做了哪些具体的功能,这样能加深对内核的理解。

1 从bootloader 到内核部分

代码1行:显示当前bootloader的信息

代码3行:从nand flash 启动内核

代码4行:加载内核到内存

代码5~6行:解压内核

代码7行:解压内核成功,得到内核版本,编译器版本等内容

2 初始化cache和CPU时钟

代码9行: 得到ARM内核信息

代码10行:开启数据cache和指令cache

代码11行:得到机器号

代码12行:提示bootloader太老了,这里不去管它,只要内核能正常启动就行

代码13行:关闭ECC,回写数据cache

代码15行:得到CPU ID

代码16行:初始化Clock

代码17行:配置时钟频率,外围资源的工作时钟

代码18行:使能锁相环

代码19行:建立系统内存页区(zone)链表和分配CPU 内的页面表

3 获取cache和memory信息

代码22行: console解析命令功能初始化

代码23行: 得到PID hash table信息

代码24行: 得到dentry-cache信息

代码25行: 得到Inode-cache信息

代码26行:得到内存的空间

4 初始化cache、电源管理和中断

代码32行:清除中断挂起状态

代码34行:控制台谁出功能使能

代码36行:挂载hash table

代码37行:测试写数据功能

代码38行:注册网络协议族

代码39行:初始化S3C2440电源管理模块

代码40行:初始化S3C2440 系统架构

代码41行:初始化S3C2440 IRQ中断模块

代码42~46行:初始化S3C2440 DMA驱动模块

5 初始化USB和I2C

代码50~52行:注册USB driver

代码53~55行:初始化S3C2440 I2C设备

6 网络协议初始化

代码58行:分配IP协议cache

代码59~62行:分配TCP协议cache

代码63~66行:注册TCP和UDP协议

7 挂载JFFS2文件系统和初始化IO

代码68行:得到JFFS2文件系统的版本

代码71~75行:初始化IO调度表

8 初始化外围device

代码79行:lcd 背光驱动初始化

代码80行:adc驱动初始化

代码82行:pwm驱动初始化

代码83行:leds驱动初始化

代码84~86行:串口驱动初始化

9 Nand Flash资源分配

代码89~92行:初始化nandflash,获取nand flash的相关参数

代码94~97行:分配nand flash内部空间

10 初始化网络接口

代码102行:初始化dm9000驱动

代码103行:配置MAC地址

11 注册USB Devices

代码105~113行:注册USB设备协议栈

代码114行:注册设备信息

12 初始化触摸屏驱动

代码116行:初始化触摸屏驱动

代码117行:背景灯初始化

代码118行:加载驱动

代码119行:触摸屏功能使能

13 RTC、watchdog,sd初始化

代码121~124行:rtc初始化

代码125行:i2c设备使能

代码126~127行:watch dog初始化

代码130~139行:sd卡设备初始化

代码140~142行:注册USB设备

14 初始化声卡设备

代码144行:得到声卡的信息

代码147~149行:初始化声卡设备

15 注册网络设备和初始化文件系统

代码153行:注册TCP协议栈

代码156~157行:yaffs文件系统和设备已经绑定起来

代码158~160行:sdi接口已经正常工作

代码161~163行:sd卡初始化完成,已经能识别SD的内存信息

16 挂载根文件系统和进入控制台

代码156行:挂载根文件系统

代码169~172行:系统时间初始化

代码174行:网络连接成功

代码177行:控制台输入使能提示信息

代码179行:进入控制台

17 完整log文件

 log文件内容:

Superboot-2440 V1.5(20150414) by FriendlyARM

Booting from NAND
Load Kernel...
Uncompressing Linux....................................................................
.............................................................. done, booting the kernel.
Linux version 2.6.32.24 (mftang@mftang-HP-350-G1) (gcc version 4.4.3 (ctng-1.6.1) ) #25 Thu Mar 21 10:00:48 CST 2024

CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: MFTANG_MINI2440
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback

CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256


Kernel command line: noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60572KB available (3656K code, 419K data, 132K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.

NR_IRQS:85
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0

usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter

NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.

JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 118
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered

Console: switching to colour frame buffer device 120x45
fb0: s3c2410fb frame buffer device
backlight       initialized
adc     initialized
pwm     initialized
leds    initialized
buttons initialized
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded

S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "supervivi"
0x000000040000-0x000000060000 : "param"
0x000000060000-0x000000560000 : "Kernel"
0x000000560000-0x000040560000 : "root"
mtd: partition "root" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0xfaa0000
0x000000000000-0x000040000000 : "nand"
mtd: partition "nand" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0x10000000

dm9000 Ethernet Driver, V1.31
eth0: dm9000e at c4872300,c4876304 IRQ 51 MAC: 08:90:90:90:90:90 (platform data)

ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
s3c2440-usbgadget s3c2440-usbgadget: S3C2440: increasing FIFO to 128 bytes
mice: PS/2 mouse device common for all mice

touchscreen-1wire       initialized
backlight-1wire initialized
s3c2410 TouchScreen successfully loaded
input: s3c2410 TouchScreen as /devices/virtual/input/input0

S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
one_wire_status: 5
s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdi s3c2440-sdi: powered down.
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
s3c-sdi s3c2440-sdi: running at 0kHz (requested: 0kHz).
s3c-sdi s3c2440-sdi: running at 398kHz (requested: 400kHz).
s3c-sdi s3c2440-sdi: running at 398kHz (requested: 400kHz).
s3c-sdi s3c2440-sdi: running at 398kHz (requested: 400kHz).
s3c-sdi s3c2440-sdi: running at 398kHz (requested: 400kHz).
s3c-sdi s3c2440-sdi: running at 398kHz (requested: 400kHz).
s3c-sdi s3c2440-sdi: running at 398kHz (requested: 400kHz).
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver

Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI UDA134X
No device for DAI s3c24xx-i2s 
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: UDA134X <-> s3c24xx-i2s mapping ok
ALSA device list:
  #0: S3C24XX_UDA134X (UDA134X)

TCP cubic registered
NET: Registered protocol family 17
s3c2410-rtc s3c2410-rtc: hctosys: invalid date/time
yaffs: dev is 32505859 name is "mtdblock3" rw
yaffs: passed flags ""
s3c-sdi s3c2440-sdi: running at 398kHz (requested: 400kHz).
s3c-sdi s3c2440-sdi: running at 16875kHz (requested: 25000kHz).
s3c-sdi s3c2440-sdi: running at 16875kHz (requested: 25000kHz).
mmc0: new SD card at address e624
mmcblk0: mmc0:e624 SD02G 1.84 GiB
mmcblk0: p1

VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing init memory: 132K
FAT: codepage cp437 not found
FAT: codepage cp437 not found
hwclock: settimeofday() failed: Invalid argument
[01/Jan/1970:00:00:17 +0000] boa: server version Boa/0.94.13
[01/Jan/1970:00:00:17 +0000] boa: server built Jul 26 2010 at 15:58:29.
[01/Jan/1970:00:00:17 +0000] boa: starting server pid=787, port 80

Try to bring eth0 interface up......eth0: link down
Done

Please press Enter to activate this console. eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1

[root@FriendlyARM /]#

  • 31
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值