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:
Bash:
pacman -S --noconfirm switch-dev devkitA64 dkp-toolchain-vars libnx switch-tools switch-mesa switch-libdrm_nouveau switch-sdl2

And 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

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

Additional you need the packages git make lz4 for all to work, use the command:

Bash:
Pacman -Sy --noconfirm 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 if there are changes on LibNX you need to build it and install on your setup.
If you haven't done already, setup the environment variables

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

Never forget to create the environment variables for DevKitPro
Bash:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=/opt/devkitpro/devkitARM
export DEVKITPPC=/opt/devkitpro/devkitPPC

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.

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:
Sigpatch-IPS-Creator_1.5.7_Yandex.png





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

Attachments

  • 1695782853186.png
    1695782853186.png
    62.7 KB · Views: 55
  • 1695782902542.png
    1695782902542.png
    6.4 KB · Views: 56
Last edited by impeeza,

Muxi

Well-Known Member
Member
Joined
Jun 1, 2016
Messages
605
Trophies
0
Age
52
XP
2,130
Country
Germany
I'll give it a try and let you know how it went. Thanks for the support.
Post automatically merged:

Libnx was compiled correctly, but when compiling AMS the same error messages regarding the keys came again. However, AMS was still compiled correctly.
 

Attachments

  • compiling_libnx_and_atmosphere.txt
    153.6 KB · Views: 22
Last edited by Muxi,
  • Like
Reactions: impeeza

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,393
Trophies
3
Age
46
Location
At my chair.
XP
18,861
Country
Colombia
yeah, for building the latest Atmosphère you need the prod.keys with keys 0x10 on it, you could use lockPick 1.9.1 to generate them even if you SYSNAND and EmuNAND are on lower firmwares.
Post automatically merged:

Sorry 1.9.1 is now called PickLock
 
Last edited by impeeza,
  • Like
Reactions: Muxi

josete2k

Well-Known Member
Member
Joined
Apr 24, 2009
Messages
680
Trophies
1
Age
43
Location
Spain
XP
1,612
Country
Spain
I think the issue was on commit d9fff85

https://github.com/Atmosphere-NX/Atmosphere/commit/d9fff85bc4a3d5fa18e14d41ff853d0c16681b77

This was the error shown:

Code:
Z:/msys64/opt/devkitpro/libnx/include/switch/result.h:12: note: this is the location of the previous
 definition
   12 | #define R_FAILED(res)      ((res)!=0)
      |
make -C reboot_to_payload all
fusee_display.cpp
make[3]: Entering directory '/home/josete2k/atmosphere/troposphere/reboot_to_payload'
fssystem_block_cache_buffered_storage.cpp
gpu_console.c
ams_bpc.c
make[4]: *** No rule to make target '/home/josete2k/atmosphere/troposphere/haze/romfs/shaders/console_fsh.dksh', needed by '/home/josete2k/atmosphere/troposphere/haze/haze.nro'.  Stop.
make[4]: *** Waiting for unfinished jobs....
built ... haze.nacp
make[3]: *** [Makefile:182: build] Error 2
make[3]: Leaving directory '/home/josete2k/atmosphere/troposphere/haze'
make[2]: *** [Makefile:10: haze] Error 2
make[2]: *** Waiting for unfinished jobs....
main.c
built ... reboot_to_payload.nacp
linking reboot_to_payload.elf
Checked library.
Checking kernel...
built ... reboot_to_payload.nro

Now it seems solved with the lib I've linked before... Now compiling...
 
  • Love
Reactions: impeeza

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,393
Trophies
3
Age
46
Location
At my chair.
XP
18,861
Country
Colombia
I just create a clean MSYS environment and installed all packages listed on OP, switch-dev requires deko3d, so got installed on my system.

then I downloaded the file you referenced and compare bit to bit to the files installed on my new MSYS and are the same:

1697495146972.png


So maybe you had corrupted files or old ones.
 
  • Like
Reactions: josete2k

Muxi

Well-Known Member
Member
Joined
Jun 1, 2016
Messages
605
Trophies
0
Age
52
XP
2,130
Country
Germany
I have problems compiling Atmosphére again. Has anything changed in the procedure? I just tried to compile AMS 1.6.1 (6 commits) and got error messages at the end. Compiling AMS 1.6.1 (5 commits) still worked fine. I have to ask for help again. Thanks in advance for any feedback.

Code:
make[3]: *** [/opt/devkitpro/devkitA64/base_rules:16: fs_api.o] Error 1
make[2]: *** [/home/ML/Atmosphere/libraries/config//../libstratosphere/libstratosphere.mk:111: all] Error 2
make[1]: *** [/home/ML/Atmosphere/atmosphere.mk:152: libstratosphere] Error 2
make[1]: Leaving directory '/home/ML/Atmosphere'
make: *** [Makefile:39: nx_release] Error 2

PS:
What I had already tried so far was the following:
Msys2 started, as always at the beginning with a "pacman -Syu".
libnx folder deleted and recompiled (incl. git checkout 1700_support).
recompiled ams with "make" at the end instead of "make -j$(nproc)".

But this did not change the result (see attachment for details)
 

Attachments

  • compiling_ams.txt
    25.9 KB · Views: 16
Last edited by Muxi,

josete2k

Well-Known Member
Member
Joined
Apr 24, 2009
Messages
680
Trophies
1
Age
43
Location
Spain
XP
1,612
Country
Spain
I have problems compiling Atmosphére again. Has anything changed in the procedure? I just tried to compile AMS 1.6.1 (6 commits) and got error messages at the end. Compiling AMS 1.6.1 (5 commits) still worked fine. I have to ask for help again. Thanks in advance for any feedback.

Code:
make[3]: *** [/opt/devkitpro/devkitA64/base_rules:16: fs_api.o] Error 1
make[2]: *** [/home/ML/Atmosphere/libraries/config//../libstratosphere/libstratosphere.mk:111: all] Error 2
make[1]: *** [/home/ML/Atmosphere/atmosphere.mk:152: libstratosphere] Error 2
make[1]: Leaving directory '/home/ML/Atmosphere'
make: *** [Makefile:39: nx_release] Error 2

PS:
What I had already tried so far was the following:
Msys2 started, as always at the beginning with a "pacman -Syu".
libnx folder deleted and recompiled (incl. git checkout 1700_support).
recompiled ams with "make" at the end instead of "make -j$(nproc)".

But this did not change the result (see attachment for details)
git checkout erpt_fs_info
make install
 
  • Love
Reactions: impeeza

Muxi

Well-Known Member
Member
Joined
Jun 1, 2016
Messages
605
Trophies
0
Age
52
XP
2,130
Country
Germany
gitcheckout erpt_fs_info
make install
Thanks! At which point does the command have to be entered? I have made a list here so that I can always stick to the correct order.
Code:
1.
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH

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

3.
git checkout 1700_support

4.
make all

5.
make install

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

7.
cd Atmosphere

8.
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=/opt/devkitpro/devkitARM
export DEVKITPPC=/opt/devkitpro/devkitPPC

9.
make -j$(nproc)
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Veho
  • BakerMan
    I rather enjoy a life of taking it easy. I haven't reached that life yet though.
    Veho @ Veho: https://youtube.com/watch?v=Y23PPkftXIY