我们有基于BBB的定制板,
我们在板上有SPI NOR闪存和NAND闪存,
我们能够为NAND制作mtd分区。但NOR分区不起作用:(
我们添加了以下定义来创建mtd NOR分区。
#define MTDIDS_DEFAULT "nand0=omap2-nand.0, nor0=omap2-nor.0"
#define MTDPARTS_DEFAULT "mtdparts=omap2-nand.0:" \
"128k(SPL)," \
"128k(SPL.backup1)," \
"128k(SPL.backup2)," \
"128k(SPL.backup3)," \
"1024k(u-boot)," \
"1024k(u-boot.backup1)," \
"128k(u-boot-env)," \
"5m(kernel)," \
"5m(kernel.backup1)," \
"512k(fdt)," \
"512k(fdt.backup1)," \
"100m(rootfs)," \
"100m(rootfs.backup1)," \
"13m(reserved)," \
";" \
"mtdparts=omap2-nor.0:" \
"128k(SPL1_nor)," \
"128k(SPL2_nor)," \
"128k(SPL3_nor)," \
"128k(SPL4_nor)," \
"512k(usr_nor)," \
另一个疑问是,
是否可以在u-boot中使用mtd设备文件进行读/写?
据我了解,u-boot也使用Linux的mtd驱动程序,所以
是否可以从u-boot代码执行类似fd = open(" / dev / mtd0",O_WRONLY)的操作?
答案 0 :(得分:2)
为了允许对SPI NOR进行分区,我在spi_flash_probe()的末尾添加了以下内容:
/* Release spi bus */
spi_release_bus(spi);
extern nand_info_t nand_info[];
struct mtd_info *mtd;
mtd = &nand_info[1];
mtd->name = "nor0";
mtd->size = flash->size;
mtd->erasesize = flash->erase_size;
mtd->writesize = flash->page_size;
mtd->priv = flash;
mtd->_write = sf_mtdwrite;
mtd->_read = sf_mtdread;
mtd->_erase = sf_mtderase;
#ifdef CONFIG_MTD_DEVICE
add_mtd_device(mtd);
#endif
return flash;
然而,没有例如“读/写/擦除分区”的概念,这些概念分别存在于NAND和SPIFLASH中。因此,在SPI NOR上定义分区并不是很有用,除非要创建通用的mtd命令(mtd write,mtd read,mtd erase ...)。