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,
all MSYS and start over.
alright
Post automatically merged:

all MSYS and start over.
do you have discord?
Post automatically merged:

all MSYS and start over.
$ pacman -S switch-dev
:: There are 13 members in group switch-dev:
:: Repository dkp-libs
1) catnip 2) deko3d 3) devkita64-cmake 4) libnx 5) switch-cmake 6) switch-examples
7) switch-pkg-config
:: Repository dkp-windows
8) devkit-env 9) devkitA64 10) devkitA64-gdb 11) general-tools 12) switch-tools 13) uam

Enter a selection (default=all):
warning: devkit-env-1.0.1-2 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (15) devkita64-rules-1.1.1-1 dkp-cmake-common-utils-1.5.2-1 catnip-0.1.0-1
deko3d-0.5.0-1 devkit-env-1.0.1-2 devkitA64-r27-2 devkitA64-gdb-14.1-1
devkita64-cmake-1.1.2-1 general-tools-1.4.4-1 libnx-4.7.0-1 switch-cmake-1.5.1-1
switch-examples-20231028-1 switch-pkg-config-0.28-4 switch-tools-1.12.0-1
uam-1.1.0-2

Total Download Size: 0.77 MiB
Total Installed Size: 426.32 MiB
Net Upgrade Size: 426.32 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
switch-cmake-1.5.1-1-any 5.7 KiB 43.7 KiB/s 00:00 [###############################] 100%
dkp-cmake-common-utils-1.5... 8.0 KiB 45.5 KiB/s 00:00 [###############################] 100%
switch-examples-20231028-1-any 770.1 KiB 1217 KiB/s 00:01 [###############################] 100%
Total (3/3) 783.9 KiB 722 KiB/s 00:01 [###############################] 100%
(15/15) checking keys in keyring [###############################] 100%
(15/15) checking package integrity [###############################] 100%
error: dkp-cmake-common-utils: signature from "fincs <[email protected]>" is unknown trust
:: File /var/cache/pacman/pkg/dkp-cmake-common-utils-1.5.2-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] n
error: switch-cmake: signature from "fincs <[email protected]>" is unknown trust
:: File /var/cache/pacman/pkg/switch-cmake-1.5.1-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] n
error: switch-examples: signature from "fincs <[email protected]>" is unknown trust
:: File /var/cache/pacman/pkg/switch-examples-20231028-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] n
error: failed to commit transaction (invalid or corrupted package)
Errors occurred, no packages were upgraded.
 
Last edited by Bosstendo97,
For those that are having trouble with getting lz4 installed - no need to reinstall, you only need to do this:

First remove all python installs and dependencies:

Pacman -Rsc python
Now install python and python-pip:

Pacman -Sy python python-pip
Once they are installed, create an environment so you can use pip to install lz4:

python -m venv my-venv
my-venv/bin/pip install lz4

At this point you can just copy lz4 folder and lz4-4.3.3.dist-info folder from:

C:\msys64\home\MrDude\my-venv\lib\python3.12\site-packages
to
C:\msys64\usr\lib\python3.12\site-packages

Now anytime you want to use pip to install a package you can use:

my-venv/bin/pip install somepackage

Then just copy it into your site packages. That should save those that are having issues a lot of time.
 
someone having problems to build latets atmosphere 1900_support ? Yesterday I try to build it again, but now console won't boot, only show atmo logo for 1 sec and black screen... I already update libnx to 1900_support too. Any tip?
 
  • Like
Reactions: impeeza and ELY_M
Them is something Michael won't commit on GH yet... i was wondering is my MSYS2 setup broken

From this message:

you need new tool and set flag. npdmtool.exe has a pull request for the needed change. Or you can wait for @impeeza who is coming back soon.
"allow_debug": false,
"force_debug_prod": false, <= add this line
"force_debug": true
Attached switch-tools
 

Attachments

I have same issue with black screen after I built with latest libnx (the 1900 support one)
I hope the last post before me will help. Thank you
 
Stay safe out there sir 🤙🏽

someone having problems to build latets atmosphere 1900_support ? Yesterday I try to build it again, but now console won't boot, only show atmo logo for 1 sec and black screen... I already update libnx to 1900_support too. Any tip?

Same here

Sure.

The first commits of 1900_support were compiling and working fine even without the libnx update.

From this message:


Attached switch-tools
Hello there fellow tempers, I am just returning to my home. I am tired as hell.

@josete2k you are completely right, normally when a new firmware is released @SciresM also pull request to LibNX needed for the new Atmosphère get built, and on this case even he made a PR to npdmtool, I am looking what lots of homebrew will need to be rebuilt and modify the source, by example, for SYS-PATCH the sys-patch.json file needs to add:


1728958574693.png

Post automatically merged:

On this case SciresM also pull a request on Switch-Tools DevKitPro package https://github.com/switchbrew/switch-tools/pull/47 this change on the Firmware 19 kernel make what «force_debug/force_debug_prod/allow_debug» properties are now mutually exclusive (enforced by kernel), so most of the SYSMODULES will be needed to build again after changing the SYSMODULE.json file to be sure only one of the possible values have true value and if the file is missing one or more, be sure have the three values, by example:


C++:
"kernel_capabilities":    [{
            "type":    "debug_flags",
            "value":    {
               "allow_debug":    false,
               "force_debug_prod":   false,
               "force_debug":    true
            }

So far Sys-Patch Sysmodule was needed to rebuilt, @miniminx published a build on the Sys-Patch Sysmodule thread.
 
Last edited by impeeza,
alright
Post automatically merged:


do you have discord?
Post automatically merged:


$ pacman -S switch-dev
:: There are 13 members in group switch-dev:
:: Repository dkp-libs
1) catnip 2) deko3d 3) devkita64-cmake 4) libnx 5) switch-cmake 6) switch-examples
7) switch-pkg-config
:: Repository dkp-windows
8) devkit-env 9) devkitA64 10) devkitA64-gdb 11) general-tools 12) switch-tools 13) uam

Enter a selection (default=all):
warning: devkit-env-1.0.1-2 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (15) devkita64-rules-1.1.1-1 dkp-cmake-common-utils-1.5.2-1 catnip-0.1.0-1
deko3d-0.5.0-1 devkit-env-1.0.1-2 devkitA64-r27-2 devkitA64-gdb-14.1-1
devkita64-cmake-1.1.2-1 general-tools-1.4.4-1 libnx-4.7.0-1 switch-cmake-1.5.1-1
switch-examples-20231028-1 switch-pkg-config-0.28-4 switch-tools-1.12.0-1
uam-1.1.0-2

Total Download Size: 0.77 MiB
Total Installed Size: 426.32 MiB
Net Upgrade Size: 426.32 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
switch-cmake-1.5.1-1-any 5.7 KiB 43.7 KiB/s 00:00 [###############################] 100%
dkp-cmake-common-utils-1.5... 8.0 KiB 45.5 KiB/s 00:00 [###############################] 100%
switch-examples-20231028-1-any 770.1 KiB 1217 KiB/s 00:01 [###############################] 100%
Total (3/3) 783.9 KiB 722 KiB/s 00:01 [###############################] 100%
(15/15) checking keys in keyring [###############################] 100%
(15/15) checking package integrity [###############################] 100%
error: dkp-cmake-common-utils: signature from "fincs <[email protected]>" is unknown trust
:: File /var/cache/pacman/pkg/dkp-cmake-common-utils-1.5.2-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] n
error: switch-cmake: signature from "fincs <[email protected]>" is unknown trust
:: File /var/cache/pacman/pkg/switch-cmake-1.5.1-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] n
error: switch-examples: signature from "fincs <[email protected]>" is unknown trust
:: File /var/cache/pacman/pkg/switch-examples-20231028-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] n
error: failed to commit transaction (invalid or corrupted package)
Errors occurred, no packages were upgraded.
Sorry never got the notification of this post.

I have discord, but almos never open it. so you will get me more easy here.

on the two first weeks of october Github made changes and the keys become invalid, they solved the problem last week.
Post automatically merged:

On november of 2024, just must take in account: The most recent LibNX commit is needed. So BEFORE built Atmosphère but after installing all packages you need to run this commands:

Bash:
cd ~
git clone --recursive https://github.com/Atmosphere-NX/libnx.git -b 1900_support
cd libnx
make install -j$(nproc)

This clone the LibNX repo from Atmosphère's team using the branch for 1900 support and install it on your environment.

After this you can continue to build Atmosphère.

I am running a build process just now and no error at all.

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.
 
Last edited by impeeza,
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.
These files also contain "xrange":
  • Atmosphere\utilities\erpt.py
  • Atmosphere\utilities\nxo64.py
Is it enough to just change "xrange" to "range" there as well or do the code in those files need additional adjustments?
 
These files also contain "xrange":
  • Atmosphere\utilities\erpt.py
  • Atmosphere\utilities\nxo64.py
Is it enough to just change "xrange" to "range" there as well or do the code in those files need additional adjustments?
So far, manually changing Xrange for range has been working fine for me.
 
  • Like
Reactions: hetop
These files also contain "xrange":
  • Atmosphere\utilities\erpt.py
  • Atmosphere\utilities\nxo64.py
Is it enough to just change "xrange" to "range" there as well or do the code in those files need additional adjustments?

What do those two files do exactly? I only edited update_mtc_tables.py & update_sdram_params.py. I didn't edit the two you listed and have had no problems at all. I assume those two would be mentioned in the guide if it was necessary to edit them.
 
What do those two files do exactly? I only edited update_mtc_tables.py & update_sdram_params.py. I didn't edit the two you listed and have had no problems at all. I assume those two would be mentioned in the guide if it was necessary to edit them.
I really do not know, they are big python scripts, and my python knowledge is very low. so I haven't take the time to explore them in deep.
 
I really do not know, they are big python scripts, and my python knowledge is very low. so I haven't take the time to explore them in deep.

I think perhaps they don't need to be changed. Wouldn't compiling throw an error if it was necessary for those two to be edited?
 

Site & Scene News

Popular threads in this forum