Tutorial Homebrew Building Atmosphère on Windows using MSYS2

impeeza

¡Kabito!
OP
Member
Joined
Apr 5, 2011
Messages
1,556
Trophies
1
Age
44
XP
2,483
Country
Colombia
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 shell and execute the command: pacman -Syuu several times until you get the message: "there is nothing to do".

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:

[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:
pacman-key --recv BC26F752D25B92CE272E0F44F7FD5492264BB9D0 --keyserver keyserver.ubuntu.com

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

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

You should get a response just like:

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
pacman -U https://downloads.devkitpro.org/devkitpro-keyring.pkg.tar.xz

Now verify MSYS2 database:
pacman -Sy pacman -Syu

The last step is to install DevKitPro packages:
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
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 zip

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

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)

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

go to new created Atmosphère folder
cd Atmosphere

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

and now you are ready to start the building process:
make -j

I do use the "-j" 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.

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: https://gbatemp.net/threads/autoips-sig-patcher.574126/ you use the script to generate a new set of patches for your recently build package3 file.


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

binkinator

Garfield’s Fitness Coach
Member
GBAtemp Patron
Joined
Mar 29, 2021
Messages
2,532
Trophies
2
XP
1,764
Country
United States
Works a treat! Tried my best to be a mindless fool just clicking what I was told and had no issues. Nicely done!

I’m going to destroy it all and see if I can run it like this:

go to https://switchbrew.org/wiki/Setting_up_Development_Environment and hit this link to download latest Windows graphical installer.

open up MSYS2 and run these two commands (basically just combining all yours into one)

Code:
pacman -Syu

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

(From here everything flows the same as the rest of the tut…
 
  • Love
Reactions: impeeza

fvig2001

Well-Known Member
Member
Joined
Aug 21, 2006
Messages
704
Trophies
0
XP
2,092
Country
Philippines
Can you enable debug outputs? Will probably be useful if I have to debug on a 1 bit mode switch (normally does not boot atmosphere without hacks)
 
  • Like
Reactions: impeeza
General chit-chat
Help Users
  • No one is chatting at the moment.
    DEMONGreninjaPG @ DEMONGreninjaPG: hello