PetaLinux启动过程解析
Posted 中国思想史
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PetaLinux启动过程解析相关的知识,希望对你有一定的参考价值。
1、BootROM部分
在器件上电运行后,处理器自动开始Stage-0 Boot,也就是执行片内BootROM中的代码
BootROM会初始化CPU和一些外设,以便读取下一个启动阶段所需的程序代码,FSBL(First
2、BOOT.bin部分
BootROM会去读取MIO[2..8],从而确定启动设备方式(Zynq支持多种启动设备方式,可以使用跳线帽设置),将选定设备的头192Kbyte内容,也就是FSBL,复制到OCM(On Chip Memory)中,并将控制器交给FSBL。
FSBL部分
FSBL启动时可以使用整块256Kb的OCM,当FSBL开始运行后,器件就正式由开发者或用户控制了。Xilinx提供了一份FSBL代码,如果没什么特殊要求,可以直接使用。
嵌入式系统系统启动一般都是在 nor flash (NOR flash 可以直接运行程序,NAND flash需要将程序加载到内存运行,和 Bios 很类似,nor flash 成本很高)。
BIOS是(Basic Input Output System)"基本输入输出系统"
它是一组固化到计算机内主板上一个ROM芯片上的程序,它保存着计算机最重要的基本输入输出的程序、开机后自检程序和系统自启动程序,它可从CMOS中读写系统设置的具体信息。 其主要功能是为计算机提供最底层的、最直接的硬件设置和控制。
RAM(random access memory)即随机存储内存,这种存储器在断电时将丢失其存储内容,故主要用于存储短时间使用的程序。ROM(Read-Only Memory)即只读内存,是一种只能读出事先所存数据的固态半导体存储器。
uboot 就是针对嵌入式环境特别编译准备的一级引导程序。用来初始化环境,并且读取启动 Linux 内核的东西。
因为在u-boot中配置从eMMC启动,所以在u-boot之前会先初始化一些外设,配置PL端资源,如eMMC,下面为初始化eMMC的打印信息。
Device: sdhci@e0100000
Manufacturer ID: fe
OEM: 14e
Name: MMC02
Tran Speed: 52000000
Rd Block Len: 512
MMC version 4.4.1
High Capacity: No
Capacity: 1.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 KiB
HC WP Group Size: 0 Bytes
User Capacity: 1.8 GiB
Boot Capacity: 1 MiB ENH
RPMB Capacity: 128 KiB ENH
u-boot.elf从发eMMC加载image.ub到片上内存DDR3(2G)中
readingimage.ub
11274340 bytes read in 611 ms (17.6 MiB/s)
首先是加载Linux kernel,状态为尚未解压,大小3.8MiB,使用了SHA1安全哈希算法(Secure Hash Algorithm)
## Loading kernel from FIT Image at10000000 ...
Using 'conf@1' configuration
Verifying Hash Integrity ... OK
Trying 'kernel@0' kernel subimage
Description: Linux Kernel
Type: Kernel Image
Compression: uncompressed
Data Start: 0x100000d4
Data Size: 4005144 Bytes = 3.8MiB
Architecture: ARM
OS: Linux
Load Address: 0x00008000
Entry Point: 0x00008000
Hash algo: sha1
Hash value: 3b953474750d8fb67e6a25dece81e156c4ecdcb2
Verifying Hash Integrity ... sha1+ OK
接着是加载ramdisk,状态为尚未解压,大小6.9MiB,使用了SHA1安全哈希算法(Secure Hash Algorithm)
## Loading ramdisk from FIT Image at10000000 ...
Using 'conf@1' configuration
Trying 'ramdisk@0' ramdisk subimage
Description: ramdisk
Type: RAMDisk Image
Compression: uncompressed
Data Start: 0x103d686c
Data Size: 7248902 Bytes = 6.9MiB
Architecture: ARM
OS: Linux
Load Address: unavailable
Entry Point: unavailable
Hash algo: sha1
Hash value: e934ce35c9f408811fcb859dff09b0aed896871b
Verifying Hash Integrity ... sha1+ OK
最后是加载fdt(设备树文件),状态为尚未解压,大小18.2KiB,使用了SHA1安全哈希算法(Secure Hash Algorithm)
## Loading fdt from FIT Image at 10000000...
Using 'conf@1' configuration
Trying 'fdt@0' fdt subimage
Description: Flattened DeviceTree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x103d1ee0
Data Size: 18649 Bytes = 18.2KiB
Architecture: ARM
Hash algo: sha1
Hash value: 97ab0c048f0da9de6329b48e1345c2aedc552995
Verifying Hash Integrity ... sha1+ OK
Booting using the fdt blob at 0x103d1ee0
Loading Kernel Image ... OK
Loading Ramdisk to 07916000, end 07fffc06... OK
Loading Device Tree to 0790e000, end079158d8 ... OK
引导加载完成,准备运行
解压Linux内核镜像并启动Linux内核,运行在CPU0上
Starting kernel ...
Uncompressing Linux...done, booting the kernel.
Booting Linux on physical CPU0x0
Linux version 4.6.0-xilinx(bjut@virtua-ubuntu1604) (gcc version 5.2.1 20151005 (Linaro GCC 5.2-2015.11-2)) #1 SMP PREEMPT Mon Apr 24 15:03:20 CST 2017
CPU: ARMv7 Processor[413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPTnonaliasing data cache, VIPT aliasing instruction cache
Machine model:huanbao_qspi_emmc
bootconsole [earlycon0]enabled
cma: Reserved 16 MiB at0x3f000000
Memory policy: Data cachewritealloc
percpu: Embedded 12pages/cpu @ef7d0000 s19776 r8192 d21184 u49152
Built 1 zonelists in Zoneorder, mobility grouping on. Totalpages: 260608
Kernel command line:console=ttyPS0,115200 earlyprintk
开始解压文件系统镜像
Trying to unpack rootfsimage as initramfs...
Freeing initrd memory:7080K (c7916000 - c8000000)
hw perfevents: enabledwith armv7_cortex_a9 PMU driver, 7 counters available
futex hash table entries:512 (order: 3, 32768 bytes)
workingset:timestamp_bits=28 max_order=18 bucket_order=0
jffs2: version 2.2. (NAND)(SUMMARY) 漏2001-2006 Red Hat, Inc.
bounce: pool size: 64pages
io scheduler noopregistered
io scheduler deadlineregistered
io scheduler cfqregistered (default)
dma-pl330 f8003000.dmac:Loaded driver for PL330 DMAC-241330
dma-pl330 f8003000.dmac: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4Num_Events-16
42c00000.serial: ttyUL1 atMMIO 0x42c00000 (irq = 167, base_baud = 0) is a uartlite
42c10000.serial: ttyUL2 atMMIO 0x42c10000 (irq = 168, base_baud = 0) is a uartlite
42ca0000.serial: ttyUL3 atMMIO 0x42ca0000 (irq = 169, base_baud = 0) is a uartlite
42cb0000.serial: ttyUL4 atMMIO 0x42cb0000 (irq = 170, base_baud = 0) is a uartlite
42c20000.serial: ttyUL5 atMMIO 0x42c20000 (irq = 171, base_baud = 0) is a uartlite
42c30000.serial: ttyUL6 atMMIO 0x42c30000 (irq = 172, base_baud = 0) is a uartlite
42c40000.serial: ttyUL7 atMMIO 0x42c40000 (irq = 173, base_baud = 0) is a uartlite
42c50000.serial: ttyUL8 atMMIO 0x42c50000 (irq = 174, base_baud = 0) is a uartlite
42c60000.serial: ttyUL9 atMMIO 0x42c60000 (irq = 175, base_baud = 0) is a uartlite
42c70000.serial: ttyUL10at MMIO 0x42c70000 (irq = 176, base_baud = 0) is a uartlite
42c80000.serial: ttyUL11at MMIO 0x42c80000 (irq = 177, base_baud = 0) is a uartlite
42c90000.serial: ttyUL12at MMIO 0x42c90000 (irq = 178, base_baud = 0) is a uartlite
e0000000.serial: ttyPS1 atMMIO 0xe0000000 (irq = 145, base_baud = 3125000) is a xuartps
e0001000.serial: ttyPS0 atMMIO 0xe0001000 (irq = 146, base_baud = 3125000) is a xuartps
郼onsole [ttyPS0] enabled
console [ttyPS0] enabled
bootconsole [earlycon0]disabled
bootconsole [earlycon0]disabled
xdevcfg f8007000.devcfg:ioremap 0xf8007000 to f090c000
[drm] Initialized drm1.1.0 20060810
brd: module loaded
loop: module loaded
m25p80 spi0.0: n25q128a11(16384 Kbytes)
4 ofpart partitions foundon MTD device spi0.0
Creating 4 MTD partitionson "spi0.0":
0x000000000000-0x000000500000: "boot"
0x000000500000-0x000000520000: "bootenv"
0x000000520000-0x000000fa0000: "kernel"
0x000000fa0000-0x000001000000: "spare"
CAN device driverinterface
gpiod_set_value: invalidGPIO
libphy: MACB_mii_bus:probed
[Firmware Warn]:/amba/ethernet@e000b000/mdio/phy@7: Whitelisted compatible string. Pleaseremove
macb e000b000.etherneteth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 148 (00:0a:35:00:1e:53)
Marvell 88E1111e000b000.etherne:07: attached PHY driver [Marvell 88E1111](mii_bus:phy_addr=e000b000.etherne:07, irq=-1)
e1000e: Intel(R) PRO/1000Network Driver - 3.2.6-k
e1000e: Copyright(c) 1999- 2015 Intel Corporation.
//开始注册驱动
PPP generic driver version2.4.2
PPP BSD Compression moduleregistered
PPP Deflate Compressionmodule registered
PPP MPPE Compressionmodule registered
NET: Registered protocolfamily 24
usbcore: registered newinterface driver asix
usbcore: registered newinterface driver ax88179_178a
usbcore: registered newinterface driver cdc_ether
usbcore: registered newinterface driver net1080
usbcore: registered newinterface driver cdc_subset
usbcore: registered newinterface driver zaurus
usbcore: registered newinterface driver cdc_ncm
usbcore: registered newinterface driver huawei_cdc_ncm
usbcore: registered newinterface driver cdc_mbim
ehci_hcd: USB 2.0'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCIplatform driver
ohci_hcd: USB 1.1 'Open'Host Controller (OHCI) Driver
ohci-pci: OHCI PCIplatform driver
ohci-platform: OHCIgeneric platform driver
uhci_hcd: USB UniversalHost Controller Interface driver
usbcore: registered newinterface driver cdc_acm
cdc_acm: USB AbstractControl Model driver for USB modems and ISDN adapters
usbcore: registered newinterface driver cdc_wdm
usbcore: registered newinterface driver usb-storage
usbcore: registered newinterface driver usbserial
usbcore: registered newinterface driver option
usbserial: USB Serialsupport registered for GSM modem (1-port)
e0002000.usb supply vbusnot found, using dummy regulator
ULPI transceivervendor/product ID 0x0424/0x0007
Found SMSC USB3320 ULPItransceiver.
ULPI integrity check:passed.
ci_hdrc ci_hdrc.0: EHCIHost Controller
ci_hdrc ci_hdrc.0: new USBbus registered, assigned bus number 1
ci_hdrc ci_hdrc.0: USB 2.0started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 portdetected
mousedev: PS/2 mousedevice common for all mice
i2c /dev entries driver
rtc-pcf8563 0-0051: chipfound, driver version 0.4.4
rtc-pcf8563 0-0051: rtccore: registered rtc-pcf8563 as rtc0
cdns-i2c e0004000.i2c: 400kHz mmio e0004000 irq 142
Driver for 1-wire Dallasnetwork protocol.
EDAC MC: ECC not enabled
Xilinx Zynq CpuIdle Driverstarted
sdhci: Secure Digital HostController Interface driver
sdhci: Copyright(c) PierreOssman
sdhci-pltfm: SDHCIplatform and OF driver helper
mmc0: SDHCI controller one0100000.sdhci [e0100000.sdhci] using DMA
ledtrig-cpu: registered toindicate activity on CPUs
usbcore: registered newinterface driver usbhid
usbhid: USB HID coredriver
NET: Registered protocolfamily 10
sit: IPv6 over IPv4tunneling driver
NET: Registered protocolfamily 17
can: controller areanetwork core (rev 20120528 abi 9)
NET: Registered protocolfamily 29
can: raw protocol (rev20120528)
can: broadcast managerprotocol (rev 20120528 t)
can: netlink gateway (rev20130117) max_hops=1
Registering SWP/SWPBemulation handler
rtc-pcf8563 0-0051:setting system clock to 2000-04-09 21:55:13 UTC (955317313)
ALSA device list:
No soundcards found.
mmc0: new high speed MMCcard at address 0001
Freeing unused kernelmemory: 1024K (c0a00000 - c0b00000)
mmcblk0: mmc0:0001 MMC02G1.79 GiB
INIT: mmcblk0boot0:mmc0:0001 MMC02G partition 1 1.00 MiB
version 2.88bootingmmcblk0boot1: mmc0:0001 MMC02G partition 2 1.00 MiB
mmcblk0rpmb: mmc0:0001MMC02G partition 3 128 KiB
mmcblk0: p1
usb 1-1: new high-speedUSB device number 2 using ci_hdrc
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 portsdetected
EXT4-fs (mmcblk0rpmb):unable to read superblock
EXT4-fs (mmcblk0rpmb):unable to read superblock
EXT2-fs (mmcblk0rpmb):error: unable to read superblock
FAT-fs (mmcblk0rpmb):unable to read boot sector
EXT4-fs (mmcblk0rpmb):unable to read superblock
EXT4-fs (mmcblk0rpmb):unable to read superblock
EXT2-fs (mmcblk0rpmb):error: unable to read superblock
FAT-fs (mmcblk0rpmb):unable to read boot sector
FAT-fs (mmcblk0rpmb):unable to read boot sector
usb 1-1.1: new high-speedUSB device number 3 using ci_hdrc
mount: mounting/dev/mmcblk0rpmb on /run/media/mmcblk0rpmb failed: Input/output error
mount: mounting/dev/mmcblk0boot0 on /run/media/mmcblk0boot0 failed: Invalid argument
cdc_ether 1-1.1:2.0 usb0:register 'cdc_ether' at usb-ci_hdrc.0-1.1, CDC Ethernet Device,02:1e:10:1f:00:00
//检测到4G模块,启动4G模块
option 1-1.1:2.2: GSMmodem (1-port) converter detected
usb 1-1.1: GSM modem(1-port) converter now attached to ttyUSB0
option 1-1.1:2.3: GSMmodem (1-port) converter detected
mount: mounting/dev/mmcblk0boot1 on /run/media/mmcblk0boot1 failed: Invalid argument
usb 1-1.1: GSM modem(1-port) converter now attached to ttyUSB1
option 1-1.1:2.4: GSMmodem (1-port) converter detected
usb 1-1.1: GSM modem (1-port)converter now attached to ttyUSB2
option 1-1.1:2.5: GSMmodem (1-port) converter detected
usb 1-1.1: GSM modem(1-port) converter now attached to ttyUSB3
option 1-1.1:2.6: GSMmodem (1-port) converter detected
usb 1-1.1: GSM modem(1-port) converter now attached to ttyUSB4
/etc/mdev/mdev-mount.sh:line 28: [: /sys/block/mmcblk0/mmcblk0boot1: binary operator expected
mount: mounting/dev/mmcblk0 on /run/media/mmcblk0 failed: Device or resource busy
random: dd urandom readwith 5 bits of entropy available
Mon Apr 24 07:06:36 UTC2017
Starting internetsuperserver: inetd.
INIT: Entering runlevel: 5
//配置以太网接口,等待网口芯片启动
Configuring networkinterfaces... IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
done.
// 启动Dropbear并生成密钥,Dropbear是一个相对较小的SSH服务器和客户端(开源软件)。
Starting Dropbear SSHserver: Generating key, this may take a while...
//公钥,用公钥加密数据就必须用私钥解密,如果用私钥加密也必须用公钥解密。
Public key portion is:
ssh-rsaAAAAB3NzaC1yc2EAAAADAQABAAABAQCQWM1vqfFHlIPbduTWsKeX1iQI4HMwuDZ46GV4FgJbtAFG/+9inB9K42p4YR06RrdnPdkvv2cPAQ/srfbm/qgF5BoKGdE32JsLU4EP9ovBecA6xSe2C2yzJ3e1HQOIaHcSWf59QpxTPFUrw+GYHNR4N8WZj6V9XJ+w6/5NWWSTwICjgo2yizVEodjsPc0VChAqmC8EBUz2evgBBJGbzm3mxgHXzsoKD/kKSlw2dtGcPCvO7GSdxYE1hBtk6xb8a6zToVOAPIqZFCnWtfEKUSexUx60I72nZngOtwqZR+ILR6BBLZqpomwc0AONZtjAYRrdIqnVPR2y0irVNIz1JAPx
root@plnx_arm
Fingerprint: md5b4:d4:cf:bc:ad:c0:79:93:89:66:ce:4a:b0:93:a5:2c
dropbear.
//启动PetaLinux成功
Start Hello PetaLinux.
//运行初始化脚本
run init.sh
//配置网络、路由
config network
//启动系统日志
Starting syslogd/klogd:set board time
//启动4G拨号程序,后台运行
run LTEConnection &
done
open /dev/ttyUSB0 SUCCESS
ttyclear:
Starting tcf-agent: OK
PetaLinux 2016.4 plnx_arm/dev/ttyPS0
//网卡芯片启动成功
macb e000b000.etherneteth0: link up (1000/Full)
IPv6:ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
//用户登录系统
plnx_arm login:
//查看系统网卡信息
ifconfig
eth0 Link encap:Ethernet HWaddr 00:0A:35:00:1E:53
inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr:fe80::20a:35ff:fe00:1e53%768720/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:60 errors:0 dropped:0overruns:0 frame:0
TX packets:10 errors:0 dropped:0overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6671 (6.5 KiB) TX bytes:1206 (1.1 KiB)
Interrupt:148 Base address:0xb000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1%768720/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8 errors:0 dropped:0overruns:0 frame:0
TX packets:8 errors:0 dropped:0overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:488 (488.0 B) TX bytes:488 (488.0 B)
usb0 Link encap:Ethernet HWaddr 02:1E:10:1F:00:00
inet addr:10.81.49.191 Bcast:10.81.49.255 Mask:255.255.255.128
inet6 addr:fe80::1e:10ff:fe1f:0%768720/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9 errors:0 dropped:0overruns:0 frame:0
TX packets:15 errors:0 dropped:0overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1040 (1.0 KiB) TX bytes:1802 (1.7 KiB)
//查看系统设备信息
root@plnx_arm:~# ls /dev
bus null tty21 tty59
console port tty22 tty6
cpu_dma_latency ppp tty23 tty60
full psaux tty24 tty61
i2c-0 ptmx tty25 tty62
initctl pts tty26 tty63
input ram0 tty27 tty7
kmsg ram1 tty28 tty8
log ram10 tty29 tty9
loop-control ram11 tty3 ttyPS0
loop0 ram12 tty30 ttyPS1
loop1 ram13 tty31 ttyUL1
loop2 ram14 tty32 ttyUL10
loop3 ram15 tty33 ttyUL11
loop4 ram2 tty34 ttyUL12
loop5 ram3 tty35 ttyUL2
loop6 ram4 tty36 ttyUL3
loop7 ram5 tty37 ttyUL4
mdev.seq ram6 tty38 ttyUL5
mem ram7 tty39 ttyUL6
memory_bandwidth ram8 tty4 ttyUL7
mmcblk0 ram9 tty40 ttyUL8
mmcblk0boot0 random tty41 ttyUL9
mmcblk0boot1 rtc0 tty42 ttyUSB0
mmcblk0p1 shm tty43 ttyUSB1
mmcblk0rpmb snd tty44 ttyUSB2
mtab tty tty45 ttyUSB3
mtd0 tty0 tty46 ttyUSB4
mtd0ro tty1 tty47 urandom
mtd1 tty10 tty48 usbmon0
mtd1ro tty11 tty49 usbmon1
mtd2 tty12 tty5 vcs
mtd2ro tty13 tty50 vcs1
mtd3 tty14 tty51 vcsa
mtd3ro tty15 tty52 vcsa1
mtdblock0 tty16 tty53 vga_arbiter
mtdblock1 tty17 tty54 watchdog
mtdblock2 tty18 tty55 watchdog0
mtdblock3 tty19 tty56 xdevcfg
network_latency tty2 tty57 zero
network_throughput tty20 tty58
//系统关机过程:
oot@plnx_arm:~# shutdown-h now
Broadcast message fromroot@plnx_arm (ttyPS0) (Fri Oct 20 11:28:20 2017):
The syste@J蛠going down for system halt NOW!
INIT: Switching to runlev
//改变系统runlevel,0表示关机
//向系统进程发送中断信号
INIT: Sending processesthe TERM signal
//停止Dropbear SSH server
root@plnx_arm:~# StoppingDropbear SSH server: stopped /usr/sbin/dropbear (pid 1160)
dropbear.
//停止Linux系统
Stop Hello PetaLinux.
//停止系统日志进程
Stopping syslogd/klogd:stopped syslogd (pid 1173)
stopped klogd (pid 1175)
done
Stopping tcf-agent:random: nonblocking pool is initialized
FAIL
//清空网络接口的配置
Deconfiguring networkinterfaces... done.
Sending all processes theTERM signal...
//退出用户登录
logout
macb e000b000.etherneteth0: link down
Sending all processes theKILL signal...
//卸载远程文件系统和本地文件系统
Unmounting remotefilesystems...
Deactivating swap...
Unmounting localfilesystems...
//系统关机完成
reboot: System halted
附加信息:
Linux系统有7个运行级别(runlevel)
Linux系统有7个运行级别(runlevel)
运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动
运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆
运行级别2:多用户状态(没有NFS)
运行级别3:完全的多用户状态(有NFS),登陆后进入控制台命令行模式
运行级别4:系统未使用,保留
运行级别5:X11控制台,登陆后进入图形GUI模式
运行级别6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动
多数的桌面的linux系统缺省的runlevel是5,用户登陆时是图形界面,而多数的服务器版本的linux系统缺省的runlevel是3,用户登陆时是字符界面,runlevel 1和2除了调试之外很少使用,runlevel s和S并不是直接给用户使用,而是用来为Single user mode作准备。
在基于Busybox的系统上执行busybox --list即可看到一个系统可用命令列表
以上是关于PetaLinux启动过程解析的主要内容,如果未能解决你的问题,请参考以下文章
14020.petalinux之platform-auto.h和platform-top.h