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 > DLDI on arm7

#145990 - knight0fdragon - Tue Nov 27, 2007 8:44 am

ok, I am currently working on a project that relies on the fact that the arm7 does not change when another program is loaded in.

In order for me to do this, I would need the arm7 to be accessing the FAT, so that it can load code into the arm9 memory without ending up correcpting something.

Now I have tried a lot of approaches, but so far none have seemed to work, this is my latest attempt

I start off with a loader, contains both arm7 and arm9 with DLDI on the arm9 side

I take the arm9 DLDI, and I load it into VRAM_D

I set arm9 into a passme loop

now I need the arm7 to actually read the DLDI functions off of VRAM_D, instead of having to copy it over to the arm7s RAM. Does anybody have any ideas on how I can do this?
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#145994 - DragonMinded - Tue Nov 27, 2007 10:04 am

I could be totally off, but wouldn't the fact that the arm7 is a different procesor type than arm9 mean that it can't actually share code? And, if not, you would at least need to make sure the proper control registers were set.
_________________
Enter the mind of the dragon.

http://dragonminded.blogspot.com

Seriously guys, how hard is it to simply TRY something yourself?

#145996 - PypeBros - Tue Nov 27, 2007 10:46 am

i have once been studying the loader code from DSchannels, where during the boot of another program, ARM9 was executing the "stub" that was located in a VRAM bank (C comes to mind).

That stub was doing the FAT and DLDI thing, and while it was modifying the ARM7 too, it wasn't a requirement for that method. HTH. I never heard of someone doing FAT from the ARM7 and i don't know if the ARM7 would have access to the proper bus anyway...
_________________
SEDS: Sprite Edition on DS :: modplayer

#146001 - simonjhall - Tue Nov 27, 2007 1:32 pm

I had a look at this a while ago (there's a thread somewhere), and it seems that libfat is a no-go for the ARM7. Were you gonna use this or just call the DLDI stuff directly?
_________________
Big thanks to everyone who donated for Quake2

#146004 - Lick - Tue Nov 27, 2007 4:34 pm

I think I once copied a ARM7-compiled function that only accessed the BG_PALETTE using memcpy to main RAM. Then executed it on ARM9, and it worked!

Edit: more on topic: yes, you can write a ARM7 stub (not just the DLDI) that works from the VRAM. But remember that you can't initialize libfat twice using fatInitDefault, since the hardware is already initialized. You have to do some hackery (which I forgot), and AFAIK chism is the only one who've made a working stub with the current libfat.
_________________
http://licklick.wordpress.com

#146010 - thoduv - Tue Nov 27, 2007 5:51 pm

ARM9 code won't work everytime on ARM7, there are some instructions that are new on ARM9 (such as blx, which is often used) and that will make ARM7 lock on "undefined instruction" state.

But as Lick wrote, ARM7 code will work on ARM9, although it can result in some memory corruption, if this code uses main memory or local ARM7 memory. That's why compiling code for both CPU would require some special linker script and you would have to remove the "arm9" option from cflags.

#146012 - knight0fdragon - Tue Nov 27, 2007 6:16 pm

well libfat does work on the arm7 from what I have seen, I just have to give the arm7 access to the ROM. The big problem is that DLDI sucks up about a third of arm7s memory, which is why I want to place it inside of VRAM_D
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#146016 - Lazy1 - Tue Nov 27, 2007 7:21 pm

I remember reading that the arm7 does not support the required newlib hooks for libfat to work.
Maybe a hacked version of gba_nds_fat would be what you need.

#146018 - knight0fdragon - Tue Nov 27, 2007 7:38 pm

maybe, I dunno, I am using the hacked version that chishm used in his loader, maybe I will just try to find a way to get his loader to reset arm9 only
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#146056 - chishm - Wed Nov 28, 2007 2:40 am

DLDI code is compiled for the ARM7's instruction set, so it should run on either CPU. The only one I've come across that doesn't like the ARM7 is the R4 DLDI. I'm not sure of the exact reason for this. I need to investigate it further.

DLDI drivers can be run from any memory region that is 8-bit writeable, which includes VRAM allocated to the ARM7. You just need to patch the offsets correctly.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#146060 - knight0fdragon - Wed Nov 28, 2007 3:48 am

yeah that is what I need to know, how do I patch the offsets to the correct spots, the DLDI wiki is not exactly helpful on that part
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#146068 - knight0fdragon - Wed Nov 28, 2007 10:31 am

ok, well I got arm7 to load stuff from the DLDI, but I did not use VRAM_D.
The only problem with this though is that arm7 and arm9 both require DLDI, since I am not using the libfat portion, and most patchers only load up one side. I will share my code when I clean it up a little bit for others to use
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206