How to Fix uTasker USB to SD Card Stuck at 98% when Copying File?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Fix uTasker USB to SD Card Stuck at 98% when Copying File?

2,431 Views
alresarena
Contributor III

How to Fix uTasker USB to SD Card Stuck at 98% when Copying File?

Board:       Teensy 3.5

SD Card:   8GB Sandisk SDHC

The Copying speed is moving while the Copy progress stucks at 98%.

utasker-msd.png

13 Replies

2,028 Views
alresarena
Contributor III

Hello Sir Mark :smileyhappy: I updated uTasker with the latest usb_application.c file and its now working perfectly. I tried copying a file with 12mb size and it completes the copying process. Thank you so much Sir Mark :smileyhappy: I really appreciate your help :smileyhappy:

0 Kudos

2,028 Views
mjbcswitzerland
Specialist V

Alres

That is good news.

I wasn't expecting the update to be needed (the open source code is at least 2 years old now and this is the first time the effect has been reported) but it looks as though Windows USB-MSD timing has changed recently and the FAT write after file transfer is much faster than it used to be (which the update cures). This may explain why the error occurred at the end of the transfer and not during the file content transfer. It doesn't explain why it was only seen for larger sized files, but there are some things that may never be fully explained....

I am pleased however that the update looks to have confirmed its usefulness so the OpenSource version should also be reliable again ;-)

Regards

Mark

0 Kudos

2,028 Views
alresarena
Contributor III

Its ok Sir Mark :smileyhappy: Thank you so much for your response :smileyhappy: I really appreciate it :smileyhappy: I'll try the fix code when I got home :smileyhappy:

0 Kudos

2,028 Views
alresarena
Contributor III

Yes i can format the sd Card using SdCard slot on PC  and the sdcard is working but when I put the Sd card on Teensy 3.5 with updated utasker usb_application.c code, the sd card shows unformatted on PC

0 Kudos

2,028 Views
mjbcswitzerland
Specialist V

Alres

I am very sorry but I made a mistake when I updated the code for you.
I have put the line
iWriteInProgress = 1;                    // {46} do not handle further commands until the data had been received
to line 2661 in the file and it should be at 2681!

If you move it from the UFI_READ_12 case to the UFI_WRITE_12 it will then not cause the read to be (incorrectly) affected.

I have checked in the correction to the Open Source repository too.

Sorry again: I hope that this then allows operation...

Regards

Mark

2,028 Views
alresarena
Contributor III

Hello Sir Mark :smileyhappy: When I try to format it shows  unable to format message.

UTASKER2.jpg

0 Kudos

2,028 Views
mjbcswitzerland
Specialist V

Alres

Can you format the SD card in the SD slot of the PC?
Make sure that write-protection is not enabled.

Regards

Mark

0 Kudos

2,028 Views
mjbcswitzerland
Specialist V


Hi Alres

From what I can see you are copying a 6MByte file to the SD card. After copying most of the data at a fairly steady rate of close to 1MB/s it stopped and possibly didn't complete.
In such cases there is no information shown by the PC host to inform of the problem but it sounds like USB stalled, but the reason is also not visible. It could have been due to firmware not related to the USB interface (eg. other tasks blocking resources) or even a crash at the processor.

Question:
- do you always get the same behavior or is it something that happened just once?

Please could you also update your "usb_application.c" file from the Open Source repository because I have just checked in a modification taken from the developer's version. This modification was added to ensure that the class didn't try to handle received data as a class command (which was encountered [due to a race state] when the USB task was delayed). If you find that you can't reproduce such an effect after the update it could have been this effect that you had. (The effect was that the device would return a stall after a write, causing the PC to repeat - but only after a fairly long wait where it signals that it is "calculating" the remaining time).
You can see the modification in the code by searching for the modification reference number {46}

Regards

Mark

2,028 Views
alresarena
Contributor III

Thank you so much Sir Mark :smileyhappy: I really appreciate your response :smileyhappy: 

0 Kudos

2,028 Views
alresarena
Contributor III

Answer: It will not happen when I try to copy a file  with a size of 2MB or below it didn't stuck but when I try to copy 3MB or higher like on the screenshot which is 6MB it will stuck at 98% 

0 Kudos

2,028 Views
mjbcswitzerland
Specialist V

Alres

Did you update the "usb_application.c" file to check whether the behavior remains the same?

At the moment I can't explain how a transfer above a certain size will (always) result in it freezing at 98% (is it always 98% or is it random?).

I'll explain the USB-MSD operation:

- the first thing to understand is that the PC host is entirely in control of the FAT
- the PC host writes and reads SD card sectors (always 512 bytes at a time) in order to save data to the card and to modify the file objects(s) and the FAT entries
- the USB-MSD class has almost no intelligence with respect to the data being copied or the file system being used
- when the PC transfers 1 byte or 100MBytes the USB-MSD  class simply has more reads/writes to execute but it has no idea about what is being read or written and also has no idea how much more data will be transferred until the transaction is complete

Due to the above explanation and reasoning I see no reason for a file size to cause a difference in behavior and so couldn't explain why a transfer freezes at a certain percentage.
The only dependency that I could see with the file size is the amount of of written blocks of data - if there is a "chance" or a transfer failing for whatever reason, the probability of a failure at some point during the transfer would increase with the fie size. However it still it wouldn't explain it occurring at the same point in a file transfer.

I think that it will be necessary to repeat tests to be sure of a representative description of the error in order to identify where its cause could be. Also, are there other activities in the firmware that may have an effect (eg. things that are performed at certain times?)

Regards

Mark

0 Kudos

2,028 Views
alresarena
Contributor III

Hello Sir Mark :smileyhappy: I tried your updated code usb_application.c but unfortunately the SD Card that is mounted on the PC became unformatted even the SD Card itself is physically formatted with FAT32.

Here's the screenshot :

UTASKER.jpg

0 Kudos

2,028 Views
mjbcswitzerland
Specialist V

Alres

I doubt that the update influences the state of the card since it effects only writes and not reads.

Try formatting the card as the PC suggests and perform the tests again.

During developments it makes sense to have a small number of SD cards that you can change in case anything goes wrong and also so you can repeat tests to see whether behavior is consistent or random.

Regards

Mark

0 Kudos