日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

DM3730 X-load 分析

發布時間:2024/1/1 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 DM3730 X-load 分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

DM3730的啟動過程:ROM code -->MLO-->u-boot.bin-->解析boot.scr-->uImage->掛載文件系統

其中MLO就是x-load編譯而來,相當于SPL

以我現在使用的LogicPD SOM-LV核心板及其SDK為例,該SDK是在官方SDK基礎上小改而來,大同小異

X-loader編譯

cd rpm/BUILD/x-loader-1.46/

make distclean?

make CROSS_COMPILE=/opt/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi- dm3730logic_config

make CROSS_COMPILE=/opt/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-?

具體編譯腳本請查看目錄下的makefile

編譯OK后,會生成MLO x-load x-load.bin x-load_usb x-load_usb.bin?

由編譯腳本可知:

$(obj)MLO:?? ?$(obj)x-load.bin.ift
?? ?cp $(obj)x-load.bin.ift $(obj)MLO

$(obj)x-load.bin.ift:?? ?$(obj)x-load.bin $(obj)scripts/signGP
?? ?$(obj)scripts/signGP $(obj)x-load.bin $(CONFIG_SYS_TEXT_BASE)
$(obj)scripts/signGP: ?? ?$(src)scripts/signGP.c
?? ?mkdir -p $(obj)scripts
?? ?$(HOSTCC) -o $@ $<

$(obj)x-load.bin:?? ?$(obj)x-load
?? ??? ?$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@

MLO是通過signGP工具從x-loader.bin生成而來,具體可看 scripts/signGP.c的實現,實質是在x-load.bin的基礎上增加了一個4字節的header,header內容是4個字節的x-loader長度和x-loader被load的目標地址。

本開發板的目標地址是定義在board/dm3730logic/config.mk下?CONFIG_SYS_TEXT_BASE=0x40200800 該變量在編譯腳本中被傳給了signGP,

先用連接腳本board/dm3730logic/x-load.lds開始

OUTPUT_ARCH(arm) ENTRY(_start) SECTIONS {. = 0x00000000;. = ALIGN(4);.text ? ? ?:{cpu/omap3/start.o?? ?(.text)*(.text)}. = ALIGN(4);.rodata : { *(.rodata) }. = ALIGN(4);.data : { *(.data) }. = ALIGN(4);.got : { *(.got) }. = ALIGN(4);__bss_start = .;.bss : { *(.bss) }_end = .; }


指定了入口函數_start以及最先執行的程度代碼start.S

_start:b?? ?resetldr?? ?pc, _hangldr?? ?pc, _hangldr?? ?pc, _hangldr?? ?pc, _hangldr?? ?pc, _hangldr?? ?pc, _hangldr?? ?pc, _hangreset:/** set the cpu to SVC32 mode*/mrs?? ?r1,cpsrbic?? ?r1,r1,#0x1forr?? ?r1,r1,#0xd3msr?? ?cpsr,r1/* Save the booting parameter structure ?** (passed via pointer from r0 from ROM) ** (12 bytes) ? ? ? ? ? ? ? ? ? ? ? ? ? ?*/adr?? ?r1, booting_parameter? //保存Rom code讀取到的啟動設備參數ldmia?? ?r0!, {r4-r7}stmia?? ?r1!, {r4-r7}/* Copy vectors to mask ROM indirect addr */adr ? ? r0, _start ? ? ? ? ? ? ?/* r0 <- current position of code ? */add ? ? r0, r0, #4?? ??? ?/* skip reset vector ? ? ? ? ? ? ? ?*/mov ? ? r2, #64 ? ? ? ? ? ? ? ? /* r2 <- size to copy ? ? ? ? ? ? ? */add ? ? r2, r0, r2 ? ? ? ? ? ? ?/* r2 <- source end address ? ? ? ? */mov ? ? r1, #SRAM_OFFSET0 ? ? ? /* build vect addr ? ? ? ? ? ? ? ? ?*/mov ? ? r3, #SRAM_OFFSET1add ? ? r1, r1, r3mov ? ? r3, #SRAM_OFFSET2add ? ? r1, r1, r3 next:ldmia ? r0!, {r3-r10} ? ? ? ? ? /* copy from source address [r0] ? ?*/stmia ? r1!, {r3-r10} ? ? ? ? ? /* copy to ? target address [r1] ? ?*/cmp ? ? r0, r2 ? ? ? ? ? ? ? ? ?/* until source end address [r2] ? ?*/bne ? ? next ? ? ? ? ? ? ? ? ? ?/* loop until equal */bl?? ?cpy_clk_code ? ? ? ? ? ?/* put dpll adjust code behind vectors *//* the mask ROM code should have PLL and others stable */bl ?cpu_init_critldr?? ?pc, _start_armboot?? ?/* jump to C code ? ? ? ? ? ? ? ? ? */_start_armboot: .word start_armboot

start.S里面先設置CPU工作方式,保存啟動設備參數,初始化CPU,最好調_stat_armboot?
?? ?// cpu/omap3/start.S?
?? ?bl ?cpu_init_crit ?// cpu/ompa3/start.S?
?? ??? ??? ?bl?? ?lowlevel_init?? ?// cpu/omap3/platform.S?
?? ??? ??? ? ? ??? ?bl ? ? ?s_init ?// board/dm3730logic.c? ?//進行主要的CPU級初始化,bss,watchdog,clk,timer,serial, ddr, nand,i2c等

特別說明logicpd這個核心板,硬件默認優先nand啟動,

一切初始化OK之后,跳到lib/board.c:start_armboot() 開始執行C代碼

init_fnc_t *init_sequence[] = {
?? ?cpu_init,?? ??? ?/* basic cpu dependent setup */
?? ?board_init,?? ??? ?/* basic board dependent setup */
#ifdef CFG_PRINTF
??? ?serial_init,?? ??? ?/* serial communications setup */
?? ?trace_dump,
?? ?print_info,
#endif
? ?? ?nand_init,?? ??? ?/* board specific nand init */
? ?? ?NULL,
};

misc_init_r();

?? ?/* go run U-Boot and never return */
??? ?((init_fnc_t *)boot_fnc_ptr)();

這個函數中先是進一步初始化了一些外設和CPU功能,然后根據Romcode識別到的啟動設備,從啟動設備加載u-boot.bin 到啟動地址,然后直接跳轉執行。(注意我手頭的x-load只實現了從nand,emmc,usb啟動,沒有實現從nor啟動)

有一個問題,為什么TI 平臺不直接用u-boot或者bootloader,而要先搞一個x-loader呢?

在回答這個問題之前,我們先回顧下Nor和Nand的區別,Nand Flash的讀寫速度慢,但是容量大,價格相對便宜,壽命更長。Nor編程簡單,有獨立的地址引腳,可以方便的存取其內容的每一個字節。一般的,Nandflash用于存儲數據,NorFlash一般用于存儲啟動代碼。

Samsuang公司未了彌補Nandflash的不足,在Nandflahs芯片內集成了一個RAM接口,命令未OneNandFlash,這類Flash擁有和NorFlash相同的簡單接口,而且不受地址引腳的限制,即容量與地址引腳無關。簡單的說,OneNandFlash就是采用了Nor的接口,Nand的架構,是兩者的性能得到了綜合。傳統的bootloader是放在Nand的架構下的,而CPU卻是從Nor的接口下讀取bootloader到SDRAM中,因此需要有一個步驟,就是怎么把Bootloader/uboot從OneNand架構下復制到SDRAM中,這就是x-loader的功能,不僅初始化OneNand,并且把u-boot從Nand的架構下復制到bufferRam中,再復制到SDRAM中。

X-loader還支持從SD/MMC/下引導uboot。本質上x-loader起到了初始化OneNand和引導u-boot的作用。

TI平臺的GPMC ,可以接Nor,也可以和FPGA等通信,通過不同的CS片選來通信,本開發板所使用的RAM和Nand,是直接POP到CPU的,即DM3730背上貼有一片MCP(DDR+NAND)

對于GPMC,本文不詳訴,參考網絡資料。

有其他疑問,歡迎留言提問,我有空會回復解答

總結

以上是生活随笔為你收集整理的DM3730 X-load 分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。