External Flash W25Q64 with USBD_MSC example on NRF52840

Hi All,

        I have an external flash W25Q64 on which I have to mount a file system. I am using USBD_MSC example of NRF52840. My main goal is to create a file inside the flash memory chip. And when USB is plugged into the device it should be seen as a drive on laptop/desktop and I should be able to access the file which was created in the flash chip.I have made the connections on the NRF52840 using the pin configurations below:-


#define SDC_SCK_PIN     (25) 
#define SDC_MOSI_PIN   (23) 
#define SDC_MISO_PIN   (24) 
#define SDC_CS_PIN       (15) 

I have also configured the details in nrf_serial_flash_params.c file. 

static const nrf_serial_flash_params_t m_sflash_params[] = {
    {    
        .read_id = { 0xEF,0x40,0x17 },
        .capabilities = 0x00,
        .size = 8 * 1024 * 1024,
        .erase_size = 2 * 1024,
        .program_size = 256,
    }
};

nrf_serial_flash_params_t const * nrf_serial_flash_params_get(const uint8_t * p_read_id)
{
    size_t i;

    for (i = 0; i < ARRAY_SIZE(m_sflash_params); ++i)
    {
        if (memcmp(m_sflash_params[i].read_id, p_read_id, sizeof(m_sflash_params[i].read_id)) == 0)
        {
            return &m_sflash_params[i];
        }
    }

    return NULL;
}

When I run the example , i get the following error:-

<info> app: Initializing disk 0 (QSPI)...

 <error> app: Disk initialization failed.

1) Will this example run for W25Q64 IC??

2) This example also includes FATfs files. Will it automatically create a file system on the external SPI W25Q64 flash memory??

3) Why am I getting "Disk initialization failed." error?

4) Inside sdk_config.h do I also need to enable pin configurations for Qspi??

5) How to test this application? Currently I am using NRF52840 DK and then connecting external spi flash to it. But for USB detection how will it work?

I have attached few files here to check for the configurations

04162.sdk_config.h

5287.W25Q64BV.PDF

Please help me to solve this issue. I need to solve this issue on an urgent basis. Your help will be appreciated. I have also attached W25Q64 datasheet for your reference.

Thanks & Regards,

Snehal

  • Hi,

    I unfortunately don't have any SPI flash to test against. Are they working on your end?

  • Actually even I will be able to test with device next week. Currently dont have set up to test. But just wanted to make sure the conversion done in the file is okay and I am on the right path. Can you please take a look into the files?

  • Hi,

    I don't see anything wrong in the code, you might find some issues when you start testing, but I think you are on the right path.

  • Hi Sigurd, We will start testing the device soon. The compiler is giving error for this particular part of code.

        /* Send reset enable */
        ret = nrfx_spim_xfer(&cinstr_cfg, NULL, NULL);
        if (ret != NRF_SUCCESS)
        {
            NRF_LOG_INST_ERROR(p_spi_dev->p_log, "SPI reset enable command error: %"PRIu32"", ret);
            return ret;
        }
    
        /* Send reset command */
        cinstr_cfg.opcode = SPI_STD_CMD_RST;
        ret = nrfx_spim_xfer(&cinstr_cfg, NULL, NULL);
        if (ret != NRF_SUCCESS)
        {
            NRF_LOG_INST_ERROR(p_spi_dev->p_log, "SPI reset command error: %"PRIu32"", ret);
            return ret;
        }
    
        /* Get 3 byte identification value */
        uint8_t rdid_buf[3] = {0, 0, 0};
        cinstr_cfg.opcode = SPI_STD_CMD_READ_ID;
        cinstr_cfg.length = NRF_SPI_CINSTR_LEN_4B;
        ret = nrfx_spim_xfer(&cinstr_cfg, NULL, rdid_buf);
        if (ret != NRF_SUCCESS)
        {
            NRF_LOG_INST_ERROR(p_spi_dev->p_log, "SPI get 3 byte id error: %"PRIu32"", ret);
            return ret;
        }
    
        nrf_serial_flash_params_t const * serial_flash_id = nrf_serial_flash_params_get(rdid_buf);
    

    For all the lines which have the function "nrfx_spim_xfer", the compiler gives me an error

    passing argument 3 of 'nrfx_spim_xfer' makes integer from pointer without a cast [-Wint-conversion]

    how can we solve this??  Actually wrong type of argument is passed. Unlike QSPI I did not find function through which we can send reset enable, send reset command and get 3 byte identification values.

    Please help me on this.

    Thanks & Regards,

    Snehal.

Related