uboot移植之环境变量在NandFlash

时间:2024-07-18 11:35:44

一、概述

  u-boot环境变量可以设置在Norflash上,也可以在NandFlash上。

  倘若环境变量在NorFlash上,再假设S3C2440从NorFlash启动,是能正确从NorFlash上读取环境变量。但是,倘若从NandFlash启动,由于Bank0被挂载成S3C2440的stepstone,就不能从NorFlash上读取环境变量。

  倘若环境变量在NandFlash上,无论S3C2440以什么方式启动,由于NandFlash的逻辑空间与S3C2440的逻辑空间独立,NandFlash都能够正常使用,当然也能够从NandFlash上读取环境变量。

二、参数收集

1、NandFlash

芯片:K9F2G08U0B

擦除单位:块

块大小:128KB

2、环境变量存储区设置

uboot移植之环境变量在NandFlash

  可以看到,分区0是uboot代码区,分配了256KB,分区1是环境变量区,分配了NandFlash的一个Block,128KB。

三、移植

  修改TQ2440.h,添加如下内容。

/*-----------------------------------------------------------------------
*environment configuration
*/ //#define CFG_ENV_IS_IN_FLASH 1
//#define CFG_ENV_SIZE 0x20000 /* Total Size of Environment Sector */ #define CFG_ENV_IS_IN_NAND 1
#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x40000) /* addr of environment at 256K */
#define CFG_ENV_OFFSET 0x40000 /* Environment offset */
#define CFG_ENV_SIZE 0x20000 /* Environment Size 128K */ #define CFG_MONITOR_BASE CFG_ENV_ADDR