Homebrew WIP nxdumptool - Nintendo Switch Dump Tool

DarkMatterCore

Finding my light.
OP
Developer
Joined
May 30, 2009
Messages
1,292
Trophies
1
Age
28
Location
Madrid, Spain
Website
github.com
XP
2,606
Country
Spain
First of all, let me start by explaining myself. I'm gonna quote a comment I made on this issue in the GitHub repository:

DarkMatterCore said:
It is assumed this padding does exist.

Every cartridge has two different IStorage instances that can be accessed: one with partition ID #0 (which contains the gamecard header, the gamecard certificate, the root HFS0 header, the "update" partition, the "normal" partition and the "logo" partition [this last one only on type 0x02 gamecards]), and one with partition ID #1 (which contains the "secure" partition, along with what I think is incomplete 0xFF padding).

The buffers pointed by both IStorage instances contain data that is decrypted by the gamecard controller (so yeah, it's not a 1:1 dump) and the sum of the sizes from both instances never matches the total gamecard size from the gamecard header (which is expressed in GiB).

This is further supported by the fact that the Valid Data End Address from the gamecard header (at offset 0x118) point to an offset that *never* matches the sum of the sizes from both instances; it's actually lower. At that very same offset, the padding included by BBB in their XCI dumps starts, but never goes up to a point where it matches the full gamecard size.

So why does the secure partition include any padding at all if isn't needed? I don't know yet, but the Switchbrew page for the gamecard format includes the following statement:

"The entire rest of the Gamecard after the secure partition ends is all FF padding."

So yeah, that's why games are padded up to their full cartridge storage size. As I said before, this is gonna be a configurable option in the next release (which I'm already testing).
__________________________________________________

I dumped my copy of Minecraft (0100D71004694000) this morning, my CRC32 ended up being 753F2AD5 vs 262EC0D2 for the BBB release. Also, on my dump the XCI file size is 2,048.00 MB and the cartridge size is 1,904.00 MB while both the XCI file size and cartridge size is 1,904.00 MB on the BBB release.

Z8ENAsQ.jpg

gd1fcyj.jpg

EuDuoEl.png

Read my previous posts:
Thanks for your help, really! If it isnt't too much to ask, make sure to take a screenshot while you're creating the XCI dump (without cert). You'll need the XCI dump size from that screenshot to perform the CRC32 calculation because BBB dumps are not 0xFF padded.

What I really meant is that the 0xFF padding they have doesn't take up the whole cartridge size (e.g. 7.44 GiB vs 8 GiB for Super Mario Odyssey).

It's expressed in GiB. There's a byte in the gamecard header that indicates the storage size. The dump size is incomplete because the application only dumps the range covered by the two IStorage interfaces available for every gamecard, which are concatenated in the dump process (but their combined size never takes up all that space).

Historically speaking, this is a pretty common thing with ROM images.

You're right. Just make sure you calculate the CRC32 hash over the XCI dump size displayed on that screen and not over the whole file. Worked fine for me using Super Mario Odyssey.

I'll just probably make the additional padding a configurable option.

You can use HxD in Windows to open the XCI dump, select a block from offset 0 with a length = XCI data size from the dump screen, leave the block highlighted and calculate a CRC32 hash over it. It should match the CRC32 hash from the BBB dump.

__________________________________________________

You are padding waaay too much. 301 989 888 bytes on a 4GB image to be exact.

This is what i found out:

https://i.imgur.com/b3enlxu.png
https://i.imgur.com/Kpx7E0f.png

https://i.imgur.com/tnBs4LQ.png

After removing the extra 288MB of padding from my Kirby cart it CRC 100% with Kirby.Star.Allies.NSW-BigBlueBox.

Maybe this will help with Card2 support?
https://github.com/StudentBlake/XCI-Explorer/commit/1b09d6b978ba20458f91455dea5b5796f1b00b26

Read the start of this post. The extra padding is added for a reason. But I'm gonna make this a configurable option, nonetheless.

And nope, that won't help with supporting type 0x02 gamecards (it's a PC program).
__________________________________________________

Cut and then un-cut your file with XCI-Cutter to get a file that (hopefully) matches the Scene release, if Card2 is working! Double check that your cert is not included, as well.

Nope, it's not gonna work like that. The second IStorage instance for any gamecard (using partition ID #1) already includes some unused padding that's not referred to anywhere in the game card dump (which is the padding included in BBB dumps). That's why the XCI data size from the XCI dump screen is needed.
__________________________________________________

So users have to set the pad values?

Nope.
 
Last edited by DarkMatterCore,

Drejj

Well-Known Member
Newcomer
Joined
Dec 31, 2006
Messages
55
Trophies
1
XP
501
Country
Thanks for the answers. Looks like you took your time to learn how gamecards and their partitions really work. Someone should donate a Mario Tennis card2 to you and i'm sure we have card2 support in the future :)
 
Last edited by Drejj,

cubex

Member
Newcomer
Joined
Jun 23, 2007
Messages
17
Trophies
0
XP
207
Country
Canada
You can use HxD in Windows to open the XCI dump, select a block from offset 0 with a length = XCI data size from the dump screen, leave the block highlighted and calculate a CRC32 hash over it. It should match the CRC32 hash from the BBB dump.

Sorry, that's my bad, I didn't read the instructions fully beforehand. I did now and the CRC32 on that data ended up being the exact same as the BBB release, 262EC0D2.
 

DarkMatterCore

Finding my light.
OP
Developer
Joined
May 30, 2009
Messages
1,292
Trophies
1
Age
28
Location
Madrid, Spain
Website
github.com
XP
2,606
Country
Spain
Just updated gcdumptool to v1.0.3! Go check it out in the first post. Also, check the following screenshots, I'm sure you'll like them:

jUUIysn.jpg



cAZMXgO.jpg



983UJFx.png

Thanks for the answers. Looks like you took your time to learn how gamecards and their partitions really work. Someone should donate a Mario Tennis card2 to you and i'm sure we have card2 support in the future :)

I'm confident that, with enough support and testing, we can achieve type 0x02 gamecard compatibility without doing that. hahaha

Sorry, that's my bad, I didn't read the instructions fully beforehand. I did now and the CRC32 on that data ended up being the exact same as the BBB release, 262EC0D2.

No problem. I'm actually glad it turned out to be fine in the end! Was it a type 0x02 gamecard?
 
Last edited by DarkMatterCore,
  • Like
Reactions: Hking0036

Drejj

Well-Known Member
Newcomer
Joined
Dec 31, 2006
Messages
55
Trophies
1
XP
501
Country
Last edited by Drejj,

DarkMatterCore

Finding my light.
OP
Developer
Joined
May 30, 2009
Messages
1,292
Trophies
1
Age
28
Location
Madrid, Spain
Website
github.com
XP
2,606
Country
Spain
Last edited by DarkMatterCore,
  • Like
Reactions: comput3rus3r

DarkMatterCore

Finding my light.
OP
Developer
Joined
May 30, 2009
Messages
1,292
Trophies
1
Age
28
Location
Madrid, Spain
Website
github.com
XP
2,606
Country
Spain
Updating now, I'll test and let you know.

edit: Using the new options in 1.0.3 the CRC32 for the dump is 262EC0D2 :)

That's really freakin' nice to know. Have you tested the other features? (raw partition dumping, partition data dumping and partition filebrowser)

Manual game card certificate dumping is pretty much confirmed to work up to this point.

Every update since the original build breaks on 1.0 any clue why?

The application currently crashes when it's not being run under CFW (Hekate/Atmosphere, I suppose you're using PegaSwitch or a different entrypoint). It also uses some IPC calls that aren't available in 1.0.0, but that should work fine from 2.0.0 onwards.

I probably won't be able to fix compatibility with 1.0.0 (seriously bro, update to 3.0.0 at least), but missing compatibility with FW > 1.0.0 and < 4.0.0 is a known bug I'm looking into.
 

TheRedRacon79

Well-Known Member
Newcomer
Joined
Apr 11, 2018
Messages
52
Trophies
0
Age
33
XP
437
Country
United States
That's really freakin' nice to know. Have you tested the other features? (raw partition dumping, partition data dumping and partition filebrowser)

Manual game card certificate dumping is pretty much confirmed to work up to this point.



The application currently crashes when it's not being run under CFW (Hekate/Atmosphere, I suppose you're using PegaSwitch or a different entrypoint). It also uses some IPC calls that aren't available in 1.0.0, but that should work fine from 2.0.0 onwards.

I probably won't be able to fix compatibility with 1.0.0 (seriously bro, update to 3.0.0 at least), but missing compatibility with FW > 1.0.0 and < 4.0.0 is a known bug I'm looking into.
I'm using cfw always been and 1.0 still has coldboot explaine
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: https://youtube.com/shorts/ykuU8hnotr0?si=HzEN_fL2UyOn35HQ +1