Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch: updated build environment for Nintendo Switch. #476

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

xlanor
Copy link

@xlanor xlanor commented Nov 15, 2024

THIS DOES NOT INDICATE THAT CHIAKI-NG IS READY FOR THE SWITCH!

This is an initial PR fixes the build environment and updates some libraries for Nintendo Switch environment. Tested against fw 18.1.

photo_2024-11-15_22-49-59 (2)
photo_2024-11-15_22-49-59

A basic compilation works and I am able to connect locally. However, note that things like unlocking the PS5 doesnt seem to work.

I'm pretty sure the cmake stuff that I changed is not optimal but thats the only thing that can find the right libraries at compile time. open to suggestions.

switch-curl and switch-mbedtls have been updated past the devkitpro supplied versions to 8.11.0 and 3.6.2 respectively.

Both of them have been patched before compilation for compatibility with existing code in libchiaki/switch architecture. You can find the build scripts and patches for the updated development and compilation environment here. I will move them into this repository once I have stopped pushing changes every other day to test different things out.

The gist of the changes is that switch-curl has been bumped to 8.11.0 with WSS and mbedtls has been re-enabled, while mbed-tls has been bumped to 3.6.2 and patched to removed private variables in structs.

Thanks to ngynkvyn as well for helping to debug some of the environment stuff.

I am sure there will be more work to be done, but this gets the switch code to a state where it is buildable at least.

Those in #355 who wanted to help with development, this is probably a good time now that it can be compiled.

@@ -161,11 +195,6 @@ else()
target_link_libraries(chiaki-lib OpenSSL::Crypto)
endif()

if (CHIAKI_USE_SYSTEM_CURL)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if curl comes after mbedtls, it fails at linking time as it is unable to find the mbedtls references.

@@ -251,7 +251,7 @@ static void set_timeout(struct timespec *timeout, uint64_t ms_from_now)
}
#endif

#if !__APPLE__
#if !__APPLE__ && !__SWITCH__
Copy link
Author

@xlanor xlanor Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pthread_clockjoin_np is not avaliable in aarch64_none_elf. It appears that this function is used in chiaki-cli only (I believe) so I have removed it for switch for now.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be removed for switch, it's just used for the discover command in the cli

@@ -384,7 +387,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gmac(ChiakiGKCrypt *gkcrypt, uint64
}

// encrypt without additional data
if(mbedtls_gcm_starts(&actx, MBEDTLS_GCM_ENCRYPT, iv, CHIAKI_GKCRYPT_BLOCK_SIZE, NULL, 0) != 0)
if(mbedtls_gcm_starts(&actx, MBEDTLS_GCM_ENCRYPT, iv, CHIAKI_GKCRYPT_BLOCK_SIZE) != 0)
Copy link
Author

@xlanor xlanor Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe switch is the only build that uses mbedtls, I can add switch ifdefs around the mbedtls api updates if need be.

In other areas, mbedtls 3.x breaks a ton of stuff especially around ecdh calculation as all the variables are private. I have patched switch-mbedtls to remove the private checks on the structs as I don't see a clear way in the public API to extract the required variables to recalculate dhk.

lib/CMakeLists.txt Outdated Show resolved Hide resolved
@xlanor xlanor changed the title switch: updated environment and various functions for Nintendo Switch switch: updated build environment for Nintendo Switch. Nov 15, 2024
@@ -108,7 +108,7 @@ class IO

~IO();
void SetMesaConfig();
bool VideoCB(uint8_t *buf, size_t buf_size);
bool VideoCB(uint8_t *buf, size_t buf_size, int32_t frames_lost, bool frame_recovered, void *user);
Copy link
Author

@xlanor xlanor Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libavcodec api changes

@@ -28,7 +28,6 @@ bool appletMainLoop()
// use a custom nintendo switch socket config
// chiaki requiers many threads with udp/tcp sockets
static const SocketInitConfig g_chiakiSocketInitConfig = {
.bsdsockets_version = 1,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libnx changes, doxygen

@streetpea
Copy link
Owner

@xlanor the icon is different from the logo and is here: https://github.com/streetpea/chiaki-ng/blob/main/gui/chiaking.png

@xlanor
Copy link
Author

xlanor commented Nov 16, 2024

@xlanor the icon is different from the logo and is here: https://github.com/streetpea/chiaki-ng/blob/main/gui/chiaking.png

Will swap in the morning

@streetpea
Copy link
Owner

other than the icon swapping and potentially looking at setting CPATH instead of hardcoding the path, LGTM

@xlanor
Copy link
Author

xlanor commented Nov 16, 2024

@streetpea changes made!

Signed-off-by: xlanor <[email protected]>
@xlanor
Copy link
Author

xlanor commented Nov 16, 2024

hmm I just realised the changes worked for mbedtls + curl but not jsonc.

Will come back and look at json c again. For some reason the INCLUDE_DIRECTORIES is not being set which I think is causing this


-- CMAKE_FIND_ROOT_PATH = 
-- PKG_CONFIG_EXECUTABLE = /opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-pkg-config
-- CMAKE_EXE_LINKER_FLAGS = 
-- INCLUDE_DIRECTORIES = 
-- CMAKE_C_COMPILER = /opt/devkitpro/devkitA64/bin/aarch64-none-elf-gcc
-- CMAKE_CXX_COMPILER = /opt/devkitpro/devkitA64/bin/aarch64-none-elf-g++
-- elf2nro: /opt/devkitpro/tools/bin/elf2nro - found
-- nacptool: /opt/devkitpro/tools/bin/nacptool - found
-- CMAKE_FIND_ROOT_PATH = 
-- PKG_CONFIG_EXECUTABLE = /opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-pkg-config
-- CMAKE_EXE_LINKER_FLAGS = 
-- INCLUDE_DIRECTORIES = 
-- CMAKE_C_COMPILER = /opt/devkitpro/devkitA64/bin/aarch64-none-elf-gcc
-- CMAKE_CXX_COMPILER = /opt/devkitpro/devkitA64/bin/aarch64-none-elf-g++
-- elf2nro: /opt/devkitpro/tools/bin/elf2nro - found
-- nacptool: /opt/devkitpro/tools/bin/nacptool - found
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0

Will look at it tonight.

@Black-Hill852
Copy link

Black-Hill852 commented Nov 16, 2024

can someone upload a compiled .nro for the switch 2 use?

@xlanor
Copy link
Author

xlanor commented Nov 16, 2024 via email

@Black-Hill852
Copy link

This is not ready for use yet, only updates the build environment.

Sent from my iPhone
On Sat, 16 Nov 2024 at 11:23, Black-Hill852 @.> wrote: can someone upload a compiled .ro for the switch 2 use? — Reply to this email directly, view it on GitHub <#476 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG64FNRKNT3OVPNZMDYQXVL2A4TLZAVCNFSM6AAAAABR4DVI6SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOBQGUZDQNRRGU . You are receiving this because you were mentioned.Message ID: @.>

okay thanks for that info. I use the old chiaki.nro and there is the Problem, no Pin Support.

Signed-off-by: xlanor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants