From a7984de0c87604c99253d4b02a61f05bde1bcceb Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Tue, 16 Mar 2021 01:08:38 -0400 Subject: [PATCH] Send Git commit hash as part of the StartSession block. --- Makefile | 4 ++++ code_templates/usb_gc_dumper.c | 4 +++- nxdt_host.pyw | 9 +++++---- source/usb.c | 4 +++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 4afd9cc..d7c3120 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ include $(DEVKITPRO)/libnx/switch_rules # - /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` diff --git a/code_templates/usb_gc_dumper.c b/code_templates/usb_gc_dumper.c index 264679a..e25fdd0 100644 --- a/code_templates/usb_gc_dumper.c +++ b/code_templates/usb_gc_dumper.c @@ -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) diff --git a/nxdt_host.pyw b/nxdt_host.pyw index 27d4b0c..5c03e2c 100644 --- a/nxdt_host.pyw +++ b/nxdt_host.pyw @@ -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('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)