Skip to content

Latest commit

 

History

History
656 lines (472 loc) · 29.7 KB

INSTALL.md

File metadata and controls

656 lines (472 loc) · 29.7 KB

Instructions

These instructions explain how to set up the tools required to build pokeemerald Expansion, which assembles the source files into a ROM (pokeemerald.gba).

These instructions come with notes which can be expanded by clicking the "Note..." text. In general, you should not need to open these unless if you get an error or if you need additional clarification.

If you run into trouble, ask for help on Discord or IRC (see README.md).

Windows

Windows has instructions for building with three possible terminals, providing 3 different options in case the user stumbles upon unexpected errors.

Unscientific benchmarks suggest msys2 is 2x slower than WSL1, and Cygwin is 5-6x slower than WSL1.

Note for advanced users: WSL2...

WSL2 is an option and is even faster than WSL1 if files are stored on the WSL2 file system, but some tools may have trouble interacting with the WSL2 file system over the network drive. For example, tools which use Qt versions before 5.15.2 such as porymap may have problems with parsing the \wsl$ network drive path.

All of the Windows instructions assume that the default drive is C:\. If this differs to your actual drive letter, then replace C with the correct drive letter when reading the instructions.

A note of caution: As Windows 7 and Windows 8 are officially unsupported by Microsoft, some maintainers are unwilling to maintain the Windows 7/8 instructions. Thus, these instructions may break in the future with fixes taking longer than fixes to the Windows 10/11 instructions.

Windows 10/11 (WSL1)

WSL1 is the preferred terminal to build pokeemerald Expansion. The following instructions will explain how to install WSL1 (referred to interchangeably as WSL).

Installing WSL1

  1. Open Windows Powershell as Administrator, and run the following commands (Right Click or Shift+Insert is paste in the Powershell).

    wsl --install -d Ubuntu --enable-wsl1
  2. Once the process finishes, restart your machine.

  3. Open Windows Powershell as Administrator again (after restarting), and run the following command to configure Ubuntu to use WSL1.

    wsl --set-version Ubuntu 1
    Note...

    WSL may open automatically after restarting, but you can ignore it for now.

Setting up WSL1

Some tips before proceeding:

  • In WSL, Copy and Paste is either done via
    • right-click (selection + right click to Copy, right click with no selection to Paste)
    • Ctrl+Shift+C/Ctrl+Shift+V (enabled by right-clicking the title bar, going to Properties, then checking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste").
  • Some of the commands that you'll run will ask for your WSL password and/or confirmation to perform the stated action. This is to be expected, just enter your WSL password and/or the yes action when necessary.
  1. Open Ubuntu (e.g. using Search).

  2. WSL/Ubuntu will set up its own installation when it runs for the first time. Once WSL/Ubuntu finishes installing, it will ask for a username and password (to be input in).

    Note...

    When typing in the password, there will be no visible response, but the terminal will still read in input.

  3. Update WSL/Ubuntu before continuing. Do this by running the following command. These commands will likely take a long time to finish:

    sudo apt update && sudo apt upgrade

Note: If the repository you plan to build has an older revision of the INSTALL.md, then follow the legacy WSL1 instructions from here.

  1. Certain packages are required to build pokeemerald Expansion. Install these packages by running the following command:

    sudo apt install build-essential binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi git libpng-dev
    Note...

    If the above command does not work, try the above command but replacing apt with apt-get.

    This will install GCC v10 on Ubuntu 22.04. pokeemerald Expansion works with GCC v10, but remote repositories and the RHH Team use GCC v13 for stricter error-checking. If you want to upgrade from v10 to v13, also follow the devkitpro install instructions.

Installing devkitARM on WSL1

  1. Change directory to somewhere you can download a package, such as C:\Users\<user>\Downloads (the Downloads location for most users). To do so, enter this command, where *<user> is your Windows username:

    cd /mnt/c/Users/<user>/Downloads
  2. Once the directory has been changed, run the following commands to install devkitARM.

    sudo apt install wget
    wget https://apt.devkitpro.org/install-devkitpro-pacman
    chmod +x ./install-devkitpro-pacman
    sudo ./install-devkitpro-pacman
    sudo dkp-pacman -S gba-dev

    The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation.

  3. Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL):

    source /etc/profile.d/devkit-env.sh

devkitARM is now installed.

Installing Python on WSL1

To install Python on WSL1, simply run the following commands:

sudo apt update && sudo apt upgrade
sudo apt install python3

Python is now installed.

Choosing where to store pokeemerald Expansion (WSL1)

WSL has its own file system that's not natively accessible from Windows, but Windows files are accessible from WSL. So you're going to want to store pokeemerald Expansion within Windows.

For example, say you want to store pokeemerald Expansion in C:\Users\<user>\Desktop\decomps. First, ensure that the folder already exists. Then, enter this command to change directory to said folder, where <user> is your Windows username:

cd /mnt/c/Users/<user>/Desktop/decomps
Notes...

Note 1: The Windows C:\ drive is called /mnt/c/ in WSL. Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. cd "/mnt/c/users/<user>/Desktop/decomp folder". Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed

If this works, then proceed to Installation.

Otherwise, ask for help on Discord or IRC (see README.md), or continue reading below for Windows instructions using msys2.

Windows (msys2)

Installing devkitARM

  1. Download the devkitPro installer here.
  2. Run the devkitPro installer. In the "Choose Components" screen, uncheck everything except GBA Development unless if you plan to install other devkitPro components for other purposes. Keep the install location as C:\devkitPro and leave the Start Menu option unchanged.

Setting up msys2

Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert.

  1. Open msys2 at C:\devkitPro\msys2\msys2_shell.bat.

  2. Certain packages are required to build pokeemerald Expansion. Install these by running the following two commands:

    pacman -Sy msys2-keyring
    pacman -S make gcc zlib-devel git
    Note...

    The commands will ask for confirmation, just enter the yes action when prompted.

  3. Download libpng.

  4. Change directory to where libpng was downloaded. By default, msys2 will start in the current user's profile folder, located at C:\Users\⁠<user>, where <user> is your Windows username. In most cases, libpng should be saved within a subfolder of the profile folder. For example, if libpng was saved to C:\Users\<user>\Downloads (the Downloads location for most users), enter this command:

    cd Downloads
    Notes...

    Note 1: While not shown, msys uses forward slashes / instead of backwards slashes \ as the directory separator. Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. cd "Downloads/My Downloads". Note 3: Windows path names are case-insensitive so adhering to capitalization isn’t needed. Note 4: If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. cd c:/devkitpro/msys2 if it was saved there.

  5. Run the following commands to uncompress and install libpng.

    tar xf libpng-1.6.37.tar.xz
    cd libpng-1.6.37
    ./configure --prefix=/usr
    make check
    make install
  6. Then finally, run the following command to change back to the user profile folder.

    cd

Installing Python on msys2

To install Python on msys2, simply run the following commands:

pacman -S mingw-w64-x86_64-python3

Python is now installed.

Choosing where to store pokeemerald Expansion (msys2)

At this point, you can choose a folder to store pokeemerald Expansion into. If you're okay with storing pokeemerald Expansion in the user profile folder, then proceed to Installation. Otherwise, you'll need to account for where pokeemerald Expansion is stored when changing directory to the pokeemerald-expansion folder.

For example, if you want to store pokeemerald Expansion in C:\Users\<user>\Desktop\decomps (where <user> is your Windows username), enter this command:

cd Desktop/decomps

If this works, then proceed to Installation.

Otherwise, ask for help on Discord or IRC (see README.md), or continue reading below for Windows instructions using Cygwin.

Windows (Cygwin)

  1. If devkitARM is not installed, then follow the instructions used to install devkitARM for the msys2 setup before continuing. Remember to not continue following the msys2 instructions by mistake!

Installing Cygwin

  1. Download Cygwin: setup-x86_64.exe for 64-bit Windows, setup-x86.exe for 32-bit.

  2. Run the Cygwin setup. Within the Cygwin setup, leave the default settings until the "Choose A Download Site" screen.

  3. At "Choose a Download Site", select any mirror within the Available Download Sites.

  4. At "Select Packages", set the view to "Full" (top left) and search for the following packages:

    • make
    • git
    • gcc-core
    • gcc-g++
    • libpng-devel

    To quickly find these, use the search bar and type the name of each package. Ensure that the selected package name is the exact same as the one you're trying to download, e.g. cmake is NOT the same as make.

  5. For each package, double click on the text that says "Skip" next to each package to select the most recent version to install. If the text says anything other than "Skip", (e.g. Keep or a version number), then the package is or will be installed and you don't need to do anything.

  6. Once all required packages have been selected, finish the installation.

Configuring devkitARM for Cygwin

Note that in Cygwin, Copy is Ctrl+Insert and Paste is Shift+Insert.

  1. Open Cygwin.

  2. Run the following commands to configure devkitPro to work with Cygwin.

    export DEVKITPRO=/cygdrive/c/devkitpro
    echo export DEVKITPRO=$DEVKITPRO >> ~/.bashrc
    export DEVKITARM=$DEVKITPRO/devkitARM
    echo export DEVKITARM=$DEVKITARM >> ~/.bashrc
    Note...

    Replace the drive letter c with the actual drive letter if it is not c.

Choosing where to store pokeemerald Expansion (Cygwin)

Cygwin has its own file system that's within Windows, at C:\cygwin64\home\<user>. If you don't want to store pokeemerald Expansion there, you'll need to account for where ppokeemerald Expansion is stored when changing directory to the pokeemerald-expansion folder.

For example, if you want to store pokeemerald Expansion in C:\Users\<user>\Desktop\decomps, enter this command, where <user> is your Windows username:

cd c:/Users/<user>/Desktop/decomps

Note that the directory must exist in Windows. If you want to store pokeemerald Expansion in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the cd command.

Notes...

Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. cd "c:/users/<user>/Desktop/decomp folder". Note 2: Windows path names are case-insensitive so adhering to capitalization isn't needed

If this works, then proceed to Installation. Otherwise, ask for help on Discord or IRC (see README.md).

macOS

  1. If the Xcode Command Line Tools are not installed, download the tools here, open your Terminal, and run the following command:

    xcode-select --install

Installing libpng (macOS)

Note for advanced users...

This guide installs libpng via Homebrew as it is the easiest method, however advanced users can install libpng through other means if they so desire.

  1. Open the Terminal.

  2. If Homebrew is not installed, then install Homebrew by following the instructions on the website.

  3. Run the following command to install libpng.

    brew install libpng

    libpng is now installed.

    Continue to Installing pkg-config (macOS) if pkg-config is not installed. Otherwise, continue to Installing devkitARM (macOS) if devkitARM is not installed.

    If both pkg-config and devkitARM are already installed, go to Choosing where to store pokeemerald Expansion (macOS).

Installing pkg-config (macOS)

Note for advanced users...

This guide installs pkg-config via Homebrew as it is the easiest method, however advanced users can install pkg-config through other means if they so desire.

  1. Open the Terminal.

  2. If Homebrew is not installed, then install Homebrew by following the instructions on the website.

  3. Run the following command to install libpng.

    brew install pkg-config

    pkg-config is now installed.

    Continue to Installing devkitARM (macOS) if devkitARM is not installed, otherwise, go to Choosing where to store pokeemerald Expansion (macOS).

Installing devkitARM (macOS)

  1. Download the devkitpro-pacman-installer.pkg package from here.

  2. Open the package to install devkitPro pacman.

  3. In the Terminal, run the following commands to install devkitARM:

    sudo dkp-pacman -Sy
    sudo dkp-pacman -S gba-dev
    sudo dkp-pacman -S devkitarm-rules

    The command with gba-dev will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation.

  4. After the tools are installed, devkitARM must now be made accessible from anywhere by the system. To do so, run the following commands:

    export DEVKITPRO=/opt/devkitpro
    echo "export DEVKITPRO=$DEVKITPRO" >> ~/.zshrc
    export DEVKITARM=$DEVKITPRO/devkitARM
    echo "export DEVKITARM=$DEVKITARM" >> ~/.zshrc
    
    echo "if [ -f ~/.zshrc ]; then . ~/.zshrc; fi" >> ~/.zprofile

    Note: Starting with macOS 10.15, the default Unix shell is now zsh. If you migrated from an older version of macOS, you might still be using bash. You can check my running echo $0 in the terminal.

    If your terminal is using bash instead of zsh...
    export DEVKITPRO=/opt/devkitpro
    echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc
    export DEVKITARM=$DEVKITPRO/devkitARM
    echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc
    
    echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile

Installing Python (macOS)

  1. Download the latest Python package from here.
  2. Open the package to install Python.

Python is now installed.

Choosing where to store pokeemerald Expansion (macOS)

At this point, you can choose a folder to store pokeemerald Expansion into. If you're okay with storing pokeemerald Expansion in the user folder, then proceed to Installation. Otherwise, you'll need to account for where pokeemerald Expansion is stored when changing directory to the pokeemerald-expansion folder.

For example, if you want to store pokeemerald Expansion in ~/Desktop/decomps, enter this command to change directory to the desired folder:

cd Desktop/decomps

Note that the directory must exist in the folder system. If you want to store pokeemerald Expansion in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Finder) before executing the cd command.

Note...

Note: If the path has spaces, then the path must be wrapped with quotations, e.g. cd "Desktop/decomp folder"

If this works, then proceed to Installation. Otherwise, ask for help on Discord or IRC (see README.md).

Linux

Open Terminal and enter the following commands, depending on which distro you're using.

Debian/Ubuntu-based distributions

Run the following command to install the necessary packages:

sudo apt install build-essential binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi git libpng-dev

Then proceed to Choosing where to store pokeemerald Expansion (Linux).

Note for legacy repos...

If the repository you plan to build has an older revision of the INSTALL.md, then you will have to install devkitARM. Install all the above packages except for the arm-none-eabi packages, and follow the instructions to install devkitARM on Debian/Ubuntu-based distributions.

Installing devkitARM on Debian/Ubuntu-based distributions

  1. Change directory to somewhere you can download a packages, like a Downloads folder. Then, run the following commands to install devkitARM:

    wget https://apt.devkitpro.org/install-devkitpro-pacman
    chmod +x ./install-devkitpro-pacman
    sudo ./install-devkitpro-pacman
    sudo dkp-pacman -S gba-dev

    The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation.

  2. Run the following command to set devkitPro related environment variables (alternatively, close and re-open the Terminal):

    source /etc/profile.d/devkit-env.sh

devkitARM is now installed.

Arch Linux

Run this command as root to install the necessary packages:

pacman -S base-devel arm-none-eabi-binutils arm-none-eabi-gcc arm-none-eabi-newlib git libpng

Installing devkitARM on Arch Linux

  1. Follow devkitPro's instructions to configure pacman to download devkitPro packages.

  2. Install gba-dev: run the following command as root.

    pacman -S gba-dev

    This will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation.

  3. Run the following command to set devkitPro related environment variables (alternatively, close and re-open the Terminal):

    source /etc/profile.d/devkit-env.sh

devkitARM is now installed.

Then proceed to Choosing where to store pokeemerald Expansion (Linux).

NixOS

Run the following command to start an interactive shell with the necessary packages:

nix-shell -p pkgsCross.arm-embedded.stdenv.cc git pkg-config libpng

Then proceed to Choosing where to store pokeemerald Expansion (Linux).

NixOS

Run the following command to start an interactive shell with the necessary packages:

nix-shell -p pkgsCross.arm-embedded.stdenv.cc git pkg-config libpng

Then proceed to Choosing where to store pokeemerald Expansion (Linux).

Other distributions

(Specific instructions for other distributions would be greatly appreciated!)

  1. Try to find the required software in its repositories:

    • gcc
    • g++
    • make
    • git
    • libpng-dev
  2. Follow the instructions here to install devkitPro pacman. As a reminder, the goal is to configure an existing pacman installation to recognize devkitPro's repositories.

  3. Once devkitPro pacman is configured, run the following commands:

    sudo pacman -Sy
    sudo pacman -S gba-dev

    The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation.

Installing Python in Linux

Installing Python depends on your distribution, please refere to the instructions here.

Choosing where to store pokeemerald Expansion (Linux)

At this point, you can choose a folder to store pokeemerald Expansion into. If so, you'll have to account for the modified folder path when changing directory to the pokeemerald-expansion folder.

If this works, then proceed to Installation. Otherwise, ask for help on Discord or IRC (see README.md).

Installation

Note for Windows users...

Consider adding an exception for the pokeemerald-expansion and/or decomps folder in Windows Security using these instructions. This prevents Microsoft Defender from scanning them which might improve performance while building.

  1. If pokeemerald Expansion is not already downloaded (some users may prefer to download pokeemerald Expansion via a git client like GitHub Desktop), run:

    git clone https://github.com/rh-hideout/pokeemerald-expansion
    Note for WSL1...

    If you get an error stating fatal: could not set 'core.filemode' to 'false', then run the following commands:

    cd
    sudo umount /mnt/c
    sudo mount -t drvfs C: /mnt/c -o metadata,noatime
    cd <folder where pokeemerald-expansion is to be stored>

    Where <folder where pokeemerald-expansion is to be stored> is the path of the folder where you chose to store pokeemerald Expansion. Then run the git clone command again.

Now you're ready to build pokeemerald Expansion.

Build pokeemerald Expansion

If you aren't in the pokeemerald-expansion directory already, then change directory to the pokeemerald-expansion folder:

cd pokeemerald-expansion

To build pokeemerald.gba (Note: to speed up builds, see Parallel builds):

make

If it has built successfully you will have the output file pokeemerald.gba in your project folder.

Note for Windows... > If you switched terminals since the last build (e.g. from msys2 to WSL1), you must run `make clean-tools` once before any subsequent `make` commands.

Building guidance

Parallel builds

See the GNU docs and this Stack Exchange thread for more information.

To speed up building, first get the value of nproc by running the following command:

nproc

Builds can then be sped up by running the following command:

make -j<output of nproc>

Replace <output of nproc> with the number that the nproc command returned.

nproc is not available on macOS. The alternative is sysctl -n hw.ncpu (relevant Stack Overflow thread).

Other toolchains

To build using a toolchain other than devkitARM, override the TOOLCHAIN environment variable with the path to your toolchain, which must contain the subdirectory bin.

make TOOLCHAIN="/path/to/toolchain/here"

The following is an example:

make TOOLCHAIN="/usr/local/arm-none-eabi"

To compile the modern target with this toolchain, the subdirectories lib, include, and arm-none-eabi must also be present.

Building with debug info

To build pokeemerald.elf with debug symbols under a modern toolchain:

make DINFO=1

Note that this is not necessary for a non-modern (agbcc) build since those are built with debug symbols by default.

agbcc

Deprecated; installing agbcc is optional since 1.7.0.
  1. Install agbcc into pokeemerald-expansion. The commands to run depend on certain conditions. You should only follow one of the listed instructions:
  • If agbcc has not been built before in the folder where you chose to store pokeemerald Expansion, run the following commands to build and install it into pokeemerald-expansion:

    git clone https://github.com/pret/agbcc
    cd agbcc
    ./build.sh
    ./install.sh ../pokeemerald-expansion
  • Otherwise, if agbcc has been built before (e.g. if the git clone above fails), but was last built on a different terminal than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pokeemerald-expansion:

    cd agbcc
    git clean -fX
    ./build.sh
    ./install.sh ../pokeemerald-expansion
  • Otherwise, if agbcc has been built before on the same terminal, run the following commands to install agbcc into pokeemerald-expansion:

    cd agbcc
    ./install.sh ../pokeemerald-expansion
    Note...

    If building agbcc or pokeemerald results in an error, try deleting the agbcc folder and re-installing agbcc as if it has not been built before.

  1. Once agbcc is installed, change directory back to the base directory where pokeemerald-expansion and agbcc are stored:

    cd ..
  2. To compile with agbcc:

    make agbcc

Useful additional tools