Assembling 3DS Homebrew for Gateway

While the newest Gateway update brought two major features, the addition of homebrew support seemed rather unclear initially because of the lack of a method to actually assemble Gateway-compatible 3DS files. However, thanks to the work of 3DSGuy, we can effectively convert ELFs to 3DS files. While many developers will already be able to make use of this, this guide is intended to expand the options for 3DS homebrew by walking through how to compile ctrulib, a library for writing ARM11 homebrew, as well as going over the basics of compiling and running one of ctrulib's example programs.

Note: I carried out this process on an Ubuntu 12.04 system. While these steps should theoretically apply for any desktop operating system, your results may vary. I'll try to make everything as universally helpful as possible.

Step 1: Setting Up

Obviously, you'll need to start by having everything set up to actually be able to compile. To start, you'll need the basic developer essentials for your given operating system. That goes beyond the scope of this guide, but if you're developing homebrew, it's a safe assumption that you've already carried this step out, or at least know how to on your own.

Next, you'll need to install GCC for ARM embedded systems. You can download the files for that here. Windows users will have a straightforward installer, while OSX and Linux users will have to do a little extra setup later. For now, if you're one of these people, extract your associated download in some folder that you'll be able to conveniently remember. Alternatively, Ubuntu users can install an alternate PPA available here.

You'll also need DevKitPro set up as you would if you were developing standard DS homebrew, along with all optional libraries (included in the following guide). A fairly straightforward guide for doing so is available here. Windows users have an easy installer available, and while scripts can handle the task for OSX and Linux users, I highly recommend they follow the guide for a manual setup. It isn't very long or difficult, and will give you a good grasp on where everything you'll be using is located.

Finally, you'll need makerom, this file for compiling ctrulib software with makerom, and this workaround for using makerom with Gateway. Put those all somewhere convenient; we won't be using them right now, but they'll be needed at the end of this guide.

Step 2: Compiling ctrulib and homebrew

So you're all set up and ready to go! Now we get to the fun part. You're going to want to download ctrulib from here. If you're familiar with git, this process should be straightforward. Otherwise, just click the "Download ZIP" button on the right side of the screen. You're going to want to get everything from that link somewhere on your computer, with the same organization as it has on there. This is for convenience sake, as you'll have everything downloaded at once and readily available. As well, the makefiles of all the example programs assume that everything will be in the same places that it is on github, so moving things around may cause issues.

Now that you've got ctrulib downloaded, open up your command line/terminal and navigate to your newly created ctrulib directory (for most operating systems, the command to do this will be cd). navigate into the "libctru" folder, and type "make". If all goes well, you should now have ctrulib ready for use!*

*If you were one of the users in step 1 who had to just extract the GCC ARM toolkit into a convenient location, then you'll need to make some slight changes to the Makefile first. Open up the Makefile in a text editor, and the first line should say "CC = arm-none-eabi-gcc". Get rid of the last part so it simply reads "CC = ", and then add the directory you extracted it to, plus "bin/arm-none-eabi-gcc", all in quotation marks. So, if I extracted to /usr/local, I would replace arm-none-eabi-gcc with "/usr/local/gcc-arm-none-eabi-[version]/bin/arm-none-eabi-gcc". Repeat this process for the second line, and just replace the "gcc" at the end with "ar".

But we didn't just come here to compile ctrulib, we want to be able to use it. So let's go compile an example program. Pull up your command line/terminal again, and go up a directory ("cd .."). Now, navigate into the "arm11u" folder. We almost have everything we need to compile this homebrew right now (You'll have to repeat the above steps for this makefile as well, if you're an OSX/Linux user). However, if you try to compile this right now, you'll find that you're missing a file- a linker named "ccd00.ld". Our makefile needs this in order to determine how to compile our homebrew.

Thankfully, if you followed step 1, you should already have this file- it was the file you downloaded immediately after makerom (This one, in case you skipped over it). All you need to do is copy/paste that into the "arm11u" folder, and rename it to "ccd00.ld". If everything went right, you should now be able to type make into your command line/terminal to create a file called "arm11u.elf"!

Step 3: Converting the .elf into a .3ds
Thankfully, this is the easiest step so far. Now that you've got your homebrew file ("arm11u.elf" in the step 2 example), go ahead and paste it into the same folder where you keep makerom and the workaround you downloaded in step 1. Now, use your command line/terminal to navigate to this folder. If you're a Windows user, at this point you can simple type "build.bat arm11u.elf arm11u.3ds". If you're an OSX or Linux user, the steps aren't much harder. Open up the "build.bat" file in a text editor, change "%1" to "arm11u.elf" and "%2" to "arm11u.3ds", and copy/paste the whole thing into your terminal. You should now have a Gateway usable 3DS file.

I hope this guide is helpful to people in setting up ctrulib and and assembling homebrew for the new Gateway update. As a note on the ctrulib examples, so far arm11u is the only one I've had full success with, but it should be enough to get you started, and can be used as a base file for developing new homebrew or porting old homebrew to Gateway. I'm currently working on successfully compiling the "gpu" example, however some odd issues are coming up. If you think you can help with this process, feel free to respond to this thread or PM me about it.

Anyway, I hope this guide helps some people get started in working with ctrulib and Gateway supported homebrew. Most of this information could be determined through trial and error or experience, but I wrote it out so you wouldn't have to. This is my first guide, so please leave feedback, and if I missed something or you have a question I'll try to respond quickly. Happy developing, and here's to seeing some amazing progress from the homebrew scene in the near future.
 

cearp

瓜老外
Developer
Joined
May 26, 2008
Messages
8,725
Trophies
2
XP
8,510
Country
Tuvalu
Like posts mentioned above, running DS/DSi mode will wipe your NVRAM, so not gonna happen
sure, i understand that, but i'm sure eventually we will be able to load ds roms without a ds mode flash cart, well probably at that stage we will not even need gateway anymore :)
 
  • Like
Reactions: Margen67

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
well it depends its probably a lot of work for a feature that not too many people would use, supposing they could redirect the NVRAM too they could make it so you don't need to re-install the exploit to play DS games, you will of course still need it to install the exploit initially though, but iirc the exploit breaks the ds compatiblity anyway which is why DS/DSi/GBA games won't work in emunand
 

Sylantemp

Active Member
OP
Newcomer
Joined
Jul 20, 2012
Messages
43
Trophies
0
XP
71
Country
United States
well it depends its probably a lot of work for a feature that not too many people would use, supposing they could redirect the NVRAM too they could make it so you don't need to re-install the exploit to play DS games, you will of course still need it to install the exploit initially though, but iirc the exploit breaks the ds compatiblity anyway which is why DS/DSi/GBA games won't work in emunand


I'm an ambassador, and I can actually use most of the GBA games in emunand. Oddly enough, specific ones fail to load (Metroid Fusion is the one that sticks out in my mind), but it seems unlikely that it's directly (perhaps indirectly) tied to the exploit, while the others continue to function.
 

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
I'm an ambassador, and I can actually use most of the GBA games in emunand. Oddly enough, specific ones fail to load (Metroid Fusion is the one that sticks out in my mind), but it seems unlikely that it's directly (perhaps indirectly) tied to the exploit, while the others continue to function.
from what i heared none of the gba ambassador games work, the nes ones are fine though, and iirc it is because the exploit breaks twl_firm/agb_firm which is used for DS/DSi/GA games but im no expert on it just from what i have read
 

Sylantemp

Active Member
OP
Newcomer
Joined
Jul 20, 2012
Messages
43
Trophies
0
XP
71
Country
United States
from what i heared none of the gba ambassador games work, the nes ones are fine though, and iirc it is because the exploit breaks twl_firm/agb_firm which is used for DS/DSi/GA games but im no expert on it just from what i have read


That appears to be correct. I just tried a few that I thought for sure worked, and they all locked on a black screen. Guess I just got confused and thought I was using emunand some time when I wasn't. Whoops!

At least we can say with good confidence that a community built GBA emulator WILL come around eventually. I love that the ambassador games were little gifts to loyal fans, but I'm heavily opposed to Nintendo keeping them locked away from the public. Not to mention that there's so many great games that have yet to see playability on the 3DS.
 

cearp

瓜老外
Developer
Joined
May 26, 2008
Messages
8,725
Trophies
2
XP
8,510
Country
Tuvalu
so the 'ds' emulates it, and not the 3ds, which means the gba games is basically running in ds mode?
so it means nintendo didn't want to make use of the 3ds hardware for it... hmm weird
 
  • Like
Reactions: Margen67

cearp

瓜老外
Developer
Joined
May 26, 2008
Messages
8,725
Trophies
2
XP
8,510
Country
Tuvalu
the NDS already played GBA games, so why not utilize that rather than make a whole emulator for 10 games that only a few people even have
i thought the ds played the games because it has gba hardware in it...? maybe i'm getting it confused with wii and gc.
were they really so similar that they basically just worked (gba games) on the ds?
 

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
but nds has the same cpu as gba(arm7) while 3ds doesnt
i thought the ds played the games because it has gba hardware in it...? maybe i'm getting it confused with wii and gc.
were they really so similar that they basically just worked (gba games) on the ds?
"It's unknown how exactly DS(i)-mode ARM7 code is run"
from 3dbrew....so if the experts are not sure how it works exactly no chance i would, i just read what they share, if you read the link
http://3dbrew.org/wiki/FIRM#TWL_FIRM
it would appear arm7 code does work but they dont know how exactly,
 
  • Like
Reactions: cearp

Sylantemp

Active Member
OP
Newcomer
Joined
Jul 20, 2012
Messages
43
Trophies
0
XP
71
Country
United States
"It's unknown how exactly DS(i)-mode ARM7 code is run"
from 3dbrew....so if the experts are not sure how it works exactly no chance i would, i just read what they share, if you read the link
http://3dbrew.org/wiki/FIRM#TWL_FIRM
it would appear arm7 code does work but they dont know how exactly,


To be fair, it's not an impossible feat of backwards compatibility. We've seen similar successes in the community in the past, such as GBA emulation being carried out on DS consoles without a GBA port (or DS2), and the ever famous Nintendont project. I'm sure carrying out backwards compatibility with a prior architecture was much easier for Nintendo developers especially, since they have direct access to all the information they would need.
 
  • Like
Reactions: Margen67

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
To be fair, it's not an impossible feat of backwards compatibility. We've seen similar successes in the community in the past, such as GBA emulation being carried out on DS consoles without a GBA port (or DS2), and the ever famous Nintendont project. I'm sure carrying out backwards compatibility with a prior architecture was much easier for Nintendo developers especially, since they have direct access to all the information they would need.
yeah regarless of how its done its still implemented in the 3DS already to use the DS/DSi functions so it would be easier to reuse the work thats already in place in NDS mode than create another emulator for a limited bunch of people who bought the console at launch, nobody else can get gba games anyway
 

Mariko

Well-Known Member
Member
Joined
Oct 13, 2009
Messages
190
Trophies
0
XP
282
Country
it's a bit like having gamecube usb loading on wii, having your music on your phone instead of on a separate player, why did we even want multirom support? it's just convenience!
that's why i would want to do that, since it is more convenient to have everything on one cart, it's hardly a weird idea.

3DS flash cartridges still have ways to go, and we're still stuck on the 4.x exploit. There's plenty to be done in the 3DS field, so multi-format experimentation is probably not going to happen until the 3DS is blown wide open. And when it is, it's more likely that a software solution will be created, rather than an overly complicated cartridge design, to accommodate such features. Anyway, two separate cartridges are just fine for me, and should be fine for anyone else. Think of those poor souls who not only pay for their games, but have to swap them out constantly. Poor bastards will need joint replacement soon, because of all the unnecessary swapping.

If you want DSi support, you're better off mailing DS cartridge manufacturers about it, but there probably isn't enough interest to support the DSi mode.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: @salazarcosplay, no sabría cómo decirte