Gateway 3DS microSD Tool

Discussion in '3DS - ROM Hacking, Translations and Utilities' started by _Tim_, Jul 24, 2014.

  1. _Tim_
    OP

    _Tim_ Advanced Member

    Newcomer
    63
    107
    Dec 23, 2013
    Belgium
    Run "gw3ds.exe scan x:" (where "x:" is the driveletter of your GW3DS microSD card) from a command prompt window to scan for problems. Run "gw3ds.exe fix x:" to fix fragmentation errors and missing game icons.

    You receive a fragmentation error when the rom file has more than 32 fragments.
    You receive a fragmentation error when the rom file occupies either of the last two clusters on an exFAT partition.
    You don't see all game icons if the root directory entry is fragmented.

    https://dl.dropboxusercontent.com/u/94421767/gw3ds_ver_12.zip
    https://dl.dropboxusercontent.com/u/94421767/gw3ds_ver_10.zip

    EDIT: Avast seems to think that my program is infected with malware. I can assure you that it contains no malware. I wrote and compiled the program myself. I reported the false positive to Avast so hopefully they will fix it in their next virus database update.
     


  2. migles

    migles Mei the sexiest bae

    Member
    GBAtemp Patron
    migles is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    6,806
    4,567
    Sep 19, 2013
    Saint Kitts and Nevis
    my dad works for nintendo.
    AVAST POPED UP VIRUS OMG OMG VIRUS!111!!!ONEONEONE!!!

    people, now seriously, make sure you be carefull..

    edit: also, dont use defragger tools on sd cards or any flash memory, it kills the card much faster...

    and windows and OSes already have their own degragger tools, and ther is the defragger from piriform, this tool is not needed...
     
  3. _Tim_
    OP

    _Tim_ Advanced Member

    Newcomer
    63
    107
    Dec 23, 2013
    Belgium
    I wrote this tool to fix GW3DS fragmentation errors. It defragments only if it is necessary. For example, if a rom file consists of 35 fragments, my program will reduce the number of fragments to 32 by combining the 4 smallest fragments into a single fragment. It is faster and introduces less wear than reformatting and copying everything back.
     
  4. migles

    migles Mei the sexiest bae

    Member
    GBAtemp Patron
    migles is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    6,806
    4,567
    Sep 19, 2013
    Saint Kitts and Nevis
    my dad works for nintendo.
    heres the screenshot.
    gw3ds screen.PNG
     
  5. zhdarkstar

    zhdarkstar GBAtemp Advanced Fan

    Member
    571
    225
    Jan 30, 2008
    United States
    While I have no immediate use for this tool, as all of the roms on my mSD are working properly, thinking about how it functions does bring up one possible concern. External fragmentation as a result of repeated usage of this tool over time. I'll admit that it's more of an outlier scenario affecting mostly smaller mSDs or those kept near capacity, it's one that your targeted defragging code could probably fix with only a little tweaking. Perhaps you could add a free space optimizer that triggers only when external fragmentation reaches a certain threshold, or at least a warning message advising the user to address the issue. That way it also helps to prevent newer files added to the mSD from suffering excessive data fragmentation, by making the free space look less like swiss cheese.

    Also, I'm curious as to why you decided to defrag only the smallest fragments, as opposed to the largest fragments. I understand from a wear and tear perspective, but couldn't the creation of all of those small holes in the memory allocation cause files added later to be excessively fragmented due to a large amount of small clusters of free space? Just a little food for thought.
     
  6. _Tim_
    OP

    _Tim_ Advanced Member

    Newcomer
    63
    107
    Dec 23, 2013
    Belgium
    Free space optimizer? I'd rather leave that to a real defragmentation program. I could calculate and show some statistics to know how fragmented the microSD card is. For instance, I could show the size of the largest contiguous block of free space, the total size of the 32 smallest/largest contiguous blocks of free space, ... If you run "gw3ds.exe scan x:" you can already see the number of fragments for each 3DS file.

    I wanted to fix those fragmentation errors without having to wait longer than necessary.
     
  7. Oxybelis

    Oxybelis GBAtemp Fan

    Member
    348
    74
    Jan 10, 2010
    There are could be a lot of cases. But the case where a lot of ROMs scattered with >32 fragments is already an extreme case which should not happen frequently. I think program logic is fine.
     
    Subtle Demise likes this.
  8. Bug_Checker_

    Bug_Checker_ GBAtemp Advanced Fan

    Member
    950
    444
    Jun 10, 2006
    United States

    Is this problem seen with other exfat implementations or only Gateway's?

    btw 0/53 on virustotal
    https://virustotal.com/en/file/c857b056c3b85a92fe327bd746250bf48e486d53f32ab9cba71b7ce3335f14d4/analysis/
    https://virustotal.com/en/file/5416ed0097c28f217afd6d39131b5ceab2584ff77eda6bfcbd6da359a7e56e0e/analysis/
     
  9. _Tim_
    OP

    _Tim_ Advanced Member

    Newcomer
    63
    107
    Dec 23, 2013
    Belgium
    It is a GW3DS bug. The exFAT partition info contains the cluster count, unlike FAT16/32 partitions. The first data cluster starts at number 2. Number 0 and 1 are reserved. If the number of clusters is "n" then the number of the last cluster is "n+2". There is probably a check somewhere in the GW3DS code to see if a cluster number is valid where they compare the cluster number against the cluster count, without adding/subtracting 2. My program "releases" those two last clusters if they are in use by a file and then creates a small file named "_GW3DS_DO_NOT_DELETE.BIN" in the root directory which will occupy the last two clusters, to prevent the fragmentation error from reoccurring.
     
  10. mijuu

    mijuu GBAtemp Fan

    Member
    372
    19
    Jan 9, 2010
    This tool works great, no more fragmentation errors in GW. Both me and a friend of mine had this bug so its not that uncommon.
     
  11. Dark Fulgore

    Dark Fulgore GBAtemp Regular

    Member
    147
    37
    Apr 30, 2010
    Brazil
    Belo Horizonte - MG
    Thank you, man! My MicroSD gives me the fragmentation error very often. I created a .bat for this and it's helping me a LOT. Thanks!
     
  12. glass

    glass Member

    Newcomer
    48
    47
    Oct 14, 2013
    Release source code please?
     
  13. _Tim_
    OP

    _Tim_ Advanced Member

    Newcomer
    63
    107
    Dec 23, 2013
    Belgium
    Why? If you're thinking about porting it to Linux, don't bother, there appears to be no defragmentation library for Linux.
     
  14. json

    json MUSCLEMAN

    Member
    693
    781
    Aug 9, 2013
    Burkina Faso
    Have you tried to email Gateway team? I'm sure they can fix it in the next launcher release
     
  15. DragonSky

    DragonSky GBAtemp Advanced Fan

    Member
    745
    71
    Oct 27, 2010
    Belgium
    Gateways email is taken down. Only resellers can.
     
  16. Kazuma77

    Kazuma77 GBAtemp Advanced Fan

    Member
    859
    360
    May 11, 2008
    United States
    What can I say? Nice app. I usually don't get errors, being a Total Commander user, but this is nice for checking the card. Certainly beats having to format and re-copy if something does go wrong. And I like the way the output is displayed. Thanks.
     
    Sirius64 likes this.
  17. tony_2018

    tony_2018 GBAtemp Psycho!

    Member
    3,106
    1,050
    Jan 3, 2014
    United States

    Gotta say.......Homeboys nipples are hard as fuck. LOL
     
    Herobroski likes this.
  18. Captain_N

    Captain_N GBAtemp Advanced Fan

    Member
    761
    248
    Mar 29, 2010
    United States
    There is no virus/trojan/malware in his file. i scanned it with 4 corporate antiviruses.
    Yeah i only use corporate versions of antiviruses and i tested it in a virtual machine.
     
    Margen67 and Sirius64 like this.
  19. tyons

    tyons GBAtemp Advanced Fan

    Member
    642
    97
    Jul 11, 2012
    Italy
    I have a micro sd formatted in exFat that my gateway can't read (the diagnostic test always fails). it happened when it was formatted in FAT32, too.
    I tried this tool but it says

    Drive F

    Error: The drive type is not supported. (1)

    ### ERROR CODE 15 ###

    I inserted the card in its oiriginal SD adapter and plugged that in the pc.
    I use windows 8.1, if it can matter.
    I run the tool with the command prompt opened as an admin and it's the same.

    I'll try to format the microSD to FAT32 now.

    edit: the same error is given with FAT32.


    EDIT 2: I FEEL SO STUPID. I had to write "F:" not "F".

    aaand the gateway still can't read the microSD. I guess it's definitely malfunctional... (I had it repaired because I couldn't update it, but probably that ruined the microSD reading stuff).

    edit 3: lol the test fails but sometimes in emunand it manages to show the games. when I open one it says "fragmentation error" (even though I used this tool). sometimes the icons show up white and sometimes corrupted >_>

    edit 4: oh wow, when I keep the top of the gateway card pressed against the 3ds, it works perfectly. I guess I need to glue it properly.
     
  20. WildArms

    WildArms GBAtemp Regular

    Member
    168
    5
    Mar 13, 2010
    Venezuela
    Works like charm, thanks for this tool man