Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1224251
  • 博文数量: 479
  • 博客积分: 12240
  • 博客等级: 上将
  • 技术积分: 4999
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-24 17:12
文章分类

全部博文(479)

文章存档

2014年(1)

2013年(1)

2012年(1)

2011年(95)

2010年(177)

2009年(167)

2008年(16)

2007年(21)

分类: 嵌入式

2009-10-14 19:44:01

U-Boot for LPC3250


Linux 2.6.27.8版本的配套U-Boot

    烧写全新U-Boot后,默认参数很少,需要根据自己的实际环境进行设置和更改。
    包括ip、服务器的IP、网关、文件名,甚至连bootcmd也需要自行配置。如下是配置好的参数:
U-Boot 1.3.3 (Feb  3 2009 - 10:03:29)

DRAM:  64 MB
NAND:  32 MiB
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
uboot> printenv
bootdelay=3
baudrate=115200
ethaddr=DE:AD:BE:EF:00:01
netmask=255.255.255.0
gatewayip=192.168.1.1
bootfile=uImage
ipaddr=192.168.7.236
serverip=192.168.7.110
ipaddr=192.168.7.236
gatewayip=192.168.7.254
bootcmd=tftpboot;bootm
stdin=serial
stdout=serial
stderr=serial

    非常有必要对U-Boot进行修改,添加必要的默认参数,以使更加方便使用。

单独编译U-Boot

    下载u-boot和补丁

        到GPP下载u-boot-1.3.3.tar.bz2和u-boot-1.3.3-lpc32xx.patch。假定在~/home/u-boot目录下。

    打补丁

        先解压u-boot-1.3.3.tar.bz2,得到u-boot-1.3.3目录,然后使用patch命令进行打补丁:
    [chenxibing@localhost u-boot]$ cat u-boot-1.3.3-lpc32xx.patch | patch -p1 -d u-boot-1.3.3

    编译phy3250的U-Boot

        为了以后编译方便,写一个脚本用于编译U-Boot,文件名build-uboot,内容如下:

    #!/bin/sh

    make ARCH=arm CROSS_COMPILE=/opt/nxp/gcc-4.3.2-glibc-2.7/bin/arm-vfp-linux-gnu- phy3250_config
    make ARCH=arm CROSS_COMPILE=/opt/nxp/gcc-4.3.2-glibc-2.7/bin/arm-vfp-linux-gnu- 

        给build-uboot增加可执行权限后,运行即可。
        $ ./build-uboot


增加SmartARM3250支持 

    增加编译项

        修改顶层目录的Makefile,增加SmartARM3250的编译项,可以参考phy3250的,在NXP ARM926EJ-S Systems处增加。

2360 #########################################################################   

2361 ## NXP ARM926EJ-S Systems

2362 #########################################################################

2363 

2364 phy3250_config  :   unconfig

2365     @$(MKCONFIG) $(@:_config=) arm arm926ejs phy3250 NULL lpc3250

2366 

2367 smartarm3250_config :   unconfig

2368     @$(MKCONFIG) $(@:_config=) arm arm926ejs smartarm3250 zhiyuan lpc3250

        如上的设置,要求在board目录下建立zhiyuan目录,然后在其中建立smartarm3250目录,并存放板级支持文件。

    增加板级目录并修改

       在board目录下建立zhiyuan目录,并将参考版目录board/phy3250目录复制为zhiyuan/smartarm3250。修改phy3250相关文件为smartarm3250,并修改相关文件,如Makefile等。

    增加默认配置文件

        在include/configs/目录下增加smartarm3250的配置文件,可从phy3250.h复制而来,然后进行修改。

    编译

        修改编译文件,编译U-Boot,如果遇到问题,进行修改即可。有可能一些文件还没有改完,如smartarm3250目录下的net.c等。

LED驱动

        LED2由GPO_06驱动。
        U-Boot中LPC3250的GPIO操作范例:
 
146     GPIO->p3_outp_clr = OUTP_STATE_GPIO(5);
147     ssp_write(out, bytes);
148     while (rbytes < bytes)                                                                                                                                                
149     {
150         rbytes += ssp_read(&in [rbytes], 1);
151     }
152 
153     GPIO->p3_outp_set = OUTP_STATE_GPIO(5);
        
        其中GPIO结构在include/lpc3250.h中定义:
1786 /* Macro pointing to GPIO registers */
1787 #define GPIO  ((GPIO_REGS_T *)(GPIO_BASE))
        lpc3250.h中还有其它如SLCNAND、MAC等定义,在使用的时候直接使用即可。

        LPC3250的GPI、GPO、GPIO等使用比较复杂,需要仔细对照用户手册进行操作。对于存在功能复用的,需要首先设置MUX寄存器,对功能进行选择。但是引脚和寄存器的关系比较乱,需要仔细对照。
        下面是通过GPO_06控制LED2的代码,首先设置P3_MUX_CLR寄存器的bit6,设置为GPO_06,然后设置p3_outp_set或者p3_outp_clr寄存器。至于为何是P3端口,请分别查看用户手册GPIO和MUX章节。

156     GPIO->p3_mux_clr = 1<<6;      //configure as GPO_6  配置为GPO_06
157     //GPIO->p3_outp_set = 1<<6;   //                    输出高电平                                                                 
158     GPIO->p3_outp_clr = 1<<6;     //                    输出低电平


NAND FLASH驱动

    写保护

        GPIO14是写保护引脚,低有效。GPO_14是单功能引脚,仅仅GPO功能。

NAND FLASH和环境变量

    该本版U-Boot将U-Boot的环境变量env存放在U-Boot中。注意,环境变量的存放地址一定要以扇区为单位(扇区、Block对齐),否则无法保存。
    文件:include/configs/开发板.h
    这是Phy3250的参数,Phy3250采用32MB的NAND FLASH,扇区大小为16KB:
189 /* Phy3250's NAND FLASH, 32MB, 16K size(Block, Sector) */
190 //#define CFG_ENV_SIZE             0x4000      /* 1 block, 16K */
191 //#define CFG_ENV_OFFSET        0x168000  /* Block 90       */

    如下是SmartARM3250的NAND FLASH,K9F2G08,256MB,扇区大小为128K:
193 /* SmartARM3250's NAND FLASH, K9F2G08, 256MB, 128K size(Block, Sector) */
194 #define CFG_ENV_SIZE           0x40000       /* 2 Block, 256K */
195 #define CFG_ENV_OFFSET      0x180000     /* Block 12         */  

    NAND FLASH规划:
 
        分     区                                   地址范围                        扇区范围                    大    小                                 用     途
    Bootloader             0x0000 0000 ~ 0x0018 0000         0 ~ 11                     12个扇区,1.50M                 S1L和U-Boot
    param                    0x0018 0000 ~ 0x001C 0000         12~13                      2个扇区,  256K                  U-Boot参数
    保留                        0x001C 0000 ~ 0x0020 0000         14~15
    Linux Kernel           0x0020 0000 ~ 0x0060 0000         16~47                      32个扇区,4.00M                Linux内核
    Safefs                    0x0060 0000 ~ 0x0016 0000          48~176                    128个扇区,16M                 Linux安全文件系统(cramfs)
    Rootfs                    0x0160 0000 ~ 0x1000 0000         176~2047           2000-128个扇区,250-16M            Linux文件系统              
    
        
 
rootfs
2047

176
 
共2000-128扇区
 
    safefs
 175

48
 
128扇区

 Kernel
47

16

共32扇区 

 保留
15 

14
 
共2扇区

 param
13
 
12
 
共2扇区
 
Bootlloader
11 

0
 
共12扇区
  

在linux-2.6.27.8/arch/arm/mach-lpc32xx/board-smartarm3250.c中的实现代码:
153 #define BLK_SIZE (0x20000) //128KB
154 static struct mtd_partition __initdata smartarm3250_nand_partition[] = {
155     {
156         .name   = "smartarm3250-boot",
157         .offset = 0,
158         .size   = (BLK_SIZE * 12)
159     },
160     {
161         .name   = "smartarm3250-ubt-prms",
162         .offset = (BLK_SIZE * 12),
163         .size   = (BLK_SIZE * 2)
164     },
165     {
166         .name   = "smartarm3250-kernel",
167         .offset = (BLK_SIZE * 16),
168         .size   = (BLK_SIZE * 32)
169     },
170     {
171         .name   = "smartarm3250-rootfs",
172         .offset = (BLK_SIZE * 48),
173         .size   = MTDPART_SIZ_FULL
174     },
175 };


NXP后来发过一个补丁,修改了u-boot的CFG_LOAD_ADDR的值:
 18  /*
 19   * Default load address for programs
 20   */
 21 -#define    CFG_LOAD_ADDR       0x80010000  /* default load address */
 22 +#define    CFG_LOAD_ADDR       0x80100000  /* default load address */


参数设置注意事项


这个版本的U-Boot设置参数不能加引号,否则参数内核将无法启动:
setenv bootargs root=/dev/nfsroot console=tty0 console=ttyS0,115200n8 nfsroot=192.168.7.231:/home/chenxibing/lpc3250/ltib/rootfs  ip=192.168.7.236:192.168.7.1:192.168.7.1:255.255.255.0:nxp.z:eth0:off

阅读(2773) | 评论(0) | 转发(5) |
0

上一篇:Stage 1 Loader

下一篇:NOR FLASH的U-Boot

给主人留下些什么吧!~~