启动概述:
Mx50的在上电复位的时候开始启动:执行on-chip boot ROM,boot ROM根据配置的模式,及其OCOTP bits值和GPIO的设置,判断具体启动方式。
boot ROM的代码主要功能:
支持多种启动设备
USB下载支持DCD(Device Configuration Data)
数字签名基于HAB(High Assurance Boot)
Mx50 boot ROM支持一下设备启动:
Parallel NOR Flash
NAND Flash
ONFI 2.x BA-NAND
Toggle-Mode High speed NAND
OneNAND Flash
SD/eSD/MMC/eMMC
Serial ROM devices, including SPI NOR/EEPROM, I C EEPROM
boot ROM由启动引(GPIO)和OCOTP bits位配置,根据启动模式,判断其具体作用。
boot ROM支持下载程序运行:
例如:为方便NAND启动,可以通过USB串行no-stream模式链接到外部的带有image的boot device,下载image到内部RAM中。
DCD( Device Configuration Data):
允许ROM从外部boot device中的 program image 获得IC 配置数据(例如mx508 u-boot 把它放在image的开始,详情参看u-boot的lds分析和image分析)。
一, 4种启动模式:
BOOT_MODE[1:0] Boot Type
00 Internal Boot
01 Reserved
10 Internal Boot—Fuses Only
11 USB Downloader
所有的启动模式都支持HAB(High Assurance Boot),
1,Internal Boot (BOOT_MODE[1:0] = 00):
BT_FUSE_SEL = 1, OCOTP bit 配置启动参数
BT_FUSE_SEL = 0, GPIO 值会覆盖OCOTP的值,配置启动参数(主要用于开发,freescale官方推荐用OCOTP配置)
2,Internal Boot—Fuses Only (BOOT_MODE[1:0] = 10):
和internal boot mode一样,唯一的区别是忽视掉GPIO,也就是说只是OCOTP配置起作用。
BT_BLANK=0,表示启动设备例如flash,SD/MMC等不被使用,直接通过串口下载。
BT_BLANK=1,表示正常启动,从所选择的启动设备中ROM启动
3,USB Downloader (BOOT_MODE[1:0] = 11)
a)。USB Downloader 在以下几种情况会被激活;
* USB Downloader mode
* Internal boot—Fuses Only 且 OCOTP bit BT_BLANK = 0
* Internal Boot 或者 Internal Boot—Fuses Only模式中,启动设备中找不到image,或者image无效
* 内部错误
* 运行异常发生
* 在HAB 中SEC_CONFIG = HAB_CLOSED,运行错误返回.
(在 SEC_CONFIG = HAB_OPENED 配置中,错误被忽略).
b)。安全启动设置
SEC_CONFIG = HAB_CLOSED
用于产品安全,所有的HAB功能生效
SEC_CONFIG = HAB_CLOSED
与上面相反。
NOR Flash Boot Operation:
Booting from the NOR Flash is supported via WEIM interface. The ROM reads Image Vector Table and Boot Data structures to determine if the image can be executed directly from WEIM address space or should be copied to other memory. The start field of Boot Data Structure specifies the final location of the image.
OneNAND Flash boot option:
ROM中的onenand 驱动程序 通过发送软件命令,接受回应,得到页大小。
上电的时候,onenand 自动读取前1k的代码到ROOT RAM里面。
例如,boot ram包括onenand image向量表(也就是onenand启动的入口地址),boot rom拷贝前1k代码到boot ram中
At system power-up, OneNAND automatically copies 1 Kbyte data from start of Flash array (sector 0 and sector 1, page 0, block 0) to its Boot RAM 。For example, the Boot RAM contains the OneNAND Image Vector Table. Boot ROM copies the 1 Kbyte OneNAND Boot RAM1 contents to the application destination pointer (located in the app_dest_ptr entry of application header) and decrements the length of the image to be read from OneNAND by 1k. Because the Boot RAM1 area is memory mapped, the copy operation is a simple memory copying operation. The length of image to be read from the OneNAND device is specified in Image Vector Table structure described in Figure 7-15. Failure loading data from OneNAND flash for any reason forces the processor Boot ROM to switch to serial download. Due to limited 1Kbyte size of OneNAND Boot RAM both IVT and DCD must fit in first 1Kbyte. This limits the max size of DCD for OneNAND device to 736 bytes as specified in Table 7-21. ROM reads rest of image and copies it to destination address during HAB authentication process.
At system power-up, the voltage detector in the device detects the rising edge of Vcc and releases internal power-up reset signal which triggers bootcode loading. Bootcode loading means that the boot loader in the OneNAND copies the designated sized data (1Kbyte) from the beginning of memory to the BootRAM1. The Bootcode copy operation starts 400 μs later than POR activation and the 1Kbyte Bootcode copy takes
70 μs (estimated) from sector0 and sector1/page0/block0 of NAND Flash array to the BootRAM. The INT bit of Interrupt status register goes from ‘Low’ to ‘High’ on the condition of ‘Bootcode-copy done’ and RP rising edge.
外部设备启动支持:
Mx508中的ROOT ROM 支持MMMC/eMMC and SD/eSD启动。
通过配置 BOOT_CFG3[5:4]和GPIO选择 eSDHC-1, eSDHC-2, eSDHC-3, or eSDHC-4
详细见imx50RM.pdf的p209。
启动代码支持以下格式:
• MMCv4.4 or less
• eMMCv4.4 or less
• SDv2.0 or less
• eSDv2.10 rev-0.9, with or without FAST_BOOT.
当启动时,拷贝前2k的代码到内部ram中,然后检测boot image 中的Image Vector Table header value (0xD1) ,ROM code执行DCD检测,检测成功后提取出需要拷贝的image的目的指针和大小。
基于SD卡启动分析过程:
在normal boot mode 初始化开始后,SD和eSD频率被设置到357.143kHZ,然后鉴别MMC还是SD ,鉴别完成后,boot code 首先高电压检测,失败后,检测低电压。同时并检测容量,rom root code 支持大,小容量的SD和eSD卡。电压设定后,初始化完成。
初始化期间还会检测分区,如果失败则按照普通SD和eSD处理。初始化完毕后,boot
Code将频率提高到20M(normal speed mode)或者40M(hight speed mode)。
ROM boot cade也支持eSD卡的FAST_BOOT mode,这种模式的可在BOOT_CFG1[4](fast boot)设置。