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.

  • Hi Bojan, 

    Can you please share your project?

    Kind regards,
    Øyvind

  • Hello .

    Sure. Find it attached. However, the project is just a copy from usbd_msc example.

    It is placed under examples/peripheral.

    Sincerely,

    Bojan.

    usbd_msc_custom_board.zip

  • Thank you, ! Could you also add as much debug information as possible, i.e. the error codes that returned, etc? I will need to provide our developers with as much information as possible.

  • when I include the following piece of the code before fatfs_init() function:

    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();

    the init() function in the chain of calls:

    fatfs_init() >> disk_initialize(0) >> nrf_blck_dev_init() >> init()

    returns 0x8 error code which should be the code for NRF_ERROR_INVALID_STATE (Invalid state, operation disallowed in this state).

    When I remove the above piece of code before fatfs_init() function, the init() function returns error code 0x6 - NRF_ERROR_NOT_SUPPORTED

  • Try enabling the following in your sdk_config.h

    // <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


    And after running once or twice with settings above, please run with the following as well:
    // <e> APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED
    #define APP_USBD_MSC_CONFIG_LOG_ENABLED 1
    #endif
    // <o> APP_USBD_MSC_CONFIG_LOG_LEVEL  - Default Severity level
     
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL
    #define APP_USBD_MSC_CONFIG_LOG_LEVEL 4
    #endif

    This should give more information on what is going on.

    The last suggestion after adding debug information would be to test with the latest SDK v16.0.0.

Reply
  • Try enabling the following in your sdk_config.h

    // <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


    And after running once or twice with settings above, please run with the following as well:
    // <e> APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED
    #define APP_USBD_MSC_CONFIG_LOG_ENABLED 1
    #endif
    // <o> APP_USBD_MSC_CONFIG_LOG_LEVEL  - Default Severity level
     
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL
    #define APP_USBD_MSC_CONFIG_LOG_LEVEL 4
    #endif

    This should give more information on what is going on.

    The last suggestion after adding debug information would be to test with the latest SDK v16.0.0.

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

Related