小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

中國(guó)linux公社 - 基于atmel at91rm9200的armlinux的bootloader啟動(dòng)代碼分析

 昵稱346 2005-08-17
基于Atmel at91rm9200的armlinux的bootloader啟動(dòng)代碼分析
  貼出者為 balancesli
編程開發(fā) balancesli寫著 ‘ 前階段做了一次基于at91rm9200引導(dǎo)部分的技術(shù)分析,主要采用了u-boot,這里只面向使用at91rm9200板子的的朋友做個(gè)簡(jiǎn)單的推敲,希望起到拋磚引玉的作用

Author : balancesli
mail : balancesli@thizlinux.com.cn

前階段做了一次基于at91rm9200引導(dǎo)部分的技術(shù)分析,主要采用了u-boot,這里只面向使用at91rm9200板子的
的朋友做個(gè)簡(jiǎn)單的推敲,希望起到拋磚引玉的作用.

關(guān)鍵詞 :
u-boot: 一個(gè)開源的面向多個(gè)目標(biāo)平臺(tái)(ppc, mips, arm, x86)的bootloader.
at91rm9200 : Atmel 公司生產(chǎn)的基于arm9核的Soc處理器.

以下先給出at91rm9200引導(dǎo)流程圖

Boot program Flow Diagram

Device Setup
|
|
Boot SPI DataFlash Boot --> Download from DataFlash --> run
|
|
TWI EEPROM Boot --> Download from EEPROM --> run
|
|
Parallel Boot --> Download from 8-bit Device -->
|
| Xmodem protocol
| |---DBGU Serial Download ---------------------> run
|____|
| DFU protocol
|-----USB download -----------------------> run

在這里我主要介紹通過(guò)片內(nèi)引導(dǎo)和片外引導(dǎo), 片內(nèi)引導(dǎo)主要采用串口下載并引導(dǎo)u-boot,并完成程序被燒寫到Flash上,
然后就可以通過(guò)跳線的方式從片外引導(dǎo)執(zhí)行已經(jīng)燒寫到片外Flash上的引導(dǎo)程序(bootloader).

這里要提及的是at91rm9200內(nèi)部本身有128k的片內(nèi)rom,其固化了一個(gè)bootloader和uploader, 用來(lái)支持程序的
下載和引導(dǎo),而且其內(nèi)部固化的程序提供了很多內(nèi)部服務(wù)接口(Internel Service)供我們來(lái)使用,例如Xmodem,Tempo
DataFlash, CRC, Sine服務(wù)接口,這樣我們就可以利用它所提供的Service interface API完成程序的下載。
這里主要介紹Xmodem接口服務(wù)。

at91rm9200內(nèi)部固化的代碼在設(shè)計(jì)上采用了面向?qū)ο蟮脑O(shè)計(jì)方法,如下:


typedef struct _AT91S_Service
{
char data;
char (*MainMethod)();
char (*ChildMethod)();
}AT91S_Service, *AT91PS_Service;

char AT91F_MainMethod()
{

}
char AT91F_ChildMethod()
{

}

/*init the Service */
AT91PS_Service AT91F_OpenDevice(AT91PS_Service pService)
{
pService->data = 0;
pService->MainMethod = AT91F_MainMethod;
pService->ChildMethod = AT91F_ChildMethod;
}

//使用方法如下
AT91S_Service service;
AT91PS_Service pService = AT91F_OpenDevice(&service);
pService->AT91F_MainMethmod();
.....

通過(guò)如上代碼片斷可以看出它采用了類似面向?qū)ο蟮脑O(shè)計(jì)方法。
其實(shí)如果各位朋友接觸過(guò)的話或者看過(guò)這本書的話,應(yīng)該很容易便接受它。
下面以Xmodem服務(wù)為例子介紹:


at91rm9200內(nèi)部提供的服務(wù)包含了幾個(gè)服務(wù)對(duì)象, 這些對(duì)象在片內(nèi)啟動(dòng)xmodem協(xié)議Host端和Targe端通訊時(shí)會(huì)用到.


typedef struct _AT91S_RomBoot
{
const unsigned int version;
// Peripheral descriptors
const AT91S_MEMCDesc MEMC_DESC;
const AT91S_STDesc SYSTIMER_DESC;
const AT91S_Pio2Desc PIOA_DESC;
const AT91S_Pio2Desc PIOB_DESC;
const AT91S_USART2Desc DBGU_DESC;
const AT91S_USART2Desc USART0_DESC;
const AT91S_USART2Desc USART1_DESC;
const AT91S_USART2Desc USART2_DESC;
const AT91S_USART2Desc USART3_DESC;
const AT91S_TWIDesc TWI_DESC;
const AT91S_SPIDesc SPI_DESC;

// Objects entry
const AT91PF_OpenPipe OpenPipe;
const AT91PF_OpenSBuffer OpenSBuffer;
const AT91PF_OpenSvcUdp OpenSvcUdp;
const AT91PF_OpenSvcXmodem OpenSvcXmodem;
const AT91PF_OpenCtlTempo OpenCtlTempo;
const AT91PF_OpenDfuDesc OpenDfuDesc;
const AT91PF_OpenUsbDesc OpenUsbDesc;
const AT91PF_OpenSvcDataFlash OpenSvcDataFlash;
const AT91PF_SVC_CRC16 CRC16;
const AT91PF_SVC_CRCCCITT CRCCCITT;
const AT91PF_SVC_CRCHDLC CRCHDLC;
const AT91PF_SVC_CRC32 CRC32;
// Array
const AT91PS_SVC_CRC_BIT_REV Bit_Reverse_Array;
const AT91PS_SINE_TAB SineTab;
const AT91PF_Sinus Sine;
} AT91S_RomBoot;

//AT91S_Pipe
typedef struct _AT91S_Pipe
{
// A pipe is linked with a peripheral and a buffer
AT91PS_SvcComm pSvcComm;
AT91PS_Buffer pBuffer;

// Callback functions with their arguments
void (*WriteCallback) (AT91S_PipeStatus, void *);
void (*ReadCallback) (AT91S_PipeStatus, void *);
void *pPrivateReadData;
void *pPrivateWriteData;

// Pipe methods
AT91S_PipeStatus (*Write) (
struct _AT91S_Pipe *pPipe,
char const * pData,
unsigned int size,
void (*callback) (AT91S_PipeStatus, void *),
void *privateData
);

AT91S_PipeStatus (*Read) (
struct _AT91S_Pipe *pPipe,
char *pData,
unsigned int size,
void (*callback) (AT91S_PipeStatus, void *),
void *privateData
);

AT91S_PipeStatus (*AbortWrite)(struct _AT91S_Pipe *pPipe);
AT91S_PipeStatus (*AbortRead)(struct _AT91S_Pipe *pPipe);
AT91S_PipeStatus (*AbortRead)(struct _AT91S_Pipe *pPipe);
AT91S_PipeStatus (*Reset)(struct _AT91S_Pipe *pPipe);
char (*IsWritten)(struct _AT91S_Pipe *pPipe, char const *pVoid);
char (*IsReceived) (struct _AT91S_Pipe *pPipe, char const *pVoid);
} AT91S_Pipe;

//AT91S_Buff
typedef struct _AT91S_SBuffer
{
AT91S_Buffer parent;
char *pRdBuffer;
char const *pWrBuffer;
unsigned int szRdBuffer;
unsigned int szWrBuffer;
unsigned int stRdBuffer;
unsigned int stWrBuffer;
} AT91S_SBuffer;

// AT91S_SvcTempo
typedef struct _AT91S_SvcTempo
{

// Methods:
AT91S_TempoStatus (*Start) (
struct _AT91S_SvcTempo *pSvc,
unsigned int timeout,
unsigned int reload,
void (*callback) (AT91S_TempoStatus, void *),
void *pData);
AT91S_TempoStatus (*Stop) (struct _AT91S_SvcTempo *pSvc);

struct _AT91S_SvcTempo *pPreviousTempo;
struct _AT91S_SvcTempo *pNextTempo;

// Data
unsigned int TickTempo; //* timeout value
unsigned int ReloadTempo;//* Reload value for periodic execution
void (*TempoCallback)(AT91S_TempoStatus, void *);
void *pPrivateData;
AT91E_SvcTempo flag;
} AT91S_SvcTempo;

// AT91S_CtrlTempo
typedef struct _AT91S_CtlTempo
{
// Members:

// Start and stop for Timer hardware
AT91S_TempoStatus (*CtlTempoStart) (void *pTimer);
AT91S_TempoStatus (*CtlTempoStop) (void *pTimer);

// Start and stop for Tempo service
AT91S_TempoStatus (*SvcTempoStart) (
struct _AT91S_SvcTempo *pSvc,
unsigned int timeout,
unsigned int reload,
void (*callback) (AT91S_TempoStatus, void *),
void *pData);
AT91S_TempoStatus (*SvcTempoStop) (struct _AT91S_SvcTempo *pSvc);
AT91S_TempoStatus (*CtlTempoSetTime)(struct _AT91S_CtlTempo *pCtrl, unsigned int NewTime);
AT91S_TempoStatus (*CtlTempoGetTime)(struct _AT91S_CtlTempo *pCtrl);
AT91S_TempoStatus (*CtlTempoIsStart)(struct _AT91S_CtlTempo *pCtrl);
AT91S_TempoStatus (*CtlTempoCreate) (struct _AT91S_CtlTempo *pCtrl,struct _AT91S_SvcTempo *pTempo);
AT91S_TempoStatus (*CtlTempoRemove) (struct _AT91S_CtlTempo *pCtrl,struct _AT91S_SvcTempo *pTempo);
AT91S_TempoStatus (*CtlTempoTick) (struct _AT91S_CtlTempo *pCtrl);

// Data:

void *pPrivateData; // Pointer to devived class
void const *pTimer; // hardware
AT91PS_SvcTempo pFirstTempo;
AT91PS_SvcTempo pNewTempo;
} AT91S_CtlTempo;



//以下代碼是上面幾個(gè)對(duì)象的使用范例,通過(guò)這樣就可以完成Host端和Targe端之間的xmodem通訊,并可以下載代碼了。

AT91S_RomBoot const *pAT91;
AT91S_SBuffer sXmBuffer;
AT91S_SvcXmodem svcXmodem;
AT91S_Pipe xmodemPipe;
AT91S_CtlTempo ctlTempo;

AT91PS_Buffer pXmBuffer;
AT91PS_SvcComm pSvcXmodem;
unsigned int SizeDownloaded;

/* Init of ROM services structure */
pAT91 = AT91C_ROM_BOOT_ADDRESS;//這里取得內(nèi)部ROM服務(wù)的入口地址

/* Tempo Initialization */
pAT91->OpenCtlTempo(&ctlTempo, (void *) &(pAT91->SYSTIMER_DESC));
ctlTempo.CtlTempoStart((void *) &(pAT91->SYSTIMER_DESC));

/* Xmodem Initialization */
pXmBuffer = pAT91->OpenSBuffer(&sXmBuffer);
pSvcXmodem = pAT91->OpenSvcXmodem(&svcXmodem, (AT91PS_USART)AT91C_BASE_DBGU, &ctlTempo);
pAT91->OpenPipe(&xmodemPipe, pSvcXmodem, pXmBuffer);
xmodemPipe.Read(&xmodemPipe, (char *)AT91C_UBOOT_BASE_ADDRESS, AT91C_UBOOT_MAXSIZE,
AT91F_XmodemProtocol, 0);
while(XmodemComplete !=1);



//上面部分主要針對(duì)at91rm9200片內(nèi)啟動(dòng)時(shí)我們可以使用的片內(nèi)接口服務(wù)介紹,玩H9200的朋友可以參考一下便知道緣由。

下面主要介紹at91rm9200片外啟動(dòng)時(shí)所使用的bootloader-->u-boot.

一. bootloader
BootLoader(引導(dǎo)裝載程序)是嵌入式系統(tǒng)軟件開發(fā)的非常重要的環(huán)節(jié),它把操作系統(tǒng)和硬件平臺(tái)銜接在一起,
是跟硬件體系密切相關(guān)的。



1.1 典型的嵌入式系統(tǒng)軟件部分Image memory layout : bootloader , bootloader param, kernel, rootfs.

1.2 引導(dǎo)模式 : 1. bootstrap或download
2. autoboot
1.3 u-boot簡(jiǎn)介 :
u-boot是由Wolfgang Denk開發(fā),它支持(mips, ppc, arm, x86)等目標(biāo)體系,
可以在http:// 上下載獲得源碼,

1.4 u-boot源代碼目錄結(jié)構(gòu)

board:開發(fā)板相關(guān)的源碼,不同的板子對(duì)應(yīng)一個(gè)子目錄,內(nèi)部放著主板相關(guān)代碼。

at91rm9200dk/at91rm9200.c, config.mk, Makefile, flash.c ,u-boot.lds等都和具體開發(fā)板的硬件和地址分配有關(guān)。

common:與體系結(jié)構(gòu)無(wú)關(guān)的代碼文件,實(shí)現(xiàn)了u-boot所有命令,
其中內(nèi)置了一個(gè)shell腳本解釋器(hush.c, a prototype Bourne shell grammar parser), busybox中也使用了它.


cpu:與cpu相關(guān)代碼文件,其中的所有子目錄都是以u(píng)-boot所支持的cpu命名.

at91rm9200/at45.c, at91rm9200_ether.c, cpu.c, interrupts.c serial.c, start.S, config.mk, Makefile等.
其中cpu.c負(fù)責(zé)初始化CPU、設(shè)置指令Cache和數(shù)據(jù)Cache等;

interrupt.c負(fù)責(zé)設(shè)置系統(tǒng)的各種中斷和異常,比如快速中斷、開關(guān)中斷、時(shí)鐘中斷、軟件中斷、
預(yù)取中止和未定義指令等;

start.S負(fù)責(zé)u-boot啟動(dòng)時(shí)執(zhí)行的第一個(gè)文件,它主要是設(shè)置系統(tǒng)堆棧和工作方式,為跳轉(zhuǎn)到C程序入口點(diǎn).

disk:設(shè)備分區(qū)處理代碼。

doc:u-boot相關(guān)文檔。


drivers:u-boot所支持的設(shè)備驅(qū)動(dòng)代碼, 網(wǎng)卡、支持CFI的Flash、串口和USB總線等。

fs: u-boot所支持支持文件系統(tǒng)訪問(wèn)存取代碼, 如jffs2.

include:u-boot head文件,主要是與各種硬件平臺(tái)相關(guān)的頭文件,
如include/asm-arm/arch-at91rm9200/, include/asm-arm/proc-armv

net:與網(wǎng)絡(luò)有關(guān)的代碼,BOOTP協(xié)議、TFTP協(xié)議、RARP協(xié)議代碼實(shí)現(xiàn).

lib_arm:與arm體系相關(guān)的代碼。(這里我們主要面向的是ARM體系,所以該目錄是我們主要研究對(duì)象)

tools:編譯后會(huì)生成mkimage工具,用來(lái)對(duì)生成的raw bin文件加入u-boot特定的image_header.


1.5 u-boot的功能介紹


 u-boot支持SCC/FEC以太網(wǎng)、OOTP/TFTP引導(dǎo)、IP和MAC的功能.

讀寫Flash、DOC、IDE、IIC、EEROM、RTC

支持串行口kermit和S-record下載代碼, 并直接從串口下載并執(zhí)行。

在我們生成的內(nèi)核鏡像時(shí),要做如下處理.
1. arm-linux-objcopy -O binary -R.note -R.comment -S vmlinux linux.bin
2. gzip -9 linux.bin
3. mkimage -A arm -O linux -T kernel -C gzip -a 0xc0008000 -e 0xc0008000 -n
"Linux-2.4.19-rmk7” -d linux.bin.gz uImage

即在Linux內(nèi)核鏡像vmLinux前添加了一個(gè)特殊的頭,這個(gè)頭在include/image.h中定義,
typedef struct image_header
{
uint32_t ih_magic; /* Image Header Magic Number */
uint32_t ih_hcrc; /* Image Header CRC Checksum */
uint32_t ih_time; /* Image Creation Timestamp */
uint32_t ih_size; /* Image Data Size */
uint32_t ih_load; /* Data Load Address */
uint32_t ih_ep; /* Entry Point Address */
uint32_t ih_dcrc; /* Image Data CRC Checksum */
uint8_t ih_os; /* Operating System */
uint8_t ih_arch; /* CPU architecture */
uint8_t ih_type; /* Image Type */
uint8_t ih_comp; /* Compression Type */
uint8_t ih_name[IH_NMLEN]; /* Image Name */
} image_header_t;

當(dāng)u-boot引導(dǎo)時(shí)會(huì)對(duì)這個(gè)文件頭進(jìn)行CRC校驗(yàn),如果正確,才會(huì)跳到內(nèi)核執(zhí)行.

如果u-boot啟動(dòng)以后會(huì)出現(xiàn)
u-boot>
敲入help, 會(huì)出現(xiàn)大量的命令提示,Monitor command
go - start application at address ‘a(chǎn)ddr‘
run - run commands in an environment variable
bootm - boot application image from memory
bootp - boot image via network using BootP/TFTP protocol
tftpboot- boot image via network using TFTP protocol
and env variables "ipaddr" and "serverip"
(and eventually "gatewayip")
rarpboot- boot image via network using RARP/TFTP protocol
diskboot- boot from IDE devicebootd - boot default, i.e., run ‘bootcmd‘
loads - load S-Record file over serial line
loadb - load binary file over serial line (kermit mode)
md - memory display
mm - memory modify (auto-incrementing)
nm - memory modify (constant address)
mw - memory write (fill)
cp - memory copy
cmp - memory compare
crc32 - checksum calculation
imd - i2c memory display
imm - i2c memory modify (auto-incrementing)
inm - i2c memory modify (constant address)
imw - i2c memory write (fill)
icrc32 - i2c checksum calculation
iprobe - probe to discover valid I2C chip addresses
iloop - infinite loop on address range
isdram - print SDRAM configuration information
sspi - SPI utility commands
base - print or set address offset
printenv- print environment variables
setenv - set environment variables
saveenv - save environment variables to persistent storage
protect - enable or disable FLASH write protection
erase - erase FLASH memory
flinfo - print FLASH memory information
bdinfo - print Board Info structure
iminfo - print header information for application image
coninfo - print console devices and informations
ide - IDE sub-system
loop - infinite loop on address range
mtest - simple RAM test
icache - enable or disable instruction cache
dcache - enable or disable data cache
reset - Perform RESET of the CPU
echo - echo args to console
version - print monitor version
help - print online help
- alias for ‘help‘

u-boot支持大量的命令可用, 這里就不作介紹,大家有興趣可以看看u-boot 的README文檔
3.3 對(duì)u-boot-1.0.0的修改和移植

1.6 關(guān)于u-boot的移植如下,由于u-boot的軟件設(shè)計(jì)體系非常清晰,它的移植工作并不復(fù)雜,
相信各位的代碼閱讀功力不錯(cuò)的話,參照如下就可以完成。

If the system board that you have is not listed, then you will need
to port U-Boot to your hardware platform. To do this, follow these
steps:

1. Add a new configuration option for your board to the toplevel
"Makefile" and to the "MAKEALL" script, using the existing
entries as examples. Note that here and at many other places
boards and other names are listed in alphabetical sort order. Please
keep this order.

2. Create a new directory to hold your board specific code. Add any
files you need. In your board directory, you will need at least
the "Makefile", a ".c", "flash.c" and "u-boot.lds".

3. Create a new configuration file "include/configs/.h" for
your board

4. If you‘re porting U-Boot to a new CPU, then also create a new
directory to hold your CPU specific code. Add any files you need.

5. Run "make _config" with your new name.

6. Type "make", and you should get a working "u-boot.srec" file

7. Debug and solve any problems that might arise.
[Of course, this last step is much harder than it sounds.]

為了使u-boot-1.0.0支持新的開發(fā)板,一種簡(jiǎn)便的做法是在u-boot已經(jīng)支持的開發(fā)板中參考選擇一種較接近板的進(jìn)行修改,
幸運(yùn)的是在u-boot-1.0.0中已經(jīng)有了at91rm9200的支持。

1.7 與at91rm9200相關(guān)的u-boot代碼

在include/configs/at91rm9200dk.h 它包括開發(fā)板的CPU、系統(tǒng)時(shí)鐘、RAM、Flash系統(tǒng)及其它相關(guān)的配置信息。
在include/asm-arm/AT91RM9200.h, 該文件描述了H9200寄存器的結(jié)構(gòu)及若干宏定義。
具體內(nèi)容要參考相關(guān)處理器手冊(cè)。
在cpu/at91rm9200/目錄下別為cpu.c、interrupts.c和serial.c等文件.
在board/at91rm9200dk/目錄下分別為flash.c、at91rm9200dk.c, config.mk, Makefile,u-boot.lds

flash.c : u-boot讀、寫和刪除Flash設(shè)備的源代碼文件。由于不同開發(fā)板中Flash存儲(chǔ)器的種類各不相同,
所以,修改flash.c時(shí)需參考相應(yīng)的Flash芯片手冊(cè)。它包括如下幾個(gè)函數(shù):
unsigned long flash_init (void ),F(xiàn)lash初始化;
void flash_print_info (flash_info_t *info),打印Flash信息;
int flash_erase (flash_info_t *info, int s_first, int s_last),F(xiàn)lash擦除;
volatile static int write_dword (flash_info_t *info, ulong dest, ulong data),F(xiàn)lash寫入;
int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt),從內(nèi)存復(fù)制數(shù)據(jù)。

u-boot.lds :linker scripte, 設(shè)置u-boot中各個(gè)目標(biāo)文件的連接地址.

網(wǎng)口設(shè)備控制程序

  在drivers/目錄中網(wǎng)口設(shè)備控制程序cs8900, bcm570x等, 還可以添加其他網(wǎng)卡驅(qū)動(dòng)
int eth_init (bd_t *bd) : 初始化網(wǎng)絡(luò)設(shè)備;
void eth_halt (void) : 關(guān)閉網(wǎng)絡(luò)設(shè)備;
int eth_send (volatile void *packet,int len) : 發(fā)送數(shù)據(jù)包;
int eth_rx (void) : 接收數(shù)據(jù)包。


Makefile

  在u-boot-1.0.0/Makefile中
at91rm9200dk_config : unconfig
./mkconfig $(@:_config=) arm at91rm9200 at91rm9200dk

1.8 編譯u-boot

  make at91rm9200_config
Configuring for at91rm9200 board...
make all
生成三個(gè)文件:u-boot.bin, u-boot, u-boot.srec

u-boot.bin is a raw binary image
u-boot is an image in ELF binary format
u-boot.srec is in Motorola S-Record format (objcopy -O srec -R.note -R.comment -S [inputfile] [outfile]


以上工作完成我們可以通過(guò)串口將u-boot.bin下載到主板的SDRAM中,它會(huì)自動(dòng)執(zhí)行, 并出現(xiàn)uboot>
這里我們可以通過(guò)串口把boot.bin, u-boot.bin.gz下載到主板,再用u-boot的提供的寫flash功能分別
把boot.bin, u-boot.bin.gz寫入到flash中,完成以上工作后,對(duì)主板跳線選擇片外啟動(dòng),
板子復(fù)位后會(huì)自動(dòng)啟動(dòng)u-boot.




二.loader.bin, boot.bin, u-boot.bin代碼執(zhí)行流分析.

以上三個(gè)文件時(shí)at91rm9200啟動(dòng)所需要的三個(gè)bin,他們的實(shí)現(xiàn)代碼并不難。
如果是你是采用at91rm9200的評(píng)估版,應(yīng)該能得到其源碼。

2.1 loader.bin 執(zhí)行流程,這個(gè)文件主要在片內(nèi)啟動(dòng)從串口下載代碼時(shí)會(huì)用到
loader/entry.S init cpu
b main ---> crt0.S
--> copydata --> clearbss --> b boot
main.c --> boot -->
/*Get internel rom service address*/
/* Init of ROM services structure */
pAT91 = AT91C_ROM_BOOT_ADDRESS;

/* Xmodem Initialization */
--> pAT91->OpenSBuffer
--> pAT91->OpenSvcXmodem
/* System Timer initialization */
---> AT91F_AIC_ConfigureIt
/* Enable ST interrupt */
AT91F_AIC_EnableIt
AT91F_DBGU_Printk("XMODEM: Download U-BOOT ");

Jump.S
// Jump to Uboot BaseAddr exec
Jump((unsigned int)AT91C_UBOOT_BASE_ADDRESS)



2.2 boot.bin執(zhí)行流程 該文件會(huì)在從片內(nèi)啟動(dòng)時(shí)被下載到板子上,以后還會(huì)被燒寫到片外Flash中,以便在片外啟動(dòng)時(shí)
用它來(lái)引導(dǎo)并解壓u-boot.gz,并跳轉(zhuǎn)到u-boot來(lái)執(zhí)行。
boot/entry.S
b main --> crt0.S --> copydata --> clearbss --> b boot

T91F_DBGU_Printk(" ");
AT91F_DBGU_Printk("************************************** ");
AT91F_DBGU_Printk("** Welcome to at91rm9200 ** ");
AT91F_DBGU_Printk("************************************** ");

boot/misc.s /* unzip uboot.bin.gz */
----> decompress_image(SRC,DST,LEN) --> gunzip

//jump to ubootBaseAddr exec 這里跳轉(zhuǎn)到解壓u-boot.gz的地址處直接開始執(zhí)行u-boot
asm("mov pc,%0" : : "r" (DST));

2.3 uboot.bin執(zhí)行流程
u-boot/cpu/at91rm9200/start.S
start --->reset
---> copyex ---> cpu_init_crit
---> /* set up the stack */ --> start_armboot
u-boot/lib_arm/board.c

init_fnc_t *init_sequence[] = {
cpu_init, /* basic cpu dependent setup */
board_init, /* basic board dependent setup */
interrupt_init, /* set up exceptions */
env_init, /* initialize environment */
init_baudrate, /* initialze baudrate settings */
serial_init, /* serial communications setup */
console_init_f, /* stage 1 init of console */
display_banner, /* say that we are here */
dram_init, /* configure available RAM banks */
display_dram_config,
checkboard,
NULL,
};

---> start_armboot ---> call init_sequence
---> flash_init --> display_flash_config
---> nand_init ---> AT91F_DataflashInit
---> dataflash_print_info --> env_relocate
---> drv_vfd_init --> devices_init --> jumptable_init
---> console_init_r --> misc_init_r --> enable_interrupts
---> cs8900_get_enetaddr --> board_post_init -->

u-boot/common/main.c
for (;;)
{ /* shell parser */
main_loop () --> u_boot_hush_start --> readline
--> abortboot
-->printf("Hit any key to stop autoboot: %2d ", bootdelay);
}


以上是at91rm9200啟動(dòng)并進(jìn)入u-boot的執(zhí)行流分析。后面u-boot還會(huì)將uImage解壓到特定的位置并開始執(zhí)行內(nèi)核代碼。


三. 綜述
總之, 不同廠商的出的Soc片子在啟動(dòng)方式大都提供片內(nèi)和片外啟動(dòng)兩種方式,一般都是在片內(nèi)固化一段小程序
方便于程序開發(fā)而已,在其DataSheet文檔中有詳盡的描述。若是對(duì)at92rm9200有興趣或玩過(guò)的朋友,可以與我共同探討相互學(xué)習(xí)。‘

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多