Setting up Development Environment

Revision as of 21:09, 18 January 2016 by Tomsterley (talk | contribs)

Setup

  • Install devkitARM. If it's already installed, update it. On Windows there's a GUI installer. On Linux/Mac there's a perl-script. Make sure you also select libctru and the 3ds examples when installing.
  • Depending on the kind of homebrew you want to develop, you may be interested in installing and using additional libraries and tools which don't ship alongside devkitARM/libctru. A list of them can be found in Homebrew Libraries and Tools.

Linux

  • First get the devkitARM updater Perl script for Linux.
  • Run it with superuser privileges if your /opt directory is not marked world read-writeable.
sudo apt-get install git curl
curl -L http://sourceforge.net/projects/devkitpro/files/Automated%20Installer/devkitARMupdate.pl/download -o devkitARMupdate.pl
chmod +x ./devkitARMupdate.pl
sudo ./devkitARMupdate.pl /opt/devkitpro
echo "export DEVKITPRO=/opt/devkitpro" >> ~/.bashrc
echo "export DEVKITARM=$DEVKITPRO/devkitARM" >> ~/.bashrc
echo "export PATH=$PATH:$DEVKITARM/bin" >> ~/.bashrc
source ~/.bashrc

Building the examples

3DS examples are still being created. Currently there are a few examples distributed by the devkitPro supplied updaters - these can be found in $DEVKITPRO/examples/3ds and the 3ds examples repository. There are now too many to list here in detail.

These can be built from the command line - on Windows devkitPro supply msys which can be started using the msys shortcut in the devkitPro Start Menu entry or by browsing to <installdir>\devkitPro\msys and double clicking the msys.bat file found there. This will launch a bash shell. On Linux/OSX you can just open your system supplied shell.

To start a new homebrew project from here simply type

cp -r $DEVKITPRO/examples/3ds/templates/application ~/projects/my3dsproject
cd ~/projects/my3dsproject
make

To run it on your 3DS start up The Homebrew Launcher, press the Y button to open the netloader then

$DEVKITARM/bin/3dslink my3dsproject.3dsx

Hopefully you'll see it boot on the 3DS.

Obviously you can add $DEVKITARM/bin to your PATH from the shell then simply run 3dslink as normal. You shouldn't add this permanently - it could potentially interfere with other tools.


Building the examples on Linux with Netbeans

  • Go to File->New Project...
  • Select C/C++ Project with existing code
  • Navigate to the examples directory and select the folder for the project you want to build; eg. /home/vtsingaras/3ds/examples/app_launch
  • Leave Configuration Mode to 'Automatic' and click 'Finish'.
  • It will fail to build. Now edit Makefile and insert these two lines, adjusting for your devkitpro path, at the top:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=/opt/devkitpro/devkitARM
  • Right-click the project and go to Properties->Code Assistance and click C Compiler.
  • In include directories enter
/opt/devkitpro/devkitARM/include;/opt/devkitpro/ctrulib/libctru/include

adjusting again for your devkitPro path.

  • Do the same for 'C++ Compiler'.
  • Go to 'Run' and click 'Clean and Build Project'.
  • Now right-click on the project and select Code Assistance->Reparse Project.

Now you can use Netbeans' code completion feature and build your project from the Run menu.

Building homebrew for distribution

To build your homebrew open a terminal, browse to your homebrew's folder and run make.

  • This will build a .elf file and a .3dsx file together with a .smdh. The .smdh and .3dsx file are the format required for the Homebrew Channel.
  • To build a Gateway-compatible .3ds file you need to strip the .elf file and use makerom on it (with the provided RSF file):
arm-none-eabi-strip [ELF file]
makerom -f cci -o [.3ds file] -rsf [RSF file] -target d -exefslogo -elf [ELF file] -icon [icon file] -banner [banner file]