您的位置:首页 > Web前端

深入研究移植u-boot.

2010-11-22 16:33 1186 查看
从并行flash移植到串行flash(winbond 25Q64BVF1C(G)?)

http://www.winbond.com.tw/NR/rdonlyres/591A37FF-007C-4E99-956C-F7EE4A6D9A8F/0/W25Q64BV.pdf

http://www.spansion.com/Support/Datasheets/S25FL129P_00_06_e.pdf

env_relocate_spec()的定义处有:

 

   #   line  filename / context / line
   1     49  common/env_dataflash.c <<env_relocate_spec>>
             void env_relocate_spec (void )
   2     49  common/env_eeprom.c <<env_relocate_spec>>
             void env_relocate_spec (void )
   3    394  common/env_flash.c <<env_relocate_spec>>
             void env_relocate_spec (void )
   4     45  common/env_mgdisk.c <<env_relocate_spec>>
             void env_relocate_spec(void )
   5    287  common/env_nand.c <<env_relocate_spec>>
             void env_relocate_spec (void )
   6    346  common/env_nand.c <<env_relocate_spec>>
             void env_relocate_spec (void )
   7     40  common/env_nowhere.c <<env_relocate_spec>>
             void env_relocate_spec (void )
   8     95  common/env_nvram.c <<env_relocate_spec>>
             void env_relocate_spec (void )
   9     59  common/env_onenand.c <<env_relocate_spec>>
             void env_relocate_spec(void )
  10    119  common/env_sf.c <<env_relocate_spec>>
             void env_relocate_spec(void )

 

saveenv()的定义处有:

   #   line  filename / context / line                                                                    251,5         34%
   1     55  common/env_dataflash.c <<saveenv>>
             int saveenv(void )
   2     57  common/env_eeprom.c <<saveenv>>
             int saveenv(void )
   3    156  common/env_flash.c <<saveenv>>
             int saveenv(void )
   4    279  common/env_flash.c <<saveenv>>
             int saveenv(void )
   5     72  common/env_mgdisk.c <<saveenv>>
             int saveenv(void )
   6    184  common/env_nand.c <<saveenv>>
             int saveenv(void )
   7    227  common/env_nand.c <<saveenv>>
             int saveenv(void )
   8    104  common/env_nvram.c <<saveenv>>
             int saveenv (void )
   9     90  common/env_onenand.c <<saveenv>>
             int saveenv(void )
  10     62  common/env_sf.c <<saveenv>>
             int saveenv(void )
可见对不同的flash类型,都定义了通用的接口saveenv()和env_relocate_spec().

commond下的makefile定义了选择哪里的flash驱动.

50 # environment
 51 COBJS-y += env_common.o
 52 COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o
 53 COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o
 54 COBJS-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o                                                                      
 55 COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_embedded.o
 56 COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o
 57 COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_embedded.o
 58 COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 59 COBJS-$(CONFIG_ENV_IS_IN_MG_DISK) += env_mgdisk.o
 60 COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o
 61 COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o
 62 COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
 63 COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
 64 COBJS-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
而其中的CONFIG_ENV_IS_IN_FLASH在include/configs/emma3slx.h中定义.

 

在emma3slx.h中加入了CONFIG_ENV_IS_IN_SPI_FLASH, 编译,出现"CONFIG_ENV_OFFSET"没有定义的错误.

在emma3slx.h中加入了CONFIG_ENV_OFFSET的定义0xE00000后,就没有这个错误了.出现了下面的错误,

common/libcommon.a(env_sf.o): In function `env_relocate_spec':
/home/qlj/SRC/u-boot_src/u-boot_fta/include/spi_flash.h:(.text+0x70): undefined reference to `spi_flash_probe'
/home/qlj/SRC/u-boot_src/u-boot_fta/include/spi_flash.h:(.text+0xf4): undefined reference to `spi_flash_free'
make: *** [u-boot] Error 1

又定义了如下两个宏后,

CONFIG_SPI_FLASH

CONFIG_SPI_FLASH_SPANSION

出现如下错误:

drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_free':
spi_flash.c:(.text+0x1c): undefined reference to `spi_free_slave'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_cmd_write':
spi_flash.c:(.text+0x7c): undefined reference to `spi_xfer'
spi_flash.c:(.text+0xb4): undefined reference to `spi_xfer'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_cmd_read':
spi_flash.c:(.text+0x130): undefined reference to `spi_xfer'
spi_flash.c:(.text+0x168): undefined reference to `spi_xfer'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_read_common':
spi_flash.c:(.text+0x1dc): undefined reference to `spi_claim_bus'
spi_flash.c:(.text+0x220): undefined reference to `spi_release_bus'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_cmd':
spi_flash.c:(.text+0x280): undefined reference to `spi_xfer'
spi_flash.c:(.text+0x2b8): undefined reference to `spi_xfer'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_probe':
spi_flash.c:(.text+0x314): undefined reference to `spi_setup_slave'
spi_flash.c:(.text+0x32c): undefined reference to `spi_claim_bus'
spi_flash.c:(.text+0x370): undefined reference to `spi_release_bus'
spi_flash.c:(.text+0x390): undefined reference to `spi_release_bus'
spi_flash.c:(.text+0x39c): undefined reference to `spi_release_bus'
spi_flash.c:(.text+0x3ac): undefined reference to `spi_free_slave'
drivers/mtd/spi/libspi_flash.a(spansion.o): In function `spansion_write':
spansion.c:(.text+0x20c): undefined reference to `spi_claim_bus'
spansion.c:(.text+0x304): undefined reference to `spi_release_bus'
drivers/mtd/spi/libspi_flash.a(spansion.o): In function `spansion_erase':
spansion.c:(.text+0x430): undefined reference to `spi_claim_bus'
spansion.c:(.text+0x4f0): undefined reference to `spi_release_bus'
make: *** [u-boot] Error 1

 

需要CONFIG_ATMEL_SPI?不行,加上后,出现下面的错误,

 atmel_spi.c:28:26: error: asm/arch/clk.h: No such file or directory
atmel_spi.c:29:33: error: asm/arch/m
4000
emory-map.h: No such file or directory
make[1]: *** No rule to make target `.depend', needed by `libspi.a'.  Stop.

并且asm/arch/找不到这个目录. 

 

common/env_sf.c

common/cmd_sf.c中调用了spi_flash_read(),spi_flash_write(),spi_flash_erase().

 

 

使用windbond.c( #define CONFIG_SPI_FLASH_WINBOND)后,编译错误如下:

... configured for Nor Flash
Configuring for emma3slx board...
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_free':
spi_flash.c:(.text+0x1c): undefined reference to `spi_free_slave'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_cmd_write':
spi_flash.c:(.text+0x7c): undefined reference to `spi_xfer'
spi_flash.c:(.text+0xb4): undefined reference to `spi_xfer'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_cmd_read':
spi_flash.c:(.text+0x130): undefined reference to `spi_xfer'
spi_flash.c:(.text+0x168): undefined reference to `spi_xfer'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_read_common':
spi_flash.c:(.text+0x1dc): undefined reference to `spi_claim_bus'
spi_flash.c:(.text+0x220): undefined reference to `spi_release_bus'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_cmd':
spi_flash.c:(.text+0x280): undefined reference to `spi_xfer'
spi_flash.c:(.text+0x2b8): undefined reference to `spi_xfer'
drivers/mtd/spi/libspi_flash.a(spi_flash.o): In function `spi_flash_probe':
spi_flash.c:(.text+0x314): undefined reference to `spi_setup_slave'
spi_flash.c:(.text+0x348): undefined reference to `spi_claim_bus'
spi_flash.c:(.text+0x3b0): undefined reference to `spi_release_bus'
spi_flash.c:(.text+0x3c8): undefined reference to `spi_release_bus'
spi_flash.c:(.text+0x3d4): undefined reference to `spi_release_bus'
spi_flash.c:(.text+0x3e4): undefined reference to `spi_free_slave'
drivers/mtd/spi/libspi_flash.a(winbond.o): In function `winbond_wait_ready':
winbond.c:(.text+0x1b4): undefined reference to `spi_xfer'
winbond.c:(.text+0x200): undefined reference to `spi_xfer'
winbond.c:(.text+0x254): undefined reference to `spi_xfer'
drivers/mtd/spi/libspi_flash.a(winbond.o): In function `winbond_write':
winbond.c:(.text+0x2ec): undefined reference to `spi_claim_bus'
winbond.c:(.text+0x40c): undefined reference to `spi_release_bus'
drivers/mtd/spi/libspi_flash.a(winbond.o): In function `winbond_erase':
winbond.c:(.text+0x554): undefined reference to `spi_claim_bus'
winbond.c:(.text+0x640): undefined reference to `spi_release_bus'
make: *** [u-boot] Error 1
ls: cannot access u-boot.bin: No such file or directory

主要是下面的接口,没有定义:

spi_free_slave'

spi_xfer'
spi_claim_bus'

spi_release_bus'

spi_setup_slave'

基本上是SPI接口,.

应用程序在使用flash前,先spi_flash_probe(),检测flash类型(read ID code),看能否支持,然后调用spi_flash_probe_winbond(),得出flash的详细信息,并安装操作函数,

321     stm->flash.write = winbond_write;
322     stm->flash.erase = winbond_erase;
323     stm->flash.read = winbond_read_fast;

 

通过SPI相接的SPI flash,通过调用spi_flash.c中的通用接口spi_flash_cmd(), spi_flash_read_common()等来操作flash.

而调试用的V1.0的板子直接接到EMMA3SLP上的,没有spi,所以不能用这个驱动,得自己写了,主要有probe,erase, read, write.

 

注:

W25Q64 flash->128block->16sector->16page, 256bytes per page.

21:25

把flash的驱动放进winbond.c里了,还没有集成.

 

11/23 second day

现在和以前的状态一致了,需要在flash的erase和write驱动中加打印才能跑通.why?flash driver unstable?

 

使用another driver? same result, even same driver, at least same theory.

使用emma_writel写register? when time is enough.

 

next two point's printf is necessary. why?

in serialflash_write256b()

686     for (cnt = 0; cnt < length/4; cnt++) {
687         *(unsigned long *)SFLASH_BASE_ADDR = arr[cnt];
688     }  
689     printf("<%s>(%s)[%d]/r/n", __FILE__,__FUNCTION__, __LINE__);

 

in wait_status_notbusy()

602     int temp1 = 0xffffffff;                                                                                            
603 #if 1
604     while (temp1) {
605         emmaBROI_BROI_SERIALROM_CONTROL = 0x05000003;
606         printf("temp1=0x%x/r/n",temp1);
607 //        temp1 = 0xffffffff;  
608         temp1 = *(unsigned long *)SFLASH_BASE_ADDR;
609     }

 

so, leave this issue,  go on next board(16M S-flash).

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息