u-boot-2009.08在mini2440上的移植(十)---增加I2C EEPROM功能
移植環(huán)境
1,主機(jī)環(huán)境:VMare下CentOS 5.5 ,1G內(nèi)存。
2,集成開發(fā)環(huán)境:Elipse IDE
3,編譯編譯環(huán)境:arm-linux-gcc v4.4.3,arm-none-eabi-gcc v4.5.1。
4,開發(fā)板: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,實(shí)現(xiàn)u-boot的I2C EEPROM功能
mini2440開發(fā)板上的AT24C08A芯片提供了8kbyte的非易失的EEPROM存儲空間,而且是通過I2C協(xié)議進(jìn)行讀寫的,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是注釋掉的,如果想將環(huán)境變量保存的位置設(shè)置在EEPROM中,需要將nandflash的CONFIG_ENV_IS_IN_NAND的相關(guān)幾行代碼注釋掉,將上面注釋掉的幾行代碼恢復(fù)即可。這里先不作修改了。
10.3 本次u-boot移植遺留問題
【1】由于mini2440出廠配置的LCD的型號是TD035STED4,是240X320分辨率的,是豎屏,但是想進(jìn)行橫向輸出時遇到了困難,究竟怎么實(shí)現(xiàn),還有待研究。
【2】開機(jī)時顯示的logo信息,旁邊空白的部分沒有文字顯示,如何實(shí)現(xiàn)開機(jī)是logo圖片周邊有文字環(huán)繞,還有待研究。
【3】開機(jī)時的詳細(xì),可以通過環(huán)境變量stdout設(shè)置成vga是LCD輸出,serial是串口控制臺輸出??匆雰烧咄瑫r輸出時遇到了困難。
【4】開機(jī)前LCD動畫顯示后在輸出信息還沒有實(shí)現(xiàn)。