µTasker Forum

µTasker Forum => utFAT => Topic started by: neil on August 24, 2015, 01:12:47 PM

Title: Files saved on SD card dont show on PC
Post by: neil on August 24, 2015, 01:12:47 PM
Hi Mark,
  I am using the latest version of the SD source, v2.01 with changes to some SD cards where they didn't format.    These cards are formatted as FAT32, and the files are created and read ok when connected to the processor. When I remove the card and place in the PC , it says the card is empty. The properties shows that 1.5MB has been used, but now files are displayed.

Regards
Neil
Title: Re: Files saved on SD card dont show on PC
Post by: mark on August 24, 2015, 04:31:24 PM
Hi Neil

I haven't heard of such an effect. Is this reproducible with all cards or just a few?

What you could do is use the HDD Raw Copy Tool "HDDRawCopy V1.1" to make an image of the card and send it to me. I can then copy the exact image to a card (including one that sent me that was causing initialisation problems) so that I can see it happening and possible explain it.

Regards

Mark
Title: Re: Files saved on SD card dont show on PC
Post by: neil on August 28, 2015, 03:51:44 PM
Hi Mark
  The 2 types of cards we have are sandisk , and transcend  cards. And it happens on both types. I have attached the file.

Regards
Neil
Title: Re: Files saved on SD card dont show on PC
Post by: neil on September 02, 2015, 04:41:26 PM
Hi Mark
  Any luck with the file?

Regards
Neil
Title: Re: Files saved on SD card dont show on PC
Post by: mark on September 02, 2015, 11:22:47 PM
Neil

I have used this to create an image on a 4GByte SanDisk card.

In the PC I see it as a disk called "QWIKDISK" with no data on it.

When I insert it into a Kinetis board (SDHC) I see this as info:

Disk QWIKDISK (3965190144 bytes) SDHC FAT32
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: 0x00076da8
Next free: 0x00000991
CSD: 0x40 0x0e 0x00 0x32 0x5b 0x59 0x00 0x00 0x1d 0x8a 0x7f 0x80 0x0a 0x40 0x40 0x00


The "dir" commnd shows it as empty.
The "dird" command shows that there was a file deleted called "ReadyBoostPerfTest.tmp"

[D]---A 24.08.2015  11:44          8388608 ReadyBoostPerfTest.tmp
1 files with 8388608 bytes
0 directories, 1994031104 bytes free



When I then analyse this file with the "infod" command I get:

D:\>infod ReadyBoostPerfTest.tmp
File: ReadyBoostPerfTest.tmp is LFN
Starting at entry 0x04 in sector 0x00001e45 (cluster 0x00000002)
Deleted LFN
Data = 0xe5 0x66 0x00 0x54 0x00 0x65 0x00 0x73 0x00 0x74 0x00 0x0f 0x00 0x49 0x2e 0x00 0x74 0x00 0x6d 0x00 0x70 0x00 0x00 0x00 0xff 0xff 0x00 0x00 0xff 0xff 0xff 0xff
Deleted LFN
Data = 0xe5 0x52 0x00 0x65 0x00 0x61 0x00 0x64 0x00 0x79 0x00 0x0f 0x00 0x49 0x42 0x00 0x6f 0x00 0x6f 0x00 0x73 0x00 0x74 0x00 0x50 0x00 0x00 0x00 0x65 0x00 0x72 0x00
Deleted LFN
End
SFN File located at entry 0x06 in sector 0x00001e45 (cluster 0x00000002)
Data = 0xe5 0x45 0x41 0x44 0x59 0x42 0x7e 0x31 0x54 0x4d 0x50 0x20 0x00 0x49 0x87 0x5d 0x18 0x47 0x18 0x47 0x00 0x00 0x89 0x5d 0x18 0x47 0x91 0x01 0x00 0x00 0x80 0x00
SFN name (archive) = .EADYB~1TMP Alias CS = 0x49
File length = 8388608 starting in sector 0x00002abd (cluster 0x00000191) FAT sector 0x00000062 offset 0x11


Finally, I check the sector content (0x1e45) where the deleted file object is located:

sect 1e45
Reading sector 0x00001e45
 0x57205141 0x2e006265 0x0872452e 0x60000000 0x44eb44eb 0x60000000 0x000044eb 0x00000000 0x49002042 0x66006e00 0x0f006f00 0x00727200 0x0061006d 0x00690074 0x0000006f 0x0000006e
 0x79005301 0x74007300 0x0f006500 0x006d7200 0x00560020 0x006c006f 0x00000075 0x0065006d 0x54535953 0x317e4d45 0x16202020 0x5d6f6800 0x47184718 0x5d700000 0x018f4718 0x00000000
 0x540066e5 0x73006500 0x0f007400 0x002e4900 0x006d0074 0x00000070 0x0000ffff 0xffffffff 0x650052e5 0x64006100 0x0f007900 0x00424900 0x006f006f 0x00740073 0x00000050 0x00720065
 0x444145e5 0x317e4259 0x20504d54 0x5d874900 0x47184718 0x5d890000 0x01914718 0x00800000 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


Here I see the same data content and no other file objects (following are only 0x00000000).

Therefore, it looks like there is really no data on the card (once the original single file was deleted).

Could you do the same to see whether there is a difference? What do your see on the card? If you find files on it can you use the "infof" to see its location on the disk so that I can check whether it is on it somewhere?

Regards

Mark
Title: Re: Files saved on SD card dont show on PC
Post by: neil on September 03, 2015, 09:46:10 AM
Hi Mark,
   Hmmmm..  I think I must have copied the wrong card. When in operation, our board saves the data , and various setup for the board on the SD .  The board then sends the data that was saved to our server, so we know the data is saved. I took out the card and simply done opened it up on Windows. One of our customers done the same with their board. We have quite a few SD cards about, so it could have well been the wrong card. Is it okay if I (I will make sure this time it is the correct card) send another file?  Im on vacation at the moment, so will do it when I get back .

Best Regards
Neil
Title: Re: Files saved on SD card dont show on PC
Post by: mark on September 03, 2015, 02:18:50 PM
Neil

Resend an image when you are back so that I can compare.

Regards

Mark
Title: Re: Files saved on SD card dont show on PC
Post by: neil on September 03, 2015, 05:03:39 PM
Thanks Mark

Regards
Neil
Title: Re: Files saved on SD card dont show on PC
Post by: neil on September 22, 2015, 04:59:06 PM
Hi Mark,
   I have ran my application now for several hours, and able to collect the data on the SD card, I can download the data at any point (I connect through tcp and download the data), the application opens the files and sends the data. I still cant see the data on a PC, when I run the test utasker  application and do a dir I get no files , and when I look at the info I get the following below.

If I restart my application , I can see the files (I have debug code) being opened during initialization of  the system, and when it downloads the data, I can see the files being opened, and data sent (which is correct info).

I have removed the sd card, and copied it now (attached), this time i know its teh same card :)

Following from dir and info:
Directory D:\

0 files with 0 bytes
0 directories, 1973481472 bytes free
D:\>info

SD-card  (1977614336 bytes)
Bytes per sector: 512
Cluster size: 4096
Directory base: 0x00000002
FAT start: 0x0000005f
FAT size: 0x00000eb9
Number of FATs: 2
LBA: 0x00001dd1
Total clusters: 0x00075a45
Info sect: 0x00000040
Free clusters: 0x00075a0f
Next free: 0x00000038
CSD: 0x00 0x26 0x00 0x32 0x5f 0x5a 0x83 0xae 0xfe 0xfb 0xcf 0xff 0x92 0x80 0x40
0xdf
D:\>

Regards
Neil
Title: Re: Files saved on SD card dont show on PC
Post by: mark on September 23, 2015, 09:55:39 PM
Neil

With this image I can't see any content on the disk.

What I do see is that there is FAT content:

D:\>sect 5f
Reading sector 0x0000005f
 0x0ffffff8 0xffffffff 0x00000003 0x00000005 0x0fffffff 0x00000007 0x00000036 0x00000009 0x0fffffff 0x0000000b 0x0000000d 0x0fffffff 0x00000035 0x0000000f 0x0fffffff 0x00000011
 0x0fffffff 0x00000013 0x0fffffff 0x00000015 0x0fffffff 0x00000017 0x0fffffff 0x00000019 0x0fffffff 0x0000001b 0x0fffffff 0x0000001d 0x0fffffff 0x0000001f 0x0fffffff 0x00000021
 0x0fffffff 0x00000023 0x0fffffff 0x00000025 0x0fffffff 0x00000027 0x0fffffff 0x00000029 0x0fffffff 0x0000002b 0x0fffffff 0x0000002d 0x0fffffff 0x0000002f 0x0fffffff 0x00000031
 0x0fffffff 0x00000033 0x0fffffff 0x0fffffff 0x0fffffff 0x0fffffff 0x0fffffff 0x00000038 0x00000039 0x0000003a 0x0000003b 0x0000003c 0x0000003d 0x0000003e 0x0000003f 0x00000040
 0x00000041 0x00000042 0x00000043 0x00000044 0x00000045 0x00000046 0x00000047 0x00000048 0x00000049 0x0000004a 0x0000004b 0x0000004c 0x0000004d 0x0000004e 0x0000004f 0x00000050
 0x00000051 0x00000052 0x00000053 0x0fffffff 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:\>


This shows that there are some cluster chains (still) in use. For example, the root directories cluster chain starts in sector 1dd1 (Cluster 2 / 8 sectors per cluster), followed by 0x1dd9 (cluster 3), followed by 0x1de9 (cluster 5), followed by 0x1df9 (cluster 7), followed by 0x1e09 (cluster 9), followed by 0x1e19 (cluster 0xb) - end

What I notice is that each of these clusters has a single file in it (as if each were an independent sub-directory) with names like FLUSH, 2015, INDEX, CALIB etc., each marked as files.

There is also data content that can be seen in some clusters (possibly OK) but the strangest thing is that the root directory looks to be made up of a number of clusters, each with a single file name in each one. It is expected that the root (and any other directory) is made up of entries that are all alongside each other - each cluster can contain 128 such file objects (they are all short file names) and not just one per cluster (!)
The result is that the directory listing scans the cluster until it finds an empty entry signalling the end (which happens immediately since there is such a lot of space).

At the moment it is surprising that your firmware actually sees the content - it is clear that Windows also won't find anything, as the firmware that I am running doesn't. If I understnd correctly this is also the case when you take a 'standard' project build and only happens with your build (?)

At a first educated guess it looks like your code is not using 32 bytes as a directory entry size but instead using the cluster size (4k). File object increments look to be stepping by this amount. This supposedly works when written and read by code doing this but will not be understood by anything else.

I would: check with the debugger any code that is using a pointer to DIR_ENTRY_STRUCTURE_FAT32 and executing something like
ptrDirectoryEntry += ptr_disk_location->ucDirectoryEntry;        // move to the present entry
Each ptrDirectoryEntry++ should be a 32 byte increment, whereby it looks like your compiled code may be incrementing in 4k steps instead.
Has something happened to DIR_ENTRY_STRUCTURE_FAT32 that explains this or is the compiler going crazy??

Hope you find something quickly based on this data.

Regards

Mark


Title: Re: Files saved on SD card dont show on PC
Post by: neil on September 24, 2015, 04:07:31 PM
Hi Mark
  Thanks for the reply. I will take a look and see if its this causing the issue. You are correct with the files on the card,  FLUSH, 2015, INDEX, CALIB . There are all files names in the root directory , and 2015 is a folder where data is stored.

Regards
Neil
Title: Re: Files saved on SD card dont show on PC
Post by: neil on September 27, 2015, 08:44:36 PM
Hi Mark
  What routines use this? Is the size dictated during the format procedure?  I remember it used to work okay before the last SD latest version. I simply overwrote the .h and .c mass storage files. Was there anything else needed?


regards
Neil
Title: Re: Files saved on SD card dont show on PC
Post by: mark on September 28, 2015, 12:47:16 PM
Hi Neil

Exchanging the utFAT files in its folder is all that is needed at an update.

I suggest doing the following as a test: reformat the card and the create a directory, monitoring the location of the directory object. This is how it should work, using the command line:

  Disk interface
===================
up           go to main menu
info         utFAT/card info
dir          [path] show directory content
dird         [path] show deleted directory content
dirh         [path] show hidden content
infof        [path] show file info
infod        [path] show deleted info
cd           [path] change dir. (.. for up)
file         [path] new empty file
write        [path] test write to file
mkdir        new empty dir
rename       [from] [to] rename
trunc        truncate to [length] [path]
print        [path] print file content
del          [path] delete file or dir.
undel        undelete [name]
format       [-16/12] [label] format (unformatted) disk
fformat      [-16/12] [label] full format (unformatted) disk
re-format    [-16/12] [label] reformat disk!!!!!
re-fformat   [-16/12] [label] full reformat disk!!!!!
sect         [hex no.] display sector
help         Display menu specific help
quit         Leave command mode
>re-format TEST
Formatting FAT32 in progress - please wait...
D:\>**Disk formatted
Disk D mounted
dir
Directory D:\

0 files with 0 bytes
0 directories, 4115947520 bytes free
D:\>info

Disk TEST (4124049408 bytes) SDHC FAT32
Bytes per sector: 512
Cluster size: 4096
Directory base: 0x00000002
FAT start: 0x0000005f
FAT size: 0x00001eb3
Number of FATs: 2
LBA: 0x00003dc5
Total clusters: 0x000f5547
Info sect: 0x00000040
Free clusters: 0x000f5546
Next free: 0x00000003
CSD: 0x40 0x0e 0x00 0x32 0x5b 0x59 0x00 0x00 0x1e 0xb9 0x7f 0x80 0x0a 0x40 0xff 0x00
D:\>sect 3dc5
Reading sector 0x00003dc5
 0x54534554 0x00000000 0x08000000 0x60000000 0x44eb44eb 0x60000000 0x000044eb 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:\>mkdir dir1
sect 3dc5
Reading sector 0x00003dc5
 0x54534554 0x00000000 0x08000000 0x60000000 0x44eb44eb 0x60000000 0x000044eb 0x00000000 0x69006441 0x31007200 0x0f000000 0xffffe400 0xffffffff 0xffffffff 0x0000ffff 0xffffffff
 0x0a010020 0x0c161d0c 0x1000002f 0x60000000 0x44eb44eb 0x60000000 0x000344eb 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:\>


Notice that in the root directory of a freshly formatted card there is just a single entry (the volume entry - TEST in this case). When I create a directory there is a new directory object added immediately after it.
From what I could see from your card, each new directory object is added in the next cluster (4kBytes away), rather than "immediately" after the present entry.

In fnCreateFile():
    ptrFoundEntry = (DIR_ENTRY_STRUCTURE_FAT32 *)ptr_utDisk->ptrSectorData; // the directory entry in the sector buffer
    ptrFoundEntry += ptrDiskLocation->ucDirectoryEntry;                  // move to the present directory entry


Here the pointer ptrFoundEntry should point to the first entry and then increment to the next (free location). ptrDiskLocation->ucDirectoryEntry will be 1 on first use and so increment by 32 bytes.

If this works correctly the question is whether it is a problem that starts only over time and usage.

Regards

Mark

Title: Re: Files saved on SD card dont show on PC
Post by: neil on September 28, 2015, 01:18:46 PM
Hi Mark
  Thanks for this. Where would I find the latest version of your utasker Demo?  It happens on all cards we used, and as soon as we use them.

Regards
Neil
Title: Re: Files saved on SD card dont show on PC
Post by: mark on September 28, 2015, 03:51:10 PM
Neil

If you are using debug.c you will have this interface in your code.
You can take V1.4.7 and build for a standard target - or better, the latest developer' code at http://www.utasker.com/kinetis/developers.html

If you would like to compare with a standard build there are binaries at http://www.utasker.com/kinetis.html

Regards

Mark
Title: Re: Files saved on SD card dont show on PC
Post by: neil 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
Title: Re: Files saved on SD card dont show on PC
Post by: neil 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
>
Title: Re: Files saved on SD card dont show on PC
Post by: mark 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
Title: Re: Files saved on SD card dont show on PC
Post by: neil 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



Title: Re: Files saved on SD card dont show on PC
Post by: mark 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
Title: Re: Files saved on SD card dont show on PC
Post by: neil 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
Title: Re: Files saved on SD card dont show on PC
Post by: mark 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
Title: Re: Files saved on SD card dont show on PC
Post by: neil 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

Title: Re: Files saved on SD card dont show on PC
Post by: mark 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





Title: Re: Files saved on SD card dont show on PC
Post by: neil 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
Title: Re: Files saved on SD card dont show on PC
Post by: mark 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
Title: Re: Files saved on SD card dont show on PC
Post by: neil 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