本次修改是建立在上次版本之上,相对于nand的环境变量支持,SD卡的就相对麻烦些。
修改real210.h头文件,修改部分如下所示:
/*-----------------------------------------------------------------------
* Boot configuration
*/
#if 0
//#define CONFIG_ENV_IS_IN_ONENAND 1
#define CONFIG_ENV_IS_NOWHERE 1
#define CONFIG_ENV_SIZE (128 << 10) /* 128KiB, 0x20000 */
#define CONFIG_ENV_ADDR (256 << 10) /* 256KiB, 0x40000 */
#define CONFIG_ENV_OFFSET (256 << 10) /* 256KiB, 0x40000 */
#define CONFIG_USE_ONENAND_BOARD_INIT
#define CONFIG_SAMSUNG_ONENAND 1
#define CONFIG_SYS_ONENAND_BASE 0xE7100000
#endif
//#define CONFIG_ENV_IS_IN_NAND 1 /* 打开该宏,环境变量会保存在nand,同时CONFIG_ENV_IS_IN_MMC和CONFIG_SYS_MMC_ENV_DEV需要注释掉*/
#define CONFIG_ENV_IS_IN_MMC 1 /* 打开该宏,环境变量会保存在mmc,同时CONFIG_SYS_MMC_ENV_DEV需要打开并注释掉CONFIG_ENV_IS_IN_NAND*/
#define CONFIG_SYS_MMC_ENV_DEV 0
#define CONFIG_CMD_SAVEENV /* 开启环境变量操作命令*/
#define CONFIG_ENV_SIZE 0x40000 /* 环境变量的大小 */
#define CONFIG_ENV_ADDR 0 /* 该定义不清楚什么作用,测试结果它的值没有影响环境变量的存储地址 */
#define CONFIG_ENV_OFFSET 0x80000 /* 环境变量nand相对基址的偏移量,u-boot的大小一般在500KB以内,所以环境变量设置在512KB到1MB之间即可 */
增加下面代码
/*SD driver*/
#define CONFIG_GENERIC_MMC
#define CONFIG_MMC
#define CONFIG_SDHCI
#define CONFIG_S5P_SDHCI
#define CONFIG_CMD_MMC
修改real210.c文件,增加下面的代码:
#ifdef CONFIG_GENERIC_MMC
int board_mmc_init (bd_t *bis)
{
//printf ("haha\n");
/*#define GPG0CON (*(volatile unsigned int *)0xE02001A0)
#define GPG0DRV (*(volatile unsigned int *)0xE02001AC)
#define GPG3CON (*(volatile unsigned int *)0xE0200200) */
#define CLK_DIV4 (*(volatile unsigned int *)0xE0100310)
#define CLK_SRC4 (*(volatile unsigned int *)0xE0100210)
#define MOUTMMC (50000000) /* 50MHz */
unsigned long clk_src, clk_div, mpll, div;
//初始化MMC0 MM3管脚,4bit模式
*(volatile unsigned int *)GPG0CON = (0x2<<0)|(0x2<<4)|(0x2<<8)|(0x2<<12)|(0x2<<16)|(0x2<<20)|(0x2<<24);
*(volatile unsigned int *)GPG3CON = (0x2<<0)|(0x2<<4)|(0x2<<8)|(0x2<<12)|(0x2<<16)|(0x2<<20)|(0x2<<24);
//GPG0DRV = 0x3fdf;
//初始化SD时钟
clk_src = CLK_SRC4;
clk_src &= ~((0xf << 12) | 0xf);
clk_src |= (0x6 << 12) | 0x6;
mpll = get_pll_clk(MPLL);
div = ((mpll + MOUTMMC) / MOUTMMC) - 1;
clk_div = CLK_DIV4;
clk_div &= ~((0xf << 12) | 0xf);
clk_div |= (div << 12) | div;
CLK_SRC4 = clk_src;
CLK_DIV4 = clk_div;
return s5p_sdhci_init(0xEB000000, 0, 4)|s5p_sdhci_init(0xEB000000, 0, 4)|s5p_sdhci_init(0xEB300000, 1, 4);
}
#endif
改完保存,编译,测试。