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: 48
  • 1695782902542.png
    1695782902542.png
    6.4 KB · Views: 50
Last edited by impeeza,

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,345
Trophies
3
Age
46
Location
At my chair.
XP
18,663
Country
Colombia
View attachment 327265

Always get this!
WTF am I doing wrong???

Did everything step by step, and also deleted everything completely and installed again!

I need help please! :(

Took me a while to get the free time to test.

I did remove all the Python and MSYS from my computer.

Follow the steps on the OP one by one and the only thing needed to change was: you need the packages git make lz4 what normally you have, but are not installed by default.

Think you error is your are missing the switch-libjpeg-turbo package.

after removing the package from my system I do get the same error:
1663371765095.png


My instructions are for using MSYS2, but think you are using WSL I really never use that environment and do not if the packages are installed the same.
 

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
Took me a while to get the free time to test.

I did remove all the Python and MSYS from my computer.

Follow the steps on the OP one by one and the only thing needed to change was: you need the packages git make lz4 what normally you have, but are not installed by default.

Think you error is your are missing the switch-libjpeg-turbo package.

after removing the package from my system I do get the same error:
View attachment 327499

My instructions are for using MSYS2, but think you are using WSL I really never use that environment and do not if the packages are installed the same.
They should be identical iirc on wsl. I think lz4 is installed through pip, so make sure you have that installed.
 

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
yep, lz4 for python is installed by pip, but on MSYS you use the pacman package mingw-w64-x86_64-python-lz4 which install all needed.
I think that might be a difference, but it's been a while since I compiled atmosphere. It's possible to compile it in cmd prompt. It was quite intensive on my laptop, as much as when I compiled sm64 for Android. My computer was sluggish as hell.
 
  • Haha
Reactions: impeeza

BeckysFootSlave

Well-Known Member
Newcomer
Joined
Jan 4, 2022
Messages
52
Trophies
0
Age
50
XP
665
Country
Germany
@impeeza
Right I used the windows cmd!

I did every step in Msys2 ming64 shell and just changed to cmd because till the step download atmosphere repository = I get error in msys saying "git" is no command
Also cd atmosphere = cd is no command

OMG I am so lost
How did you get there:
Screenshot_20220917_180357_Chrome.jpg

Msys2 icon ~/atmosphere
I just have the Msys2 icon with tilde (~), because I don't know how to change into the directory? 😭

That's the only reason I fired up windows cmd!

This here are the environmental systemvariables settings!
Screenshot 2022-09-17 171135.png
Screenshot 2022-09-17 171220.png
Screenshot 2022-09-17 171251.png


EDIT: I did everything step by step with Msys2 ming64 till the point = get, but get = no command

Then every step with Msys2 (start > DevKit64 > msys2
Again till the point = get = no command

Then I did anything again with cmd as admin
Everything worked and I can use any command like git, cd and make, but as before I get the error!
WTF anything is installed, ANYTHING!!!

All three "consoles" tell me the same and anything I need is installed with 100% at the end of any line!

EDIT2: Now it works on the Msys2 ming64 console window!
Keep you updated (saw an error and will ask for that!)
 
Last edited by BeckysFootSlave,
  • Like
Reactions: impeeza

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,345
Trophies
3
Age
46
Location
At my chair.
XP
18,663
Country
Colombia
Excellent, yes the guide was written for MSYS, MSYS is a encapsulated environment, and all is installed inside, you don need external programs or deal with others installations.

That's why I do preffer MSYS over native windows packages.

I will start to test compilation on WSL but I am not so fan of it neither.
 

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
you need to add environmental variables to the .bashrc for msys and wsl, not the normal windows way. that's only for devkitpro and the like through cmd prompt. it will have something like export EVNAME=location or you can do a path=EVNAME:$PATH (this is usually for bin locations so it can access commands. that might be why your commands weren't working.
 
  • Love
Reactions: impeeza

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
btw, .bashrc is in the home directory. you can do it manually by opening it normally or at least in linux you can use nano, which requires admin privileges. I'm not sure how to grant them in msys, but in linux it's usually sudo.
 
  • Love
Reactions: impeeza

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
put those environmental variables at the very bottom of the .bashrc. I know that some of those commands, if not all of them, will not work in cmd prompt either if you don't have them set up in environmental variables (not the path way but the environmental itself). that's how computer knows where your sdk is located. it's always going to be the same name for all things that use that sdk. devkitpro is like a catch all for most Nintendo systems, so it's much easier than say playstation where there's a separate sdk for each system, sometimes multiple sdks depending on the app you're trying to build. pita tbh.
 

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
btw, if you mess up any environmental setting, even ones that have nothing to do with the command you entered, no command will work, so make sure they're set up correctly. I've made that error myself on linux.
 
  • Like
Reactions: impeeza

hetop

Member
Newcomer
Joined
May 31, 2021
Messages
19
Trophies
0
Age
32
XP
564
Country
Norway
I know that when creating sigpatches I only need to use a couple of the keys in the prod.keys file and rename that file to keys.dat, so I'm wondering if it's the same here, if there's a specific prod.keys template I must follow or if I can just import the whole prod.keys file I create with Lockpick_RCM and use that?
 
  • Like
Reactions: impeeza

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,345
Trophies
3
Age
46
Location
At my chair.
XP
18,663
Country
Colombia
I know that when creating sigpatches I only need to use a couple of the keys in the prod.keys file and rename that file to keys.dat, so I'm wondering if it's the same here, if there's a specific prod.keys template I must follow or if I can just import the whole prod.keys file I create with Lockpick_RCM and use that?
yes you can, the GUI only is a convenient way to edit the needed file.
 

hetop

Member
Newcomer
Joined
May 31, 2021
Messages
19
Trophies
0
Age
32
XP
564
Country
Norway
I get some warnings that it failed to match some of the keys. I'm not sure I should share them or not, so I've changed them to "censored". If I google the value that pops up in the warning, I can find a page on Github with prod.keys where all of the values match the ones on the warning I received, but when I check my own prod.keys, the values there are different from what I received in the warning. Should I exchange my prod.keys file with the one on Github, or should I add my own values to the Atmosphere folder somehow?

b0crypto_aes_impl.arch.arm64.cpp
3")
[Wkern_k_synchronization_object.cpp
ARN]: kern_k_system_control_base.cpp
[WARN]: Failed to match key "bis_key_source_00", (value "censored")
[WARN]: Failed to match key "bis_key_source_01", (value "censored")
[WARN]: Failed to match key "bis_key_source_02", (value "censored")
[WARN]: Failed to match key "device_key", (value "censored")
[WARN]: Failed to match key "device_key_4x", (value "censored")
[WARN]: Failed to match key "eticket_rsa_kek", (value "censored")
[WARN]: Failed to match key "eticket_rsa_kek_source", (value "censored")
[WARN]: Failed to match key "eticket_rsa_kekek_source", (value "censored")
[WARN]: Failed to match key "eticket_rsa_keypair", (value "censored")
[WARN]: Failed to match key "mariko_master_kek_source_05", (value "censored")
[WARN]: Failed to match key "retail_specific_aes_key_source", (value "censored")
[WARN]: Failed to match key "rsa_oaep_kek_generation_source", (value "censored")
[WARN]: Failed to match key "rsa_private_kek_generation_source", (value "censored")
[WARN]: Failed tcrypto_ctr_mode_impl.arch.arm64.cpp
o match key "save_mac_key", (value "censored")
[WARN]: Failed to match key "save_mac_sd_card_kek_source", (value "censored")
[WARN]: Failed to match key "save_mac_sd_card_key_source", (value "censored")
[WARN]: Failed to match key "sd_card_custom_storage_key_source", (value "censored")
[WARN]:crypto_gcm_mode_impl.arch.arm64.cpp
crypto_sha1_impl.arch.arm64.cpp
crypto_sha256_impl.arch.arm64.cpp
 
  • Like
Reactions: impeeza

binkinator

Garfield’s Fitness Coach
Member
GBAtemp Patron
Joined
Mar 29, 2021
Messages
6,511
Trophies
2
XP
6,155
Country
United States
I get some warnings that it failed to match some of the keys. I'm not sure I should share them or not, so I've changed them to "censored". If I google the value that pops up in the warning, I can find a page on Github with prod.keys where all of the values match the ones on the warning I received, but when I check my own prod.keys, the values there are different from what I received in the warning. Should I exchange my prod.keys file with the one on Github, or should I add my own values to the Atmosphere folder somehow?

b0crypto_aes_impl.arch.arm64.cpp
3")
[Wkern_k_synchronization_object.cpp
ARN]: kern_k_system_control_base.cpp
[WARN]: Failed to match key "bis_key_source_00", (value "censored")
[WARN]: Failed to match key "bis_key_source_01", (value "censored")
[WARN]: Failed to match key "bis_key_source_02", (value "censored")
[WARN]: Failed to match key "device_key", (value "censored")
[WARN]: Failed to match key "device_key_4x", (value "censored")
[WARN]: Failed to match key "eticket_rsa_kek", (value "censored")
[WARN]: Failed to match key "eticket_rsa_kek_source", (value "censored")
[WARN]: Failed to match key "eticket_rsa_kekek_source", (value "censored")
[WARN]: Failed to match key "eticket_rsa_keypair", (value "censored")
[WARN]: Failed to match key "mariko_master_kek_source_05", (value "censored")
[WARN]: Failed to match key "retail_specific_aes_key_source", (value "censored")
[WARN]: Failed to match key "rsa_oaep_kek_generation_source", (value "censored")
[WARN]: Failed to match key "rsa_private_kek_generation_source", (value "censored")
[WARN]: Failed tcrypto_ctr_mode_impl.arch.arm64.cpp
o match key "save_mac_key", (value "censored")
[WARN]: Failed to match key "save_mac_sd_card_kek_source", (value "censored")
[WARN]: Failed to match key "save_mac_sd_card_key_source", (value "censored")
[WARN]: Failed to match key "sd_card_custom_storage_key_source", (value "censored")
[WARN]:crypto_gcm_mode_impl.arch.arm64.cpp
crypto_sha1_impl.arch.arm64.cpp
crypto_sha256_impl.arch.arm64.cpp
Good job on censoring Ninty Intellectual Property. It is not allowed here. 👍

You can safely ignore those WARN…only ERR matters. Those are simply key values the tool doesn’t parse.

If the warnings bother you, you can remove them from the prod.keys file. No need to exchange anything.
 
  • Love
  • Like
Reactions: impeeza and hetop

hetop

Member
Newcomer
Joined
May 31, 2021
Messages
19
Trophies
0
Age
32
XP
564
Country
Norway
Good job on censoring Ninty Intellectual Property. It is not allowed here. 👍

You can safely ignore those WARN…only ERR matters. Those are simply key values the tool doesn’t parse.

If the warnings bother you, you can remove them from the prod.keys file. No need to exchange anything.
It continued compiling after it had showed me the warnings, so I thought it would be ok, but it's good to have it confirmed. :)
 

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
6,345
Trophies
3
Age
46
Location
At my chair.
XP
18,663
Country
Colombia
Hello, can someone help me?
I have this error but lz4 is installed.
I hope someone can help me.
View attachment 349413View attachment 349414
When something similar happened to me, I had to run this command:

Pacman -Sy --noconfirm mingw-w64-x86_64-python mingw-w64-x86_64-python-lz4 zip lz4

To reinstall LZ4 for MSYS and for Python.

delete the Atmosphere folder and then clone again the repo.
 
  • Like
Reactions: binkinator

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Bunjolio @ Bunjolio: c