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

SDK 15.3 USB MSC can not modify file in pc.

Hi.

    I use SDK15.3 (PCA10056 NRF52840) USB MSC example.

    i can enumerate disk, creat file and delete file. but  i can not edit file. 

    When I edited the file, re-plugged the USB and opened the file I just edited again. pc display file does not exist. The content I just edited does not exist.

    

    wait for help.  thank you.

    

Parents
  • Hello, 

    The USB MSC example should work "out of the box". Have you tried to debug while running the example? Are you getting any type of error message? 
    What happens when you press any of the following (from the USB MSC example docs)? 

    • Button 1 creates a randomly named file in the root directory.
    • Button 2 lists the root directory.
    • Button 3 creates a file system (equivalent of the format command).

    Kind regards,
    Øyvind

  • Thank you for reply.

    i do not get any error message when i running the example.  and three buttons function normally.

    my  question is similar to [FATFS] FA_OPEN_APPEND destroy first file content 

    I have modified the bug as prompted. 

    However, after I modified the file, I still can't read the file normally after re-plugging the USB.

    wait for reply. thank you.

  • Hello again, 

    I've been testing and digging more into this. It seems that this a known bug which has been reported internally. See this thread.

    If you connect to your board via a terminal, you will get the output of the example similar to this:

    [00:00:00.000,000] <info> app: Initializing disk 0 (QSPI)...
    
    [00:00:00.000,000] <info> app: Mounting volume...
    
    [00:00:00.000,000] <info> app: 
    
    Listing directory: /
    
            0  000041C6.TXT
    
    Entries count: 2
    
    Creating random file: 000041c6.txt ...done
    
    [00:00:00.000,000] <info> app: USBD MSC example started.
    
    Creating random file: 0000167e.txt ...done
    
    [00:00:00.000,000] <info> app: 
    
    Listing directory: /
    
            0  000041C6.TXT
    
            0  0000167E.TXT
    
    Entries count: 3
    
    [00:00:00.000,000] <info> app: USB power detected
    
    [00:00:00.000,000] <info> app: Un-initializing disk 0 (QSPI)...
    
    [00:00:00.000,000] <info> app: USB ready
    
    [00:00:00.039,581] <info> app: USB power removed
    
    [00:00:00.039,581] <info> app: Initializing disk 0 (QSPI)...
    
    [00:00:00.039,581] <error> app: Disk initialization failed.
    
    [00:00:00.039,581] <info> app: USB power detected
    
    [00:00:00.039,581] <info> app: Un-initializing disk 0 (QSPI)...
    
    [00:00:00.039,581] <info> app: USB ready
    
    

    The issue is connected to the error "Disk initialization failed". Not sure when to expect a fix. I have asked the responsible team and will get back to you.

    Kind regards,
    Øyvind

Reply
  • Hello again, 

    I've been testing and digging more into this. It seems that this a known bug which has been reported internally. See this thread.

    If you connect to your board via a terminal, you will get the output of the example similar to this:

    [00:00:00.000,000] <info> app: Initializing disk 0 (QSPI)...
    
    [00:00:00.000,000] <info> app: Mounting volume...
    
    [00:00:00.000,000] <info> app: 
    
    Listing directory: /
    
            0  000041C6.TXT
    
    Entries count: 2
    
    Creating random file: 000041c6.txt ...done
    
    [00:00:00.000,000] <info> app: USBD MSC example started.
    
    Creating random file: 0000167e.txt ...done
    
    [00:00:00.000,000] <info> app: 
    
    Listing directory: /
    
            0  000041C6.TXT
    
            0  0000167E.TXT
    
    Entries count: 3
    
    [00:00:00.000,000] <info> app: USB power detected
    
    [00:00:00.000,000] <info> app: Un-initializing disk 0 (QSPI)...
    
    [00:00:00.000,000] <info> app: USB ready
    
    [00:00:00.039,581] <info> app: USB power removed
    
    [00:00:00.039,581] <info> app: Initializing disk 0 (QSPI)...
    
    [00:00:00.039,581] <error> app: Disk initialization failed.
    
    [00:00:00.039,581] <info> app: USB power detected
    
    [00:00:00.039,581] <info> app: Un-initializing disk 0 (QSPI)...
    
    [00:00:00.039,581] <info> app: USB ready
    
    

    The issue is connected to the error "Disk initialization failed". Not sure when to expect a fix. I have asked the responsible team and will get back to you.

    Kind regards,
    Øyvind

Children
  • Thank you for reply.

    I have add this code at the beggining of block_dev_qspi_uninit:

    as a result.  Disk initialization success. the log as follow:

    [00:00:00.000,000] <info> app: Initializing disk 0 (QSPI)...
    [00:00:00.000,000] <info> qspi: Init
    [00:00:00.000,000] <info> app: Mounting volume...
    [00:00:00.000,000] <info> app: 
    Listing directory: /
       <DIR>   SYSTEM~1
            0  000041C6.TXT
            5  123.TXT
    [00:00:00.000,000] <info> app: Entries count: 4
    [00:00:00.000,000] <info> app: Creating random file: 000041c6.txt ...
    [00:00:00.000,000] <info> app: done
    [00:00:00.000,000] <info> app: USBD MSC example started.
    [00:00:00.000,000] <info> app: USB power detected
    [00:00:00.000,000] <info> app: Un-initializing disk 0 (QSPI)...
    [00:00:00.000,000] <info> qspi: IOCtl: Cache flush
    [00:00:00.000,000] <info> qspi: Uninit
    [00:00:00.000,000] <info> app: USB ready
    [00:00:00.000,000] <info> qspi: Init
    [00:00:00.000,000] <info> qspi: IOCtl: Cache flush
    [00:00:00.009,063] <info> qspi: IOCtl: Cache flush
    [00:00:00.009,063] <info> app: USB power removed
    [00:00:00.009,063] <info> qspi: Uninit
    [00:00:00.009,063] <info> qspi: Uninit wait_for_idle
    [00:00:00.009,063] <info> app: Initializing disk 0 (QSPI)...
    [00:00:00.009,063] <info> qspi: Init
    [00:00:00.009,063] <info> app: Mounting volume...
    [00:00:00.009,063] <info> app: USB power detected
    [00:00:00.009,063] <info> app: Un-initializing disk 0 (QSPI)...
    [00:00:00.009,063] <info> qspi: IOCtl: Cache flush
    [00:00:00.009,063] <info> qspi: Uninit
    [00:00:00.009,063] <info> app: USB ready
    [00:00:00.009,063] <info> qspi: Init
    [00:00:00.009,063] <info> qspi: IOCtl: Cache flush
    

    but, When I re-plugged the USB and viewed the edited file, the file could not be viewed on the PC again.

    picture like this:

    wait for reply. thank you.

Related