diff --git a/config.h b/config.h index d486aad..128134a 100644 --- a/config.h +++ b/config.h @@ -181,7 +181,7 @@ extern "C" { /* Flash memory configuration */ -#define SPI_FLASH_DEVICE_NAME "spiFlash_SM25QU256E" +#define SPI_FLASH_DEVICE_NAME "spiFlash_sp25probe" #define SZ_32M (0x02000000) #define SZ_64K (0x00010000) #define SPI_FLASH_SIZE (SZ_32M) diff --git a/hwconf.c b/hwconf.c index 780e1e5..1a8e090 100644 --- a/hwconf.c +++ b/hwconf.c @@ -241,8 +241,8 @@ struct hcfResource ftCanDev2Resources[] = { struct vxbSpiDevInfo qspiDevTbl[] = { /* name cs width freq mode */ #ifdef DRV_SPIFLASH_SP25 - { SPI_FLASH_DEVICE_NAME, 0, 8, 30000000, 1}, -#endif + { SPI_FLASH_DEVICE_NAME, 0, 8, 18000000, 1}, +#endif }; struct hcfResource qspiResources[] = { @@ -253,7 +253,6 @@ struct hcfResource qspiResources[] = { { "addrMode", HCF_RES_INT, { (void *)(QSPI_ADDR_SEL_4) } }, { "spiDev", HCF_RES_ADDR, { (void *)&qspiDevTbl[0]} }, { "spiDevNum", HCF_RES_INT, { (void *)NELEMENTS(qspiDevTbl)}}, - }; # define qspiNum NELEMENTS(qspiResources) #endif /* DRV_FTQSPI */ @@ -520,6 +519,7 @@ struct hcfResource lfsResources[] = { { "flashName" , HCF_RES_STRING, {(void *)TFFS_PART0_FLASH_NAME}}, { "flashOffset", HCF_RES_INT, {(void *)(TFFS_PART0_FLASH_BOOT_SIZE)}}, { "flashSize" , HCF_RES_INT, {(void *)((TFFS_PART0_FLASH_SIZE) - (TFFS_PART0_FLASH_BOOT_SIZE))}}, + { "autoFormat", HCF_RES_INT, {(void *)(1)}}, }; #define lfsResNum NELEMENTS(lfsResources) #endif @@ -538,8 +538,6 @@ const struct hcfDevice hcfDeviceList[] = { #endif /* DRV_ARM_GIC */ { "primeCellSioDev", 0, VXB_BUSID_PLB, 0, primeCellSioDev0Num , primeCellSioDev0Resources }, { "primeCellSioDev", 1, VXB_BUSID_PLB, 0, primeCellSioDev1Num , primeCellSioDev1Resources }, - /* { "primeCellSioDev", 2, VXB_BUSID_PLB, 0, primeCellSioDev2Num , primeCellSioDev2Resources }, */ /* 1553B SPI */ - /* { "primeCellSioDev", 3, VXB_BUSID_PLB, 0, primeCellSioDev3Num , primeCellSioDev3Resources }, */ #ifdef DRV_VXBEND_FTGMAC { "gmac", 0, VXB_BUSID_PLB, 0, gmac0Num, gmac0Resources}, diff --git a/lfs/lfs.c b/lfs/lfs.c index 172f3c3..067cad2 100644 --- a/lfs/lfs.c +++ b/lfs/lfs.c @@ -4577,7 +4577,7 @@ static int lfs_mount_(lfs_t *lfs, const struct lfs_config *cfg) { } // scan directory blocks for superblock and any global updates - lfs_mdir_t dir = {0}; + lfs_mdir_t dir = {{0}, 0}; dir.tail[0] = 0; dir.tail[1] = 1; lfs_block_t tortoise[2] = {LFS_BLOCK_NULL, LFS_BLOCK_NULL}; @@ -5374,7 +5374,7 @@ static int lfs_fs_gc_(lfs_t *lfs) { if (lfs->cfg->compact_thresh < lfs->cfg->block_size - lfs->cfg->prog_size) { // iterate over all mdirs - lfs_mdir_t mdir = {0}; + lfs_mdir_t mdir = {{0}, 0}; mdir.tail[0] = 0; mdir.tail[1] = 1; while (!lfs_pair_isnull(mdir.tail)) { diff --git a/vxbLfsLib.c b/vxbLfsLib.c index 493b49e..af9ef23 100644 --- a/vxbLfsLib.c +++ b/vxbLfsLib.c @@ -51,8 +51,11 @@ struct __lfs_drv_ctrl { VXB_DEVICE_ID pDev; /* per-driver info */ void *pDrvCtrl; + char name[16]; const char *mountPoint; + BOOL autoFormat; + const char *flashDrvName; int flashUnit; @@ -117,8 +120,13 @@ LOCAL void lfsDevInstInit(VXB_DEVICE_ID pDev) drv->pageSize = 256; } + if (devResourceGet(pHcf, "autoFormat", HCF_RES_INT, (void *)&drv->autoFormat) != OK) { + drv->autoFormat = 0; + } + if (devResourceGet(pHcf, "mountPoint", HCF_RES_STRING, (void *)&drv->mountPoint) != OK) { - drv->mountPoint = "/lfs0"; + snprintf(drv->name, sizeof drv->name, "/lfs%d", pDev->unitNumber); + drv->mountPoint = drv->name; } vxbNextUnitGet(pDev); @@ -490,8 +498,14 @@ LOCAL void lfsDevInstConnect(VXB_DEVICE_ID pDev) } } semGive(pDrvCtrl->lock); - if (pDrvCtrl->mtd) - lfs_mount(&pDrvCtrl->fsh, &pDrvCtrl->lfsConfig); + if (pDrvCtrl->mtd) { + int ret; + ret = lfs_mount(&pDrvCtrl->fsh, &pDrvCtrl->lfsConfig); + if ((ret != LFS_ERR_OK) && pDrvCtrl->autoFormat) { + lfs_format(&pDrvCtrl->fsh, &pDrvCtrl->lfsConfig); + lfs_mount(&pDrvCtrl->fsh, &pDrvCtrl->lfsConfig); + } + } } LOCAL struct drvBusFuncs lfsDevFuncs = { @@ -628,7 +642,7 @@ int lfsLowRawWrite(unsigned long offset, const char *buffer, int size) } if (pDrvCtrl->mtd->flashOPs.write) { - ok = pDrvCtrl->mtd->flashOPs.write(pDrvCtrl->mtd, offset, 1, size, &buffer, NULL); + ok = pDrvCtrl->mtd->flashOPs.write(pDrvCtrl->mtd, offset, 1, size, (UINT8 **)&buffer, NULL); } semGive(pDrvCtrl->lock); diff --git a/vxbSp25SpiFlash.c b/vxbSp25SpiFlash.c index 2118d66..7883379 100644 --- a/vxbSp25SpiFlash.c +++ b/vxbSp25SpiFlash.c @@ -323,6 +323,7 @@ LOCAL const struct spiFlash_info spiFlashList[] = { "sp25probe", 0, 0, 0, 0, 0, 0, 0}, /* KM02 use this flash */ { "SM25QU256E", 0x20, 0x7019, 0, 256, 64 * 1024, 512, JEDECID_NO_EXT}, + { "GD25LQ256" , 0xc8, 0x6019, 0, 256, 64 * 1024, 512, JEDECID_NO_EXT}, /* SPANSION S25FLXX serials */