(一)linux系统运行过程

一、嵌入式linux系统的启动过程

上电–>U-boot—>加载linux内核—>挂载rootfs—>执行应用程序
在这里插入图片描述

 

二、分析uboot

1、什么是u-boot
u-boot是一个通用的bootloader。boot—>完成硬件的初始化,启动硬件平台
loader—>初始化硬件结束后,加载操作系统
bios也是一种bootloader。
ftp://ftp.denx.de/pub/u-boot/

通用---->CPU:u-boot支持多种架构的CPU,如:ARM、MIPS、PowerPC、x86、…
开发板:Cortex-A8、A9、A53不同厂家的开发板
操作系统:linux、WinCE、VxWorks、…

2、uboot的作用
1)stage1:CPU(S5P6818–>Cortex-A53)的初始化,使用汇编语言编写。
初始化Cache、MMU、clock、中断、看门狗、DDR3、eMMC、…
2)stage2:板级初始化,使用C语言编写。
uart、网卡、usb、LCD、…
3)提供了一些工具,进入uboot的命令行,使用u-boot命令
4)加载操作系统。

3、uboot的输出

U-Boot 2014.07 (Jul 17 2017 - 10:56:44)--->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~0x43c81e40
GLD  = 0x43bffeb8
GLBD = 0x43bffe68
SP   = 0x43bffe68,0x43bffe48(CURR)
PC   = 0x43c06640
TAGS = 0x40000100 
PAGE = 0x43c90000~0x43c9c000
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)      : 0x40 0x40 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:   Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot:  0 
GEC6818# 

4、uboot的信息
1)GEC6818# bdinfo —>查看硬件平台的信息
arch_number = 0x000010EA ---->uboot针对具体硬件平台的ID
boot_params = 0x40000100 ---->uboot传递给内存的启动参数
DRAM bank = 0x00000000
-> start = 0x40000000 ---->内存的开始地址
-> size = 0x40000000 ---->内存的大小
current eth = unknown
ip_addr = 192.168.1.165
baudrate = 115200 bps
TLB addr = 0x7FFF0000
relocaddr = 0x46000000
reloc off = 0x00000000
irq_sp = 0x7DF6DF00
sp start = 0x43BFFE68

DDR3内存的地址范围:0x40000000~0x7FFFFFFF

2)GEC6818# printenv —>查看uboot的环境变量

baudrate=115200
bootargs=lcd=at070tn92 tp=gslx680-linux root=/dev/mmcblk0p2 rw rootfstype=ext4
bootcmd=ext4load mmc 2:1 0x48000000 uImage;bootm 0x48000000
bootdelay=5
bootfile=uImage
ethaddr=00:e2:1c:ba:e8:60    ---->网卡的mac地址
ethprime=RTL8211   ---->网卡芯片的型号
fastboot=flash=mmc,2:ubootpak:2nd:0x200,0x78000;flash=mmc,2:2ndboot:2nd:0x200,0x4000;flash=mmc,2:bootloader:boot:0x8000,0x70000;flash=mmc,2:boot:ext4:0x00100000,0x04000000;flash=mmc,2:system:ext4:0x04100000,0x2F200000;flash=mmc,2:cache:ext4:0x33300000,0x1AC00000;flash=mmc,2:misc:emmc:0x4E000000,0x00800000;flash=mmc,2:recovery:emmc:0x4E900000,0x01600000;flash=mmc,2:userdata:ext4:0x50000000,0x0;
filesize=41ee8
gatewayip=192.168.1.1   ---->网管
ipaddr=192.168.1.165    ---->板子的IP
netmask=255.255.255.0   ---->子网掩码
qtcrc=1876878128  
serverip=192.168.1.164  ---->tftp服务器的IP
stderr=serial
stdin=serial
stdout=serial

关键的内容:
(1)bootargs—>启动参数
lcd=at070tn92 ---->液晶屏的型号,7inches的800*480
tp=gslx680-linux ---->触摸屏的型号
root=/dev/mmcblk0p2 —>rootfs在哪里。告诉kernel去哪里挂载rootfs。
/dev/mmcblk0p2 —>mmcblk0–emmc电子硬盘,p2—>partion2,emmc电子硬盘的第二个分区
brw-rw---- 1 root root 179, 1 Jan 1 1970 /dev/mmcblk0p1
brw-rw---- 1 root root 179, 2 Jan 1 1970 /dev/mmcblk0p2 —> linux + QT, rootfs
brw-rw---- 1 root root 179, 3 Jan 1 1970 /dev/mmcblk0p3
brw-rw---- 1 root root 179, 4 Jan 1 1970 /dev/mmcblk0p4
brw-rw---- 1 root root 179, 5 Jan 1 1970 /dev/mmcblk0p5
brw-rw---- 1 root root 179, 6 Jan 1 1970 /dev/mmcblk0p6
brw-rw---- 1 root root 179, 7 Jan 1 1970 /dev/mmcblk0p7
179—主设备号,2—次设备号 设备号=主设备号<<20 + 次设备号

rw rootfstype=ext4 ----->rootfs可读可写的,根文件系统的类型是ext4

(2)bootcmd —>启动命令
ext4load mmc 2:1 0x48000000 uImage;bootm 0x48000000

以ext4文件系统格式去emmc的第一个分区加载linux内核,加载到0x48000000地址上;然后在0x48000000地址上启动linux内核。

通俗理解:bootcmd告诉uboot去哪里加载linux内核;bootargs告诉linux内核,去哪里挂载rootfs。

(3)修改启动延时时间

setenv bootdelay  3
saveenv

 

三、linux内核

1、linux内核的作用
1)进程管理和进程通信:进程的创建和删除、进程的优先级抢占、进程的时间片轮转、进程间的通信机制
2)内存管理:内存分配算法,每个进程的内存空间
3)内核支持的文件系统:#cat /proc/filesystems
4) 设备管理:—>linux驱动:字符设备、块设备、网络设备、中断、内核时钟
5)网络协议:---->TCP/IP

https://www.kernel.org/pub/linux/kernel/

2、GEC6818开发板----输出信息
Guangdong Embedded Center

1)uboot加载内核

Booting kernel from Legacy Image at 48000000 ...
   Image Name:   Linux-3.4.39-gec    ---->linux内核版本
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    5525544 Bytes = 5.3 MiB
   Load Address: 40008000  ---->DDR3内存的地址
   Entry Point:  40008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

2)linux内核启动
[ 0.000000] Booting Linux on physical CPU 0

3)linux内存管理

[    0.000000] Memory: 1024MB = 1024MB total
[    0.000000] Memory: 810820k/810820k available, 237756k reserved, 272384K highmem
[    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 - 0xc0a51018   (10533 kB)
[    0.000000]       .init : 0xc0a52000 - 0xc0a8f100   ( 245 kB)
[    0.000000]       .data : 0xc0a90000 - 0xc0b297d8   ( 614 kB)
[    0.000000]        .bss : 0xc0b297fc - 0xc0d09488   (1920 kB)

[    0.000000] SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0, CPUs=8, Nodes=1

3)设备管理

[    0.171000] usbcore: registered new interface driver usbfs

[    0.172000] i2c-gpio i2c-gpio.0: using pins 99 (SDA) and 98 (SCL)

[    0.173000] s3c-i2c s3c2440-i2c.1: i2c-1: S3C I2C adapter
[    0.174000] s3c-i2c s3c2440-i2c.1: slave address 0x10
[    0.174000] s3c-i2c s3c2440-i2c.1: bus frequency set to 195 KHz
[    0.175000] s3c-i2c s3c2440-i2c.2: i2c-2: S3C I2C adapter
[    0.175000] s3c-i2c s3c2440-i2c.2: slave address 0x10
[    0.175000] s3c-i2c s3c2440-i2c.2: bus frequency set to 195 KHz
[    0.176000] Linux video capture interface: v2.00
[    0.187000] axp22_ldo1: 3000 mV
[    0.273000] Advanced Linux Sound Architecture Driver Version 1.0.25.
[    0.317000] Display LCD register operation 
[    0.317000] Display LVDS register operation 
[    0.318000] Display MiPi register operation 

4)网络协议

[    0.295000] NET: Registered protocol family 2
[    0.295000] IP route cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.296000] TCP established hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.298000] TCP bind hash table entries: 65536 (order: 8, 1572864 bytes)
[    0.300000] TCP: Hash tables configured (established 131072 bind 65536)
[    0.300000] TCP: reno registered
[    0.300000] UDP hash table entries: 512 (order: 3, 32768 bytes)
[    0.300000] UDP-Lite hash table entries: 512 (order: 3, 32768 bytes)
[    0.301000] NET: Registered protocol family 1

5)挂载rootfs

[    3.884000] EXT4-fs (mmcblk0p2): recovery complete
[    3.886000] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    3.891000] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    3.897000] devtmpfs: mounted
[    3.900000] Freeing init memory: 244K
[    3.904000] Write protecting the kernel text section c0008000 - c0a1b000
[    3.911000] rodata_test: attempting to write to read-only section:
[    3.917000] write to read-only section trapped, success
[    4.064000] EXT4-fs (mmcblk0p2): re-mounted. Opts: data=ordered

根文件系统在emmc的第2个分区上,根文件系统的格式是:ext4

 

四、rootfs

1、什么rootfs
linux内核挂载的第一个文件系统,根文件系统是挂载到根目录下的文件系统。rootfs是一个“包”,里面包含:

[root@GEC6818 /]#ls /
IOT         etc         lost+found  root        sys         usr
bin         lib         mnt         run         tmp         var
dev         linuxrc     proc        sbin        udisk

这些内容是什么???

1)linux的shell命令
/bin —>一般的shell命令
/sbin —>超级用户管理员命令
/usr/bin
/usr/sbin —>shell命令或工具

2)设备文件节点
—>应用程序访问驱动的接口
/dev/ —>只有块设备和字符设备有设备文件,网络设备没有设备文件。

3)linux系统的配置文件
/etc/
用户名/密码/主机名/网络配置/系统配置

4)实时反映linux系统的工作状态
/proc
(1)数字---->PID进程的状态信息
(2)version —>linux系统的版本
(3)cpuinfo —>cpu的信息:MIPS ----> Million Instructions Per Second
(4)meminfo —>系统内存的使用
(5)uptime —>系统的工作时间
作业:分析proc下文件的作用。

5)linux应用程序运行的时候使用的动态库—.so.
/lib
/usr/lib
/usr/local/Qt-Embedded-5.7.0

arm-linux-gcc -o hello1 hello.c ---->动态编译
arm-linux-gcc -o hello2 hello.c -static ---->静态编译

6)指向linux的shell命令环境
#ls linuxrc -l
lrwxrwxrwx 1 root root 11 Dec 27 2016 linuxrc -> bin/busybox

7)系统的挂载点
/mnt

如:

[root@GEC6818 /]#mount
sda1 on /mnt/udisk type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
root@GEC6818 /]#ls /mnt/udisk
System Volume Information

8)linux设备驱动的详细信息
/sys

9)系统的工作日志
/var

2、rootfs是挂载的方式
我们挂载rootfs中的文件,所以下载到rootfs中的文件,就相当于下载emmc(电子硬盘)

 

五、执行应用程序

GEC6818平台—>IOT–Internet Of Things

rootfs挂载后—>自动执行脚本/etc/init.d/rcS—>自动执行/etc/profile —>安装驱动---->执行应用程序

/etc/profile文件:
cd /IOT
./iot & ----> 在后台运行一个iot应用程序
cd /

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值