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.
In my case, I had to read several documents in order to
get a working DevKitPro environment.
First you need
Download the latest version from: https://github.com/msys2/msys2-installer/releases

Install the version corresponding to your Operating System (64 or 32 bits).

Accept the defaults in installation program of MSYS2 once you finish the installation you will have shortcuts for MSYS2, MinGW32 and MinGW64. MSYS2 is used to compiling POSIX binaries for Linux from Windows.

MinGW32 & MinGW64 compile Native Windows binaries using a linux toolchain (gcc, bash, etc.)

Launch MSYS2 (MinGW64): shell:
1695782853186.png
1695782902542.png


And on it execute the command: pacman -Syuu several times until you get the message: "there is nothing to do". Sometimes you will need to restart the environment.

Then install DevKitPro
First at all you need to edit the pacman.conf file located on c:\msys64\etc\ (default installation folder)
And add the next lines at end of it:

Code:
[dkp-libs]
Server = https://pkg.devkitpro.org/packages

[dkp-windows]
Server = https://pkg.devkitpro.org/packages/windows/$arch/

Then you need to import the keys of the repositories, so execute the next command:
Bash:
pacman-key --recv BC26F752D25B92CE272E0F44F7FD5492264BB9D0 --keyserver keyserver.ubuntu.com

and sign locally the key:
Bash:
pacman-key --lsign BC26F752D25B92CE272E0F44F7FD5492264BB9D0

Verify the key is working well:
Bash:
pacman-key -l BC26F752D25B92CE272E0F44F7FD5492264BB9D0

You should get a response just like:

Bash:
pub  rsa4096 2018-02-28 [SC]
      BC26F752D25B92CE272E0F44F7FD5492264BB9D0
uid          [  full  ] Dave Murphy (WinterMute) <[email protected]>
sub  rsa4096 2018-02-28 [E]

After that you will install the DevKitPro Keyring
Bash:
pacman -U https://downloads.devkitpro.org/devkitpro-keyring.pkg.tar.xz

Now verify MSYS2 database:
Bash:
pacman -Sy
pacman -Syu

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

After you have a working environment you need to install 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

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.




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

gdavies

Well-Known Member
Newcomer
Joined
Mar 1, 2023
Messages
67
Trophies
0
XP
105
Country
United Kingdom
yeah, I'm on windows 11 as well. I tested building it. after installing the libnx, I had no issues with the latest atmosphere. btw, do not run the commands on the first page again unless you reinstall libnx from github, because it will overwrite the github libnx and error again during either stratosphere or mesosphere building iirc.
Noted, I gave it a go just out of curiosity more than anything, but it would be fun one day to give it a full days attention to tweak every part just so i could get the switch too boot quicker, but think that would be like trying to run before you can walk haha
 

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
4,318
Trophies
3
Age
45
Location
At my chair.
XP
11,785
Country
Colombia
For building Atmosphère on UBUNTU, I had to run this commands:

DevKitPro Installation
Bash:
sudo apt install wget
wget https://apt.devkitpro.org/install-devkitpro-pacman
chmod +x ./install-devkitpro-pacman
sudo ./install-devkitpro-pacman


Base packages
Bash:
sudo apt install lz4 zip git make gcc python3 python-is-python3 python3-pip
sudo pip install pycryptodome lz4
sudo dkp-pacman -Sy --noconfirm --needed 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
sudo dkp-pacman -Syuu --noconfirm

You need to copy prod.keys file on $HOME/.switch

Building
Bash:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH
git clone --recursive https://github.com/Atmosphere-NX/Atmosphere
cd Atmosphere
make -j$(nproc)
 

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,473
Trophies
3
XP
28,821
Country
United States
For building Atmosphère on UBUNTU, I had to run this commands:

DevKitPro Installation
Bash:
sudo apt install wget
wget https://apt.devkitpro.org/install-devkitpro-pacman
chmod +x ./install-devkitpro-pacman
sudo ./install-devkitpro-pacman


Base packages
Bash:
sudo apt install lz4 zip git make gcc python3 python-is-python3 python3-pip
sudo pip install pycryptodome lz4
sudo dkp-pacman -Sy --noconfirm --needed 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
sudo dkp-pacman -Syuu --noconfirm

You need to copy prod.keys file on $HOME/.switch

Building
Bash:
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH
git clone --recursive https://github.com/Atmosphere-NX/Atmosphere
cd Atmosphere
make -j$(nproc)
I would put the export portion in the .bashrc, so you don't have to do it each time you open the terminal.
 

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
4,318
Trophies
3
Age
45
Location
At my chair.
XP
11,785
Country
Colombia
you need to compile and install the official master branch:

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

has been updated with all commits up to 2 days ago.
Post automatically merged:

@impeeza The 16_Support branch is no longer available.
Yes was commited on the main branch, I am trying to build the latest commit of Atmosphère, will let you to know.
Post automatically merged:

Just finished to build the latest Atmosphère commit (476d658) just build and install the latest LIBNX commit (c09a21d) before start the process.
 
Last edited by impeeza,

Jandresquiroga

New Member
Newbie
Joined
Sep 27, 2023
Messages
1
Trophies
0
Age
36
XP
7
Country
Chile
friends I'm new to this
When I am installing the dependencies at this point I get these errors, how would I solve it?


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.
 

Attachments

  • IMG_20230926_212711.jpg
    IMG_20230926_212711.jpg
    2.7 MB · Views: 3

Popular threads in this forum

General chit-chat
Help Users
  • Veho @ Veho:
    Smegma male podcasts?
    +1
  • K3N1 @ K3N1:
    I want a jumping spider
  • Veho @ Veho:
    Republicans aborted Kevin in the third trimester.
  • Veho @ Veho:
    "Speaker of the House to be replaced by a Bose soundbar, by general consensus a much better speaker."
  • K3N1 @ K3N1:
    Knowing the government it'll be an Alexa to save money
  • Veho @ Veho:
    Government... save money? Nah.
  • K3N1 @ K3N1:
    Or something from Temu
  • K3N1 @ K3N1:
    Sure they need those billions for our quarterly vaccination
  • Veho @ Veho:
    They need those billions to subsidize oil companies and corn farmers.
  • K3N1 @ K3N1:
    Alexa how much should we charge for gas this week
  • Veho @ Veho:
    "Several UAE-owned companies are dropping in value, therefore gas should be $100 per gallon."
  • Veho @ Veho:
    There's a new "magazine" 'round these parts, one of those where you get a piece of a model ship every issue, and you can build the whole ship eventually.
  • Veho @ Veho:
    Only problem is, the ship will come in a few hundred issues total, and each issue is $15...
  • Veho @ Veho:
    It would be cheaper to buy a ship, in the end.
  • Bunjolio @ Bunjolio:
    god damn the world of ds and 3ds flashcarts is so big
  • Veho @ Veho:
    Wait there are 3DS flashcards? I forgot.
  • Bunjolio @ Bunjolio:
    yeah i think, this whole thing is new to me
  • Bunjolio @ Bunjolio:
    i wanna get my sister (21) a r4 for her ds lite
  • Bunjolio @ Bunjolio:
    sylver helped me find one ofc
  • Bunjolio @ Bunjolio:
    maybe i should start collecting them (althought that would be a expensive hobby)
  • K3N1 @ K3N1:
    Cayman jacks pretty good
    K3N1 @ K3N1: Cayman jacks pretty good