This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB Mass Storage Class on external QSPI flash

Hello guys,

We are using SES and SDK15.3.0. Our SoC is from nRF52840 family. We have a custom board with external QSPI flash memory that we want to use as USB MSC device. After some consultations with Nordic technical support (see this thread), we selected  MX66L1G45G (3.0V) memory module for our external memory.

usbd_msc example from SDK 15.3.0 did not work on our custom board - disk initialization failed issue:

Changing the addressing mode to 32-bit (because we are using memory that is >128Mb) did not help. We changed the addressing mode inside sdk_config.h file as follows:

// <o> QSPI_CONFIG_ADDRMODE  - Addressing mode.
 
// <0=> 24bit 
// <1=> 32bit 

#ifndef QSPI_CONFIG_ADDRMODE
#define QSPI_CONFIG_ADDRMODE 1
#endif

// <o> NRFX_QSPI_CONFIG_ADDRMODE  - Addressing mode.
 
// <0=> 24bit 
// <1=> 32bit 

#ifndef NRFX_QSPI_CONFIG_ADDRMODE
#define NRFX_QSPI_CONFIG_ADDRMODE 1
#endif

QSPI link between our nRF52840 and external memory is OK because QSPI example is working properly.

Do you have any suggestions on what should we change in order to have usbd_msc example working on our custom board?

Thank you very much for your time and effort! It is really appreciated.

Sincerely,

Bojan.

Parents
  • Hello Bojan, 

    QSPI link between our nRF52840 and external memory is OK because QSPI example is working properly.

     I'm glad to hear that the QSPI example is working properly. 

    Do you have any suggestions on what should we change in order to have usbd_msc example working on our custom board?

    Are the settings the same as with QSPI example? Are you using FAT FS? Can you please provide your project for testing? Difficult for me to say at this moment.

    Thanks!

    Kind regards,
    Øyvind 

  • Hello ,

    Thanks for your reply!

    My starting point is usbd_msc example. Inside sdk_config.h file I just defined and set QSPI_CONFIG_ADDRMODE and NRFX_QSPI_CONFIG_ADDRMODE to have 32-bit addressing mode and that's all. The rest of the code is actually the code from usbd_msc example.

    Yes, FAT FS is used. The issue appears when disk_initialize(0); function is called within fatfs_init(). This is when I get the error "Disk initialization failed".

    Am I missing something?

    Sincerely,

    Bojan.

  • Hello, .

    Any updates from your side? Where are you currently in the process of checking the issue with usbd_msc example on custom MX66L1G45G (3.0V) memory chip?

    Would changing the chip module and taking MX25L3233F, for example, resolve the issue? Is there any other memory module you would recommend that supports the functionality of usbd_msc example?

    Thanks in advance.

    Bojan.

  • Hi Bojan, 

    My sincere apologies, I have not heard back from our team and forgot to follow up on the case. I have asked for more details as to why you are receiving the "disk initialization failed" error and forwarded your last question.

    Kind regards,
    Øyvind

  • , can you please configure the following in sdk.config:

    / <e> NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED
    #define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 1
    #endif
    // <o> NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL  - Default Severity level
     
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL
    #define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 4
    #endif
    

    I've been discussing the error you get, and the issue may be due to FatFS. Please note the USB MSC example uses button 3 (#define BTN_MKFS 2)

    to create a fat volume. There might be an issue with disk_initialize in the sample, as this is handled by the fatfs module. Here is an example from the FatFS module

    /* Format default drive and create a file */
    int main (void)
    {
        FATFS fs;           /* Filesystem object */
        FIL fil;            /* File object */
        FRESULT res;        /* API result code */
        UINT bw;            /* Bytes written */
        BYTE work[FF_MAX_SS]; /* Work area (larger is better for processing time) */
    
    
        /* Format the default drive with default parameters */
        res = f_mkfs("", 0, work, sizeof work);
        if (res) ...
    
        /* Gives a work area to the default drive */
        f_mount(&fs, "", 0);
    
        /* Create a file as new */
        res = f_open(&fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
        if (res) ...
    
        /* Write a message */
        f_write(&fil, "Hello, World!\r\n", 15, &bw);
        if (bw != 15) ...
    
        /* Close the file */
        f_close(&fil);
    
        /* Unregister work area */
        f_mount(0, "", 0);
    ...

    More information about the functions can be found here.

    Kind regards,
    Øyvind

  • Hey, .

    I changed sdk_config.h file according to your suggestions. I can see the same logs I was able to see before:

    <info> app: Initializing disk 0 (QSPI)...
    <info> app: m_drives[drv].config.wait_func = NULL
    <error> app: QSPI FLASH not supported
    <error> app: Error: nrf_blk_dev_init() function!
    <error> app: err_code: 0x6
    <info> app: Return state 
    <error> app: Disk initialization failed.

    fatfs_init()>>disk_initialize(0) function fails. I am aware there is FatFS implementation in the base of usbd_msc example. By pressing a button 3 in usbd_msc example, fatfs_mkfs() function is called. However, this happens inside while(true) loop, and AFTER fatfs_init()>>disk_initialize(0) function calls.

    When I run the same code for my custom board on nRF52840 DK board without pressing ANY button, fatfs_init()>>disk_initialize(0) function passes without any problem!

    Sincerely,

    Bojan.



  • I have to apologize for my last reply, as I realize now that I must have been drunk or something. I see that I already asked you to edit sdk_config in this answer (Nov. 11).

     

    bojan said:
    When I run the same code for my custom board on nRF52840 DK board without pressing ANY button, fatfs_init()>>disk_initialize(0) function passes without any problem!

     This is very interesting. What is different? I assume that it uses the default QSPI device on the DK?

    The specialists on QSPI have not returned from their holidays yet, and I expect them to be back on Monday. I will get back to you then.

    Sorry for the inconvenience!

    BR,
    Øyvind

Reply


  • I have to apologize for my last reply, as I realize now that I must have been drunk or something. I see that I already asked you to edit sdk_config in this answer (Nov. 11).

     

    bojan said:
    When I run the same code for my custom board on nRF52840 DK board without pressing ANY button, fatfs_init()>>disk_initialize(0) function passes without any problem!

     This is very interesting. What is different? I assume that it uses the default QSPI device on the DK?

    The specialists on QSPI have not returned from their holidays yet, and I expect them to be back on Monday. I will get back to you then.

    Sorry for the inconvenience!

    BR,
    Øyvind

Children
Related