Page 3 of 3

Re: [INFO] Flash Driver model

Posted: Fri Mar 10, 2017 1:21 pm
by Tabulous
Hi there is an error on this driver.

When JESD216_BUS_MODE is defined as SPI i.e.

Code: Select all

#if !defined(JESD216_BUS_MODE) || defined(__DOXYGEN__)
#define JESD216_BUS_MODE                    JESD216_BUS_MODE_SPI
#endif


the driver will not compile, there are errors in hal_jesd216_flash.c like this one where addr is used undeclared as it does not exist.

Code: Select all

void jesd216_cmd_addr(BUSDriver *busp,
                      uint32_t cmd,
                      flash_offset_t offset) {
#if JESD216_BUS_MODE != JESD216_BUS_MODE_SPI
  qspi_command_t mode;

  mode.cfg = QSPI_CFG_CMD(cmd) |
#if JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI1L
             QSPI_CFG_CMD_MODE_ONE_LINE |
             QSPI_CFG_ADDR_MODE_ONE_LINE |
             QSPI_CFG_ADDR_SIZE_24;
#elif JESD216_BUS_MODE == JESD216_BUS_MODE_QSPI2L
             QSPI_CFG_CMD_MODE_TWO_LINES |
             QSPI_CFG_ADDR_MODE_TWO_LINES |
             QSPI_CFG_ADDR_SIZE_24;
#else
             QSPI_CFG_CMD_MODE_FOUR_LINES |
             QSPI_CFG_ADDR_MODE_FOUR_LINES |
             QSPI_CFG_ADDR_SIZE_24;

#endif
  mode.addr = offset;
  mode.alt  = 0U;
  qspiCommand(busp, &mode);
#else
  uint8_t buf[4];

  spiSelect(busp);
  buf[0] = cmd;
  buf[1] = (uint8_t)(addr >> 16);
  buf[2] = (uint8_t)(addr >> 8);
  buf[3] = (uint8_t)(addr >> 0);
  spiSend(busp, 4, buf);
  spiUnselect(busp);
#endif
}

Re: [INFO] Flash Driver model

Posted: Fri Mar 10, 2017 3:11 pm
by Tabulous
Also think the demo code is wrong i.e.

flashRead in teh demo passes driver object, sector offset, pointer to buffer and byte count

/* Reading back for confirmation.*/
err = flashRead(&flash, 0, buffer, 128);
if (err != FLASH_NO_ERROR)
chSysHalt("read error");


but the the definition / prototype is different, the byte count and pointer to buffer are swapped ???


/**
* @brief Read operation.
*
* @param[in] ip pointer to a @p BaseFlash or derived class
* @param[in] offset flash offset
* @param[in] n number of bytes to be read
* @param[out] rp pointer to the data buffer
* @return An error code.
* @retval FLASH_NO_ERROR if there is no erase operation in progress.
* @retval FLASH_BUSY_ERASING if there is an erase operation in progress.
* @retval FLASH_ERROR_READ if the read operation failed.
*
* @api
*/
#define flashRead(ip, offset, n, rp) \
(ip)->vmt->program(ip, offset, n, pp)

Re: [INFO] Flash Driver model

Posted: Fri Mar 10, 2017 3:51 pm
by Giovanni
Hi,

Thanks, I will give it a try again, I stopped working on it.

Giovanni

Re: [INFO] Flash Driver model

Posted: Fri Mar 10, 2017 4:01 pm
by Tabulous
Giovanni wrote:Hi,

Thanks, I will give it a try again, I stopped working on it.

Giovanni


Am just in th process of getting it working with cyprus s25fl116 flash chip, once ive got it done i'll post it back hear.

Re: [INFO] Flash Driver model

Posted: Fri Mar 10, 2017 4:18 pm
by Giovanni
OK thanks.

Giovanni

Re: [INFO] Flash Driver model

Posted: Sat Mar 11, 2017 10:13 am
by Tabulous
Hi Giovanni
Here is updated driver that is now working.

There is a bit of difference between the Micron and the Cypress flash, mainly to do with the status reg.

Think the overall struct is good :-)

Cheers

PS i have FatFS and Eprom Emulation running over this too, FAT on flash with out FTL/wear leveling is not ideal, but the application will not write alot, mainly read.

I'll post the fatfs_diskio interface soon, as just need to tidy it up lol.

Re: [INFO] Flash Driver model

Posted: Thu Mar 16, 2017 5:04 pm
by Tabulous
Here is fatfs_diskio and also wrapper files :-)

Re: [INFO] Flash Driver model

Posted: Sun Jan 06, 2019 4:54 pm
by Giovanni
Hi,

Now there is a new flash infrastructure so probably all this is no more actual. Are you planning to port this work to the new trunk code? adding flash devices should be much easier now.

Giovanni