1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-09-19 13:33:25 +01:00

Send Git commit hash as part of the StartSession block.

This commit is contained in:
Pablo Curiel 2021-03-16 01:08:38 -04:00
parent 97cd7eb53e
commit a7984de0c8
4 changed files with 15 additions and 6 deletions

View file

@ -31,6 +31,9 @@ include $(DEVKITPRO)/libnx/switch_rules
# - <libnx folder>/default_icon.jpg
#---------------------------------------------------------------------------------
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
GIT_COMMIT := $(shell git rev-parse --short HEAD)
VERSION_MAJOR := 2
VERSION_MINOR := 0
VERSION_MICRO := 0
@ -58,6 +61,7 @@ ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -Wextra -Werror -O2 -ffunction-sections $(ARCH) $(DEFINES) $(INCLUDE) -D__SWITCH__
CFLAGS += -DVERSION_MAJOR=${VERSION_MAJOR} -DVERSION_MINOR=${VERSION_MINOR} -DVERSION_MICRO=${VERSION_MICRO} -DAPP_TITLE=\"${APP_TITLE}\" -DAPP_AUTHOR=\"${APP_AUTHOR}\" -DAPP_VERSION=\"${APP_VERSION}\"
CFLAGS += -DGIT_BRANCH=\"${GIT_BRANCH}\" -DGIT_COMMIT=\"${GIT_COMMIT}\"
CFLAGS += `freetype-config --cflags`
CFLAGS += `aarch64-none-elf-pkg-config zlib --cflags`
CFLAGS += `aarch64-none-elf-pkg-config libxml-2.0 --cflags`

View file

@ -349,9 +349,11 @@ static void waitForGameCardAndUsb(void)
while(true)
{
if (gamecardGetStatus() == GameCardStatus_InsertedAndInfoLoaded && titleIsGameCardInfoUpdated()) break;
if (gamecardGetStatus() == GameCardStatus_InsertedAndInfoLoaded) break;
}
titleIsGameCardInfoUpdated();
consolePrint("waiting for usb session...\n");
while(true)

View file

@ -26,7 +26,7 @@
# libusb needs to be installed as well. PyUSB uses it as its USB backend. Otherwise, a NoBackend exception will be raised while calling PyUSB functions.
# Under Windows, the recommended way to do this is by installing the libusb driver with Zadig (https://zadig.akeo.ie). This is a common step in Switch modding guides.
# Under MacOS, use `brew install libusb` to install libusb via Homebrew.
# Under Linux, you should be good to go from the start. If not, just use the packet manager from your distro to install libusb.
# Under Linux, you should be good to go from the start. If not, just use the package manager from your distro to install libusb.
import os
import platform
@ -439,15 +439,16 @@ def usbSendStatus(code):
return usbWrite(status, USB_TRANSFER_TIMEOUT) == len(status)
def usbHandleStartSession(cmd_block):
global g_nxdtVersionMajor, g_nxdtVersionMinor, g_nxdtVersionMicro, g_nxdtAbiVersion
global g_nxdtVersionMajor, g_nxdtVersionMinor, g_nxdtVersionMicro, g_nxdtAbiVersion, g_nxdtGitCommit
g_Logger.debug('Received StartSession (%02X) command.' % (USB_CMD_START_SESSION))
# Parse command block.
(g_nxdtVersionMajor, g_nxdtVersionMinor, g_nxdtVersionMicro, g_nxdtAbiVersion) = struct.unpack_from('<BBBB', cmd_block, 0)
(g_nxdtVersionMajor, g_nxdtVersionMinor, g_nxdtVersionMicro, g_nxdtAbiVersion, g_nxdtGitCommit) = struct.unpack_from('<BBBB8s', cmd_block, 0)
g_nxdtGitCommit = g_nxdtGitCommit.decode('utf-8').strip('\x00')
# Print client info.
g_Logger.info('Client info: nxdumptool v%u.%u.%u - ABI v%u.\n' % (g_nxdtVersionMajor, g_nxdtVersionMinor, g_nxdtVersionMicro, g_nxdtAbiVersion))
g_Logger.info('Client info: nxdumptool v%u.%u.%u, ABI v%u (commit %s).\n' % (g_nxdtVersionMajor, g_nxdtVersionMinor, g_nxdtVersionMicro, g_nxdtAbiVersion, g_nxdtGitCommit))
# Check if we support this ABI version.
if g_nxdtAbiVersion != USB_ABI_VERSION:

View file

@ -80,7 +80,8 @@ typedef struct {
u8 app_ver_minor;
u8 app_ver_micro;
u8 abi_version;
u8 reserved[0xC];
char git_commit[8];
u8 reserved[0x4];
} UsbCommandStartSession;
typedef struct {
@ -606,6 +607,7 @@ static bool usbStartSession(void)
cmd_block->app_ver_minor = VERSION_MINOR;
cmd_block->app_ver_micro = VERSION_MICRO;
cmd_block->abi_version = USB_ABI_VERSION;
snprintf(cmd_block->git_commit, sizeof(cmd_block->git_commit), GIT_COMMIT);
ret = usbSendCommand();
if (ret)