Author Topic: Files saved on SD card dont show on PC  (Read 22995 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Files saved on SD card dont show on PC
« Reply #15 on: September 29, 2015, 02:40:27 PM »
Hi Mark
   I have lost my password for getting into the project, can you please resend it to me?

Many Thanks
Neil

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Files saved on SD card dont show on PC
« Reply #16 on: September 30, 2015, 10:43:33 AM »
Hi Mark,
  I have copied across my uFat files and done exact commands as yourself, I got the below, which is not the same as your example. And when I carried out a Dir, there were no signs of the directory

Regards
Neil

SD-card NO (2008023040 bytes)
Bytes per sector: 512
Cluster size: 4096
Directory base: 0x00000002
FAT start: 0x0000005f
FAT size: 0x00000ef3
Number of FATs: 2
LBA: 0x00001e45
Total clusters: 0x00077737
Info sect: 0x00000040
Free clusters: 0x00077736
Next free: 0x00000003
CSD: 0x00 0x7f 0x00 0x32 0x5b 0x5a 0x83 0xbd 0x6d 0xb7 0xff 0x80 0x0a 0x80 0x00 0x8d
D:\>

D:\>sect 1e4f
Reading sector 0x00001e45
0x006e6569 0x6c000000 0x00000008 0x00000060 0xeb44eb44 0x00000060 0xeb440000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
D:\>

D:\>mkdir dir1
>sect 1e45
 Reading sector 0x00001e45
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000010 0x00000060 0xeb44eb44 0x00000060 0xeb440300 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x2e202020 0x20202020 0x20202010 0x00000060 0xeb44eb44 0x00000060 0xeb440300 0x00000000 0x2e2e2020 0x20202020
0x20202010 0x00000060 0xeb44eb44 0x00000060 0xeb440200 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
>
#dir
Directory

0 files with 0 bytes
0 directories, 2004045824 bytes free
>
« Last Edit: September 30, 2015, 11:25:44 AM by neil »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Files saved on SD card dont show on PC
« Reply #17 on: September 30, 2015, 01:23:26 PM »
Neil

This results looks completely different to your original case. Now the content is completely wrong and I don't actually see what it is doing.
Basically, when creating this directory the process is very simple with regard to that single sector (0x1e45 in this case):
1. A copy of the sector is read from the SD card and stored into a 512 byte RAM buffer
2. The new directory objects are written into the locations (32 byte aligned after the first entry)
3. The 512 byte sector is written back to the card.

What I see here is that the first entry (the volume) has gone or part of it has possily been shifted into a new location. There look to be two new entries added (there is also a "/.." directory name added so that would be correct) but their content is not correct (I don't even see valid names or file details) and they look to be shifted to incorrect locations.

At the moment I admit to being completely lost since I have never heard of or seen anything like this and don't even see any error logic that could explain anything. (In your first case there looked to be at least some logic to the error and your file system could also understand itself, even if PCs couldn't interprete the results - now it is distroying itself in a way that is also incompatible to itself).

What I am not sure is what you actually did:
If I understood correctly you took a standard uTasker M522xx version (which version and which target?) - did the SD card work normally in its original state?
Then you updated the utFAT part (which version exactly and which files were used?)
Then you repeated with these results.
Did you try the operations in the simulator to see whether the results are identical or whether it is dependent on the HW and/or compiler used?

If it can be explained by exchanging some files for reference versions I can attempt to reproduce the state by doing exactly the same (I need to know exactly what to do).
If not, I think that the only way to work out what is happening is to remotely debug the case - there are only a few lines of code involved in the creation of the directly and errors occurring in the RAM buffer must be fairly easy to see developing.
I have updated various projects to utFAT2.0 and don't remember any problems with compatibility (the low level routines being used are identical). In the past I have had a couple of problems with the CodeWarrior compiler for the Coldfire but such effects can be excluded fastest by verifying the same errors when runnning in the simulator.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Files saved on SD card dont show on PC
« Reply #18 on: September 30, 2015, 02:01:59 PM »
Hi Mark,
   I noticed I had a version of the standard uTasker M522xx (I used target M5225X_EXT_RAM) .  The last line at the start the debug file is:
31.01.2010 File open for rename uses attribute UTFAT_OPEN_FOR_RENAME rather than UTFAT_OPEN_FOR_WRITE {20}

Before I copied the uFAT from my application  (V2.01) , it had the issue where the format wouldnt finish (I have Transcend cards)  , which you sorted. But when I had other types of cards I was able to format, mkdir etc, and see the changes doing a dir command. So seemed to work fine. I then copied uFAT 2.1 from my application to the application, and got the previous result I posted.

I dont use the emulator, I always use codewarrior V7.2. I copied over files mass_storage.c and .h.  The last few lines at the start of the .c file are:

   06.10.2014 Correct brackets in fnExtractLongFileName()                {6} [uFATV2.01]
[1] changes for formatting cards that previously didnt format.

I have tried it on a few boards I have, with same results. I have a client with sandisk card, and also experiencing the same.. He is the only customer who has taken out the card.

Regards
Neil




Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Files saved on SD card dont show on PC
« Reply #19 on: October 01, 2015, 12:03:59 AM »
Neil

I have spent some time trying to reproduce the problem but haven't been able to do so. Therefore I recommend that it will be fastest if we do a remote debugging session so that I can step the code on your board (using your IDE) to see what is happening.
Please send me an email with time that best suits (Skype plus Chrome remote desktop - you will just need Chrome installed).

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Files saved on SD card dont show on PC
« Reply #20 on: October 01, 2015, 10:18:26 AM »
Hi Mark,
  Thanks very much for this.  Currently I am working remotely to my computer in the office, and I installed the Chrome Desktop app (I am running on Windows XP on my development machine) and made sure it was enabled in the plugins. I then tried to connect to it from another machine (installed there too, and running Windows 8.1),  but no luck. After entering the access code, connection doesn't take place. I use Teamviewer, is this any good for you? I can email you the whole project if that would help.

Thanks

Regards
Neil
« Last Edit: October 01, 2015, 02:37:48 PM by neil »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Files saved on SD card dont show on PC
« Reply #21 on: October 01, 2015, 10:01:59 PM »
Neil

If Chrome remote desktop doesn't work we can use Teamviewer instead.

Please give me times per email that suit and then we can talk.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Files saved on SD card dont show on PC
« Reply #22 on: October 05, 2015, 03:53:07 PM »
Hi Mark
  Thanks for your online support.  I managed to integrate the terminal screen into my application and still I got the same issues. I know the uFAT code is the same in both utasker and my project, and I know I have plenty of memory. So looking at my config file I noticed the issue was that the #ifdef UTFAT_LFN_READ was commented out , so I changed this and now had the same as the uTasker project. Below is the settings for both my project, and uTasker Project.
  I was then able to see the files and directories with the console on my code. After rebuilding my own project I then ran into an issue, which I replicated on the uTasker project. I have 2 file handles pointing to the same file.The first handle creates the file,  the other handle opens the file for read (manage mode). I placed the following right after I create a directory on the uTasker project.

   UTFILE fdWTest,fdRTest;  //both lines are global , and ptr_utDirectory was previously initialised.
   int Ret1,Ret2;
        Ret1=utOpenFile("\\Index.dat", &fdWTest, ptr_utDirectory,UTFAT_OPEN_FOR_WRITE | UTFAT_OPEN_FOR_READ | UTFAT_CREATE);  //file created
        Ret2=utOpenFile("\\Index.dat", &fdRTest, ptr_utDirectory,UTFAT_OPEN_FOR_READ | UTFAT_MANAGED_MODE ); //same file open for read in manage mode,

Ret1 returned fine, and the file was created (I see this in a DIR command) , but Ret2 returned -6 (UTFAT_FILE_NOT_FOUND).  If I commented out UTFAT_LFN_READ in my config , works fine as far as both files are opened, and my application runs as expected. But I cant see the files (original issue).

I dont want to use the "long file Names"  so I commented out UTFAT_LFN_READ,UTFAT_LFN_WRITE,   UTFAT_LFN_WRITE_PATCH,UTFAT_LFN_DELETE but the compiler threw errors out, see attachment


////CONFIG
    #define SD_CARD_RETRY_INTERVAL       5                               // attempt SD card initialisation at 5s intervals
    #define UT_DIRECTORIES_AVAILABLE     5                               // this many directories objects are available for allocation
    #define UTMANAGED_FILE_COUNT        10                               // allow this many managed files at one time
    #define UTFAT_LFN_READ                                               // enable long file name read support
    #ifdef UTFAT_LFN_READ
        #define MAX_UTFAT_FILE_NAME     (100)                            // the maximum file name length supported
    #endif
    #define UTFAT_WRITE                                                  // enable write functions
    #ifdef UTFAT_WRITE
        #define UTFAT_FORMATTING                                         // enable formatting SD cards (requires also write)
    #endif
    #define UTFAT_FULL_FORMATTING
    #define UTFAT_LFN_WRITE   
    #define UTFAT_LFN_WRITE_PATCH
//  #define SD_CONTROLLER_AVAILABLE

Best Regards
Neil


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Files saved on SD card dont show on PC
« Reply #23 on: October 05, 2015, 06:38:29 PM »
Neil

1. Disabling LFN read will also disable all other LFN operation, but removing all of the defines causes a variable in a struct to no longer be present. There is general code that is using this variable now so it errors.
The following modification (to stOPEN_FILE_BLOCK) will make the struct variable available in this case:

    #if defined UTFAT_WRITE
    DISK_LOCATION DirectoryEndLocation;                                  // location of the end of the present directory (after a complete scan)
    #endif
    #if defined UTFAT_LFN_WRITE
    DISK_LOCATION DeleteLocationRef;                                     // temporary sector reference to start of contiguous deleted entries
    DISK_LOCATION DeleteLocation[DELETED_ENTRY_COUNT];                   // location of double, tripple entry deletes found to ease reuse by new LFN entries (21 is maximum possible length of entries in LFN including a final SFN entry)
    #endif

Notice that DirectoryEndLocation has been moved from being conditional on UTFAT_LFN_WRITE and made conditional on only UTFAT_LFN_WRITE.

2. fnDirectorySectorCreate() shoudl not be use din thsi configuration but CodeWarrior is erroring due to teh fact that it doesn't have a formal prototype definition.
You can place
static int fnDirectorySectorCreate(UTDISK *ptr_utDisk, FILE_LOCATION *ptr_location);
in the file's header to overcome it. Possibly your version hasn't been optimised (as my working version) to remove the call when never needed. Note that my working version has various improvements concerning removing unused parts in different configurations, plus additional new functions, but doesn't include any bug fixes found to be required since the release of the version that you have.

Once you have tested the final configuration please tell me if there is still an operation that is not working as expected and we can debug it again.

Regards

Mark






Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Files saved on SD card dont show on PC
« Reply #24 on: October 05, 2015, 06:54:00 PM »
Hi Mark
   I just quickly tested the uTasker project (the one you debugged remotely the other day) , I commented out the UFAT_LFN_READ and ran the application. The issue where the directory wasnt seen appeared again. Could there be an issue when not using the LFN? Also, when enabled the managed files doesnt seem to work as previously described.


regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Files saved on SD card dont show on PC
« Reply #25 on: October 06, 2015, 01:25:10 AM »
Neil

That is it - there is a problem when LFN is disabled resulting in the problem that you had that PCs can't read the data.

It looks like you will need to move to my working version, where I just corrected it.
I am a little wary though due to the fact that it contains various new support (extensions for memory sicks and multiple disks of various kinds), therefore I will send you first just the latest version of _utOpenDirectory() where the error was being made.
It does have some additional improvement to allow the SFN mode to reuse deleted directory space but I don't think that that will be a big risk.

Please check the code that I send as email to verify that it drops in to your version without any problems.
Assuming all is OK remember also that your present SD cards (with data) will in fact not be compatible with the corrected version!

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Files saved on SD card dont show on PC
« Reply #26 on: October 06, 2015, 01:27:56 PM »
Hi Mark,
  I copied across the utOpenDirectory() routine only, and all works well. I commented out the UTFAT_LFN_READ , which as you previously mentioned disables the LFN. I ran my own project for a while and was  fine, and was able to see the files that were created using the Dir command. The managed code works fine too, so all looks good.  I havent tried looking at it on the PC yet (still working from home), but will be in the office tomorrow  so will give it a try , and will let you know how I get on.

Thanks again for all your help

Regards
Neil