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 > SCSD DMA?

#80115 - linus - Tue Apr 18, 2006 10:07 pm

Does anyone know if SCSD has DMA and if it does do we know how to use it? Its not in chishms driver so I assume nobodies found it but do we know if its there? Any info is helpful cheers.

#80119 - tepples - Tue Apr 18, 2006 11:02 pm

The SD cards generally operate by bit-banging directly on the SPI lines.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#158626 - SoLo2 - Sun Jun 15, 2008 2:20 am

Hello!


I see in Chishm's "C" code that these lines
are addressed at 0x040001A0 and 0x040001B0.
The registers for SPI actually start at 4000180h.
These I know by the only references available:
GBATEK.

Then I see that the card requires some commands:
5 and up to 8 bytes are written to 0x040001A8:
40001A8h - NDS7/NDS9 - Gamecard bus 8-byte Command Out

Has anybody specifications of these
card commands? :)

Is this the same method for reading/writing
sectors to SuperCards for the GBA?

Maybe the GBA used DMA, it didn't seem
so difficult as for the NDS...


Greetings,
SoLo2
_________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Visit:
http://thebitsclub.tripod.com
http://biis.tripod.com

#158628 - tepples - Sun Jun 15, 2008 2:28 am

Are you talking about SuperCard SD (SLOT-2) or SuperCard DS One (SLOT-1)?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#158639 - elhobbs - Sun Jun 15, 2008 1:30 pm

doesn't the supercard site have some code downloads? I think I remember looking at that once - I may be think of another card though.

#158649 - SoLo2 - Sun Jun 15, 2008 7:28 pm

Hello!


The talk is about SC DS ONE, mainly.
But there must be some card read/write
code for the other cards, too.

Do you know the real site URL of
the Super Card creators?
I think they should have the drivers,
or the command codes.


Greetings,
SoLo2
_________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Visit:
http://thebitsclub.tripod.com
http://biis.tripod.com

#158705 - Mohammad - Mon Jun 16, 2008 6:13 pm

no SCSD stands for Supercard SD, which is slot-2

edit: supercard website supercard.cn

#158713 - SoLo2 - Mon Jun 16, 2008 7:53 pm

Hello!


Sorry, talk is about SC SD, slot-2.

Are there any specifications for this cartridge?
Does it use control commands over an SPI bus, too?

I remember it to be more easy, more DMA alike.


Greetings,
SoLo2
_________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Visit:
http://thebitsclub.tripod.com
http://biis.tripod.com

#158715 - Maxxie - Mon Jun 16, 2008 8:07 pm

The SC SD needs to generate a clock signal by "hand"

I don't think you can do this with profit with DMA. (you might be able to by preparing a special buffer that includes these clock generation on writes, but that would be more expensive then the actual write)

#158849 - SoLo2 - Thu Jun 19, 2008 12:25 pm

Hello!


I see in Moonshell code and also in gbatek.txt
that DMA3 of the NDS could be something like
linus asked. It looks like it is THE DMA channel
to read/write(?) from ROM cartridges...

Look at:
moonshell15_src/arm9/source/extmem.cpp
it has a _wish_, at least for EZ4, to be able
to use DMA3 for the purpose.

Confirmation?
:)


Greetings,
SoLo2
_________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Visit:
http://thebitsclub.tripod.com
http://biis.tripod.com

#158851 - SoLo2 - Thu Jun 19, 2008 12:38 pm

Hello!


As I read more of it, here is more of it...

An excerpt of source file
moonshell15_src/arm9/source/extmem.cpp
uses:


SetSC_UNLOCK(SSC_SDRAM);
MemCopy16DMA3(pSrcData,pDstData,DstSize);
SetSC_UNLOCK(SSC_CF);


Where SetSC_UNLOCK() is an ugly function
writing to the last word of the 32MB of the
cartridge ROM...

While MemCopy16DMA3() to be found in
moonshell15_src/arm9/source/memtool.cpp
says:


DMA3_SRC = (uint32)_src;
DMA3_DEST = (uint32)_dst;
DMA3_CR = DMA_ENABLE | DMA_SRC_INC | DMA_DST_INC | DMA_16_BIT | (prcdiv>>1);
while(DMA3_CR & DMA_BUSY);
[...]


And uses the DMA3 channel for the purpose
of writing to the cartridge FLASH, supposedly.

I haven't working further into it, as I had the
wish to use the known SPI command controled,
bus controled way of read/write, just to see
if it works, first.


Greetings,
SoLo2
_________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Visit:
http://thebitsclub.tripod.com
http://biis.tripod.com

#158852 - Maxxie - Thu Jun 19, 2008 12:52 pm

SoLo2 wrote:

Where SetSC_UNLOCK() is an ugly function
writing to the last word of the 32MB of the
cartridge ROM...


It's changing the control register which part of the hardware occupies the addressrange.

Quote:

And uses the DMA3 channel for the purpose
of writing to the cartridge FLASH, supposedly.


This is not what it does. it is writing to the previously mapped SDRAM (volatile memory) and then switches the hardware back to a mode where the SD-Card hardware can be accessed again.

SDRAM: volatile RAM, accessed by directly accessing GBA address space
SD-Card: non-volatile flash memory, accessed by a serial interface indirectly through some few registers within GBA address space.

#158864 - SoLo2 - Thu Jun 19, 2008 7:48 pm

Hello!



Another possibility is in the file
moonshell15_src/arm9/source/directdisk.cpp

This has the function:

static inline void Flashw8(u32 adr,u8 data)
{
GBACartRAM[0x5555]=0xaa; // to CMD1
GBACartRAM[0x2aaa]=0x55; // to CMD2
GBACartRAM[0x5555]=0xa0; // to PROGRAM
GBACartRAM[adr]=data;
}

Which supposedly writes to a Flash memory,
and using some commands. As if it were the SPI,
but it isn't.

CartWrite_AutoSelect() uses a call to Flashw8().
And CartFormat() uses CartWrite_AutoSelect().

But these could be functions for the GBA Flash
memory cart, instead of the NDS.



Greetings,
SoLo2
_________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Visit:
http://thebitsclub.tripod.com
http://biis.tripod.com

#158866 - SoLo2 - Thu Jun 19, 2008 8:02 pm

Hello!


Finally, there is a 4th method in this
fantastic moonshell source code.

It is by calling: active_interface->fn_ReadSectors()

which uses and interface and then the
functions fn_ReadSectors() or fn_WriteSectors()

And these lead to :

moonshell15_src/arm9/source/gba_nds_fat_2006-02-09_unicode_M3SD_ReadAlignDetect/ThirdPartyDriver/SCDS.cpp

which is again the way of using SPI bus
with control commands to read/write.
As used by libFAT and dldi drivers.

Unlock remains the funny writing to the
32MB end Word with:

0x09FFFFFE;
*unlockAddress = 0xA55A ;
*unlockAddress = 0xA55A ;
*unlockAddress = 0x3 ;
*unlockAddress = 0x3 ;

:)

With control commands like:
0x34 to read
0x35 to write
...

not defined anywhere except in this driver!



Greetings,
SoLo2
_________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Visit:
http://thebitsclub.tripod.com
http://biis.tripod.com