==| Browse full site |==
Home | News | NDS | NGC | Wii | PS3 | Wiki | Wordpress | Disclaimer | About


NEWS: As some of you may have noticed, I've updated the wiki to version 1.11.0. Hope you all like it! If there are any problems please report them here. ~~Scorpei 6-NOV-2007

R4 compatibility list/SD card corruption

From Scorpei.com - Wiki

Jump to: navigation, search

Contents

[edit] What this is all about?

Back in a day I found that some of ".nds" files aren't working anymore. I checked (by using md5/diff/xxd) that they were modified. Long investigation prove that there are games which trashes files on SD card.

I'm looking for someone who is skilled enough to debug this problem. Contact page at R4DS page is not available at this moment. If You know any way to find persons who develops R4DS, please inform them about this page.

I tried to describe problem as accurate as I can. Lots of effort was taken to make this page. If You want to say something like: reformat card, reinstall windows, check for viruses, clean SD/R4DS connectors, then please don't say anything.

Things I don't know at this point:

  • is it R4DS firmware (internal/external) or hardware bug,
  • is it caused on purpose.

For now I identified some ".nds" images which causes problem.

[edit] Am I affected?

Here is test which You can try. Some commands such as "mkfs.vfat", "md5sum" are part of any Linux distribution. Just use LiveCD.

I'm not responsible for anything You do related to information taken from this page or any other page. Always think about commands You issue.

[edit] Hardware

R4DS - I'm using this one. It looks like real product.

MicroSD card - I have two Kingstons 1GB and 2GB, both "Japan". I can trigger this problem on both of them.

MicroSD reader - I'm using two readers. Problem is not related to device used.

[edit] Software

Firmware - one of listed there.

"testfile.xx" - dummy file filled with "ff41" pattern (md5: b62968862b63bd661702b14007aeeb46, size: 67108864). Grab it there.

"empty.SAV" - dummy file filled with "ff" pattern (md5: 38eb11b49b828dc070270680a8a37845, size: 524288). This is to make sure that creating save by R4DS is not an issue. Grab it there.

"game.nds" - One ".nds" file from my list. I don't know where You could obtain them. Do not ask for it.

[edit] Test Part 1

Place card in reader and prepare (format) it:

"mkfs.vfat -I -F 16 -s 128 /dev/sdg" - no partition table, fat16, cluster size 64KB. Setting cluster size 32KB or 16KB does not change anything.

Extract "_ds_menu.dat" and "_ds_mshl.nds" from "English-1.18.rar" to card.

Boot R4DS. It will create addtional file called "_ds_menu.sys". Turn off NDS. Place card in reader.

[edit] Test Part 2

Fill almost whole space of MicroSD card by using "testfile.xx" file. Name them "testfile.01", "testfile.02", "testfile.03". Leave about 100MB for our trigger game.

Now copy "game.nds" and "empty.SAV" to card. Rename "empty.SAV" to "game.SAV".

Boot R4DS. Launch game. Skip intro to get game main menu.

Turn off NDS. Place card in reader.

[edit] Test Part 3

Check md5 of our dummy files:

"md5sum testfile.*"

All of them should have proper md5 (b62968862b63bd661702b14007aeeb46). Problem is that one is modified (different md5).

If you delete that file and replace with clear one from "testfile.xx" it will be corrupted next time You run game. Corruption will be exactly the same (md5sum match of broken files).

Corrupted block size is always same size for particular ".nds" file.

[edit] Firmware

Firmwares tested so far. Same results for all of them.

  • English-1.18.rar (md5: 41c21de87dcf3b1bff741c86d43d4629, size: 4836553). Get if from there, there, there.
  • English-1.11.rar (md5: 6fa09da4a848e00b1b0670ca8894c1f6, size: 7657222). Get if from there, there.
  • CD bundled with R4DS. It's the same version (diff/md5) to English-1.11.rar.

[edit] Partition table

Having partition table on SD card changes anything? Let's find out.

[edit] Simple layout

Disk /dev/sdb: 1030 MB, 1030225920 bytes
32 heads, 62 sectors/track, 1014 cylinders
Units = cylinders of 1984 * 512 = 1015808 bytes
Disk identifier: 0xe7b76032

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              16        1014      991008    e  W95 FAT16 (LBA)

There is about 16MB skip at beginning of SD card.

Corruption is exactly the same (file, start, end) to one without partition table.

[edit] Two partitions

Disk /dev/sdb: 1030 MB, 1030225920 bytes
32 heads, 62 sectors/track, 1014 cylinders
Units = cylinders of 1984 * 512 = 1015808 bytes
Disk identifier: 0x8d6118ab

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1             512        1014      498976    e  W95 FAT16 (LBA)
/dev/sdb2               1         511      506881    e  W95 FAT16 (LBA)

Partition table entries are not in disk order

This one is tricky. Data for first partition starts in middle of SD card and uses space till end. Second partition uses rest space (from start to middle). All R4DS files are located on first partition. Second one is filled with semi random files (archives made by rar, 7z, etc.).

Corruption is exactly the same (file, start, end) to one without partition table.

So our enemy knows about partition table and file system.

[edit] Filesystem

Support for fat16/32 is a total mess in R4DS. It's a disaster.

[edit] No themes

I wasn't very interested in skins/themes for R4DS. Just another "cool" addon for kids. It changed when I found princess peach sister theme, she was hot... nvm. Problem is that themes don't work for me. Tried them once, second, double checked directory tree, nothing.

Guess what. R4DS have odd directory entry support for FAT. In my scenario:

  • no partition table
  • fat16
  • mounted with "-t vfat"

Linux will always create LFN and 8.3 directory entries for every file. Even if filename fits in 8.3 scheme. So started again, now with "-t msdos" and themes works this time.

R4DS confuses about LFN in fat16 or LFN for file which fits 8.3 name space or ... I don't know.

Main problem persists. Corruption still occurs even in LFN-clean filesystem.

[edit] fat32

According to official feature list, R4DS should boot from fat32 filesystem. Not in my case. I always get "couldn't find _ds_menu.dat". No matter if there is partition table (tested types "b"-W95 FAT32 and "c"-W95 FAT32 (LBA)) or not. In my scenario:

  • no partition table
  • fat32
  • mounted with "-t vfat"

Linux won't create LFN for files which fits into 8.3. How to enforce LFN? Google says that I'm not alone with this problem, and solution is always the same, use fat16.

[edit] filedata order

Files were placed to clean (formated) card in that order:

: copy files
testfile.01
testfile.02
testfile.03
_ds_menu.dat
_ds_mshl.nds
: boot now
_ds_menu.sys
: copy rest
testfile.a
testfile.b
testfile.c
0111 - Advance Wars - Dual Strike (EU).nds
0111 - Advance Wars - Dual Strike (EU).SAV
: boot to trigger

Directory entries are set almost in same way. Just "testfile.01" and "testfile.02" are swapped. Same for "testfile.a" and "testfile.b". This swap is to check what is more important, data on card or directory listing order.

Corruption was made to "testfile.a". This is first file after "_ds_menu.sys". I mean data trashed belongs to file which is placed just after "_ds_menu.sys".

Ok, we know how targeting works.

[edit] ARM7 fix

"0111 - Advance Wars - Dual Strike (EU)" is affected. "0088 - Advance Wars - Dual Strike (US)" and "0070 - Famicom Wars DS (JP)" are working fine. It might be interesting to check if transplanting ARM7 executable changes anything. TODO

First things first. Here is dump of ARM7/9 from our games.

# rom title ARM7 md5 ARM9 md5
0111 Advance Wars - Dual Strike (EU) 464d006501ec277f93d410d8b4bed3d2 f07eabbdc6090aec648de90a01ec8955
0136 Super Princess Peach (JP) 26b60fd149f750e72c443e844059ae82 f67b1132b1a74342bddc04309e2dd79e
0340 Super Princess Peach (US) 3a92999835ea6c8fe984d0507ed057ec 1c297022635a207770cc61f46fed7414
0401 Densetsu no Stafi 4 (JP) 5e32e1ef746b228316e342641b8b06c3 b75e5c896301d6ece5291ef39ce44c71
0444 Super Princess Peach (EU) 3a92999835ea6c8fe984d0507ed057ec 4d17b85262e5969373ad99bb30927a4b

We have match! I would like to find any other affected NDS files. Searching for these ARMs might be good start. Some batch processing will point to suspicious files. Now I need to download about 37GB of data to check. WIP

[edit] Final word

There is no source code of R4DS software so I cannot check for anything.

I cannot find part of DLDI signature (68 69 73 68 6D 00) in these ROMs, so patching/modifying image by R4DS might be not an issue.

There is also cool feature called R4DS I/O Interface which allows any application to access SD card. According to this page, interface is common for R4DS/M3Simply. These two devices are very popular. Conspiracy theory is that some "releases" of ".nds" files are "poisoned" on purpose to utilize I/O Interface. Is there any way to disable this feature in R4DS?

Thanks to great support from gbadev forum I found tools like "ndstool" and "arm-eabi-objdump". Looking into assembly code will be a lot easier now.

[edit] Game list

I have tested 63 ROMs so far and found 5 games which causes problems. Four of them are developed by TOSE. Now I see pattern there ;)

# rom title crc32 md5 rom size modified block size
0111 Advance Wars - Dual Strike (EU) C42D8E67 e6105bc672701a516b730c31754f7859 33554432 27000 = 6a000 - 43000
0136 Super Princess Peach (JP) EEDB5A12 fef6141a59391d95fe5f91dfacb2a34c 33554432 cc00 = 2f6c00 - 2ea000
0340 Super Princess Peach (US) BA66A82E 3c1a8bd8ea761fc505eacabfff19ffa0 33554432 cc00 = 2e5c00 - 2d9000
0401 Densetsu no Stafi 4 (JP) 45FE3A37 668ac6e34e5c149fa15ad68e1a33ebb5 67108864 28800 = 452000 - 429800
0444 Super Princess Peach (EU) 4AECE112 771a8e925cef17ddbce3a3f7a246d141 33554432 cc00 = 470e00 - 464200
Personal tools