Building Atmosphère on Windows using MSYS2

Sometimes you need to build the binaries for Atmosphère, or you want to change something on the source code, for building your starting point should be: https://github.com/Atmosphere-NX/Atmosphere/blob/master/docs/building.md
On that document you can read:
Building Atmosphère is a very straightforward process that relies almost exclusively on tools provided by the devkitPro organization.​
Dependencies:
  • devkitA64
  • devkitARM
  • Python 2 (Python 3 may work as well, but this is not guaranteed)
  • LZ4
  • PyCryptodome (optional)
  • Hactool
Setup a DevKitPro environment: (https://devkitpro.org/wiki/Getting_Started)
Install the following packages via (dkp-)pacman:​
  • switch-dev
  • switch-glm
  • switch-libjpeg-turbo
  • devkitARM
  • devkitarm-rules
  • hactool
Install the following library via python's package manager pip, required by exosphere:​
  • lz4
Finally, clone the Atmosphère repository and run make under its root directory.​

That instructions are a little plain for we the noobs.

First you need Install a MSYS environment:
The latest instructions for install the MSYS environment are on https://gbatemp.net/threads/install-msys-environment.652234/ if you don't have one working, use them.

After you have the MSYS environment working you need to install DevKitPro
For that you can follow the instructions on the tutorial https://gbatemp.net/threads/setup-a-devkitpro-environment-on-windows.652238/

Now you can install DevKitPro packages:

You Need base DevKitPro packages:
Bash:
pacman -S --noconfirm switch-dev devkitA64 dkp-toolchain-vars libnx switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2

And the Atmosphère prerequisites
Bash:
Pacman -Sy --noconfirm devkitA64 devkitARM devkitarm-rules hactool mingw-w64-x86_64-python mingw-w64-x86_64-python-lz4 mingw-w64-x86_64-python-pycryptodome switch-dev switch-glm switch-libjpeg-turbo mingw-w64-x86_64-python-pip

I had to add zip package because even if wasn't explicit indicated on the build page, the code needs it.

You also will need the packages git make lz4 for all to work, use the command:

Bash:
Pacman -Sy --noconfirm zip git make lz4


All packages on a combined command:​

Bash:
pacman -S --noconfirm switch-dev devkitA64 dkp-toolchain-vars libnx switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2 devkitA64 devkitARM devkitarm-rules hactool mingw-w64-x86_64-python mingw-w64-x86_64-python-lz4 mingw-w64-x86_64-python-pycryptodome switch-dev switch-glm switch-libjpeg-turbo mingw-w64-x86_64-python-pip zip git make lz4


The package hactool need you to copy your own prod.keys file on $HOME/.switch folder. (c:\msys64\home\USERNAME\.switch if you use the default installation folder)


LibNX Dependency
Atmosphère depends heavily on LibNX, generally when a major version of firmware is released or great changes on the code are made, changes to LibNX are also made.
The Atmosphère team works on their own repo of LibNX (https://github.com/Atmosphere-NX/libnx) and forward Pull Request to official SwitchBrew LibNX repo (https://github.com/switchbrew/libnx).


So ONLY if there are changes on LibNX repository, no yet committed to DevKitPro release, you need to build it and install on your setup.
If you haven't done already, setup the environment variables
You can test it running the command
export
You should have this:
Bash:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH


Then go to the Atmosphere-NX/LibNX repo and look what is the new branch for the current firmware, by example, for Firmware 16.0.0 the branch name is "1600_Support"

1677718224337.png

Then go to your MSYS MinGW64 window and clone the Atmosphere-NX/LibNX repo

Bash:
cd ~
git clone --recursive https://github.com/Atmosphere-NX/libnx.git
cd libnx

And checkout the needed branch:

Bash:
git checkout 1600_support

Then build and install the new LibNX libraries

Bash:
make install -j$(nproc)

Now you can build Atmosphère with latest LibNX code; remember if you update the pacman LibNX package the changes get reversed and you need to build LibNX again.

Now is time to build the binaries
Clone the repository:
Bash:
cd ~
git clone --recursive https://github.com/Atmosphere-NX/Atmosphere

Go to new created Atmosphère folder
Bash:
cd Atmosphere

Be sure you have defined the environment variables for DevKitPro
You can test it running the command
export
You should have this:
Bash:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH


COPY YOUR PROD.KEYS FILE TO THE .SWITCH FOLDER:

Copy prod.keys file on $HOME/.switch
Bash:
mkdir ~/.switch
cp "c:\YOUR\CURRENT\PATH\TO\KEYS\PROD.KEYS" ~/.switch/prod.keys

In the case of MSYS for using localhost paths you must use "" by example in my case I use the commands:
Bash:
mkdir ~/.switch
cp "z:\Emulation\NSwitch\keys\switch\prod.keys" ~/.switch/prod.keys

Obviously you also can copy the file manually on windows to the equivalent path to ~/.switch/ which by default is c:\msys\home\USERNAME\.switch Where c:\msys is the installation folder and USERNAME is the current name for the user.


Atmosphère is a Python 2 project, even when python 2 has been deprecated by almost 5 years now. some * insist on never update it so as far as that is going, you need to change some files in order to work on python 3, on the files:
  • Atmosphere\fusee\program\update_mtc_tables.py
  • Atmosphere\fusee\program\update_sdram_params.py
The function XRANGE must to be changed to RANGE, edit the files and change xrange( to range( save the files and continue.

And now you are ready to start the building process:
Bash:
make -j$(nproc)

I do use the "-j$(nproc)" parameter to "bleed" all the available CPU to run the compiler, without that the whole process could take up to 1 hour.

Also Note:, if you use make -j is possible a Error 2 can be generated, run make again without parameters. The process will continue where failed, since the two latest versions of DevKitPro using the -j parameters is not synced and the make process can fail by timeouts.


I want to thank a lot to @binkinator and @godreborn for all the help and inspiration to make this guide, and want to ask you for help improving this guide.

Also special thanks to @godreborn for been a support of the users replies and suggestions to the OP.

Remember, as you are getting a new set of binaries, you need new set of sigpatches if you use it. So the great tool from @mrdude comes in hand, the latest release can be downloaded from: https://github.com/mrdude2478/IPS_Patch_Creator/releases/; you use the program to generate a new set of patches for your recently build package3 file.


Latest IPS Patch Creator:
https://gbatemp.net/download/ips-patch-creator-1-5-9.38850/




-Edited: add sigpatches step and clean up a little-
-Edit 2, add LibNX build-
 

Attachments

  • 1695782853186.png
    1695782853186.png
    62.7 KB · Views: 217
  • 1695782902542.png
    1695782902542.png
    6.4 KB · Views: 206
  • Sigpatch-IPS-Creator_1.5.7_Yandex.png
    Sigpatch-IPS-Creator_1.5.7_Yandex.png
    3.3 KB · Views: 136
Last edited by impeeza,
git checkout gcc-14


This should fix it.
I would like to compile the latest AMS build. Could you please tell me the exact commands on how to compile libnx?

So far I have used these commands, but you write something about gcc-14. How do I add this?

Code:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH

Code:
cd ~
git clone --recursive https://github.com/Atmosphere-NX/libnx.git
cd libnx

Code:
git checkout 1800_basic

Code:
make install -j$(nproc)
 
I would like to compile the latest AMS build. Could you please tell me the exact commands on how to compile libnx?

So far I have used these commands, but you write something about gcc-14. How do I add this?

Code:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH

Code:
cd ~
git clone --recursive https://github.com/Atmosphere-NX/libnx.git
cd libnx

Code:
git checkout 1800_basic

Code:
make install -j$(nproc)
I am trying just now let me finish and will tell you the results
Post automatically merged:

OK, this are the steps I tried:

On a completely new installed and fresh MSYS2 environment using MSYS:

#INSTALL PREREQUISITE PACKAGES
Bash:
Pacman -Syuu --noconfirm --needed zip git make lz4 libnx devkitA64 devkitARM devkitarm-rules hactool switch-dev dkp-toolchain-vars switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2 switch-libjpeg-turbo switch-glm gcc python python-pip
pip install lz4 pycryptodome

# UPGRADE LIBNX TO LATEST CODE BY SCIRESM APPLYING THE PR # 641
Bash:
cd ~
rm -rf ~/libnx
git clone --recursive https://github.com/switchbrew/libnx.git
cd ~/libnx
git fetch origin pull/641/head
git checkout -b pullrequest FETCH_HEAD
make all -j$(nproc)
make install -j$(nproc)


#YOU NEED TO PROVIDE YOUR OWN PROD.KEYS AND PUT THEM ON THE ~/.switch FOLDER as prod.keys file
Bash:
mkdir ~/.switch
cp "YOURPROD.KEYS" ~/.switch/prod.keys

#Build Atmosphère code using the Branch gcc-14
Bash:
cd ~
git clone --recursive https://github.com/Atmosphere-NX/Atmosphere
cd ~/Atmosphere
git checkout gcc-14
make

Sadly didn't worked for me, I got these errors:


1717095495529.png



1717095487844.png

I am going to attach this images on the Issue.
 
Last edited by impeeza,
  • Like
Reactions: josete2k and Muxi
Same here
SciresM answered:

... that branch requires gcc 14 devkitA64, which has not been released. I have not closed this issue or merged that code for that reason.


So far we only can wait or try to build a old commit of Atmosphère.


SciresM Thanks a lot for all your great work and for being so willing to help
 
  • Like
Reactions: Muxi and josete2k
On a completely new installed and fresh MSYS2 environment using MSYS:
I had already reinstalled Msys2 with all requirements, because I didn't know that compiling Atmosphere is currently not possible due to the missing devkitA64 update and I assumed that something was wrong with my Msys2 installation, as it was the case back then. But this time it's not because of my Msys2 installation. Too bad it's not working yet.
Post automatically merged:


@impeeza @josete2k
devkitA64 has been updated! Compiling atmosphere is working now!!
 
Last edited by Muxi,
Yes.

devkitA64-r26-1

trying to build latest atmosphère and libnx to see.

Using latest release of DevKitA64 And running this commands worked for me:


# First be sure you have this environmental variables
Bash:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH

# Install all needed packages, on MinGW you need:
Bash:
Pacman -Syuu --noconfirm --needed zip git make lz4 libnx devkitA64 devkitARM devkitarm-rules hactool switch-dev dkp-toolchain-vars switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2 switch-libjpeg-turbo switch-glm mingw-w64-x86_64-python mingw-w64-x86_64-python-lz4 mingw-w64-x86_64-python-pycryptodome mingw-w64-x86_64-python-pip


## or for MSYS (and most linux environments)
Bash:
Pacman -Syuu --noconfirm --needed zip git make lz4 libnx devkitA64 devkitARM devkitarm-rules hactool switch-dev dkp-toolchain-vars switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2 switch-libjpeg-turbo switch-glm gcc python python-pip
pip install lz4 pycryptodome


# Build latest LibNX
Bash:
cd ~
rm -rf ~/libnx
git clone --recursive https://github.com/switchbrew/libnx.git
cd ~/libnx
make all -j$(nproc)
make install -j$(nproc)


# YOU NEED TO PROVIDE YOUR OWN PROD.KEYS AND PUT THEM ON THE ~/.switch FOLDER as prod.keys file
Bash:
mkdir ~/.switch
cp "YOURPROD.KEYS" ~/.switch/prod.keys

# Build Atmosphère code using the Branch gcc-14 (for me using «make -j» generate errors, I think my machine is no fast enough)
Bash:
cd ~
git clone --recursive https://github.com/Atmosphere-NX/Atmosphere
cd ~/Atmosphere
git merge origin/gcc-14
make

This generate:
atmosphere-1.7.0-gcc-14-f4541cc83.zip

1717274246828.png


---
Edited, LIBNX repo have the PR merged so you only need to build it
 
Last edited by impeeza,
I'm still not able to compile Atmosphere using the latest DevKitPro
It fails on nx_release

Never had a problem until this latest DevKitPro

Build Atmosphere
Code:
$ cd ~
git clone --recursive https://github.com/Atmosphere-NX/Atmosphere
cd ~/Atmosphere
git merge origin/gcc-14
make

Cloning into 'Atmosphere'...
remote: Enumerating objects: 71655, done.
remote: Counting objects: 100% (448/448), done.
remote: Compressing objects: 100% (275/275), done.
remote: Total 71655 (delta 189), reused 400 (delta 169), pack-reused 71207
...
...
...................................<snip long list of files being processed for about 10 minutes>
...
...
C:/msys64/home/datalogger/Atmosphere/fusee/program/source/sdram/fusee_sdram.cpp:1012:58: error: right shi
ft count >= width of type [-Werror=shift-count-overflow]
 1012 |                             cur_reg_value |= ((src_value >> (SrcLow - DstLow)) & Mask);
   \
      |                                                ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
C:/msys64/home/datalogger/Atmosphere/fusee/program/source/sdram/fusee_sdram.cpp:1020:80: note: in expansi
on of macro 'PROCESS_IMPL'
 1020 |                 #define PROCESS_COMMON_SCRATCH(PARAM, S, SRC_RANGE, DST_RANGE) PROCESS_IMPL(
PARAM, SCRATCH##S, SRC_RANGE, DST_RANGE, false)
      |                                                                                ^~~~~~~~~~~~
C:/msys64/home/datalogger/Atmosphere/fusee/program/source/sdram/fusee_sdram.cpp:1047:17: note: in expansi
on of macro 'PROCESS_COMMON_SCRATCH'
 1047 |                 PROCESS_COMMON_SCRATCH(PllMStableTime, 4, 21:0, 31:10);
      |                 ^~~~~~~~~~~~~~~~~~~~~~
cc1plus.exe: all warnings being treated as errors
make[4]: *** [/opt/devkitpro/devkitARM/base_rules:34: fusee_sdram.o] Error 1
make[3]: *** [/home/datalogger/Atmosphere/fusee/program/program.mk:54: all] Error 2
make[2]: *** [/home/datalogger/Atmosphere/fusee/fusee.mk:29: check_program] Error 2
make[1]: *** [/home/datalogger/Atmosphere/atmosphere.mk:124: fusee] Error 2
make[1]: Leaving directory '/home/datalogger/Atmosphere'
make: *** [Makefile:39: nx_release] Error 2
 
Last edited by Datalogger,
humm strange, I just finished building two versions of Atmosphère, official latest code and modified code to re-enable FS patches loading:

1717295527375.png



The commands I used:

Bash:
date
Pacman -Syuu --noconfirm --needed zip git make lz4 libnx devkitA64 devkitARM devkitarm-rules hactool switch-dev dkp-toolchain-vars switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2 switch-libjpeg-turbo switch-glm mingw-w64-x86_64-python mingw-w64-x86_64-python-lz4 mingw-w64-x86_64-python-pycryptodome mingw-w64-x86_64-python-pip

cd ~
rm -rf ~/libnx
git clone --recursive https://github.com/switchbrew/libnx.git
cd ~/libnx
make all -j$(nproc)
make install -j$(nproc)


mkdir ~/.switch
cp "z:\Nintendo Switch\prod_2024_03_28-SYS.keys" ~/.switch/prod.keys

cd ~
rm -rf ~/Atmosphere

git clone --recursive https://github.com/Atmosphere-NX/Atmosphere
cd ~/Atmosphere

git config user.email "[email protected]"
git config user.name impeeza
git merge -m "merge gcc-14 changes" origin/gcc-14
make

date


for the FS patching I edited the fusee/program/source/fusee_stratosphere.cpp file
Post automatically merged:

Closing the Issue on the Atmosphère repository

https://github.com/Atmosphere-NX/Atmosphere/issues/2330
 
Last edited by impeeza,
  • Like
Reactions: Datalogger
humm strange, I just finished building two versions of Atmosphère, official latest code and modified code to re-enable FS patches loading:..
After capturing the output and reading it line-for-line, I saw that my email address was failing to be recognized causing the merge to fail.
It seems Github no longer allows my old junk email server to be used so I had to update to a new one and all is working again!

Thanks @impeeza for the hint!
 
  • Love
Reactions: impeeza
Just a Heads Up, @SciresM just updated the master to include the gcc-14 fork so merging is no longer needed.
It now compiles clean like normal.
1717308138556.png

Post automatically merged:

With latest commits you only need:


Bash:
date
Pacman -Syuu --noconfirm --needed zip git make lz4 libnx devkitA64 devkitARM devkitarm-rules hactool switch-dev dkp-toolchain-vars switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2 switch-libjpeg-turbo switch-glm mingw-w64-x86_64-python mingw-w64-x86_64-python-lz4 mingw-w64-x86_64-python-pycryptodome mingw-w64-x86_64-python-pip

cd ~
rm -rf ~/libnx
git clone --recursive https://github.com/switchbrew/libnx.git
cd ~/libnx
make all -j$(nproc)
make install -j$(nproc)


mkdir ~/.switch
cp "z:\Nintendo Switch\prod_2024_03_28-SYS.keys" ~/.switch/prod.keys

cd ~
rm -rf ~/Atmosphere

git clone --recursive https://github.com/Atmosphere-NX/Atmosphere
cd ~/Atmosphere
make

date


(no need to merge)
 
Last edited by impeeza,

Site & Scene News

Popular threads in this forum