最新消息:天气越来越冷,记得加一件厚衣裳

U-Boot之Bootstrap存储分配定义

IOT开发 w3sun 1767浏览 0评论

基础搭配

U-Boot-2010.06+Bootstrap1.16

代码分析

打开at91sam9263ek对应的配置文件:include/configs/at91sam9263ek.h,首先修改时钟,默认为:

#define CONFIG_SYS_AT91_MAIN_CLOCK 16367660  /* 16.367 MHz crystal */

修改为:

#define CONFIG_SYS_AT91_MAIN_CLOCK 18432000 /* 18.432 MHz crystal */

本文使用的板子本身不支持NANDFLAH启动,接下来分析at91sam9263ek.h下Dataflash启动部分的代码:

/* bootstrap + u-boot + env + linux in dataflash on CS0 */
#define CONFIG_ENV_IS_IN_DATAFLASH       1  /*片选,不用说*/
#define CONFIG_SYS_MONITOR_BASE   (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + 0x8400)
#define CONFIG_ENV_OFFSET         0x4200
#define CONFIG_ENV_ADDR   (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0+CONFIG_ENV_OFFSET)
#define CONFIG_ENV_SIZE                0x4200
#define CONFIG_BOOTCOMMAND "cp.b 0xC0042000 0x22000000 0x210000; bootm"
#define CONFIG_BOOTARGS             "console=ttyS0,115200 " \
                                    "root=/dev/mtdblock0 " \
                                    "mtdparts=atmel_nand:-(root) "\
                                    "rw rootfstype=jffs2"

/* bootstrap + u-boot + env + linux in dataflash on CS0 */的意思就是将片选CS0定位与dataflash,下文中:

#defineCONFIG_SYS_MONITOR_BASE (CONFIG_SYS_DATAFLASH_LOGIC_ADD R_ CS0 + 0x8400) 

+0x8400,结合Bootstrap的解释代码和U-boot的partition.c可以知道是U-boot的偏移量,也就是说0x8400以前的都是Bootstrap部分。

#define CONFIG_ENV_OFFSET       //0x4200保存U-boot变量的起始地址
#define CONFIG_ENV_SIZE         //0x4200保存U-boot变量的空间的大小

定制设置

修改后的Bootstrap和U-boot的代码如下:

/* ******************************************************************* */
/* BootStrap Settings                                                 */
/*                                                                    */
/* ******************************************************************* */
#define AT91C_SPI_PCS_DATAFLASH   AT91C_SPI_PCS0_DATAFLASH  /*Boot on SPI NCS0*/
#define IMG_ADDRESS                0x8000                   /*Image Address in DataFlash*/
#define IMG_SIZE                   0x40000                  /*Image Size in DataFlash*/
#define MACH_TYPE                  0x4B2                    /*AT91SAM9263-EK*/
#define JUMP_ADDR                  0x23F00000               /*Final Jump Address*/
/* ******************************************************************* */
//分区代码:
/*define the area offsets*/
dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
        {0x00000000, 0x00003FFF, FLAG_PROTECT_SET,  0, "Bootstrap"},
        {0x00004000, 0x00007FFF, FLAG_PROTECT_CLEAR, 0, "Environment"},
        {0x00008000, 0x00047FFF, FLAG_PROTECT_SET,  0, "U-Boot"},
        {0x00048000, 0x0041FFFF, FLAG_PROTECT_CLEAR, 0,    "Kernel"},
        /*{0x00252000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0,"FS"},*/
};

//CS0片选部分代码:

/* bootstrap + u-boot + env + linux in dataflash on CS0 */
#define CONFIG_ENV_IS_IN_DATAFLASH       1  /*片选,不用说*/
#define CONFIG_SYS_MONITOR_BASE   (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 +0x8000)
#define CONFIG_ENV_OFFSET         0x4000
#define CONFIG_ENV_ADDR            (CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0 + CONFIG_ENV_OFFSET)
#define CONFIG_ENV_SIZE                0x4000
#define CONFIG_BOOTCOMMAND "cp.b 0xC0042000 0x22000000 0x210000; bootm"
#define CONFIG_BOOTARGS             "console=ttyS0,115200 " \
                                    "root=/dev/mtdblock0 " \
                                    "mtdparts=atmel_nand:-(root) "\
                                    "rw rootfstype=jffs2"

最后进行编译:

[root@llocalhost u-boot-2.10.06]# make distclean
[root@llocalhost u-boot-2.10.06]#make at91sam9263ek_dataflash_cs0_config
... with environment variable in SPI DATAFLASH CS0
Configuring for at91sam9263ek board...
[root@llocalhost u-boot-2.10.06]#make

转载请注明:雪后西塘 » U-Boot之Bootstrap存储分配定义

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址