S7G2 SSP120b QSPI error 6

Hi all,

I work on my custom board, my BSP is based on S7G2-SK. I have a 32MB n25q256a QSPI (the same QSPI on S7G2-DK). Peripheral pins are configured, I added QSPI driver in e2 thread configuration (g_qspi). I modified Synergy bsp_qspi.c/.h files (copy/paste from a DK project files and set to read only to prevent any auto-edit). I call bsp_qspi_init(); and I call g_qspi.p_api->open but I have error 6. I found a topic about this error on the forum, the guy had a problem with the QSPI chip, changing the chip solved the issue, so I tried on a second identical board but I obtained the same error 6. Any idea to solve this issue ?

Regards,

  • Hi TLHQ,

    In your bsp_qspi.c file have you implemented bsp_qspi_config_get() function? It should return the current configuration of the QSPI device. If the returned value for manufacturer_id, memory_type and memory_capacity are all 0's, the open API will return SSP_ERR_UNSUPPORTED (error code 6).

    In bsp_qspi_init() for SK-S7G2 I see the following code:

        /* Read the ID of the device. Confirm it is the correct device. */
        R_QSPI->SFMCOM                         = QSPI_COMMAND_READ_ID;  /* Write the command */
        device_characteristics.manufacturer_id = R_QSPI->SFMCOM_b.SFMD; /* Read the manufacturer ID */
        device_characteristics.memory_type     = R_QSPI->SFMCOM_b.SFMD; /* Read the memory type */
        device_characteristics.memory_capacity = R_QSPI->SFMCOM_b.SFMD; /* Read the memory capacity */
        R_QSPI->SFMCMD_b.DCOM                  = 1;                     /* Close the SPI bus cycle */

     

    And then, in bsp_qspi_config_get():

    void bsp_qspi_config_get (uint8_t  * p_manufacturer_id, uint8_t  * p_memory_type, uint8_t  * p_memory_capacity, [...])
    {
        *p_manufacturer_id    = device_characteristics.manufacturer_id;
        *p_memory_type        = device_characteristics.memory_type;
        *p_memory_capacity    = device_characteristics.memory_capacity;
        [...]
    }

     

     

    Regards,
    adboc

  • Hello.
    As adboc said, error 6 is SSP_ERR_UNSUPPORTED which means that the manufacturer_id, memory_type and memory_capacity values in g_qspi->p_ctrl have not been set. Those should have been acquired while running bsp_qspi_init() function (before g_qspi->open). Since, as you've written, you run bsp_qspi_init() and then g_qspi->open, this behaviour is strange.

    First of all, I would suggest checking if bsp_qspi_init() function acquires the manufacturer_id, memory_type and memory_capacity values (debug file bsp_qspi.c, lines 295-310). If not, a possible reason is communication failure, so please double-check the pin configuration - P500-P505 shall be used.
  • In reply to JakubJasik:

    Hello,

    Thanks you for your replies.

    I agree that error 0x6 is SSP_ERR_UNSUPPORTED but I didn't know why.

    I can add an information, my hardware team told me that the QSPI is no longer a n25q256a but a mt25ql256a because the n25 was not recommanded for new design, I compared the datasheets and from a software and a pins points of view it is the same thing.

    Pin configuration seems to be OK,  

    bsp_qspi_config_get() is implemented but never called, the init function does :  

        /* Read the ID of the device. Confirm it is the correct device. */
        R_QSPI->SFMCOM                         = QSPI_COMMAND_READ_ID;  /* Write the command */
        device_characteristics.manufacturer_id = R_QSPI->SFMCOM_b.SFMD; /* Read the manufacturer ID */
        device_characteristics.memory_type     = R_QSPI->SFMCOM_b.SFMD; /* Read the memory type */
        device_characteristics.memory_capacity = R_QSPI->SFMCOM_b.SFMD; /* Read the memory capacity */
        R_QSPI->SFMCMD_b.DCOM                  = 1U;                    /* Close the SPI bus cycle */

    But datas are false :

    manufacturer_id, memory_type and memory_capacity are 0xff instead of 0x20 0xBA 0x19 (and that is why I have the error 0x6)

    I don't know where is the issue.

  • In reply to TLHQ:

    Hello.
    Just to clarify, it works on n25q256a, but it does not with mt25ql256a?

    In think it might be a problem with SPI communication, faulty memory, a bug on a board or differences between mt25ql256a and n25q256a in terms of communication.

    Have you tried hardcoding manufacturer_id, memory_type and memory_capacity so the open function doesn't return error 6? It is not a perfect solution, but it's worth checking...

    KR,
    Jakub
  • In reply to JakubJasik:

    The bsp_qspi.c file is a copy paste from the DK-S7G2 file. The DK-S7G2 use a n25q256a. The hardware team has planned to use the same reference on our custom board but due to micron note they have chosen the mt25ql256a instead. I have compared the datasheet and I have not seen any difference from a software point of view (commands, operations ...) and they have the same pinout. So I think the bsp_qspi file I use should work.
    I have tried to force manufacturer_id, memory_type and memory_capacity and it doesn't work at all, screen stay black => software is stuck smowhere in memory initialization and never return from qspi thread entry.
  • In reply to TLHQ:

    bsp_qspi.c and bsp_init.c files start with #if defined(BSP_BOARD_S7G2_DK). Have you removed that statement?

    edit: obvoiusly remember about #endif statement at the bottom

  • In reply to JakubJasik:

    yes. The init code is executed, the behavior change when I change some lines in it.
  • In reply to TLHQ:

    Please also check the board itself - is the QSPI memory powered, is it connected properly with the S7G2. Please also check the compatibility between those memories in terms of communication timing.
  • In reply to JakubJasik:

    The QSPI is powered and all pins are connected to the right synergy pins.

    I have done a test and the result was unexpected :
    I try to compile a simple app to use QSPI on the DK-S7G2 : QSPI configured, qspi driver added, bsp_init called then qspi open ... and I have the same error 0x6 on the DK board ! maybe i'm missing something...
    I suggest a fresh start : step by step what should I do to enable the QSPI on the DK board ?
  • In reply to TLHQ:

    To enable QSPI on S7G2-DK, you should:

    - create a new SSP project for S7G2-DK

    - add a new Driver -> Storage -> QSPI Driver on QSPI to the main thread stack

    - generate project content

    - write a piece of test code inside hal_entry(void) function:

        ssp_err_t err = g_qspi0.p_api->open(g_qspi0.p_ctrl, g_qspi0.p_cfg);
        if (SSP_SUCCESS != err) {
            while(1);
        }
        while(1);

    - set breakepoints on both while(1) instructions (for test purposes)

    - build the project

    - switch on the QSPI on S5 switch on DK board

    - run the project

    This procedure should work (g_qspi0->open should return 0 which is SSP_SUCCESS).

  • In reply to JakubJasik:

    Ok thanks you ! QSPI works on my DK board and with my DK project. I had forgotten the switch S5. So there is an issue with my custom board project or my custom board QSPI.