张公案2 微盘:AT91SAM9260EK移植Bootstrap-v1.15
来源:百度文库 编辑:偶看新闻 时间:2024/05/02 06:17:21
第一步 Bootstrap的编译
Bootstrap的源码来自:ftp://www.at91.com/pub/
本人使用Bootstrp-v1.15.zip
解压命令:#unizp AT91Bootstrap1.15.zip
建立交叉编译环境:
交叉编译工具链:arm-2007q1-10-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
来源于:www.linux4sam.org 进入这个网页 点击Software tools 里可以找到。
解压到/usr/local/toolchain (注:local下并没有toolchain,我们自己创建:#mkdir toolchain)下
命令:#tar xvf arm-2007q1-10-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
在local下生成arm-2007q1 #cd arm-2007q1/bin
测试一下是否成功:#./arm-none-linux-gnueabi-gcc-v
如果显示如下代码:
Using built-in specs.
Target: arm-none-linux-gnueabi
…………………………………………………………………………………………
gcc version 4.2.0 20070413 (prerelease) (CodeSourcery Sourcery G++ Lite 2007q1-10)
则为成功。
下面修改 Bootstrap
1. Include/nand_ids.h文件夹
找到:
#include "../include/nandflash.h"
/* Supported NandFlash devices */
static struct SNandInitInfo NandFlash_InitInfo[] = {
{0xecda, 0x800, 0x20000, 0x800, 0x40, 0x0, "K9F2G08U0M\0"},
{0xecaa, 0x800, 0x20000, 0x800, 0x40, 0x0, "K9F2G08R0A\0"},
{0x2cca, 0x800, 0x20000, 0x800, 0x40, 0x1, "MT29F2G16AAB\0"},
{0x2cda, 0x800, 0x20000, 0x800, 0x40, 0x0, "MT29F2G08AAC\0"},
{0x20aa, 0x800, 0x20000, 0x800, 0x40, 0x0, "STMNAND02GR3B\0"},
{0x2caa, 0x800, 0x20000, 0x800, 0x40, 0x0, "MT29F2G08ABD\0"},
{0,}
};
仿照上面加上一句话:
{0xec76, 0x1000,0x4000, 0x200, 0x10, 0x0, "K9F1208U0C\0"},
因为我们用的Nandflash 是 K9F1208U0C型号,所以加上它的定义结构。
这里的参数是什么东西???
我们可以#include "../include/nandflash.h" 照到同目录下的nandflash.h文件 vi一下。
可以看到这样的结构:
typedef struct SNandInitInfo
{
unsigned short uNandID ; 芯片ID
unsigned short uNandNbBlocks ; 芯片的块数
unsigned int uNandBlockSize ; 每块的有效字节数
unsigned short uNandSectorSize; 每页的有效字节数
unsigned char uNandSpareSize ; 每页的空闲字节数
unsigned char uNandBusWidth ; 总线的宽度
char name[16] ; 芯片的名称
} SNandInitInfo, *PSNandInitInfo;
这些数据可以到K9F1208U0C的数据手册上查找把他填充上。
2.vi board/at91sam9260ek/nandflah/Makefile
定义一下交叉编译路径:
ifndef CROSS_COMPILE
CROSS_COMPILE=/usr/local/toolchain/arm-2007q1/bin/arm-none-linux-gnueabi-
endif
然后保存退出
Make一下 如果没有意外会生成nandflash_at91sam9260ek.bin文件,这个文件能不能用还需打个问号???
这样编译的nandflash_at91sam9260ek.bin可能会大于4K,我们的平台大于4K是烧不上去的。
所以我们可以注释掉上面的其它nandflash的信息。
// {0xecda, 0x800, 0x20000, 0x800, 0x40, 0x0, "K9F2G08U0M\0"},
//{0xecaa, 0x800, 0x20000, 0x800, 0x40, 0x0, "K9F2G08R0A\0"},
// {0x2cca, 0x800, 0x20000, 0x800, 0x40, 0x1, "MT29F2G16AAB\0"},
//{0x2cda, 0x800, 0x20000, 0x800, 0x40, 0x0, "MT29F2G08AAC\0"},
//{0x20aa, 0x800, 0x20000, 0x800, 0x40, 0x0, "STMNAND02GR3B\0"},
//{0x2caa, 0x800, 0x20000, 0x800, 0x40, 0x0, "MT29F2G08ABD\0"},
这样是不是很爽!!!
如果这样编译出来的还大于4K怎么办,如果你使用高版本的交叉编译工具链是可能出现这样的情况的。我使用过arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
编译出来的就是大于4K。
解决方法 修改Bootstrap的优化等级。在Makefile里找到这段代码:
OBJDUMP=$(CROSS_COMPILE)objdump
CCFLAGS=-g -mcpu=arm926ej-s -Os -Wall -D$(TARGET) -I$(INCL)
ASFLAGS=-g -mcpu=arm926ej-s -c -Os -Wall -D$(TARGET) -I$(INCL) -DTOP_OF_MEM=$(TOP_OF_MEMORY)
修改为:
OBJDUMP=$(CROSS_COMPILE)objdump
CCFLAGS=-g -mcpu=arm926ej-s –O2 -Wall -D$(TARGET) -I$(INCL)
ASFLAGS=-g -mcpu=arm926ej-s -c –O2 -Wall -D$(TARGET) -I$(INCL) -DTOP_OF_MEM=$(TOP_OF_MEMORY)
这里改为1或者2都行,我觉得2没什么不好,就试了2。
这样改过 再make一下,把生成的nandflash_at91sam9260ek.bin文件烧上去看能否跑起来。
如果不出意外是看不到效果的,其实我们的nandflash_at91sam9260ek.bin已经成功,只是我们没有往终端打印信息罢了。我在这个地方浪费很多时间。
好吧让它打印吧 不管是死是活得有个准啦
我们vi board/at91sam9260ek/at91sam9260ek.h
找到:
#undef CFG_DEBUG //这句话是关掉DEBUG的打印信息
咱们把它改为
#define CFG_DEBUG
从新make一下应该没问题了。 QQ:525548314