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.
 

Sylantemp

Active Member
OP
Newcomer
Joined
Jul 20, 2012
Messages
43
Trophies
0
XP
71
Country
United States
In case anyone wants to know about the case of compiling the GPU example: I'm still working on it, and the problem has become less of compiling the example itself, but rather the setup. A separate file needed for the compile is provided by an external Python script, which doesn't seem to be working properly for me. Smealum has informed me that the script only (consistently) functions with a model he specifically used to work the script around, but I've had no good luck using the very model he recommended. So, if anyone's particularly skilled with Python and wants to see the GPU example publicly useful, the script in question is over here.
 

bunnei

Member
Newcomer
Joined
Apr 1, 2014
Messages
23
Trophies
0
Age
31
XP
606
Country
United States
This might work for a GPU demo.... I haven't gotten a chance to test it yet though, so who knows (I'll try when I get a chance and confirm...)
FWIW none of this work is mine, everything is from smealum and 3DSGuy.

Edit: Just wanted to point out, I very quickly hacked a bunch of stuff up for this to compile while on my lunch break, so sorry for the sloppiness :P I also disabled the texture because I didn't have time to get that working.

Regards
 

Attachments

  • gpu.zip
    670.9 KB · Views: 438

ernilos

Well-Known Member
Member
Joined
Aug 28, 2013
Messages
145
Trophies
0
Location
CAT
XP
280
Country
United States
Bah, my tool for create 3DS app's it's more sexy than this :c
XVjpe.png
 

bunnei

Member
Newcomer
Joined
Apr 1, 2014
Messages
23
Trophies
0
Age
31
XP
606
Country
United States
Can confirm... The zip I submitted in my above post draws a cluster of black triangles. With L + R you can zoom in/out, and move/rotate it with the other buttons. So, as a GPU example, seems like it does its purpose... I'll leave it as an exercise to the keen reader to fix the model :P
 

Sylantemp

Active Member
OP
Newcomer
Joined
Jul 20, 2012
Messages
43
Trophies
0
XP
71
Country
United States
Can confirm... The zip I submitted in my above post draws a cluster of black triangles. With L + R you can zoom in/out, and move/rotate it with the other buttons. So, as a GPU example, seems like it does its purpose... I'll leave it as an exercise to the keen reader to fix the model :P


Hey, thanks for providing something that at least runs on the 3DS! I was having so much trouble converting a model into a usable header that I basically had no hope of compiling the example. Now there's something to play around with.

UPDATE: I'm trying to recompile with a mdl.h generated by Smealum's updated script, and I'm now getting new issues... From DevkitARM, of all things! Any chance you ran into some odd problems with that?
 

Sylantemp

Active Member
OP
Newcomer
Joined
Jul 20, 2012
Messages
43
Trophies
0
XP
71
Country
United States
Should this thread be updated to include the templates that have been showing on the Homebrew Development thread? I've thought they might be more effective than describing the process in multiple different folders and working off of the ctrulib examples (at least one of which seems a bit harder to compile), but I have very mixed feelings about them, as they use the Gateway compatible 3DS generator upon compilation. This is very convenient for developers, of course, but I fear dependence on those templates will discourage using more compatibility-friendly methods when Smealum's (or any other ARM11/ctrulib compatible) homebrew loader releases. I'd prefer to hear from the people who would be using it before making any changes.
 

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
well i don't know what smealum will be doing to load homebrew, most of his demonstrations have been installed to the system menu......meaning it would probably be .cia format, i suppose outputting to .3ds is the most logical atm as its the only way of loading it, you could output as .elf and a .3ds, so people testing on the emulators can do so and people testing on the actual hardware can also do so, not sure its worth outputting a .cia file as i dont think anyone really knows exactly what smealum will be using once he releases
 
D

Deleted User

Guest
Should this thread be updated to include the templates that have been showing on the Homebrew Development thread? I've thought they might be more effective than describing the process in multiple different folders and working off of the ctrulib examples (at least one of which seems a bit harder to compile), but I have very mixed feelings about them, as they use the Gateway compatible 3DS generator upon compilation. This is very convenient for developers, of course, but I fear dependence on those templates will discourage using more compatibility-friendly methods when Smealum's (or any other ARM11/ctrulib compatible) homebrew loader releases. I'd prefer to hear from the people who would be using it before making any changes.


If you check ctrtool sourcecode there are 3 types of .3DS files:
1- plaintext
2- encrypted with aes with key 000000... (all zero)
3- encrypted with 3ds aes hw voodoo

Gateway format is nr. 2, which any emulator can decrypt easily.

The homebrew via launcher.dat files is a frankenstein monster and will never be accepted as a universal format by any sane person

tl;dr Emulator makers should wise up and accept the first 2 3ds formats which will be UNIVERSAL!
 
  • Like
Reactions: Snailface

Sylantemp

Active Member
OP
Newcomer
Joined
Jul 20, 2012
Messages
43
Trophies
0
XP
71
Country
United States
If you check ctrtool sourcecode there are 3 types of .3DS files:
1- plaintext
2- encrypted with aes with key 000000... (all zero)
3- encrypted with 3ds aes hw voodoo

Gateway format is nr. 2, which any emulator can decrypt easily.

The homebrew via launcher.dat files is a frankenstein monster and will never be accepted as a universal format by any sane person

tl;dr Emulator makers should wise up and accept the first 2 3ds formats which will be UNIVERSAL!


I actually absolutely agree with the objection to Launcher.dat homebrew; it's nothing more than an improvisation made to bring some level of temporary unsigned code support. Now that we have basic emulators and a decent(?) homebrew loading option, though, it seems reasonable for there to be some demand for a common standard. The question is, though, might future homebrew options restrict the use of these standards? I'd much rather be supporting something that is likely to be available for widespread use. Thanks for the tip on the different .3DS types, though. It seems like 1 and 2 would be the only ones even worth using, but I'm actually not familiar with 3. Can you reference an example?
 

NCDyson

Hello Boys...
Member
Joined
Nov 9, 2009
Messages
278
Trophies
1
XP
319
Country
United States
but I'm actually not familiar with 3. Can you reference an example?
I believe he means commercial games.

As far as the gpu demo, I've got some experience with python and 3d file formats/rendering, I'd be happy to take a look at it if you haven't gotten it working.
 

Sylantemp

Active Member
OP
Newcomer
Joined
Jul 20, 2012
Messages
43
Trophies
0
XP
71
Country
United States
I believe he means commercial games.

As far as the gpu demo, I've got some experience with python and 3d file formats/rendering, I'd be happy to take a look at it if you haven't gotten it working.


Both Bunnei and Smealum were kind enough to fix the issues with the model conversion script (sort of; see the above posts), but I'm actually getting unusual linker errors now that I've yet to quite figure out. It's probably nowhere near as complicated as the matter seems, but unfortunately, I'm as busy as can be for the next week or so, so I haven't had a chance to try and find the cause.
 
D

Deleted User

Guest
The launcher.dat homebrew will only work on 4.5 systems. When new exploits are found/released (like smealums ssspwn) you can forget about loading launcher.dat homebrew that target the arm9 and such, it will most likely not work on later systems. So yeah 3ds format homebrew is the only option.
What should happen is this: someone needs to code a launcher.dat homebrew loader that will load .3ds format homebrew. It's that simple.
 
  • Like
Reactions: Snailface

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
It would probably be more likely that and free homebrew launchers would go the route of .cia installation.....similar to what smea has set up, i imagine it would be easier to disable .cia installation checks than code a redirection of 3ds roms to load from the SD slot....essentially it would be the same kinda homebrew, just packaged differently
 

Tybus

Well-Known Member
Newcomer
Joined
Nov 24, 2013
Messages
60
Trophies
0
Age
28
XP
209
Country
So.. I've followed the guide and I still get this error :
[ELF ERROR] .rodata segment and .rodata segment are not continuous
[ELF ERROR] Failed to process ELF file (-17)
[NCCH ERROR] NCCH Build Process Failed
[RESULT] Failed to build outfile
Anyone knows what's the problem?...
Thank You
 

Snailface

My frothing demand for 3ds homebrew is increasing
Member
Joined
Sep 20, 2010
Messages
4,324
Trophies
2
Age
40
Location
Engine Room with Cyan, watching him learn.
XP
2,255
So.. I've followed the guide and I still get this error :
[ELF ERROR] .rodata segment and .rodata segment are not continuous
[ELF ERROR] Failed to process ELF file (-17)
[NCCH ERROR] NCCH Build Process Failed
[RESULT] Failed to build outfile
Anyone knows what's the problem?...
Thank You
Here's a package that I've prepared for Linux. I've tested it and it works, just make sure to change the 1st line in the makefile to the path of your Devkitpro installation.
 

Attachments

  • 3DSTemplateLinux.zip
    359.6 KB · Views: 590
  • Like
Reactions: Tybus

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: