FS#10775 - IPod NANO 2G NAND issues

Attached to Project: Rockbox
Opened by Franz-Josef Haider (liar) - Wednesday, 11 November 2009, 22:55 GMT
Last edited by Michael Sparmann (TheSeven) - Monday, 08 February 2010, 18:37 GMT
Task Type Patches
Category Operating System/Drivers
Status Closed
Assigned To Michael Sparmann (TheSeven)
Operating System iPod Nano 2G
Severity Medium
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


Some IPod Nano 2G's(with a specific flash type) seem to need a delay after clearing the NAND write FIFO. Without that delay i cant view files, play files or start apps/games/demos, FTL errors occur frequently when writing => i had to restore my ipod nearly every day)

I dont know why they need this delay and a loop that counts from 0 to 3500 is propably not the best solution(a sleep would be too slow) but its working properly with this flash type.
This task depends upon

Closed by  Michael Sparmann (TheSeven)
Monday, 08 February 2010, 18:37 GMT
Reason for closing:  Fixed
Additional comments about closing:  Looks like we finally fixed it.
Comment by Franz-Josef Haider (liar) - Thursday, 12 November 2009, 20:07 GMT
this should be a more proper fix now
the problem was, we didnt wait for the write fifo as described in the datasheet
Comment by Franz-Josef Haider (liar) - Thursday, 12 November 2009, 21:42 GMT
wait for the r fifo too, add a timeout
Comment by Franz-Josef Haider (liar) - Thursday, 12 November 2009, 23:00 GMT
the previous ones locked up sometimes, hopefully this one doesnt. if rockbox still locks up with this patch the problem might have a different root than not waiting for the fifos...
Comment by Franz-Josef Haider (liar) - Tuesday, 17 November 2009, 16:27 GMT
this one should be fully working, i have tested it thoroughly and its working fine - the fifo waiting has to be done before flushing it, thats why the previous ones failed sometimes
Comment by Laurent Papier (papier) - Monday, 14 December 2009, 20:48 GMT
I have tried your patch with r23991. It failed on boot after display rockbox logo.

FTL: Lowlevel NAND driver init failed!

Switching back to r23991 and the nano boot without error.

Comment by Franz-Josef Haider (liar) - Tuesday, 15 December 2009, 20:53 GMT
its failing with some ipods but with others not... (i have tried it with 3 different nanos)
on mine it dont get read/write problems anymore but still its failing sometimes.. i am still looking for a better(the right) solution
Comment by jean dupont (cetheph) - Wednesday, 16 December 2009, 21:02 GMT
Great for the nano patch 3, it has solved many problems on my ipod nano 2gen.
The last one make the error wich is described by laurent papier.

So, the third works fine with my ipod. Thanks a lot.
Comment by Franz-Josef Haider (liar) - Saturday, 19 December 2009, 20:41 GMT
i have updated my patch
would be great if you could test it and report how it works
Comment by jean dupont (cetheph) - Sunday, 20 December 2009, 19:23 GMT
I'm sorry but i obtain the following error with the console when i try to apply the patch :
patch : **** malformed patch at line 110: @@ -287,18 +314,21 @@

You can notice i'm working with the version 24085 (downloaded right now).

After a few day trying the 2nd version (in fact, it was the 2nd and not the third, but we can't edit, the third obtain the same error with "Lowlevel NAND Driver init failed"), i often get crash, when the firmware works on files (for instance, when i launch a music, the firmware crashes sometimes, and sometimes it doesn't).

I had a question too, (i'm a "newbie" in applying patch in svn files) : how can i apply a patch over an old one, in order to recompile without compile again from start (and redownloading sources)?
Thanks for the patches, i wish this error will be soon corrected :).
I try your patch as soon as it's available.
Comment by jean dupont (cetheph) - Sunday, 20 December 2009, 20:21 GMT
I've tried the patch by editing manually the source code, and put in the original files the corrections of the patch.
I get the initial error, i.e, i can't go in the directories, launch app...

Maybe it's because what i ve done to apply the patch is a little hazardous (i'm not sure to have done the correct manipulations, as i have edited the files without applying the patch with the console), but maybe not.
Comment by Franz-Josef Haider (liar) - Sunday, 20 December 2009, 20:48 GMT
hm seems like there was something wrong with the patch, this one should work, sorry
Comment by Franz-Josef Haider (liar) - Sunday, 20 December 2009, 21:25 GMT
i forgot to delete some undervolting stuff from the previous patch, again sorry...
Comment by jean dupont (cetheph) - Monday, 21 December 2009, 11:11 GMT
I've tried right now, and it works fine.
I've noticed that the version need a little bit more time to boot.

So, thank you really much, i will post if I notice anything which works bad.
Comment by Bernhard Fröhlich (decke) - Monday, 21 December 2009, 15:39 GMT
I couldn't properly navigate anymore with recent builds (about 3 weeks) but r23850 with that patch solves that problems for me. Thanks again!
Comment by Franz-Josef Haider (liar) - Monday, 21 December 2009, 23:19 GMT
please also try this patch or binary, that can help me debugging
Comment by Stefan Egger (slashroot) - Tuesday, 22 December 2009, 23:38 GMT
Hey! Just wanted to say thanks liar! i just successfully compiled 24099 witch your patch and that solved it for me on my nano 2g (8gb)! So thanks again and merry X-mas!
Comment by Franz-Josef Haider (liar) - Thursday, 24 December 2009, 08:44 GMT
this one shows the nand id. please tell me what it is(only if you have nand problems without my patch)
Comment by Grant Bakker (Grant) - Thursday, 24 December 2009, 17:38 GMT
liar, the binary works great!
hope that it gets added to svn soon
Comment by Thomas Schneider (BlackLotus) - Saturday, 02 January 2010, 13:38 GMT
Thx the patch is working fine and it saved me and my friends day.
It is working correctly without any misbehaviour.
Comment by Michal Koziorowski (michallos) - Saturday, 02 January 2010, 23:42 GMT
I've got
nand_reset:nand_wait_rfifo_d ne

on boot. Build from svn today(r24148-100102), ipod nano 2gen 4gb, with last patch
Comment by Franz-Josef Haider (liar) - Monday, 04 January 2010, 00:15 GMT
this patch:
differences to my recent patch:
* revert the fifo waiting - it is not needed(just some bits need to be set at different places, see below)
* falling back to the TheSeven(Apple) way of waiting for the chips to be ready(i changed that because it failed once for me. but now i am sure it was because of a side effect - i could reproduce it) - the datasheet is inaccurate in this matter

differences to the current svn:
* do not reset the NAND in nand_get_chip_type - a select bank is enough as we already reset the NAND before(and resetting is slow on NANOs with the NAND issue)
* set the fifo flush bits like the datasheet does - this avoids data corruption.
* wait for the NAND to be ready => be sure the NAND is ready for new commands - this avoids data corruption during writing to the NAND. it also avoids data corruption and panics during poweroff

do you have any problems with the NAND Driver?
i thought only 8GB nanos are affected by this problem
this patch should work for you.
Comment by Joeli Hokkanen (jho) - Monday, 04 January 2010, 05:42 GMT
I have a 2GB Nano 2g. With vanilla Rockbox I had multiple issues:
· I could not browse any files on the system. Pressing select would only throw the "selector" to the topmost entry at the top level of the file structure
· The database initialization never finished. It hung when it got around to updating the last file present on the file system. The database debug info told that the process was at -1% by then.
· My computer (Linux 2.6.31-gentoo-r5) would not recognize the player when it was plugged in via USB. Dmesg told me "sdb: unknown partition table". Only thing that helped was to reboot back into the original firmware.
· After unplugging the USB cable I got a panic: "mount: 0". When I rebooted after that, I got a panic with FTL error about trying to read an out-of-bounds page.

Over at IRC, mc2739 kindly directed me to this bug. The latest patch paniced on boot with "nand_power_up:nand_reset:2".

This patch, however, fixed all the aforementioned issues:
Comment by Franz-Josef Haider (liar) - Monday, 04 January 2010, 10:48 GMT
please try this patch and tell me which panic it throws
Comment by Joeli Hokkanen (jho) - Monday, 04 January 2010, 11:04 GMT

Hope this helps. If there's anything else I can do, just give me a shout. :-)
Comment by Franz-Josef Haider (liar) - Monday, 04 January 2010, 11:40 GMT
that means the TheSeven way of waiting for the chips to be ready does not work for you(it did not panic in previous patches because TheSeven did not check the return value of nand_reset)

nand_wait_status_ready fails for you too - as we found out while talking in IRC - so the sleep is the best solution as there is no other bit which is toggeling we could wait for.
Comment by Franz-Josef Haider (liar) - Tuesday, 05 January 2010, 11:20 GMT
this is another thing you could try(i only do nand_wait_staus_ready once instead of 4 times)
if that works we can drop that annoying sleep again
Comment by Joeli Hokkanen (jho) - Tuesday, 05 January 2010, 15:09 GMT

That patch works fine. Thanks.
Comment by Franz-Josef Haider (liar) - Tuesday, 05 January 2010, 16:55 GMT
so.. that should be working for everybody now.
Comment by Joeli Hokkanen (jho) - Friday, 08 January 2010, 05:39 GMT
Sratch that—

Actually I only yesterday really used my player with the new patch and found out there still are big issues with it. I'm still getting FTL errors with it, while the patch with sleep actually works (tested throughly this time, I promise! ;))
Comment by Franz-Josef Haider (liar) - Friday, 08 January 2010, 23:48 GMT
hm. cant think of anything else we could do then except the sleep
Comment by Franz-Josef Haider (liar) - Friday, 15 January 2010, 01:57 GMT
.. another update. hopefully the last.
jho: your nano2g has only 2 banks right?
that was the problem. my patch was waiting for bank 0-3 but you only have 0 and 1.
the current svn calls nand_wait_chip_ready for all banks too but it doesnt panic because the return value of nand_reset isnt checked.
Comment by Joeli Hokkanen (jho) - Monday, 18 January 2010, 07:26 GMT
Hi, and sorry for the late reply. I managed to get my Nano into the "use iTunes to restore" state, and only today got access to a Windows box so I could restore it.

That patch seems to work alright, so I guess my Nano only has two banks.
Comment by Craig Elliott (MoSPDude) - Monday, 18 January 2010, 20:20 GMT
I've applied the patch to my 8GB 2nd.gen. Nano and get the PANIC nand_reset:nand_wait_chip_ready:0 message if I do some quick track skips, or other heavy file usage. In general running however, its fine. Occasionally, it has been PANIC nand_reset:nand_wait_chip_ready:2 - but much more often the code is 0. Is there anything I can do to help debug?
Comment by Alen (brother_fox) - Tuesday, 19 January 2010, 10:56 GMT
Does the last patch included in r24284???
Comment by Alen (brother_fox) - Tuesday, 19 January 2010, 10:59 GMT
I have installed r24284 on my nano 2g (8 Gb) - the problem is steel - cant open any app or file...
Comment by Franz-Josef Haider (liar) - Tuesday, 19 January 2010, 20:19 GMT
MoSPDude: remove the nand_wait_chip_ready call in nand_reset. nand_wait_status_ready should be enough
brother_fox: no it is no included in the current svn
Comment by Craig Elliott (MoSPDude) - Friday, 22 January 2010, 21:50 GMT
It's actually failing on the nand_wait_status_ready call. With the nand_wait_chip_ready call removed its a lot more unstable.

The panic message in the patch above shows the wrong call name for panic nand_wait_status_ready - it prints "nand_wait_chip_ready" for both lines in nand_reset.
Comment by Tim (timn) - Sunday, 24 January 2010, 13:50 GMT
@Craig: Same here. After deleting nand_wait_chip_ready, at least Rockbox booted properly without the panic message.

Sometimes, though, I've got a nand_wait_status_ready panic. I can remember this happening while playing a song and clicking on another one in the file browser.

The nand_wait_status_ready(bank) call seems to be necessary: I tried to leave it out once and then wasn't able to browse the file hierarchy anymore.

Just change the panicf(...) call to "return 1" and it won't crash anymore.

I've been using the above patch with these two minor changes for a few days and would consider it stable. Are there any reasons not to include in SVN yet?
Comment by Tim (timn) - Sunday, 24 January 2010, 14:06 GMT
I just got a "nand_power_up:nand_reset:3" panic. What does it mean? Can I safely delete this line?
Comment by Franz-Josef Haider (liar) - Sunday, 24 January 2010, 15:43 GMT
that means nand_reset failed for bank 3(you got that message because you replaced the panicf in nand_reset with return 1).
use this patch:
Comment by Franz-Josef Haider (liar) - Tuesday, 26 January 2010, 22:43 GMT
update: dont ask the bank for its chip type before we reset that one.
Comment by Franz-Josef Haider (liar) - Tuesday, 26 January 2010, 23:24 GMT
final(!?) patch.
please test this one and report any problems regarding it.
Comment by Joeli Hokkanen (jho) - Tuesday, 26 January 2010, 23:55 GMT
Seems to work fine for me.
Comment by anglada (anglada_p) - Thursday, 28 January 2010, 15:40 GMT
Please, can anyone send me the last release for nano 2g with this patch applied (or post a link to download it). I'd be very pleased. thanks in advance
Comment by anglada (anglada_p) - Thursday, 28 January 2010, 23:41 GMT
Liar. It does not work for me. In fact I had to restore my Ipod after installing the firm you sent to me. Thank you for your fast answer anyway.
My nand ID is: A585D598.
It's strange, because this afternoon in the IRC channel #rockbox a guy there (nick Strife89) has compiled me a version of last nano 2g source applying this patch (the one in your last post) and it worked for me.
If you want me to send to you the compiled release send me an email please. It's 3.0Mb and I can't post it here...
Comment by anglada (anglada_p) - Thursday, 28 January 2010, 23:44 GMT
sorry, the revision patched by Strife89 is 24364
Comment by Franz-Josef Haider (liar) - Friday, 29 January 2010, 06:22 GMT
uhh my mistake - i did something wrong the binary i sent to you, sorry...
thanks for your test results
Comment by ben (baliking) - Friday, 29 January 2010, 18:53 GMT
this patch didnt work for me , i got the error

btw i am new :D

Comment by Franz-Josef Haider (liar) - Saturday, 30 January 2010, 13:32 GMT
you are using an old version of the patch... please use the lastest one :)
Comment by ben (baliking) - Saturday, 30 January 2010, 16:27 GMT
cheers it worked on one of my nano's on the other nano i just get
nand_power_up :nand_reset (bank = 2) failed.

can you help me on this error as well cheers
Comment by Franz-Josef Haider (liar) - Saturday, 30 January 2010, 22:20 GMT
in firmware/target/arm/s5l8700/ipodnano2g/nand-nano2g.c
seek for the function: nand_power_up, replace that if(nand_reset(i)) panicf... with nand_reset(i);
this is what the current svn does... but the rest of the patch should still avoid the file system problems
Comment by ben (baliking) - Saturday, 30 January 2010, 23:12 GMT
thanks for the help
Comment by Michael Sparmann (TheSeven) - Sunday, 31 January 2010, 14:17 GMT
Patch committed as r24414. If there is any further trouble that could be related, please report it here.
Comment by Michael Sparmann (TheSeven) - Monday, 01 February 2010, 01:27 GMT
Another related bug was caught and fixed in r24431.