Rockbox

This is the bug/patch tracker for Rockbox. Click here for more information.

Quick links: Bugs · Patches · Rockbox frontpage

Tasklist

FS#8663 - Data corruption on usb write on sansa

Attached to Project: Rockbox
Opened by Frank Gevaerts (fg) - Friday, 29 February 2008, 00:00 GMT+2
Last edited by Paul Louden (Llorean) - Tuesday, 01 July 2008, 23:02 GMT+2
Task Type Patches
Category Drivers
Status Unconfirmed
Assigned To No-one
Player type Sansa c200
Severity Low
Priority Normal
Reported Version current build
Due in Version Version 3.0
Due Date Undecided
Percent Complete 0%
Private No

Details

The udelay() in ata-c200_e200.c is not needed on my c250, and actually seems to cause write errors during USB connections. This patch makes it conditionnal on SANSA_E200.

Not committed yet because of the potential problems if I'm wrong
This task depends upon

Comment by Michael Sevakis (MikeS) - Friday, 29 February 2008, 03:46 GMT+2
We really need to find out why this creepy problem occurs at all. :\
Comment by Mark Arigo (lowlight) - Friday, 29 February 2008, 17:01 GMT+2
The OF uses the DMA engine for transfers so it's hard to say if it's needed.
If someone would like to experiment with DMA read/writes, I've attached the
disassembly from the c200 bootloader.
Comment by Tomasz Moń (desowin) - Monday, 03 March 2008, 17:55 GMT+2
Is that udelay really needed on e200?

I've removed that udelay, build with USE_ROCKBOX_USB and USB_HIGH_SPEED.
Then I've connected sansa to computer, copied xubuntu-7.10pl-desktop-i386.iso to microSD card, during copying dmesg said many high speed device reset and two "usb 2-3: device descriptor read/all, error -110" between device resets.
I've put card in card reader then, diffed file against the original - it was exactly the same!
Then, I've started sansa, put microsd card into it, copied file from card to internet memory on sansa (in rockbox), rebooted sansa into OF, and diffed that file against the original one at my computer - it was eactly the same as well.
Comment by Frank Gevaerts (fg) - Monday, 10 March 2008, 19:47 GMT+2
What happens is that "something" inserts two bytes at an offset of 0x220 into the write-block. The bytes are copied from 32 bytes earlier. Note that they are _inserted_, not overwritten. It only happens if there is a USB transfer still active (so it might be a USB related ISR that causes this, or USB related DMA).

Further testing shows that on my c250 it doesn't seem to happen (or happens much less) on the internal flash. Only the micro-sd slot seems to be affected.
Comment by Toni (ahellmann) - Friday, 28 March 2008, 18:05 GMT+2
I implemented rudimentary DMA write access on the SD driver for e260 and observed exactly the same effect (2 Bytes inserted / copied from 32 Bytes ahead at random places) at 30MHz and 24MHz, while writing data to disk (without USB dma involved!). I don't know the consequence of this.
Comment by Toni (ahellmann) - Friday, 28 March 2008, 21:19 GMT+2
After changing PLL_CONTROL from 0x8a220501 to 0x8a120501 at 30MHz the dma file transfer seems to be much more stable now on the sansa. At 24MHz I still get sporadically this '2 bytes inserted' effect. I didn't check other negative effects after changing the PLL_CONTROL setting.
Comment by Frank Gevaerts (fg) - Sunday, 20 April 2008, 15:53 GMT+2
The problem seems to go away if the write data is in IRAM
Comment by Martin Ritter (MartinR) - Monday, 21 April 2008, 13:46 GMT+2
This controller is very similar to the one in PXA255 / PXA27x series.
I would like to change the register definitions accordingly to the documentation of these chips to make further work a bit easier.
They would read like MMC_STRPCL, MMC_STAT, MMC_CLKRT and so on.
Does anybody mind?
Comment by Martin Ritter (MartinR) - Tuesday, 22 April 2008, 15:53 GMT+2
Here is my work on changing the register and bit definitions accordingly to the PXA27x Developers Manual.
Most of them obviously make sense, some unused registers have been identified by probing their default values with e200tool.
The rest is still guessing, especially the CMDAT and I_MASK bits.
It would be nice, if someone would consider to commit this or comment on what to change.
It shouldn't harm anything, as there are no functional changes yet.
Comment by Martin Ritter (MartinR) - Thursday, 12 June 2008, 10:38 GMT+2
This might be kind of a workaround for this bug. Surprisingly, it can be circumvented by filling the FIFO of the controller very fast, using a chunk of asm. Though, there has to be a short delay between detecting FIFO_EMPTY and filling the FIFO. Without this I got lockups and corruption. But if it's too long, the 'two bytes inserted' bug reappears. Probably this udelay has to be adjusted for c200 and GoGear. It has to be as short as possible.

The asm code will only work with an aligned buffer. With an unaligned buffer, the old slow routine is used along with an additional udelay to prevent the bug (that's odd, yes). But do we actually ever have an unaligned buffer with ata_write_sectors?

I did very intense testing and it turned out to be absolutely reliable with my e260 and a Sandisk 4GB SDHC card for several weeks now. Write speed is around 3.5 to 4 MB/s on the SD card, the internal flash is slower.

Though, I'm quite uncertain on how it will behave with different players or SD cards because of this fragile timing. Maybe even the speed of the SD card might have its impact (I only own one card). The speed of the internal flash might differ between devices as well. So it will still need a lot of testing. Backups!
Comment by Jonathan Backer (jrbil) - Thursday, 12 June 2008, 18:45 GMT+2
I just tried Martin's patch on my e280 with 2GB microSD card and found no corruption. Not extensive (about 1 GB) but seems to work.
Comment by Antoine Cellerier (dionoea) - Thursday, 12 June 2008, 19:03 GMT+2
Here's the result of my tests with and without the patch (udelay removal) on a Sansa e260 with a 4GB microSD HC card. All of these tests used full speed USB (high speed is a bit unreliable). Test protocol was simple:
1/ compile rockbox for clean svn trunk
2/ install on player using original firmware for transfer
3/ disconnect player
4/ connect using rockbox and copy 550 files (mostly music tracks)
5/ disconnect player
6/ connect using rockbox and run md5sum -c reference.md5 to check if files were ok or not.

Just to make sure that the microsd errors weren't due to a crappy partition, I reformated the disk (with udelay removed) and ran the test (with udelay included) again.

svn-trunk.17708.internal.check
550 OK
svn-trunk.17708.microsd.check
481 FAILED
27 FAILED open or read
42 OK
svn-trunk.17708.microsd.validation.check
465 FAILED
7 FAILED open or read
78 OK
svn-trunk.17708.no-udelay-in-sd-ata.internal.check
460 OK
svn-trunk.17708.no-udelay-in-sd-ata.microsd.check
550 OK

As you can no doubt see, removing the udelay fixes writes to the microsd card.
Comment by Jonathan Backer (jrbil) - Thursday, 12 June 2008, 21:18 GMT+2
Just with internal flash (removed SD), I formatted, copied 280 files and 1.2 GB. Did a diff and fsck, which found no corruption. Built the database and rebooted. Now I have corruption (*PANIC* Dir entry 6 in sector 3 is not free!).
Comment by Jonathan Backer (jrbil) - Thursday, 12 June 2008, 21:48 GMT+2
Just with internal flash (removed SD), I formatted, copied 280 files and 1.2 GB. Did a diff and fsck, which found no corruption. Built the database and rebooted. Now I have corruption (*PANIC* Dir entry 6 in sector 3 is not free!).
Comment by Martin Ritter (MartinR) - Friday, 13 June 2008, 09:44 GMT+2
Jonathan, thanks for testing. Can you please increase the udelay from 2 to 3 and repeat the database rebuild? Also try copying from internal flash to SD and back again.
Antoine, I assume you are referring to Franks initial patch. For me, that udelay was definitely required on my e260. But I always used high speed USB for my tests.
Comment by Antoine Cellerier (dionoea) - Friday, 13 June 2008, 12:53 GMT+2
Yes, I'm referring to the original patch. It works fine with Full Speed. I'll give it a try with high speed (I get lots of connection resets with high speed but it's still kind of usable) and post the results here. Anyway, since this seems to be the only reliable way to copy files without corruption on my microSD HC card (no support from OF), I'm using the udelay-less build for everyday stuff so I'll be able to see if it breaks at some point in the future.

(I already was able to copy files without the udelay over high speed, but I haven't had time to do the md5sums yet. What kind of issues were you getting? Are/were they easily reproducible?)
Comment by Martin Ritter (MartinR) - Friday, 13 June 2008, 14:46 GMT+2
Antoine, I just checked that again. Removing the initial udelay causes corruption on both the SD card and the internal flash for me. Especially on internal writes like building the database or when copying files within Rockbox. Just now Rockbox completely locked up on a file copy. USB transfers to the internal flash do apparently working though.
Comment by Martin Ritter (MartinR) - Friday, 13 June 2008, 15:06 GMT+2
New version of my patch:
- increased the udelay from 2 to 3 (Apparently, I was too optimistic)
- cleaned up the asm code
It's quite a bit slower but should be more reliable.
Comment by Michael Sevakis (MikeS) - Friday, 13 June 2008, 17:46 GMT+2
This wasn't a controlled check but perhaps worth noting: I had copied some movies over to my e260 for mpegplayer development with the retailos USB mode and one of them had some corruption in it. Copying over it again from the same source file fixed it. I can't say whether or not rockbox had some role in it but the file never had writes made to it by rockbox itself. It could just be yet another PP hardware bug.
Comment by Jonathan Backer (jrbil) - Friday, 13 June 2008, 20:20 GMT+2
Just tried the latest patch:

From computer to internal flash I transferred 257 files totaling 1.2 GB. Only one file was corrupted.
From SD to internal flash I transferred 234 files totaling 1.6 GB. Only three were corrupted.

Almost there. Even with the additional delays, high speed transfer is easily 3 times faster than full speed.
Comment by Jonathan Backer (jrbil) - Friday, 13 June 2008, 23:25 GMT+2
Upped the udelay to 4 and still get corruption in 1 of the 257 files when I retried the transfer from the computer to the internal flash. Without your patch 196 of the 257 files get corrupted.

I just tried to do the tests with the OF. Although I verified that there was no corruption, my computer lost connection several times (KDE automatically unmounted and remounted) which caused me to restart my verification several times. I did not have this problem with rockbox. I'm curious if other people can reproduce my problems with your latest patch.
Comment by Jonathan Backer (jrbil) - Saturday, 14 June 2008, 02:40 GMT+2
OK. Testing on my linux box at home. With your patch, I've copied over 750 files and 3.5 GB without any corruption whatsoever.

Without the patch, running hi-speed I get corruption on 203 of 253 files. Unfortunately, I left my SD card at work, so I can't test it.
Comment by Jonathan Backer (jrbil) - Saturday, 14 June 2008, 04:26 GMT+2
Copied approx 500 files (3.5 GB) and got one error. So the problem seems less frequent on my home machine, but still persists.
Comment by Martin Ritter (MartinR) - Monday, 16 June 2008, 10:20 GMT+2
Michael, I too believe that this must be some kind of hardware bug. Or the controller runs at an inappropriate clock rate or something. Maybe it would help if we had the interrupts working. But since the bug also occurs with DMA, it will probably do with interrupts as well.
Would have been interesting, which kind of corruption your file had.

Jonathan, thanks again. Did you retry the database rebuild? And can you somehow confirm that the remaining corruptions are in fact from the 'two bytes inserted' bug? In my tests it either occurred quite frequently, or it was completely gone. It never happened that sporadically to me. I don't know how to check that with Linux though. Hmm, if the file sizes would be different, then it's definitely not this bug. If they're the same, it probably is.
Comment by Linus Nielsen Feltzing (linusnielsen) - Monday, 16 June 2008, 11:14 GMT+2
Maybe it would be better if we set the CPU core speed to match the USB rate?
Comment by Martin Ritter (MartinR) - Wednesday, 18 June 2008, 17:25 GMT+2
Linus, this bug has not much to do with USB actually. If that udelay is slightly changed, it occurs with non USB writes as well. The fact that it is triggered by USB is probably just because the timing is a bit different then. The USB buffer resides in uncached memory, so the FIFO filling loop runs a bit slower than usual. But that's just my guess, I may be completely wrong.
Comment by Martin Ritter (MartinR) - Monday, 23 June 2008, 13:33 GMT+2
Final version of this patch (probably):
As I don't have any corruptions at all anymore, I don't know how to improve this any further.
- #ifdef only for e200 as no other targets have been tested yet.
- Not using sd_poll_status() inside the loop because yielding may disturb the timing.
This will hopefully fix the last remaining file corruptions.
- The new code will be used only in USB mode (usb_exclusive_ata), the current code remains completely unchanged.
This way
- We don't have to care for the buffer alignment as the USB buffer will be aligned always.
- Testing will be much easier because only USB mode has to be tested.
- It will not break anything when not in USB mode.
Comment by Jonathan Backer (jrbil) - Saturday, 28 June 2008, 04:06 GMT+2
I just did some testing on my e280, and the latest patch looks good. With USB transfer, I sent over 1000 files (5 GB) with no errors. I did a bunch of copying around (w/ rockbox not USB) to exercise the other code (1.4 GB), and found no errors there either. Looks solid to me. I haven't tried it with my micro SD card yet because it is at the office.
Comment by Toni (ahellmann) - Saturday, 28 June 2008, 15:27 GMT+2
I tried the latest patch here on e250 with external SD-card: No errors!
Comment by Jonathan Backer (jrbil) - Monday, 30 June 2008, 23:24 GMT+2
I was finally able to try the latest patch with my 2GB microSD card. Good news: the internal flash works flawlessly transferring large amounts of data by USB and directly with Rockbox (no USB) when the SD card is present. Bad news: reading and writing to the SD card causes corruption. Doesn't matter if the transfer is through the USB or Rockbox. To test Rockbox, I copied from known good internal flash to SD and back again and got corruption. Oh, and it's definitely a read _and_ write issue to SD: comparing with the internal flash (copy to SD and then back to internal using Rockbox) showed fewer errors then comparing with the SD (just copy from internal to SD). Moreover, the difference in detected corruption (just one file) disappeared when I tried that particular file again, indicating that it was a one-off read error.
Comment by Jonathan Backer (jrbil) - Tuesday, 01 July 2008, 05:48 GMT+2
Ok. I remembered from previous corruption issues that it was important to reformat. Once I reformatted the SD card, all of my corruption problems vanished. With the latest patch on my e280 with 2GB microSD card, the high speed USB is flawless. Please put it in SVN. Thanks.
Comment by Frank Gevaerts (fg) - Wednesday, 09 July 2008, 22:10 GMT+2
USB changes in r17997, while not fixing the issue, at least makes it not be triggered by USB any more. I copied 2GB to my microSD card without errors. Before r17997 I would get errors every few MBs.

Note that if there was any non-USB related corruption, this will still be there

(I didn't apply any of the patches from this task, to maximise my chances of triggering the corruption)
Comment by Jonathan Backer (jrbil) - Thursday, 10 July 2008, 02:25 GMT+2
I just tried the USB changes committed in r17997. Repeating the tests I used before, I found no corruption on my e280: 6 GB to internal from computer, 1.7 GB to SD from computer, 1.7 GB from SD to internal.

Seems to work pretty well. The write speeds seems slower but the read speeds are comparable. On write, I'm getting just over 2 MB/s.

Thanks Frank.
Comment by Frank Gevaerts (fg) - Thursday, 10 July 2008, 10:34 GMT+2
Lower write speed is to be expected : the usb storage driver now is careful not to overlap usb and sd transfers. The read path is unchanged
Comment by Martin Ritter (MartinR) - Friday, 11 July 2008, 08:55 GMT+2
Frank, unfortunately your change in r17997 did not fix this bug for me (e260 + 4GB Sandisk SDHC, plain SVN, High Speed enabled). I only copied 3 files (15MB) to the SD card and each of them were corrupted. Transfers to the internal flash seem to work, but they also worked before.

Jonathan, I wonder why our test results are so different. Just to make sure, did you remove my patch before testing r17997?
Comment by Jonathan Backer (jrbil) - Friday, 11 July 2008, 18:17 GMT+2
Yup. I did a clean build from SVN. However, my card is just a 2GB SD (not SDHC). Based on its size, I'm guessing that Frank's card is also a regular SD card. I don't know how big a difference that makes, but it's worth looking into.
Comment by Frank Gevaerts (fg) - Friday, 11 July 2008, 18:50 GMT+2
Can both of you (MartinR, jrbil) check if the corruption _only_ occurs while using usb, i.e. copy some large files within rockbox (from/to sd, sd-to-sd, internal-to-internal...) ?
Comment by Jonathan Backer (jrbil) - Friday, 11 July 2008, 19:01 GMT+2
Sure. Which revision should I use? Is anything prior to r17997 OK?
Comment by Frank Gevaerts (fg) - Friday, 11 July 2008, 19:14 GMT+2
r17997 only changed usb behaviour, so that doesn't really matter when testing non-usb behaviour.
Comment by Jonathan Backer (jrbil) - Friday, 11 July 2008, 22:31 GMT+2
By copying large files within Rockbox, I tested SD->SD (1 GB), SD->internal (2 GB), internal->SD (2 GB), and internal->internal (2 GB) and found no errors.
Comment by Martin Ritter (MartinR) - Monday, 14 July 2008, 10:24 GMT+2
All internal write operations seem to work properly for me, as long as that udelay in the SD driver is left untouched. That's why I decided to activate my patch only in USB mode.
I just double checked with current SVN and a fresh formatted SD card, but the corruption is still there. Then I did a comparison without SERIALIZE_WRITES and found no significant difference. Within a 10MB test file I had the 2 bytes inserted up to 10 times with SERIALIZE_WRITES and up to 8 times without (5 tries on each).
Comment by Jonathan Backer (jrbil) - Sunday, 03 August 2008, 05:18 GMT+2
For what it's worth, I got a new micro SD card today. It's a class 6 SDHC. With SERIALIZE_WRITES it works flawlessly.
Comment by Frank Gevaerts (fg) - Sunday, 17 August 2008, 22:56 GMT+2
Can someone who still has the problem with usb try copying some files within rockbox while the cpu is boosted (this can be done from the System/Debug menu), to see if that makes a difference?
Comment by Martin Ritter (MartinR) - Tuesday, 19 August 2008, 09:22 GMT+2
Hi Frank, I did the following tests with plain SVN r18310 (just high speed USB enabled):
- copied a directory of 415 MB (95 files) within rockbox from internal flash to sd in 2:24 min
- bitwise compared all files via USB - no error
- deleted the directory on sd
- raised the boost counter in the Debug/CPU frequency screen
- copied same files again in 2:21 min
- bitwise compared all files via USB - no error again
- copied a 12 MB file from PC to sd via USB and got 2 bytes inserted at 15 random positions
Since the measured times don't differ much, I believe the CPU is boosted during a file copy as well. So that's probably not the reason.
Another difference between internal copying and USB transfers might be the buffer size. I'll do some tests on it ASAP.
Comment by Martin Ritter (MartinR) - Tuesday, 19 August 2008, 14:39 GMT+2
The buffer size doesn't seem to matter. But if I put the buffer used for copying in uncached memory, like the USB buffer is, I get corruption also when copying. (clipboard_pastefile in onplay.c)
So that's probably the significant difference which makes the bug appear with USB only. But what to do about it? Buffer in IRAM?
Oops, did I say that? ;-)
Comment by Frank Gevaerts (fg) - Tuesday, 19 August 2008, 15:27 GMT+2
If the issue is only caching, just using the cacheable address in ata_write_sectors() should do the trick (with probably a cache flush before). I'll prepare a test patch later today
Comment by Frank Gevaerts (fg) - Tuesday, 19 August 2008, 19:01 GMT+2
Could you try the attached patch? It uses a cached address for the actual write.
Comment by Martin Ritter (MartinR) - Thursday, 21 August 2008, 11:59 GMT+2
Test results with cached.diff using 3.8 GB of data:

SERIALIZE_WRITES enabled
SD card: 2.5 MB/s, no corruption
internal flash: 2.1 MB/s, no corruption

SERIALIZE_WRITES disabled
SD card: 2.8 MB/s, no corruption
internal flash: 2.3 MB/s, no corruption

So I think, SERIALIZE_WRITES can be reverted. If the existing code in ata_write_sectors() is considered as proven to work, this patch should be safe. For gaining more speed (up to 3.6 MB/s on SD), my above patch might be considered. But that would surely need some public testing phase, as it introduces new time critical code. Basically, both patches do the same thing: speeding up the FIFO feeding by either using cache or ASM. I wonder what if both patches would be combined...
Comment by Jonathan Backer (jrbil) - Thursday, 21 August 2008, 21:13 GMT+2
Test results with latest SVN (cached.diff committed) copying 2.5 GB of data:

SERIALIZE_WRITES disabled
SD card: 1.76 MB/s, 5/506 files corrupted

SERIALIZE_WRITES enabled
SD card: 1.57 MB/s, 17/506 files corrupted

What a weird bug...
Comment by Frank Gevaerts (fg) - Thursday, 21 August 2008, 23:06 GMT+2
Could you run that a few more times, to check if the difference in number of corrupted files is really there or is just an accident?

Did you also check the filesystem for errors between tests, or did you reformat? I'd like to rule out pre-existing errors as a cause for the higher number of errors in the SERIALIZE_WRITES case.

Just to be sure : is this the same sd card that you used previously when you found no errors? Also, how big was your test then?
Comment by Steve (TheBashar) - Thursday, 21 August 2008, 23:26 GMT+2
I have a c200 and a 4GB micro SDHC card. I'm running on Vista. If someone could post a set of steps to follow, I'd be happy to provide additional testing with the latest build. Specifically I'm in the dark on how one goes about verifying the file integrity / finding the corruptions.
Comment by Jonathan Backer (jrbil) - Thursday, 21 August 2008, 23:59 GMT+2
I reformatted the card between tests. I will run a few more times to make sure that the increase in errors is not just an accident. I was dumbfounded, so I double checked by reverting the cache patch and defining SERIALIZE_WRITES. Indeed there were no errors.
Comment by Martin Ritter (MartinR) - Friday, 22 August 2008, 09:50 GMT+2
Jonathan, I'm wondering why your write rates are quite lower than mine. Can you please measure the speed with the setup that is working for you? Maybe that will give a hint.
Steve, any tool for testing USB memory sticks will do. I often used this one: ftp://ftp.heise.de/pub/ct/ctsi/h2testw_1.4.zip
Start testing 10 MB, if that works 100 MB, then the whole card.
Comment by Martin Ritter (MartinR) - Friday, 22 August 2008, 10:15 GMT+2
Jonathan, still wondering what the difference between our players might be. Maybe that's silly, but please do the following: Go to System/Debug/CPU frequency. Turn the wheel left one click. Frequency should show 80000000. Go back one level, then to View HW info. What's the Est. clock shown there? Mine is 81804.
Comment by J. Bilbrey (JB) - Friday, 22 August 2008, 13:39 GMT+2
Just out of curiosity, for those still getting SD corruption, how are you formatting your cards? I have seen elsewhere that using an OS to format SD cards can give them inappropriate cluster sizes, resulting in poor speed, and data corruption on some players.

Panasonic has a utility for properly formatting SD cards here: http://panasonic.jp/support/global/cs/sd/download/sd_formatter.html See if this makes any difference.
Comment by Frank Gevaerts (fg) - Friday, 22 August 2008, 15:17 GMT+2
At least in my tests, formatting has nothing to do with it as I use the raw unformatted partition
Comment by Tomasz Moń (desowin) - Saturday, 23 August 2008, 02:32 GMT+2
I'm experiencing unusual problem (Sansa e280)

when I have my usb printer connected then there's corruption when copying files to internal flash, but if I unplug the printer all data is ok.
(I've done 4 tests using 5.3gb of data - two with printer connected (different files were corrupted), two without (all data matched))
Comment by Jonathan Backer (jrbil) - Saturday, 23 August 2008, 05:33 GMT+2
Martin: I checked my CPU frequency and it reads 81803.

I used the program that Martin recommended for testing USB sticks and I get far fewer errors. Using SERIALIZE_WRITES and the caching patch, I twice filled my 4GB SDHC with no detected error. Once it detected about 800K of sectors that were wrong.

Before, I tested by copying my music library over to the card, and then comparing each file bit-by-bit. This is fairly easy under the linux command prompt. I just repeated this test for SERIALIZE_WRITES with caching just to be sure. 10 of 509 music files were corrupted. No such corruption occurs with just SERIALIZE_WRITES.

I have no idea why many files would cause a problem, but just a few wouldn't.

Regarding speed: my write rates are much lower than Martin's. This seems to be independent of whether I access the SD or built-in flash. It is much slower than the OF.
Comment by Jonathan Backer (jrbil) - Saturday, 23 August 2008, 07:09 GMT+2
Write speeds:

OF - 4.81 MB/s
SERIALIZE_WRITES - 1.52 MB/s
SERIALIZE_WRITES w / caching - 1.67 MB/s
caching w/o SERIALIZE_WRITES - 1.90 MB/s
Comment by Steve (TheBashar) - Sunday, 24 August 2008, 09:31 GMT+2
Just another data point. I formatted my 4GB micro with SD_Formater and then stuck it in my c250. I connected it to my vista laptop and used the h2testw utility to test all 3854MB. My c250 was running r18338 except I turned on USE_ROCKBOX_USB. I had no errors at all. My write speed was oddly low though at only 757KB/s. But slow is better than corrupted.
Comment by Martin Ritter (MartinR) - Monday, 25 August 2008, 10:01 GMT+2
Thanks for all the tests, guys. I more and more come to the conclusion, that we are chasing more than only one bug here.
Yesterday I had a corrupted file where a range of sectors hasn't been written at all. It contained the contents of the file which was stored previously at that position. The screenshot desowin did at http://www.rockbox.org/irc/log-20080822#22:25:13 looks pretty much the same. I wasn't able to reproduce this yet. It seems to happen extremely rarely, at least with my hardware.
Jonathan, do you have the ability to prove what kind of corruption you're still experiencing?
Steve, for high speed USB you have to define USE_HIGH_SPEED as well.
Comment by Frank Gevaerts (fg) - Monday, 25 August 2008, 14:06 GMT+2
This could just be the "usual" corruption, but in the FAT structure instead of in the file
Comment by Martin Ritter (MartinR) - Monday, 25 August 2008, 16:55 GMT+2
Possibly. But chkdsk should easily detect this as a FAT mismatch. So if we have wrong sectors in a file and chkdsk doesn't complain, we probably have another bug. Unfortunately, I didn't run chkdsk then.
Comment by Tomasz Moń (desowin) - Monday, 25 August 2008, 17:05 GMT+2
fsck didn't complain for me.

I wanted to chkdsk it, but when I connected sansa to my laptop, it just froze whole Vista. (it unfreezed after I unplugged sansa)
Comment by Frank Gevaerts (fg) - Sunday, 31 August 2008, 17:18 GMT+2
I reverted r18327 for now, as it made things break hard on ipod (and it didn't solve the sansa issue completely anyway)
Comment by Jonathan Backer (jrbil) - Friday, 05 September 2008, 05:41 GMT+2
I just returned from holidays and did some more testing. The corruption that I'm witnessing only occurs when copying from my computer to the SD card (not from the computer to internal memory). When it happens the corruption is contiguous and spans about 6k (exact numbers are 6066, 6046, and 6026 bytes). This was the latest SVN with the cache patch applied.
Comment by Martin Ritter (MartinR) - Friday, 05 September 2008, 09:45 GMT+2
Jonathan, thanks again. Actually, the number of corrupted (because shifted) bytes should be a multiple of 32, as the 'two bytes inserted' bug always occurs at a 32 byte boundary.
But anyway, as we see, it's hardly possible to find a workaround that will work for everyone. So we really have to find the underlying problem, instead of trying to cure the symptoms. Maybe I already found out something, but yet it raises another problem. Investigating further...
Comment by Linus Nielsen Feltzing (linusnielsen) - Friday, 05 September 2008, 11:18 GMT+2
32 bytes sounds very much like a cache line size...
Comment by Martin Ritter (MartinR) - Friday, 05 September 2008, 12:36 GMT+2
It's also the size of the controller's FIFO (actually 16 words). What probably happens is, that after all 16 words are sent to the card, the first word is sent again. So it's probably a ring buffer which does one step too much sometimes.
Comment by Jonathan Backer (jrbil) - Friday, 05 September 2008, 16:50 GMT+2
I'm pretty sure about the size of the corruption (I did a "cmp -l file1 file2 | wc -l"), but I'm not sure that it is contiguous (I checked that by glancing over the the output by hand; if it helps, I can investigate that further). It did occur away from the file boundaries (neither at the beginning nor end). As a side note, fsck and chkdsk found no errors.
Comment by Michael Sevakis (MikeS) - Friday, 05 September 2008, 17:12 GMT+2
Could the card possibly continue clocking-out data on its own from words remaining in the FIFO? Is it simply a FIFO underrun condition?
Comment by Michael Sevakis (MikeS) - Friday, 05 September 2008, 18:57 GMT+2
I might also suggest (as I've done several times) to compare this SDHC controller to that of the one for the imx31. The similarity seems worthy of note and could perhaps be a good guide.
Comment by Martin Ritter (MartinR) - Monday, 08 September 2008, 10:04 GMT+2
This really might be some FIFO underrun condition. But actually, the controller should stop the card clock automatically in that case. There's nothing we can do about it at software side, besides correct initialization.

I already compared this controller to various SoC. The closest match is probably the PXA27x series plus a bit of PXA255 (search Google for PXA27x developer's manual). My patch at http://www.rockbox.org/tracker/task/8663#comment23382 was about renaming the register and bit definitions accordingly to this manual. It's out of sync now, but I'd resync it, if it would have a chance for committing. Actually, there is too much work in it to be dumped silently.

Loading...