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, .

    When I enable QSPI logs with what you suggested, I could basically see the same codes that 

    fatfs_init() >> disk_initialize(0) >> nrf_blck_dev_init() >> init()
     function returns.

    The logs are <error> app: QSPI FLASH not supported (should correspond to return code 0x06) when I don't insert

    nrf_drv_qspi_config_t config = NRF_DRV_QSPI_DEFAULT_CONFIG;
    
    err_code = nrf_drv_qspi_init(&config, qspi_handler, NULL);
    APP_ERROR_CHECK(err_code);
    NRF_LOG_INFO("QSPI example started.");
    
    configure_memory();

    before fatfs_init().

    When I insert the above code before fatfs_init() function, I get QSPI log <error> app: QSPI init error: 8 which corresponds to return code 0x08 from init() function.

    Moving to SDK v16.0.0 did not help. I get completely the same returns from init() function and completely the same QSPI logs.

    I am starting to despair here!!! Cry

    What I want to do seems to be simple but still so much trouble experienced!

    Sincerely,

    Bojan.

  • We need to test everything. And I have forwarded this to the experts, so an answer will show itself soon. I have not heard back from them yet, will push for an answer. Do you have an nRF52840 DK? If so, could you try the code with that board? 

  • Hello .

    Thanks for your efforts! I really appreciate it. Yes, I have nRF52840DK. usbd_msc example is working fine on that board. There is no need to add the code you suggested:

    nrf_drv_qspi_config_t config = NRF_DRV_QSPI_DEFAULT_CONFIG;
    
    err_code = nrf_drv_qspi_init(&config, qspi_handler, NULL);
    APP_ERROR_CHECK(err_code);
    NRF_LOG_INFO("QSPI example started.");
    
    configure_memory();

    Looking forward to reading from you.

    Sincerely,

    Bojan.

  • I have only referred to configure_memory() in regards to sending commands to your flash.

    bojan said:
    Yes, I have nRF52840DK. usbd_msc example is working fine on that board

     I have not heard back from our team. I will update asap.

  • Hello, !

    I hope this message finds you well. Any updates from your team concerning the issue with usbd_msc example on custom MX66L1G45G (3.0V) ?

    Sincerely,

    Bojan.

Reply Children
  • No, I'm sorry, no updates. Our team is waiting for data/information from Macronix to simulate this device on the nRF52840. I will keep you posted.

    Kind regards,
    Øyvind

  • 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.

Related