#136355 - Jesse - Tue Jul 31, 2007 9:09 pm
I've been struggling to make my drawing-app Colors! compatible with a bunch of different flash-cards. It seems as saving images to flash crashes or gets corrupted on some cards. Finally, I got hold of a G6 Real 1GB card today that seems to have this problem and manage to narrow down the problem.
Not surprisingly it seems like a fwrite() call in libpng locks up for some reason. While it works flawlessly on my M3 simply, it seems like the G6 can't handle the io calls or something. I would guess it is a DLDI problem, but I can't be sure. I also managed to crash through stress-testing with fwrites() using different size and memory alignments, but I didn't mange to narrow that down into a standalone version.
I need help in solving this. I have built a small stripped-down project where this occurs and hope someone has any idea. Also, if someone with SuperCard Lite and SuperCard 2GB could test if the test-app goes through I would be happy, since there seems to be a problem with them as well. The archive contains the source as a compiled version. I'm really getting frustrated with this, so if anyone has any ideas, let me know.
http://www.collectingsmiles.com/colors/pngtest.rar
#136364 - masscat - Tue Jul 31, 2007 10:07 pm
I cannot help with solving the problem but a possible work around could be avoiding the fwrite in libpng by buffering the libpng output in memory and then writing to the file with a single fwrite call. If the NDS libpng port is the same as the desktop you will be able to set the libpng write function with png_set_write_fn (see here for more info).
#136367 - Lazy1 - Tue Jul 31, 2007 11:09 pm
Your problem may be the same that my port of Wolfenstein has with certain flash carts.
If the cart's DLDI driver does not support unaligned reads/writes you could get corruption, try running the DLDI tester on the G6 and see what it says.
http://dldi.drunkencoders.com/index.php?title=Testing_instructions
#136371 - dy - Tue Jul 31, 2007 11:53 pm
i patched it with SuperCardLite dldi and this is what came up on the screen
writing test.png
8 bytes (at 0xb003c28) - ok
4 bytes (at 0xb003bcc) - ok
4 bytes (at 0x2034ce2) - ok
13 bytes (at 0xb003c0b) - ok
4 bytes (at 0xb003bcc) - ok
4 bytes (at 0xb003bdc) - ok
4 bytes (at 0x2034ce7) - ok
8192 bytes (at 0x2083558) - ok
without it patched though it shows an error thingy.....
so does all the ok mean its fixed? ill be cheking back in about 10hrs so if there is anything new i can test it immediately
#136385 - jetboy - Wed Aug 01, 2007 7:41 am
Tested on Super Card DS ONE
All png tester tests were ok on my 2MB card.
All png tester tests were ok on my 1MB card.
Tests with dldi_tester:
1MB card: Cant handle unaligned reads
2MB card: Cant handle unaligned reads
I presume if it cannot handle unaligned reads, it cannot handle unaligned writes too.
_________________
Colors! gallery -> http://colors.collectingsmiles.com
Any questions? Try http://colors.collectingsmiles.com/faq.php first, or official forums http://forum.brombra.net
#136392 - Jesse - Wed Aug 01, 2007 10:28 am
Lazy1 wrote: |
If the cart's DLDI driver does not support unaligned reads/writes you could get corruption, try running the DLDI tester on the G6 and see what it says. |
Thanks for the tip. I tried doing that, and the testprogram crashes when it gets to Unanligned write...
Ok. That means there's not much I can do about this and it seems like both G6 and SuperCard DLDI drivers needs to be updated.
Thanks all!
#136393 - Jesse - Wed Aug 01, 2007 10:33 am
masscat wrote: |
I cannot help with solving the problem but a possible work around could be avoiding the fwrite in libpng by buffering the libpng output in memory and then writing to the file with a single fwrite call. |
Yes, now that I know that unaligned writes are the problem I could probably do that. I don't have the 512kb of memory required to do a full buffer, but with some fancy coding I could stream it through a 16k buffer or something.
#136398 - kusma - Wed Aug 01, 2007 11:11 am
Jesse wrote: |
Yes, now that I know that unaligned writes are the problem I could probably do that. |
Wouldn't it be better to fix the DLDIs?
#136406 - tepples - Wed Aug 01, 2007 12:53 pm
How would one go about fixing the DLDIs if the source code is not available?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#136409 - kusma - Wed Aug 01, 2007 1:16 pm
tepples wrote: |
How would one go about fixing the DLDIs if the source code is not available? |
Good point. However, I do believe that reverse-engineering the binary-only DLDIs and patching them would be more future proof.
#136410 - Jesse - Wed Aug 01, 2007 1:27 pm
kusma wrote: |
Jesse wrote: | Yes, now that I know that unaligned writes are the problem I could probably do that. |
Wouldn't it be better to fix the DLDIs? |
Yes, of course. But I wouldn't know how and I'm starting to receive hate-mail. ;)
#136414 - Lazy1 - Wed Aug 01, 2007 2:24 pm
People send hate mail because something that is free doesn't work properly on their crappy hardware?
I wouldn't hack a workaround either, all that does is let companies get away with writing buggy drivers rather than force the issue.
#136419 - Jesse - Wed Aug 01, 2007 3:39 pm
Lazy1 wrote: |
People send hate mail because something that is free doesn't work properly on their crappy hardware? |
Nah. That was just a joke. People are very nice and helpful, just like here.