RT ROM boot简介
目錄
- ROM Boot process
- Get boot mode
- 讀取fuse,確定HAB是否使能
- Get boot device
- Boot類型綜述
- Primary boot
- Redundant boot
- Secondary boot
- Recovery boot
- MFG boot
- Plugin boot
- Serial download
imx-RT是恩智浦新出的一款基于M7內核的芯片,其特點是高性能,低售價。
目前是MCU市場上一款炙手可熱的芯片。
本文針對RT ROM做一些介紹。
具體內容如下:
- Boot流程
- 各種類型的boot
- image架構
ROM Boot process
Get boot mode
上電后,Boot_mode撥碼的值會自動加載到SBMR2寄存器中,ROM讀取SBMR2[25:24]來決定boot_mode
RT支持四種啟動模式
- Boot from fuse。 根據fuse中的boot device進行boot
- Serial download。 ROM進入detect mode,等待上位機跟ROM通信。
- internal boot。 根據boot device撥碼進行boot
- Test mode。 ROM will run into loop
- ROM讀取SBMR2
#define HAPI_SRC_get_bootmode() ((SRC->SBMR2 & SBMR2_BMOD_MASK) >> SBMR2_BMOD_SHIFT)
SRC->SBMR2右移24位截取bit[25:24]得到boot_mode
讀取fuse,確定HAB是否使能
hab_rvt.report_status(&hab_config, NULL);
HAB - high assurance boot.
一旦開啟HAB,簽名的image需要ROM認證后才能boot。
Get boot device
ROM支持的boot device有
flexspi nand、flexspi nor、SEMC nand、SEMC nor、SD、EMMC、EEP
如果BT_FUSE_SEL沒有燒寫,boot device撥碼的值會加載到SBMR1寄存器中。
否則,fuse 0x450關于boot device的值會加載到SBMR1中
ROM根據SRC->SBMR1寄存器的值來判斷boot device- Boot device初始化代碼
pu_irom_setup_boot_selection(); Boot device撥碼
講到這里,我們來回顧下。
首先,上電后板子會自動將boot_mode的信息加載到SBMR2寄存器中。將boot_device的值加載到SBMR1中
關于boot device分兩種情況。
ROM會根據SBMR2中的信息來確定boot mode,然后根據SBMR1中值確定boot device
從對應的device boot或者進入相應的boot mode
Boot類型綜述
Primary boot
FlexSPINor\Nand boot,SD\EMMC boot
FlexSPI nor可以選擇XIP boot。其他的device都是Non-XIPboot。。即image需要從boot device中搬到RAM中執行
Nand支持redundant boot,最多給4次boot機會
SD、EMMC支持secondary boot,在offset 0x200處重新制定image的存儲架構。EMMC支持fast boot
Redundant boot
primary boot失敗后進入redundant boot。只有燒寫了支持redundant boot的fuse后,才能進入此種boot。Boot device一般都是EEPROM
MFG boot
如上boot 失敗后,會從SD卡中嘗試最后一次boot。
Plug-in boot
ROM支持的boot device只有flexspi nand\nor等等。。但是想要支持其他的boot device,比如從USB boot的話ROM是否支持呢。Plug-in boot的存在目的就是如此。
plug-in boot的話需要兩個image。
一個image存在ROM支持的boot device上,這個image的目的是用來初始化USB,將USB的數據讀取到RAM中。
第二個image存儲在USB中,這個就是用來boot的image
Primary boot
- 支持XIP的device,FlexSPI nor, SEMC nor
以FlexSPI nor為例,ROM從0x60000000處讀取12K數據。從0x60001000處獲取IVT,根據IVT中的boot data進行數據處理。如果boot image運行地址在nor上,則進行XIP。否則將image copy到ram中boot - 不支持XIP的device,FlexSPI nand等
ROM從device中讀取2K數據到0x20208000處,然后從0x20208400處獲取IVT。根據IVT中的boot data將boot image coppy對應的運行地址進行boot
Redundant boot
- nand 支持redundant boot。給4次boot機會
- NAND FCB會制定image的存儲,備份信息。
- ROM根據FCB找到對應的block,根據IVT將image復制到對應的運行地址。如果boot失敗,ROM會根據FCB查找下一個備份的image,然后進行boot
- redundant register用來標記當前是第幾次boot。 Bit[23:22]= 0b00表示第一份image,以此類推。
UINT32 redundant_boot = get_persist_redundant_boot_value();
while (++redundant_boot <= REDUNDANT_IMG_IDX_MAX)
{
/* Set secondary image persistent bit /
set_persist_redundant_boot_value(redundant_boot);
/ Add secondary image log entry /
pu_irom_log_add((pu_irom_log_entry_t)(ROM_LOG_PRIM_IMAGE_SELECT + redundant_boot));
/ Try download secondary image /
if (download_initial_image() == TRUE)
{
/ Update data_ptr on success /
data_ptr = (hab_ivt_v0_t )((UINT32)driver_data->initial_image_address + driver_data->ivt_offset);
break;
}
}
Secondary boot
- SD emmc支持secondary boot。Normal boot制定image base address為0x0,IVT offset為0x400.ROM會從0x0處讀取數據,抓取0x400處的IVT來得到boot information。
Secondary boot table位于offset0x200處。ROM第一次從0x400獲取IVT后,如果boot失敗,則從0x200處獲取table,table中可以重定義image base address為firstSectorNumber。那么ROM就會從firstSectorNumber處獲取image。
舉例說明:
結構體里面的數據是小端模式。
SD\EMMC 一個block的長度為0x200
Tag : 0x00112233
FirstSectorNumber :
EMMC的image start address = 0x8000 IVT offset = 0x400
Table address = 0x200
設定secondary start address為0x9000,則firstSectorNumber為:
(0x9000-0x8000) /0x200 = 8
secondary table如下
typedef struct {UINT32 chipNum; /* Chip Select, ROM does not use it */UINT32 driveType; /* Always system drive, ROM does not use it */UINT32 tag; /* Tag, must be 0x584D2E69 (i.MX) */UINT32 firstSectorNumber; /* Block address of secondary image, block size is 512B */UINT32 sectorCount; /* Not used by ROM */ } SECONDARY_IMG_TBL_T;Recovery boot
使能這個fuse即可。如果promary boot失敗,ROM會從recovery boot device中進行boot。
EEPROM_RECOVERY_EN
MFG boot
所有primary、recovery boot失敗后,從SD boot。
Plugin boot
這個boot類型是為了滿足ROM從不支持的device中boot。
- 當配置IVT中BootData的plugin為1時。bootRom支持boot plugimage
- Plug-in boot需要兩個image
- 供ROM boot的image,IVT, base address等都需要根據ROM的規定制定。此處的image就是沒有使用plug in功能時的boot image。
只不過這個image的功能不是我們常用的點燈,而是將IVT,base address,image length指向plug in image。如果有需要的話,還需要對存放plugin image的設備進行初始化 - plug-in image
當1中的image制定了plug-in image的base address, IVT offset, image length后。BOOTROM對這個image認證后,執行此image
示例
依照ROM的規則做第一個image
int main(uint32_t **start, uint32_t *bytes, uint32_t *ivt_offset) { *start = (uint32_t *)0x60004000; *bytes = 0x5000; *ivt_offset = 0x1000; return 1; }第二個image的功能為點燈,image中斷向量地址為NOR中的0x60006000。給這個image加上IVT,IVT的存儲地址設置為0x60005000,image的base address設置為0x60004000
將第一個image燒寫到0x6000000處,第二個image燒寫到0x60004000處。reset 板子,plug-in boot即可成功。
我們來分析下image是如何運行的。
Serial download
ROM 進到這個模式后,會等待上位機通訊。支持USB跟UART。
可以通過SD\P_host上位機的write_filem命令將image寫到RAM中,然后Jump_addr命令執行image
讀到這里,我們應該知道了primary boot,recovery boot,MFG boot,Plug-in boot
- primary boot中,SD、EMMC支持secondary boot。NAND 支持redundant boot。這兩種boot我們都可以通過persist register來查看使用第幾份image進行boot。
- recovery boot是在primary boot失敗后的一種boot,需要開啟recovery boot的fuse
- MFG boot呢,就是如上如上兩個boot都失敗,ROM給與的最后一次boot。它從SD boot
- plug-in boot則是為了讓ROM支持目前未曾支持的device,需要兩份image。第一份image的IVT中需要開啟plug-in boot flag。
我們用Nor模擬了這種boot。plug-in boot支持如上所有的boot類型 - 如果所有boot都失敗的話,ROM會進入serial download等待上位機與其通信。可以使用上位機燒寫image到RAM中,然后運行RAM中的image。
關于RT的boot 流程,boot類型就介紹到此。下個章節我們來談談image的架構,看看ROM是如何根據IVT的內容進行boot的。
轉載于:https://www.cnblogs.com/richard-xiong/p/9542603.html
總結
以上是生活随笔為你收集整理的RT ROM boot简介的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 图中长度为k的路径的计数
- 下一篇: RK3288 双屏异显,两屏默认方向不一