Chinaunix首页 | 论坛 | 博客
  • 博客访问: 548323
  • 博文数量: 105
  • 博客积分: 3274
  • 博客等级: 中校
  • 技术积分: 1161
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-21 12:14
文章分类

全部博文(105)

文章存档

2011年(1)

2010年(104)

分类: LINUX

2010-07-01 20:26:29

    从armel的官方网站上下载bootstrap,现在最新的版本是1.6。
    准备使用的板子上有dataflash和nandflash,为了不损耗nandflash,决定把bootstrap的程序与u-boot的程序都放在dataflash里面。
看看下面这句代码
 /* Load from Dataflash in RAM */
#ifdef CFG_DATAFLASH
 load_df(AT91C_SPI_PCS_DATAFLASH, IMG_ADDRESS, IMG_SIZE, JUMP_ADDR);
#endif
AT91C_SPI_PCS_DATAFLASH是一个宏如下
#define AT91C_SPI_PCS_DATAFLASH  AT91C_SPI_PCS0_DATAFLASH /* Boot
on SPI NCS0 */
它采用的spi ncs0。
然后是
#define IMG_ADDRESS    0x8400   /* Image Address
in DataFlash */
#define IMG_SIZE   0x33900   /* Image Size in
DataFlash    */
#define JUMP_ADDR   0x23F00000  /* Final Jump
Address        */
IMG_ADDRESS  这里为什么选择0x8400呢?0x8400/1024 = 33k 远远大于4k,U-boot的起始地
址放在这里是足了,至于为什么这么做,而不是更小一点,还等后续判断。
IMG_SIZE 0x33900/1024 = 206k,这里就表明了放在dataflash的U-boot程序不应该大于206k,
实际使用的时候大约是150k左右。
JUMP_ADDR的地址是0x23f00000,与u-boot的起始地址相对应,至于为什么选这个地址,也得后续验证。

这个程序的最后就是直接
return JUMP_ADDR;
直接返回到SDRAM(at91sam9263的一路sdram地址是0x20000000--0x2fffffff)去了。
 
大致原理清楚以后,就开始编译程序。
在源代码中的readme说的很清楚了,如下
1 Compiling an at91bootstrap project
1.1 GNU ARM Toolchain ===========================================================================================
1.1.1 Linux
AT91Bootstrap has been compiled and tested under Linux using the following GNU ARM binary distribution which can be downloaded from the following URL: GCC-3.4 toolchain: binutils-2.15, gcc-3.4.3-c-c++-java, newlib-1.12.0, insight-6.1, tar.bz2 (or newer) Once your toolchain is installed, install at91bootstrap in a directory and cd into it.
1.1.2 Windows
AT91Bootstrap has been compiled and tested under Cygwin using the following GNU ARM binary distribution which can be downloaded from the following URL: GCC-4.1 toolchain: binutils-2.16.1, gcc-4.1.0-c-c++, newlib-1.14.0, insight-6.4, setup.exe (or newer) Note: Cygwin can be downloaded from the following
1.2 Compiling DataFlashBoot ===========================================================================================
1.2.1 AT91SAM9261-EK
--------------------- Go into the project directory >  cd board/at91sam9261ek/dataflash >  make
Configurations are in Makefile and at91sam9261ek.h files and can be modified according your needs.
1.2.2 AT91SAM9260-EK
--------------------- Go into the project directory >  cd board/at91sam9260ek/dataflash >  make
Configurations are in Makefile and at91sam9260ek.h files and can be modified according your needs.
=================================================================================================== ===  WARNING for AT91SAM9260 DataFlashBoot       === =================================================================================================== DataFlashBoot binary image size must be less than 4kBytes as it is the AT91SAM9260 internal available SRAM size.
According the GCC toolchain which is used (GCC-3.4 Toolchain or less), resulting code size may be higher than the allowed 4kBytes. In such a case, either update your GCC toolchain to a more recent one (GCC-4.0 Toolchain or higher) or do not use the provided gpio driver to configure SDRAM PIOs for example. Indeed, replace sdramc_hw_init() function in board/at91sam9260ek.c source file by:
#ifdef CFG_SDRAM void sdramc_hw_init(void) { /* Configure the PIO controller to enable 32-bits SDRAM */ writel(0xFFFF0000, AT91C_BASE_PIOC + PIO_ASR(0)); writel(0xFFFF0000, AT91C_BASE_PIOC + PIO_PDR(0)); } #endif
Note: Code is less readable but it should be sufficient enough to have less than 4kBytes code size without having to re-compile a complete GCC toolchain.
 
所以直接进入
board/at91sam9263ek/dataflash >  make
 
当然这里,你需要在Makefile把交叉编译改成你所使用的交叉编译器。
 
编译成功后就会生成bin文件,烧入到dataflash就行了。
 
 
 
阅读(2622) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~