Author Topic: FAT drivers for multi card + MK2/3 SD/MMC access  (Read 30571 times)

0 Members and 2 Guests are viewing this topic.

Offline cory1492

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1443
    • Cory1492's NDS + PSP corner
FAT drivers for multi card + MK2/3 SD/MMC access
« on: February 13, 2006, 08:58:12 PM »
Chishm has updated his driver, and one can now use it to access SD/MMC cards with a fairly reasonable FAT and file library.

http://www.geocities.com/chishm1/gbamp/index.html

Pretty great. Also makes it alot easier to see how the reg entries are used on the SPI bus (looks like even from ARM9 too :-)

A quick demo that will copy a file "test.bin" to "test.cpy" on your SD/MMC can be found attached here
« Last Edit: February 14, 2006, 10:50:39 PM by cory1492 »
Those who have come here to hate should leave now, for in their hatred they only betray themselves.
translated from The Book of Life (Src: Sword of Truth - Phantom by Terry Goodkind)

Offline D3mon

  • Newbie
  • *
  • Posts: 7
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #1 on: February 14, 2006, 06:53:07 AM »
I havent been able to get this working, what am i doing wrong?

My source is attached

Thanks for any help you can

Offline cory1492

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1443
    • Cory1492's NDS + PSP corner
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #2 on: February 14, 2006, 11:03:38 AM »
well, for one you may want to setup your toolchain properly, and use a template instead. Including the .c files is not a great idea (it would be just like putting the source directly in the same file, but without all the proper order etc)

Also, it is better to use the default Arm7 included in NDStool wrather than write a null function, since ARM7 is what handles the SPI calls as far as I know.

I will try and make a small demo app with source by sometime tomorrow though (there is also the moonshell source available, in case something needed to be added to the ARM7 that I dont know about yet).
« Last Edit: February 14, 2006, 11:13:50 AM by cory1492 »
Those who have come here to hate should leave now, for in their hatred they only betray themselves.
translated from The Book of Life (Src: Sword of Truth - Phantom by Terry Goodkind)

Offline boblen

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1130
    • Aussie-Play.com
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #3 on: February 14, 2006, 12:29:19 PM »
so this is for the GBAMP  ???

Offline Syecon

  • Newbie
  • *
  • Posts: 4
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #4 on: February 14, 2006, 08:51:52 PM »
Quote
since ARM7 is what handles the SPI calls as far as I know.

ARM7 should only handle it by default, access can be given to the ARM9.

Quote
so this is for the GBAMP

It was for GBAMP, but chism rocks and now it will work with the MK2/MK3, finally come example code.

Offline D3mon

  • Newbie
  • *
  • Posts: 7
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #5 on: February 14, 2006, 09:03:39 PM »
So if i gave ARM9 access to DS Card slot it would work like this, and this is what im doing wrong?

Offline D3mon

  • Newbie
  • *
  • Posts: 7
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #6 on: February 14, 2006, 10:10:04 PM »
OK, the answer was no as it is failing at FAT_InitFiles()

Offline cory1492

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1443
    • Cory1492's NDS + PSP corner
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #7 on: February 14, 2006, 10:46:39 PM »
I'll be danged syecon, you are right - I see them setting the registers directly in the fat driver so I guess arm7 isnt really needed for this program to run (although I do still think it is a good idea to give the A7 default bin wrather than build a null one..).

Any rate, I did a demo with vigourous comments and using every function I could to simply copy a file. It works on my MK3 just nice, and has a decent template style layout. Youll have to adjust your paths to match if your installation if you wish to use the batch file I made up for this.

Ignore my lack of keeping up with the iprintf format as I dont have the time now to track down why when I use the standard console.h the screen inits white.
« Last Edit: February 14, 2006, 11:01:17 PM by cory1492 »
Those who have come here to hate should leave now, for in their hatred they only betray themselves.
translated from The Book of Life (Src: Sword of Truth - Phantom by Terry Goodkind)

Offline Syecon

  • Newbie
  • *
  • Posts: 4
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #8 on: February 15, 2006, 06:03:21 AM »
Nice demo, yah the ARM7 has it's own proper SPI as well as access to the DS card slot spi, to which the ARM9 has access as well. I didn't ever check his code, I agree probably any ARM7 is better then nothing.

What is the true speed in bits per second of the DS card spi? I thought the port was 6Mbps, the SPI is super slow, how slow exactly though, do you know cory? I assume that is the reason that MK2/3 SD is so slow.

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3826
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #9 on: February 16, 2006, 12:51:39 AM »
very nice demo  ;D
In my world,have 0 and 1 only ......Matrix World......

Offline D3mon

  • Newbie
  • *
  • Posts: 7
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #10 on: February 17, 2006, 09:25:42 PM »
Sorry, i have looked through your code, noticing that there are no differences and still cant get mine to work, its crashing at FAT_InitFiles() and not going any further

Offline boblen

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1130
    • Aussie-Play.com
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #11 on: February 18, 2006, 04:32:58 AM »
ok i have no ideo what this is for :-\

i am like > ::sm-03::
« Last Edit: February 18, 2006, 12:25:59 PM by boblen »

Offline cory1492

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1443
    • Cory1492's NDS + PSP corner
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #12 on: February 18, 2006, 11:15:09 AM »
Sorry, i have looked through your code, noticing that there are no differences and still cant get mine to work, its crashing at FAT_InitFiles() and not going any further
I used the actual header instead of directly including all the C files, since the header is tested and includes the proper stuff in the right order, instead of including the .c files in your main try including the header and compiling the C files with your make script. I used ndstool in the makefile to build it with the default ARM7. You are going to want to compile and link these (unless you modify it to not look for the other devices), my build puts them in this order :

disc_io.c
gba_nds_fat.c
io_fcsr.c
io_m3cf.c
io_mpcf.c
io_nmmc.c
io_sccf.c
io_scsd.c

As I said before, as well - the FAT library uses IPC for times and such (you know, timestamps and that sort of thing), you may just want to replace your fake A7 binary with the default one in ndstool instead, as that could be causing the problem.

Boblen, it is demo source code to use the FAT lib that chishm released. It copies a file (test.bin to test.cpy) that is on the SD/MMC card.

Quote
What is the true speed in bits per second of the DS card spi? I thought the port was 6Mbps, the SPI is super slow, how slow exactly though, do you know cory? I assume that is the reason that MK2/3 SD is so slow
As far as I understand it, the max speed of the DS port is 4Mbps - whether they are using that speed or a slower one I do not know. Also understand that with my demo I am using an arbitrary write size of 512bytes, and multiple writes of this size; depending on how the chishms FAT driver is handling the data, it may not be the optimum data size to gain the best performance.

Also, depending on how they implemented the SD/MMC interface hardware code (whether its directly translating commands on the SPI as if the SD/MMC was a DS card, or whether there is buffering / interpretation in between the SD/MMC and the DS) could be slowing down SD/MMC comms quite alot as well.

edit:/ just an add in, thought I should add this as well - when writing a new file to the SD/MMC card, the writes can take a long time (it is how the FAT driver allocates/finds empty space that slows it down), but when overwriting an existing file with the same size or smaller it clips along alot faster.
« Last Edit: February 18, 2006, 07:09:29 PM by cory1492 »
Those who have come here to hate should leave now, for in their hatred they only betray themselves.
translated from The Book of Life (Src: Sword of Truth - Phantom by Terry Goodkind)

Offline boblen

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1130
    • Aussie-Play.com
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #13 on: February 18, 2006, 12:26:24 PM »
o ok thank you :)  ;)

Offline 68HC11

  • Newbie
  • *
  • Posts: 8
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #14 on: February 20, 2006, 09:07:49 AM »
This is really fantasic.  Not to be critical or anything, but this really should've been available from the beginning.  Ah well.  I'll just accept it and be merry.