Rockbox Technical Forums

Support and General Use => Hardware => Topic started by: chris_s on January 16, 2019, 04:59:56 PM

Title: DMA leads to FS corruption on iPod 4G?
Post by: chris_s on January 16, 2019, 04:59:56 PM
I'm experiencing a reproducible issue on multiple iPods (all fourth-generation ones), regardless of whether I'm using the original hard drive or a compact flash card, and running either on version 3.14 or  the latest development version (with or without custom patches).

Basically, sooner or later (can be after only a few – clean – restarts or sometimes after dozens of them) the file system becomes corrupt and/or bad data has been written to the database files, config files or playlist_control or the files outright disappear, are duplicated or renamed so that I have files like DATAB~1.TCD, DATABA~5.TCD etc.. with the effect that the database has to be re-initialized (sometimes only possible after first fixing the file system).

My working assumption / wild guess is that some files don't get correctly closed when shutting down the iPod?! But I could be way off-base there.

Update: Actually, DMA appears to be the cuplrit

The only thing possibly vaguely related (?) that I could find was this: https://www.rockbox.org/tracker/task/11883 . Not sure whether this is still in any way current.

Anyone have an idea how to get to the bottom of this?  :-\
Title: Re: DMA leads to FS corruption on iPod 4G?
Post by: chris_s on January 16, 2019, 07:31:33 PM
Huh. This leads me to think it has something to do with DMA ?

http://forums.rockbox.org/index.php/topic,51112.msg235982.html#msg235982

Guess I'll check to see whether disabling DMA in the current build makes a difference. Will report back in a little while...
Title: Re: DMA leads to FS corruption on iPod 4G?
Post by: chris_s on January 17, 2019, 03:04:54 PM
After some furious testing today, I’m now growing ever more confident that the culprit is indeed DMA. Rockbox’s implementation does not seem to work reliably on the fourth-generation iPod.

I’ve compared three devices:

A) iPod 4G running 3.14 (with DMA enabled) and stock HD

B & C) each an iPod 4G running latest dev version, using flash storage (compact flash card), patched so that DMA is disabled


Between the devices I’ve probably gone through the shutdown and restart cycle hundreds of times, had them play back songs, switched between songs, and created dynamic playlists by selecting something from the database somewhat randomly.

Once again, and as expected, device A, the one with the built-in hard drive and DMA enabled, eventually asked me to re-initialize the database and ended up with a corrupted FS after a few dozen restarts.

On the other hand, both B and C have run without even a single hiccup so far.

As I mentioned, I had previously run into FS corruption on each of these devices when DMA was enabled (both on 3.14 and the latest dev version).
Title: Re: DMA leads to FS corruption on iPod 4G?
Post by: chris_s on January 19, 2019, 05:31:20 PM
At this point I'm 99% sure that disabling DMA is the "solution". I've run into no issues since disabling it and using the heck out of my iPod. Battery life doesn't appear to be noticeably worse. Whatever decrease in battery life there may be (I might measure it one of these days) is arguably worth it to assure data integrity. As a nice (maybe not so surprising) side effect, it appears that Rockbox's USB mass storage functionality, which I'd avoided before in favor of the OF, also seems to finally have become reliable – although it may be too early to tell at this point.

I'm not sure why there would be issues with DMA (only?) on this device specifically – maybe there is someone reading this who is able to shed some light on that. But as I wrote in the other thread, my suggestion to any Rockbox developers reading this, would be to disable DMA on all iPod 4Gs for the time being. I.e. removing line 234 from the file firmware/export/config/ipod4g.h (https://github.com/Rockbox/rockbox/blob/c70e40f05024537074fc20585482c8d1f007081f/firmware/export/config/ipod4g.h#L234) The current implementation does not, in my experience, work reliably even on stock hardware. My bet would be that the only reason we haven't heard from more people about this is that there are
a) few people still using the target
b) even fewer using it extensively (like me and the OP from the other thread (http://forums.rockbox.org/index.php/topic,51112.msg235982.html))
c) they may be ascribing corruption issues to different causes or
d) can't be bothered to leave feedback about it.

Maybe I'm wrong, in which case, I'd be very interested in hearing from anyone who is using an unpatched version of Rockbox >= 3.13 on an iPod 4G target, who has not run into any issues after regularly using the device for many hours at a time (including  database functionality)

Even better of course, would be making DMA work reliably on this model, but I'm not sure that is a realistic outcome in the short term (or possibly even long term).