sunxi:[0]全志SoC启动过程分析

sunxi学习:[0]全志SoC启动过程分析

参考:linux-sunxi.org


启动流程:Boot ROM→SPL→U-boot(→Kernel→RootFileSystem)

一、BROM阶段

全志SoC有一个非常具体的启动过程。首先,它执行一个微小的片上 Boot ROM(BROM),然后检查按钮的FEL模式,然后开始检查各种存储选项的有效的引导签名在正确的位置。

上电后,SoC开始从BROM所在的地址0xffff0000获取指令。BROM分为两部分:第一部分(0xffff0000)是FEL模式,第二部分是eGON.BRM(位于0xffff4000)。

FEL:FEL是包含在Allwinner设备上的BootROM中的低级子例程。它用于使用USB的设备的初始编程和恢复。所以,全志平台一般不会砖,就是有这个FEL。

一般来说,BROM首先检查SD卡(SD/MMC)启动可用性,其次再检查Nand Flash是否可以启动,然后再检查SPI Nor Flash的启动可用性,如果都无法启动则进入 FEL 模式。当程序初始化启动介质成功后,就从固定位置读入bootloader的Boot0到SRAM,然后跳到SRAM执行。

将u-boot烧录进SD卡

SD Card Layout:

|start|size|usage
|-|-|
|0 |8KB |Unused, available for partition table etc.
|8 |24KB |Initial SPL loader
|32 |512KB |U-Boot
|544 |128KB |environment
|672 |352KB |reserved
|1024 |- |Free for partitions


根据SD Card Layout表,使用dd将u-boot烧录进SD卡:

sudo dd if=u-boot-sunxi-with-spl.bin of=${card} bs=1024 seek=8

二、U-boot SPL阶段

SPL(Secondary Program Loader)程序流程如下:

  • 初始化ARM处理器
  • 初始化串口控制台
  • 配置时钟和最基础的分频
  • 初始化SDRAM
  • 配置引脚多路复用功能
  • 启动设备初始化(即上面选择的启动设备)
  • 加载完整的u-boot/kernel程序并转交控制权

使用FEL/USBBoot启动spl

sudo ./sunxi-fel uboot u-boot-sunxi-with-spl.bin
U-Boot SPL 2017.03-rc2-gc7a25b3-dirty (Mar 11 2017 - 17:09:43)
DRAM: 256 MiB
Trying to boot from FEL


三、U-boot

由SPL引导进入的U-boot:

U-Boot 2017.03-rc2-gc7a25b3-dirty (Mar 11 2017 - 17:09:43 +0800) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: Xunlong Orange Pi Zero
DRAM:  256 MiB
MMC:   SUNXI SD/MMC: 0
MMC: no card present
mmc_init: -123, time 1
*** Warning - MMC init failed, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   phy interface0
eth0: ethernet@1c30000
starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0 
u-boot@sun8i $ ?
?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootefi - Boots an EFI payload from memory
bootelf - Boot from an ELF image in memory
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
bootvx  - Boot vxWorks from an ELF image
bootz   - boot Linux zImage image from memory
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dhcp    - boot image via network using DHCP/TFTP protocol
dm      - Driver model low level access
echo    - echo args to console
editenv - edit environment variable
env     - environment handling commands
exit    - exit script
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
ext4load- load binary file from a Ext4 filesystem
ext4ls  - list files in a directory (default /)
ext4size- determine a file's size
false   - do nothing, unsuccessfully
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fatsize - determine a file's size
fatwrite- write file into a dos filesystem
fdt     - flattened device tree utility commands
fstype  - Look up a filesystem type
go      - start application at address 'addr'
gpio    - query and control gpio pins
help    - print command description/usage
iminfo  - print header information for application image
imxtract- extract a part of a multi-image
itest   - return true/false on integer compare
load    - load binary file from a filesystem
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loadx   - load binary file over serial line (xmodem mode)
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
ls      - list files in a directory (default /)
md      - memory display
mdio    - MDIO utility commands
mii     - MII utility commands
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mw      - memory write (fill)
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
part    - disk partition related commands
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
pxe     - commands to get and boot from pxe files
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
save    - save file to a filesystem
saveenv - save environment variables to persistent storage
setenv  - set environment variables
setexpr - set environment variable as the result of eval expression
showvar - print local hushshell variables
size    - determine a file's size
sleep   - delay execution for some time
source  - run script from memory
sysboot - command to get and boot from syslinux files
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true    - do nothing, successfully
usb     - USB sub-system
usbboot - boot from USB device
version - print monitor, compiler and linker version
u-boot@sun8i $ 



  • 我的个人主页:http://www.techping.cn/
  • 我的个人站点博客:http://www.techping.cn/blog/wordpress/
  • 我的CSDN博客:http://blog.csdn.net/techping
  • 我的:http://www.jianshu.com/users/b2a36e431d5e/timeline
  • 我的GitHub:https://github.com/techping
    欢迎相互follow~

你可能感兴趣的:(sunxi:[0]全志SoC启动过程分析)