u-boot-2009.08在mini2440上的移植(十)---增加I2C EEPROM功能
扫描二维码
随时随地手机看文章
移植环境
1,主机环境:VMare下CentOS 5.5 ,1G内存。
2,集成开发环境:Elipse IDE
3,编译编译环境:arm-linux-gcc v4.4.3,arm-none-eabi-gcc v4.5.1。
4,开发板:mini2440,2M nor flash,128M nand flash。
5,u-boot版本:u-boot-2009.08
6,参考文章:
http://blogimg.chinaunix.net/blog/upfile2/100811115954.pdf
10.1,实现u-boot的I2C EEPROM功能
mini2440开发板上的AT24C08A芯片提供了8kbyte的非易失的EEPROM存储空间,而且是通过I2C协议进行读写的,U-boot提供了对I2C和EEPROM的操作支持。
打开/include/configs/mini2440.h,定位到206行附近,加入宏定义:
/*
* SD Card support
* */
#if 1
#define CONFIG_CMD_MMC
#define CONFIG_MMC1
#define CONFIG_MMC_S3C1/* Enabling the MMC driver */
#define CFG_MMC_BASE0xff000000
#endif
/**
* I2C and EEPROM support
*/
#if 1
#define CONFIG_CMD_EEPROM
#define CONFIG_CMD_I2C
#define CONFIG_DRIVER_S3C24X0_I2C 1 /* we use the buildin I2C controller */
#define CONFIG_HARD_I2C 1 /* I2C with hardware support */
#define CONFIG_SYS_I2C_SPEED 100000 /* I2C speed and slave address */
#define CONFIG_SYS_I2C_SLAVE 0x7F
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 /* EEPROM at24c08 */
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1 /* Bytes of address */
/* mask of address bits that overflow into the "EEPROM chip address" */
#define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW 0x07
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 4 /* The Catalyst CAT24WC08 has */
/* 16 byte page write mode using*/
/* last 4 bits of the address */
#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10 /* and takes up to 10 msec */
#define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
//#define CONFIG_ENV_IS_IN_EEPROM 1 /* use EEPROM for environment vars */
//#define CONFIG_ENV_OFFSET 0x000 /* environment starts at offset 0 */
//#define CONFIG_ENV_SIZE 0x400 /* 1KB */
#endif
10.2,重新编译测试
待编译完成后,nor档下载nand档启动,操作如下:
[u-boot@MINI2440]# help i2c
i2c - I2C sub-system
Usage:
i2c speed [speed] - show or set I2C bus speed
i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device
i2c mm chip address[.0, .1, .2] - write to I2C device (auto-incrementing)
i2c mw chip address[.0, .1, .2] value [count] - write to I2C device (fill)
i2c nm chip address[.0, .1, .2] - write to I2C device (constant address)
i2c crc32 chip address[.0, .1, .2] count - compute CRC32 checksum
i2c probe - show devices on the I2C bus
i2c reset - re-init the I2C Controller
i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device
[u-boot@MINI2440]# i2c speed
Current bus speed=100000
[u-boot@MINI2440]# i2c probe
Valid chip addresses: 50 51 52 53
[u-boot@MINI2440]# i2c
在上面的mini2440.h文件中,CONFIG_ENV_IS_IN_EEPROM是注释掉的,如果想将环境变量保存的位置设置在EEPROM中,需要将nandflash的CONFIG_ENV_IS_IN_NAND的相关几行代码注释掉,将上面注释掉的几行代码恢复即可。这里先不作修改了。
10.3 本次u-boot移植遗留问题
【1】由于mini2440出厂配置的LCD的型号是TD035STED4,是240X320分辨率的,是竖屏,但是想进行横向输出时遇到了困难,究竟怎么实现,还有待研究。
【2】开机时显示的logo信息,旁边空白的部分没有文字显示,如何实现开机是logo图片周边有文字环绕,还有待研究。
【3】开机时的详细,可以通过环境变量stdout设置成vga是LCD输出,serial是串口控制台输出。看要要想两者同时输出时遇到了困难。
【4】开机前LCD动画显示后在输出信息还没有实现。