#110940 - Dwedit - Sun Dec 03, 2006 1:52 am
The 32MB of RAM does not always behave how you'd expect it to. For example, a fast, backwards memcopy loop using LDMDB and STMDB fails on the M3.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#110970 - OOPMan - Sun Dec 03, 2006 8:31 am
Hmmmmm, interesting...
Would this be an 8-bit write related issue?
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#110974 - Dwedit - Sun Dec 03, 2006 8:43 am
I'm using the block read/write instructions, which write in 32 bits.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#111030 - OOPMan - Sun Dec 03, 2006 7:44 pm
Erm, I think the GBA port only supports 16-bit reads/writes max...
Anyone else know whether this is true?
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#111050 - tepples - Sun Dec 03, 2006 8:37 pm
OOPMan wrote: |
Erm, I think the GBA port only supports 16-bit reads/writes max...
Anyone else know whether this is true? |
Every part of the GBA and Nintendo DS that supports 16-bit access supports 32-bit access, and vice versa. The problematic areas are GBA SRAM (no 16-bit or 32-bit reads or writes), video-related RAM (no 8-bit writes), and GBA ROM (no 8-bit writes).
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#111072 - Mighty Max - Sun Dec 03, 2006 10:52 pm
When using stm/ldm, make sure that you are using them proper aligned.
Also check if the problems are solved if you change the wait states for accessing gba memory (WAIT_CR (0x04000204:16)) to the slowest. If that fixes it, try figuring out the best working timings.
_________________
GBAMP Multiboot
#111074 - tepples - Sun Dec 03, 2006 11:11 pm
It's fastest to access ROM in sequential order. Are you trying a ROM-to-ROM copy?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#111130 - OOPMan - Mon Dec 04, 2006 8:39 am
Thanks for correcting me on the above tepples :-)
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#113530 - simonjhall - Thu Dec 28, 2006 4:31 pm
Sorry for digging up an old topic, but how did this work out in the end? Did you get the card working properly in the end?
And the thing that I *really* would like to know, how fast can do you do a memcpy from M3 RAM<-->regular RAM? Tens of megabytes per second would be really nice.
_________________
Big thanks to everyone who donated for Quake2
#113547 - Dwedit - Thu Dec 28, 2006 9:28 pm
ldmia and stmia work fine on the M3, but the backwards versions (ldmdb, stmdb) do not work. My tests were doing copies from M3 ram to M3 ram.
Going backwards one word at a time does work.
Code: |
fastcopyloop
ldmia r1!,{r4,r5,r6,r7,r8,r9,r10,r11}
stmia r0!,{r4,r5,r6,r7,r8,r9,r10,r11}
subs r2,r2,#0x20
bpl fastcopyloop
|
An equivalent version of this code using ldmdb and stmdb did not produce identical results on hardware as it did on a modified verison of VBA, but I did not bother to examine the memory, I just checked the adler32.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#113554 - simonjhall - Thu Dec 28, 2006 10:00 pm
Okey-doke, I only really want a memcpy in and memcpy out function, and if I've gotta do something particular then that's not too much of a problem.
So, regarding the speed - any info? I'm thinking about Quake2 here so the higher the better :-D
_________________
Big thanks to everyone who donated for Quake2
#113581 - tepples - Fri Dec 29, 2006 1:39 am
I don't know the number of wait states the DS uses for its 4 MB RAM in DS mode, but on the GBA, a DMA copy from ROM to EWRAM should run at 6.6 10^6 B/s at 3/1 ROM wait state (M3) or 5.5 10^6 B/s at 4/2 ROM wait state (SuperCard). Using an LDM/STM loop with the ARM9's write caching might speed this up, or it might not.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#113600 - simonjhall - Fri Dec 29, 2006 2:51 am
So the Supercard isn't that much slower than the M3? That's interesting... I assumed that it was much slower as GBA games need to be patched due to the speed of the memory... (or something)
Either way, I think the speed is just fast enough to be do-able. Just :-)
_________________
Big thanks to everyone who donated for Quake2
#113750 - HyperHacker - Sat Dec 30, 2006 9:01 am
Dwedit wrote: |
Code: |
fastcopyloop
ldmia r1!,{r4,r5,r6,r7,r8,r9,r10,r11}
stmia r0!,{r4,r5,r6,r7,r8,r9,r10,r11}
subs r2,r2,#0x20
bpl fastcopyloop
|
|
You realize this code doesn't check alignment nor ensure the number of bytes is a multiple of 0x20? I believe LDMxx/STMxx require 32-bit alignment, and not checking for multiples means if you try to copy, say, 0x21 bytes, you end up copying 0x40 and causing memory corruption.
_________________
I'm a PSP hacker now, but I still <3 DS.