嵌入式linux系统的启动过程

一、启动过程

上电---->向执行U-boot---->加载内核到内存,并启动内核---->挂载根文件系统---->执行脚本、应用程序,进入shell命令行

二、U-boot

1.什么是U-boot
是一个通用的bootloader
boot----完成硬件的初始化
loader—加载操作系统内核,并启动
源码下载地址
ftp://ftp.denx.de/pub/u-boot
通用----支持尽可能多的处理器 ,ARM MIPS POWERPC X86
----启动尽可能多的操作系统,linux wince vxworks
U-boot的作用
(1)stage 1:芯片级别的初始化,cpu的初始化-----汇编语言
初始化cache MMU wdt 中断、时钟…
(2)stage 2:板级初始化------C语言
UART 网卡、USB、LCD…

准备内核启动的参数
加载内核,并启动内核

2.u-boot的输出信息
(1)U-Boot 2014.07 (Nov 19 2017 - 09:52:45)-----U-boot版本
时钟的初始化
PLL : [0] = 800000000, [1] = 800000000, [2] = 780000000, [3] = 800000000
(0) PLL1: CPU FCLK = 800000000, HCLK = 200000000 (G0)
(7) PLL1: CPU FCLK = 800000000, HCLK = 200000000 (G1)
(2) PLL3: MEM FCLK = 800000000, DCLK = 800000000, BCLK = 400000000, PCLK = 200000000
(1) PLL0: BUS BCLK = 400000000, PCLK = 200000000
(8) PLL0: CCI4 BCLK = 400000000, PCLK = 200000000
(3) PLL0: G3D BCLK = 400000000
(4) PLL0: CODA BCLK = 400000000, PCLK = 200000000
(5) PLL0: DISP BCLK = 400000000, PCLK = 200000000
(6) PLL0: HDMI PCLK = 133333333

I2C: ready
DRAM: 1 GiB----内存大小1GB
Heap = 0x44000000~0x46000000
Code = 0x43c00000~0x43c83e48
GLD = 0x43bffeb8
GLBD = 0x43bffe68
SP = 0x43bffe68,0x43bffe48(CURR)
PC = 0x43c066f0
TAGS = 0x40000100
PAGE = 0x43c90000~0x43c9c00

MACH = [4330]
VER = 0
BOARD= [GEC6818]
MMC: NXP DWMMC: 0, NXP DWMMC: 1, NXP DWMMC: 2
In: serial
Out: serial
Err: serial
DCDC_MODE(0x80): DCDC1[PFM], DCDC2[PFM], DCDC3[PFM], DCDC4[PWM], DCDC5[PWM]
STATUS(0x00) : 0xe4 0x10
IRQ(0x48) : 0x00 0x00 0x00 0x00 0x00
CHG_TYPE : ADP
BAT_VOL : 0mV
BAT_CAP : 100%
DONE: Logo bmp 300 by 300 (3bpp), len=270056
DRAW: 0x47000000 -> 0x46000000
DONE: Logo bmp 300 by 300 (3bpp), len=270056
DRAW: 0x47000000 -> 0x46000000
RGB: display.0
MIPI: display.0
DSIM_ESCMODE 1 : 0xc0
DSIM_STATUS : 0x10010f
MIPI clk: 420MHz
DSIM_ESCMODE 2 : 0x0
DSIM_STATUS : 0x10010f
##Skip BAT Animation.
##IRQ(0x48) : 0x00 0x00 0x00 0x00 0x00
##chg_type : ADP
##battery_vol : 0mV
##battery_cap : 100%
##Booting
Card did not respond to voltage select!
Net: GEC6818 mac init…
dwmac.c0060000
3.U-boot命令的使用
(1)GEC6818# ? 或 help
? - alias for ‘help’
(2)
bdinfo - print Board Info structure
GEC6818# bdinfo
arch_number = 0x000010EA----开发板的ID,要与linux内核源码中开发板的ID一致
boot_params = 0x40000100----启动参数放在0x40000100(内存起始地址+0x100)
DRAM bank = 0x00000000
-> start = 0x40000000-----内存的起始地址
-> size = 0x40000000-----大小,结束地址是?0x7FFFFFFF
eth0name = dwmac.c0060000----网卡的名字
ethaddr = 00:e2:1c:ba:e8:60—MAC地址
current eth = dwmac.c0060000
ip_addr = 192.168.90.6----开发板的IP
baudrate = 115200 bps
TLB addr = 0x7FFF0000
relocaddr = 0x46000000
reloc off = 0x00000000
irq_sp = 0x7DF6BF00
sp start = 0x43BFFE68

(3)printenv 打印环境变量
GEC6818# printenv
bootargs=lcd=at070tn92 tp=gslx680-linux root=/dev/mmcblk0p2 rw rootfstype=ext4
告诉内核一些信息:
lcd=at070tn92----LCD屏型号
tp=gslx680-linux—触摸屏型号
root=/dev/mmcblk0p2—告诉内核,根文件系统在EMMC的第2个分区
rw----可读可写
rootfstype=ext4----根文件系统的类型是ext4

bootcmd=ext4load mmc 2:1 0x48000000 uImage;bootm 0x48000000
ext4load mmc 2:1 0x48000000 uImage--------u-boot执行到最后,以ext4格式从EMMC的第二个分区把内核镜像加载到内存的0x48000000处
bootm 0x48000000----启动0x48000000处的内核
setenv bootcmd “xxx;yyy”
bootdelay=3----启动内核前的倒计时
gatewayip=192.168.90.1
ipaddr=192.168.90.6
netmask=255.255.255.0
serverip=192.168.90.2

(4)setenv----设置环境变量
setenv bootdelay 5
GEC6818# setenv bootdelay 5
GEC6818# saveenv
Saving Environment to MMC…
Writing to MMC(2)… done

(5)tftp
GEC6818# tftp 0x50000000 tftpd32.ini
把文件tftpd32.ini 下载到内存的0x50000000
前提:setenv serverip 192.168.11.xxx

(6)go
go 0x40000000 去到内存的0x40000000处,执行指令

(7)ping
GEC6818# ping 192.168.11.3
Speed: 1000, full duplex
Using dwmac.c0060000 device
host 192.168.11.3 is alive

(8)reset

三、linux内核

1.linux内核的作用
(1)进程的管理和通信
(2)内存的管理
(3)文件的管理
(4)设备驱动的管理
(5)网络通信–TCP/IP
https://mirrors.edge.kernel.org/pub/linux/kernel/
2.Linux内核的输出信息
(1)U-Boot加载内核镜像,打印内核镜像相关信息
Booting kernel from Legacy Image at 48000000 …
Image Name: Linux-3.4.39-1862----
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 5532560 Bytes = 5.3 MiB
Load Address: 40008000
Entry Point: 40008000
Verifying Checksum … OK
Loading Kernel Image … OK

Linux-3.4.39-1862----版本号
3.—主版本号
4—次版本号----偶数:稳定版 ;奇数:开发版
39—修订版本号
1862—扩展版本号

(2)启动内核
Starting kernel …

(3)划分内存分区(虚拟内存)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
[ 0.000000] vmalloc : 0xef800000 - 0xfee00000 ( 246 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xef600000 ( 758 MB)
[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
[ 0.000000] .text : 0xc0008000 - 0xc0a54178 (10545 kB)
[ 0.000000] .init : 0xc0a55000 - 0xc0a92100 ( 245 kB)
[ 0.000000] .data : 0xc0a94000 - 0xc0b2e3c8 ( 617 kB)
[ 0.000000] .bss : 0xc0b2e3ec - 0xc0d0e108 (1920 kB)

(4)外设的初始化
[ 0.161000] gpiochip_add: registered GPIOs 96 to 127 on device: nxp-gpio.3
[ 0.162000] gpiochip_add: registered GPIOs 128 to 159 on device: nxp-gpio.4
[ 0.162000] gpiochip_add: registered GPIOs 160 to 165 on device: nxp-gpio.5
[ 0.162000] pl08xdmac pl08xdmac.0: Unbalanced pm_runtime_enable!
[ 0.162000] pl08xdmac pl08xdmac.0: initialized 8 virtual memcpy channels
[ 0.162000] pl08xdmac pl08xdmac.0: initialized 16 virtual slave channels
[ 0.164000] pl08xdmac pl08xdmac.0: DMA: PL080 rev1 at 0xc0000000 irq 33
[ 0.165000] pl08xdmac pl08xdmac.1: Unbalanced pm_runtime_enable!
[ 0.165000] pl08xdmac pl08xdmac.1: initialized 8 virtual memcpy channels
[ 0.165000] pl08xdmac pl08xdmac.1: initialized 15 virtual slave channels
[ 0.167000] pl08xdmac pl08xdmac.1: DMA: PL080 rev1 at 0xc0001000 irq 34
[ 0.168000] SCSI subsystem initialized
[ 0.168000] usbcore: registered new interface driver usbfs
[ 0.168000] usbcore: registered new interface driver hub
[ 0.168000] usbcore: registered new device driver usb
[ 0.169000] i2c-gpio i2c-gpio.0: using pins 99 (SDA) and 98 (SCL)
[ 0.169000] i2c-gpio i2c-gpio.3: using pins 80 (SDA) and 79 (SCL)
[ 0.171000] s3c-i2c s3c2440-i2c.1: i2c-1: S3C I2C adapter
[ 0.171000] s3c-i2c s3c2440-i2c.1: slave address 0x10
[ 0.171000] s3c-i2c s3c2440-i2c.1: bus frequency set to 195 KHz
[ 0.172000] s3c-i2c s3c2440-i2c.2: i2c-2: S3C I2C adapter
[ 0.172000] s3c-i2c s3c2440-i2c.2: slave address 0x10
[ 0.173000] s3c-i2c s3c2440-i2c.2: bus frequency set to 195 KHz

(5) 网络协议
[ 0.293000] NET: Registered protocol family 2
[ 0.293000] IP route cache hash table entries: 32768 (order: 5, 131072 bytes)
[ 0.294000] TCP established hash table entries: 131072 (order: 8, 1048576 bytes)
[ 0.296000] TCP bind hash table entries: 65536 (order: 8, 1572864 bytes)
[ 0.298000] TCP: Hash tables configured (established 131072 bind 65536)
[ 0.298000] TCP: reno registered
[ 0.298000] UDP hash table entries: 512 (order: 3, 32768 bytes)
[ 0.298000] UDP-Lite hash table entries: 512 (order: 3, 32768 bytes)
[ 0.299000] NET: Registered protocol family 1
[ 0.299000] RPC: Registered named UNIX socket transport module.
[ 0.299000] RPC: Registered udp transport module.
[ 0.299000] RPC: Registered tcp transport module.
[ 0.299000] RPC: Registered tcp NFSv4.1 backchannel transport module.

(6)挂载根文件系统
[ 4.364000] EXT4-fs (mmcblk0p2): recovery complete
[ 4.364000] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 4.371000] VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 4.377000] devtmpfs: mounted
[ 4.380000] Freeing init memory: 244K
[ 4.384000] Write protecting the kernel text section c0008000 - c0a1e000
[ 4.391000] rodata_test: attempting to write to read-only section:
[ 4.396000] write to read-only section trapped, success
[ 4.538000] EXT4-fs (mmcblk0p2): re-mounted. Opts: data=ordered
[ 4.858000] eth0: device MAC address 7e:82:ae:c8:00:b5
[ 4.860000] stmmac_open: failed PTP initialisation
[root@GEC6818 /]#

四、根文件系统

根文件系统是一个“包”
(1)shell命令或程序工具
/bin /sbin /usr/bin

(2)设备文件
/dev/

(3)脚本 配置文件
/etc

(4)动态库
/lib /usr/lib

(5)/proc–该目录下的文件存储着linux系统运行的状态信息
数字命名的目录----数字是进程的PID
cpuinfo meminfo …

(6)/sys ------驱动程序相关信息

(7)/mnt 挂载点
mount -t vfat /dev/sda1 /mnt

(8)/var----日志文件

挂载根文件系统之后,启动init进程----->执行/etc/init.d/rcS---->执行/etc/profile—>加载驱动模块—>后台执行iot应用程序

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一只很笨很懒的肥猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值