移植中出现的问题
s3c2410_nand.c: In function 's3c2410_hwcontrol':
s3c2410_nand.c:57: warning: implicit declaration of function 's3c2410_get_base_nand'
s3c2410_nand.c:57: warning: initialization makes pointer from integer without a cast
s3c2410_nand.c:72: error: dereferencing pointer to incomplete type
s3c2410_nand.c:72: error: dereferencing pointer to incomplete type
s3c2410_nand.c:75: error: dereferencing pointer to incomplete type
s3c2410_nand.c:75: error: dereferencing pointer to incomplete type
s3c2410_nand.c: In function 's3c2410_dev_ready':
s3c2410_nand.c:85: warning: initialization makes pointer from integer without a cast
s3c2410_nand.c:87: error: dereferencing pointer to incomplete type
s3c2410_nand.c: In function 'board_nand_init':
s3c2410_nand.c:129: warning: initialization makes pointer from integer without a cast
s3c2410_nand.c:150: error: dereferencing pointer to incomplete type
s3c2410_nand.c:153: error: dereferencing pointer to incomplete type
s3c2410_nand.c:154: error: dereferencing pointer to incomplete type
make[2]: *** [s3c2410_nand.o] Error 1
make[1]: Leaving directory`/work/my/u-boot-2012.04.01/drivers/mtd/nand'
这里看到网上提供相似的方案,就想到这里也屏蔽nand部分代码回头再讲
在drivers/mtd/nand/Makefile里面有COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
一般宏都在自己定义单板的头文件,我这里定义的头文件为mini2440.h
/*
* NAND configuration
*/
#ifdef CONFIG_CMD_NAND
#define CONFIG_NAND_S3C2410
#define CONFIG_SYS_S3C2410_NAND_HWECC
#define CONFIG_SYS_MAX_NAND_DEVICE 1
#define CONFIG_SYS_NAND_BASE 0x4E000000
#endif
看到只需不定义CONFIG_CMD_NAND,这个文件前面就有,屏蔽即可
//#define CONFIG_CMD_NAND
再次编译
fs/yaffs2/libyaffs2.o: In function `yaffs_StartUp':
/work/my/u-boot-2012.04.01/fs/yaffs2/yaffscfg.c:210: undefined reference to `nand_info'
make: *** [u-boot] Error 1
再次屏蔽下面即可
//#define CONFIG_YAFFS2
烧写进uboot到nor flash出现以下错误
U-Boot 2012.04.01 (Oct 30 2013 - 04:26:19)
CPUID: 32440001
FCLK: 405.600 MHz
HCLK: 101.400 MHz
PCLK: 50.700 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: *** failed ***
### ERROR ### Please RESET the board ###
首先搜寻Flash: *** failed ***,当然这里一定要先搜Flash: 或者*** failed ***或者Flash: *** failed ***
然后可以找到以下代码(arch/arm/lib/board.c)
#if !defined(CONFIG_SYS_NO_FLASH)
static char *failed = "*** failed ***\n";
#endif
...
#if !defined(CONFIG_SYS_NO_FLASH) //定义了falsh
puts("Flash: ");
flash_size = flash_init();
if (flash_size > 0)
{
.....
}
else
{
puts(failed);
hang();
}
#endif
这里看到应该是size<=0才会弹出这个错误,所以问题应该出在flash_init函数中
在此flash_init函数中所在文件(u-boot-2012.04.01\drivers\mtd\Cfi_flash.c)启用调试信息,头部有此信息
/* The DEBUG define must be before common to enable debugging */
/* #define DEBUG */
所以在头部定义
#define DEBUG
再次make,烧写进去
CPUID: 32440001
FCLK: 400 MHz
HCLK: 100 MHz
PCLK: 50 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: fwc addr (null) cmd f0 00f0 16bit x 16 bit
fwc addr 0000aaaa cmd aa 00aa 16bit x 16 bit
fwc addr 00005554 cmd 55 0055 16bit x 16 bit
fwc addr 0000aaaa cmd 90 0090 16bit x 16 bit
fwc addr (null) cmd f0 00f0 16bit x 16 bit
JEDEC PROBE: ID 1 2249 0
fwc addr (null) cmd ff 00ff 16bit x 16 bit
fwc addr (null) cmd 90 0090 16bit x 16 bit
fwc addr (null) cmd ff 00ff 16bit x 16 bit
JEDEC PROBE: ID 13 ea00 0
*** failed ***
### ERROR ### Please RESET the board ###
这里我改动了时钟所以时钟频率有些不一致了,看到调试的输出信息了
前面几句是向flash芯片写入地址和数据用来查询厂商ID和芯片ID
得到的是厂商ID为0x1 芯片ID 0x2249
注意:最后面一位也是芯片ID,主要是为了有些厂商区分自己的芯片ID,一般不使用
在flash_init函数里面肯定有得到芯片大小的函数,这里我们发现如下一句
if (!flash_detect_legacy(cfi_flash_bank_addr(i), i)) //老式探测flash的方法,不使用cfi
flash_get_size(cfi_flash_bank_addr(i), i); //使用cfi标准探测flash
size += flash_info[i].size; //得到size大小
这里使用旧的方法探测,如下调用
flash_detect_legacy->flash_read_jedec_ids->cmdset_amd_read_jedec_id
cmdset_amd_read_jedec_ids会自动填充厂商ID、芯片ID
然后芯片会与uboot内部定义的芯片进行匹配(调用jedec_flash_match),
我们猜肯定是定义的代码里面没有发现这个芯片,里面有个结构体jedec_table里面没有我们需要的芯片定义
我们根据上面的信息,重新定义一个如下
{
.mfr_id = (u16)FLASH_AM040,
.dev_id = AM29LV160DB,
.name = "SPANSION S29AL016J",
.uaddr = {
[1] = MTD_UADDR_0x0555_0x02AA /* x16 */
},
.DevSize = SIZE_2MiB,
.CmdSet = CFI_CMDSET_AMD_LEGACY,
.NumEraseRegions= 4,
.regions = {
ERASEINFO(0x04000, 1),
ERASEINFO(0x02000, 2),
ERASEINFO(0x08000, 1),
ERASEINFO(0x10000, 31),
}
},然后重新编译烧写,flash就正常显示2m了