QSPI Flash support

Hi,

We use Spansion NOR flash on our S7 based controller. I get SSP error SSP_ERR_UNSUPPORTED for open() call. How do I add support for Spansion flash in BSP ? 

Thanks,

Siju

  • Hi Siju,

    You must create a custom BSP for your board and edit/change the bsp_qspi.h and bsp_qspi.c files.

    The HAL level drivers use the BSP QSPI api to change the mode of operation of the device to/from XIP mode to normal SPI operation.

    -Gary

  • In reply to garyj:

    Thanks Gary,

    Siju

  • In reply to sijug:

    Hi sijug and garyj,

    I'm trying to communicate with NOR flash(MT25QL256A) and getting same SSP error. I'm not sure why I'm getting this error. So can you guys please tell me where I'm doing wrong and correct me.
    garyj you told to edit the bsp_qspi.h and bsp_qspi.c files, what to edit and why.

    I'm using 1.1.3 SSP and S7G2-DK board.
  • In reply to Prashanth:

    Prashanth,

    Please verify that you have Dip Switch S5-2 in the ON position to enable the QSPI .
    Please refer to sec. 8.8 in the R12UM0002EU0100 Dev Kit User Manual.

    -Gary
  • In reply to garyj:

    Hi garyj,

    Sorry for not mentioning that I'm using custom DK-S7G2 board, not Evaluation kit. In our custom board Dip Switches are not used and QSPI lines are directly connected to NOR flash. So, what might be the problem and what I need to do extra to make it work.

    -Prashant
  • In reply to Prashanth:

    Hello Prashanth,

    Have you included bsp_qspi.c/h files in your BSP to configure QSPI peripheral with your Micron serial flash? You can copy files from the existing DK-S7 BSP.

    Regards
  • In reply to Renesas Karol:

    Hi Karol,

    Still I'm getting same SSP error(SSP_ERR_UNSUPPORTED). Can you please mention what are the steps to follow to communicate with external flash(from creation of thread). And from where qspi external flash memory address starts from? is starting memory address is same for both internal and external flash.

    And in my experiment program I tried to modify following,
    ->In bsp_qspi.c/.h file tried to modify the memory type,memory size and ID of flash.
    ->in script folder of project, in S7G2.ld file I tried to modify the length from 64Mb(0x4000000) to 32MB(0x2000000). And qspi_max_region_size from 0x4000000 to 0x2000000.
    As size of NOR flash that I'm working with is 256Mb(32MB).

    BSP : - SSP version-1.1.3, Board-S7G2 DK.
    As I mentioned I'm working with custom S7G2-DK board and trying to communicate with external NOR flash(MT25QL256A).
    Can you please guide me to make it work.

    -Prashant
  • In reply to Prashanth:

    Hello Prashanth,

    Are you using BSP files for DK-S7 or for Custom Board? DK-S7 BSP files cannot be modified as they will be overwritten when you build the project. I recommend that you use Custom User Board for your BSP choice and configure QSPI using overriden R_BSP_WarmStart function (which is by default weakly-defined).

    Regards

  • In reply to Renesas Karol:

    Hi Karol,

    Yes, for DK-S7 BSP files cannot be modified. But for custom board I'm getting errors even after copying bsp_qspi.c/.h files into BSP. I tried to copy all missing files into Synergy and Debug folder of my project. Do I need to do extra modification, if then which files/folder.

    And how to configure QSPI using overridden function?

    -Prashant
  • In reply to Prashanth:

    Hi Prashanth,

    File in synergy/ folder are automatically generated, files in Debug/ folder are created in the build process, so you don't need to copy over these files. Some modifications might be required e.g. adjusting paths to #include's. Which errors are you getting?

    To configure QSPI using R_BSP_WarmStart, just call your configuration routine from this function. Please see synergy/ssp/src/bsp/cmsis/Device/RENESAS/S7G2/Source/system_S7G2.c file to see a prototype and an example implementation for R_BSP_WarmStart.

    Regards,
    adboc
  • In reply to adboc:

    Hi adboc,

    Now I can able to modify bsp_qspi.c/.h files and those files are overwritten when I build the project. But still open API errors with "SSP_ERR_UNSUPPORTED". And was looking at the forum discussion of TLHQ(https://renesasrulz.com/synergy/f/synergy---forum/8387/s7g2-qspi-mt25ql256-work-only-one-time), and tried to modify code as per their discussion but still no luck.

    Thanks.

  • In reply to Prashanth:

    Hi Prashanth,

    Have you tried disabling XIP mode? I suggest asking your distributor or chip's manufacturer how to intialize this chip and which commands should be used.

    Regards,
    adboc
  • In reply to adboc:

    Hi adboc,

    Yes, I tried disabling XIP mode by writing two dummy bytes before writing restart commands at the start-up. But still same response(i.e., open API errors with "SSP_ERR_UNSUPPORTED").

    Following are the two dummy bytes am writing...

    R_QSPI->SFMCOM = 0x66; // Reset enable command, just dummy data
    R_QSPI->SFMCOM = 0xFF; // set the Xb bit to 1 to take the QSPI device out of XIP mode, set all bit to 1


    Thanks.
  • In reply to Prashanth:

    Parashanth,

    There is an error in the BSP for the N25Q256A flash that causes the MT25QL256A to be put into DTR mode (double transfer rate) which the Synergy qspi interface does not support. Once the NVM is put into this mode by updating the non-volatile configuration register, the MCU can no longer talk to this part after a power cycle. The bug was the byte order of the 16bit regester read/write. This was benign on the N25Q256 part but causes an issue on the MT25QL256 part. To fix this bug, the following sections of the bsp_qspi.c file for the n25Q256 must be changed and a new BSP created. It is important to make this change and re-flash the MCU BEFORE using it with a new MT25QL256A device for the first time!

    bsp_qspi.c

    /* Read the non-volatile configuration of the device */
    R_QSPI->SFMCOM = QSPI_COMMAND_READ_NONVOLATILE_CFGREG; /* Write the command */
    regval = (uint16_t)(R_QSPI->SFMCOM_b.SFMD); /* Read the nv configuration register */
    regval = (uint16_t)(regval | (uint16_t)(R_QSPI->SFMCOM_b.SFMD << 8)); /* Read the nv configuration register */
    R_QSPI->SFMCMD_b.DCOM = 1; /* Close the SPI bus cycle */
    .
    .
    .
    /* Program the non-volatile configuration register in the device */
    R_QSPI->SFMCOM = QSPI_COMMAND_WRITE_ENABLE; /* Enable writing */
    R_QSPI->SFMCMD_b.DCOM = 1; /* Close the SPI bus cycle */
    R_QSPI->SFMCOM = QSPI_COMMAND_WRITE_NONVOLATILE_CFGREG; /* Write the command */
    R_QSPI->SFMCOM = regval; /* Write the nv configuration register */
    R_QSPI->SFMCOM = regval >> 8; /* Write the nv configuration register */
    R_QSPI->SFMCMD_b.DCOM = 1; /* Close the SPI bus cycle */


    -Gary