~exelotl/dump

Assumptions:

  • You are using a machine which runs Windows.
  • You know how to use Windows explorer.
  • You have looked in the C:/ drive and you know about places like "C:/Users" and "C:/Program Files".
  • You have never used a command prompt before but would like to learn how.
  • You want to compile some software for the GBA but don't know how (we'll get there eventually, after learning the command prompt)

#Installing devkitARM

Follow the link to the "Graphical installer" on this page: https://devkitpro.org/wiki/Getting_Started

Run the installer and be sure to select the "GBA development" packages when installing.

#Terminal / command line basics

After installation, you will find a program called MSYS2 in your Start menu. When you run it, you will be presented with a Unix-style terminal (similar to what you'd find on Mac and Linux).

Usage is pretty simple, you just type in a command and hit the Return key on your keyboard.

But there are actually two components at play here:

  • The shell - This is the underlying program which takes your input, runs the desired command, and responds with output. In our case, the shell is bash, a program usually found on Linux systems.
  • The terminal - This is the graphical window which presents the shell to you. Terminals will often let you customise things like the colour and font. In our case, the terminal is a Windows program called mintty.

#The basics

When using the command prompt, the first thing to be aware of is the concept of the "current working directory" which is basically what folder you're in. (directory is another word for folder)

Here's some commands to get you started:

echo hello Displays "hello".
pwd Display the path to the current directory.
mkdir foo Make a new directory called "foo".
ls List all files in the current directory.
ls Pictures List all files in the directory called "Pictures".
cd Pictures Change directory. This will make "Pictures" the current directory.
mv duck.jpg swan.jpg Move or rename the file "duck.jpg" to "swan.jpg"
cp dog.jpg dog2.jpg Copy the file "dog.jpg" to a new file called "dog2.jpg"
cp -r Pictures Backup Copy the entire directory "Pictures" to a new directory called "Backup"
make Compile a project (only if there is a file called "Makefile" in the current directory)

Notice how some of these commands are analogous to actions that you'd perform in the Windows file explorer. For example, cd Downloads is the terminal equivalent of double-clicking your Downloads folder to go inside it.

In addition, here are some commands that are specific to Windows:

notepad myfile.txt Open myfile.txt in Notepad (it will be created if it doesn't exist)
explorer . Open the current directory in a file explorer window.

#A note on full paths

On Windows you may be used to seeing "full" (absolute) file paths that look like this:

C:/Users/exelotl/Pictures/dog.jpg

However, because MSYS2 has a Unix-style command prompt, absolute paths begin with / instead:

/c/Users/exelotl/Pictures/dog.jpg

Also, in the MSYS2 terminal you'll notice that your Windows user directory (the one with "Documents", "Pictures" and stuff) is mapped to an equivalent Unix-style home directory.

That's why when I open MSYS2 and run pwd it displays /home/exelotl instead of /c/Users/exelotl. It's the same folder, just with a different name!

#Spaces...

You should be very careful when dealing with file and directory names containing spaces!

For example ls /c/Program Files (x86) will not display a list of everything inside the program files, because the shell sees /c/Program, Files, (x86) as 3 different arguments.

An easy solution is surround the path in quotation marks, for example ls "/c/Program Files (x86)"

#Special symbols

Certain symbols in commands have special meanings. For example:

  • . means "the current directory"
  • .. means "the directory above this one"
  • ~ means "your home directory" e.g. /home/exelotl
  • $ is used for "environment variables", for example echo $DEVKITPRO will display the path to where devkitPro is installed.

#Further reading

For more info you can check out this Unix Command Line Tutorial.

#Compiling the GBA examples

Assuming you selected the GBA-dev packages during installation, you should find that devkitARM comes with a bunch of examples.

Let's use the terminal to see what's in the examples folder:

$ ls /opt/devkitpro/examples/gba
audio            graphics  Makefile  README.md  utility
gbaexamples.prj  img       mbv2      template   xboo

Note: lines beginning with $ are those where a command is run. Lines without are the output displayed by the command. You are not supposed to write the $, it's just there for illustration purposes.

Here we see a mix of directories and files. Let's use cp to copy them all into our home directory, and ls to check that it worked.

$ cp -r /opt/devkitpro/examples/gba gba-examples
$ ls
Documents
Downloads
gba-examples
Music
Pictures
Videos
...

Looks like it's there. Now we can cd into our folder and use make to compile all the examples. (This might take a while!)

$ cd gba-examples
$ make

If this was successful, we can now open the folder and take a look inside to see all the .gba files that were produced!

About this wiki

commit eeda11cee195777e002d87e1ad9d9ce6e44ba827
Author: Jeremy Clarke <gecko@exelo.tl>
Date:   2021-12-09T02:48:18Z

.
Clone this wiki ("wiki" branch)
https://git.sr.ht/~exelotl/dump (read-only)
git@git.sr.ht:~exelotl/dump (read/write)