加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

spi-flash移植问题

发布时间:2020-12-15 17:27:40 所属栏目:百科 来源:网络整理
导读:平台:linux-2.6.35 imx53_loco 最近在弄mfgtool的时候发现一个很奇怪的问题。在自己编译的smd版本的内核中,spi-flash、nor-flash、nand-flash都需要支持。nor-flash和nand都能正常烧写,但是spi-flash却一直烧写不成功。示波器测量spi引脚一切正常,完全不

平台:linux-2.6.35 imx53_loco


最近在弄mfgtool的时候发现一个很奇怪的问题。在自己编译的smd版本的内核中,spi-flash、nor-flash、nand-flash都需要支持。nor-flash和nand都能正常烧写,但是spi-flash却一直烧写不成功。示波器测量spi引脚一切正常,完全不知道哪里出错。后来追踪代码发现,mxc_m25p16.c的probe函数中得到的platform_data的值居然是错的,导致无法正确获取分区信息,而直接在mxc_m25p16中定义分区信息,虽然可以正确输出分区信息,但是仍然无法正常烧写。看来问题还是处在分区的platform_data上面。

在board文件中需要设置nor-flash和nand-flash的分区,struct?flash_platform_data,但是这里有两个flash.h文件都有flash_platform_data结构体的定义,

一个是asm/mach/flash.h

struct flash_platform_data {
	const char	*map_name;
	const char	*name;
	unsigned int	width;
	int		(*init)(void);
	void		(*exit)(void);
	void		(*set_vpp)(int on);
	void		(*mmcontrol)(struct mtd_info *mtd,int sync_read);
	struct mtd_partition *parts;
	unsigned int	nr_parts;
	char		*type;
};
另一个是linux/spi/flash.h

struct flash_platform_data {
	char		*name;
	struct mtd_partition *parts;
	unsigned int	nr_parts;

	char		*type;

	/* we'll likely add more ... use JEDEC IDs,etc */
};
而norflash和nand的分区定义如下:

static struct flash_platform_data mxc_nor_flash_pdata = {
	.map_name = "cfi_probe",.width = 4,.parts = mxc_nor_partitions,.nr_parts = ARRAY_SIZE(mxc_nor_partitions),.init = nor_init,};
static struct flash_platform_data mxc_nand_data = {
#ifdef CONFIG_MTD_PARTITIONS
	.parts = nand_flash_partitions,.nr_parts = ARRAY_SIZE(nand_flash_partitions),#endif
	.width = 1,.init = nand_init,};
使用的是asm/mach/flash.h

而spi-flash中的分区定义则是

static struct flash_platform_data mxc_spi_flash_data = {
	 .name = "m25p80",.parts = mxc_dataflash_partitions,.nr_parts = ARRAY_SIZE(mxc_dataflash_partitions),.type = "m25p16",};
这个定义显然也符合/linux/spi/flash.h中的定义,而mxc_m25p16中使用的flash_platform_data结构体居然就是/linux/spi/flash.h

都知道c语言的结构体取值是按照数据长度来的,显然在mxc_m25p16中在获取platform_data时使用的结构体长度和board文件中是不一样的,这就导致了分区信息获取失败,将mxc_m25p16中的头文件引用改成asm/mach/flash.h,重新编译,可以正常烧写了。困扰了我一个多月的问题,就因为一个头文件的引用搞定了,唉!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读