gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > How the official roms read and write on the cartridge?

#144203 - Yota_VGA - Tue Oct 30, 2007 3:37 am

Hi, I'm new in this community.

I understand that actually is almost impossible to use the commands
that are used for read and write the official cartridges in an homebrew, but I
don't understand why.

If you have a slot-1 card, for example the R4, you can (obiously if legal) use
almost all the roms fetched from the official cartridges, but if you run
a homebrew that use the "standard commands" with this card it seem that does not work. So I suppose that the problem is the crypt system of the DS.
I've read some technical information on this crypt system, but I don't
full understand how all the things work.

How can an official game read the cartridge?
Which are the differences between a rom fetched from an official
cartridge and an homebrew, expecially with regard to reading and writing on rom?

#144208 - tepples - Tue Oct 30, 2007 4:26 am

Commercial games use the Nitro SDK to read files from the Game Card. How does knowing how to read commercial Game Cards help you to develop original homebrew games?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#144210 - Yota_VGA - Tue Oct 30, 2007 4:41 am

I know that commercial games use the Nitro SDK, but how the Nitro SDK manage the cartridge? :)

However, this is mainly a my curiosity, but the DMA reading and some other things are useful sometimes, I think.
I know that many cartridges have some commands very similar to the corrispective commands used from the official cartridges, but these aren't portable :)

#144211 - tepples - Tue Oct 30, 2007 4:56 am

Yota_VGA wrote:
I know that commercial games use the Nitro SDK, but how the Nitro SDK manage the cartridge? :)

In a different way from how homebrew programs manage the cartridge. This is documented in GBATEK by Martin Korth.

Quote:
I know that many cartridges have some commands very similar to the corrispective commands used from the official cartridges, but these aren't portable :)

That's why libfat has DLDI. It abstracts over the ways that different flash devices implement "read sector" and "write sector", so all you have to worry about are fopen(), fread(), and fclose().
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#144234 - Yota_VGA - Tue Oct 30, 2007 4:09 pm

Yes, I've read GBATEK, but I don't understand how the crypt work.
I think that the cartridge is readed whitout encryption by the official cartridges, but why the cartridges can read the card whitout encription and the homebrew can't?

tepples wrote:
That's why libfat has DLDI. It abstracts over the ways that different flash devices implement "read sector" and "write sector", so all you have to worry about are fopen(), fread(), and fclose().


Yes, but you can't use some things, for example the DMA channel.
libfat and DLDI are surely a great alternative, and I think that this is better than NitroSDK for many purposes, but in some circumstances I think that isn't it.

#144249 - tepples - Tue Oct 30, 2007 9:03 pm

Yota_VGA wrote:
Yes, I've read GBATEK, but I don't understand how the crypt work.
I think that the cartridge is readed whitout encryption by the official cartridges, but why the cartridges can read the card whitout encription and the homebrew can't?

There are two layers of encryption: cart protocol encryption and the encryption of the secure area. The cart protocol encryption, once it is turned on, is handled transparently by the DS hardware. The "secure area" of a DS card, which contains some of the executable code, is actually encrypted on the ROM chip and decrypted by the BIOS before the firmware gets control.

(Brought to you by AGF.)
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#144253 - Yota_VGA - Tue Oct 30, 2007 10:38 pm

Mh, so a homebrew can't turn on the cartridge encryption and so it don't read a cartridge?
If all work in this manner I understand all.

Thanks for the precious help :)

#144256 - Lick - Tue Oct 30, 2007 10:42 pm

Homebrew software CAN initialize the card, but it requires the card to be re-inserted, and you need to know how the procedure works.

Because that procedure is rather complicated (and requires re-insertion), homebrew device manufacturers simply opted to supply us with libfat-compatible procedures, so we can just use libfat.
_________________
http://licklick.wordpress.com

#144258 - Yota_VGA - Tue Oct 30, 2007 10:46 pm

Oh, ok :D

Thanks so much, all clear now :)