diff --git a/Makefile b/Makefile index 45ae78c..733200b 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ include $(DEVKITPRO)/libnx/switch_rules # NACP building is skipped as well. #--------------------------------------------------------------------------------- APP_TITLE := fastCFWswitch -APP_VERSION := 1.1.1 +APP_VERSION := 1.2.0 TARGET := $(notdir $(CURDIR)) BUILD := build diff --git a/README.md b/README.md index 1d455b4..fc3d23f 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,25 @@ Only Switch consoles with the old Erista SOC are supported, because exosphere us ## Configuration -Attribute | possible values | Description ------------ | ------------------------------------------ | ---------------- -`type` | empty / `section` / `payload` | This defines the type of element this section defines, if left empty it will automatically differentiate it by checking if a path is set -`name` | any string - example: `atmosphere` | The entry name, shown in the Overlay -`path` | a path - example: `/bootloader/hekate.bin` | the absolute path, based on the root of the sd, to the payload that should be loaded -`bootPos` | a number | the config position of the config the target payload should load, currently only supported for hekate -`bootId` | an 1-7 character long string - example `atmos` | the id of the config entry the target should be loaded, supported for hekate 5.0.2+ +Attribute | possible values | Description +----------- | ------------------------------------------------------ | ---------------- +`type` | empty / `section` / `payload` | This defines the type of element this section defines, if left empty it will automatically differentiate it by checking if a path is set +`name` | any string - example: `atmosphere` | The entry name, shown in the Overlay +`path` | a path - example: `/bootloader/hekate.bin` | The absolute path, based on the root of the sd, to the payload that should be loaded +`bootPos` | a number | The config position of the config the target payload should load, currently only supported for hekate +`bootId` | an 1-7 character long string - example `atmos` | The id of the config entry the target should be loaded, supported for hekate 5.0.2+ +`ums` | string from UMS target list - example `sd` | The ums target, that should automatically be exposed via usb, supported for hekate + +### UMS Target +Target | possible values +---------------- | ----------------------------- +SD-Card | `sd`, default fallback +EMMC BOOT0 | `nand_boot0`, `emmc_boot0` +EMMC BOOT1 | `nand_boot1`, `emmc_boot1` +EMMC Main/GPT | `nand_gpt`, `emmc_gpt` +EmuNAND BOOT0 | `emu_boot0` +EmuNAND BOOT1 | `emu_boot1` +EmuNAND Main/GPT | `emu_gpt` ## Example configuration ``` @@ -59,6 +71,19 @@ path=/payloads/hekate_ctcaer.bin name=Hekate path=/payloads/Lockpick_RCM.bin +[UMS] +name=UMS + +[SD_CARD] +name=SD +path=/payloads/hekate_ctcaer.bin +ums = sd + +[EMMC_GPT] +name=EMMC GPT +path=/payloads/hekate_ctcaer.bin +ums = emmc_gpt + ``` ## Screenshots diff --git a/source/configParser.cpp b/source/configParser.cpp index ad7fe63..20c327a 100644 --- a/source/configParser.cpp +++ b/source/configParser.cpp @@ -30,6 +30,9 @@ namespace fastCFWSwitcher { void setBootId(const char * bootId){ this->bootId.assign(bootId); } + void setUms(const char * bootId){ + this->ums.assign(bootId); + } Element* toElement(){ if(type == "section" || path.empty()){ @@ -42,6 +45,9 @@ namespace fastCFWSwitcher { if(!bootId.empty()){ payload->setBootId(bootId); } + if(!ums.empty()){ + payload->setUmsName(ums); + } return (Element*) payload; } @@ -58,8 +64,9 @@ namespace fastCFWSwitcher { std::string type; std::string name; std::string path; - int bootPos; + int bootPos = -1; std::string bootId; + std::string ums; private: }; } @@ -90,6 +97,8 @@ int handler(void *user, const char *section, const char *name, const char *value configEntry->setBootPos(strtol(value, (char **)NULL, 10)); } else if (!strcmp("bootId", name)) { configEntry->setBootId(value); + } else if (!strcmp("ums", name)) { + configEntry->setUms(value); } return 1; } diff --git a/source/payload.h b/source/payload.h index fb92418..9df7ac1 100644 --- a/source/payload.h +++ b/source/payload.h @@ -22,6 +22,10 @@ namespace fastCFWSwitcher { return autobootID; } + std::string getUmsName(){ + return umsName; + } + void setBootPos(int pos){ this->autobootPos = pos; } @@ -30,10 +34,15 @@ namespace fastCFWSwitcher { this->autobootID = id; } + void setUmsName(std::string umsName){ + this->umsName = umsName; + } + private: std::string name; std::string path; - int autobootPos; + int autobootPos = -1; std::string autobootID; + std::string umsName; }; } diff --git a/source/payloadHandler.cpp b/source/payloadHandler.cpp index f63ae38..e958c73 100644 --- a/source/payloadHandler.cpp +++ b/source/payloadHandler.cpp @@ -28,6 +28,18 @@ alignas(0x1000) static u8 g_reboot_payload[IRAM_PAYLOAD_MAX_SIZE]; #define BOOT_CFG_TO_EMUMMC (1 << 3) #define BOOT_CFG_SEPT_RUN (1 << 7) +#define EXTRA_CFG_NYX_UMS (1 << 5) + +typedef enum _nyx_ums_type +{ + NYX_UMS_SD_CARD = 0, + NYX_UMS_EMMC_BOOT0, + NYX_UMS_EMMC_BOOT1, + NYX_UMS_EMMC_GPP, + NYX_UMS_EMUMMC_BOOT0, + NYX_UMS_EMUMMC_BOOT1, + NYX_UMS_EMUMMC_GPP +} nyx_ums_type; typedef struct __attribute__((__packed__)) _boot_cfg_t { @@ -43,6 +55,7 @@ typedef struct __attribute__((__packed__)) _boot_cfg_t char emummc_path[0x78]; // emuMMC/XXX, ASCII null teminated. }; u8 ums; // nyx_ums_type. + u8 sept; // nyx_sept_type. u8 xt_str[0x80]; }; } boot_cfg_t; @@ -80,6 +93,28 @@ void PayloadHandler::setError(std::string errorString){ this->frame->setSubtitle(errorString); } +int getHekateUMSId(std::string name){ + if(name == "nand_boot0" || name == "emmc_boot0"){ + return nyx_ums_type::NYX_UMS_EMMC_BOOT0; + } + if(name == "nand_boot1" || name == "emmc_boot1"){ + return nyx_ums_type::NYX_UMS_EMMC_BOOT1; + } + if(name == "nand_gpt" || name == "emmc_gpt"){ + return nyx_ums_type::NYX_UMS_EMMC_GPP; + } + if(name == "emu_boot0"){ + return nyx_ums_type::NYX_UMS_EMUMMC_BOOT0; + } + if(name == "emu_boot1"){ + return nyx_ums_type::NYX_UMS_EMUMMC_BOOT1; + } + if(name == "emu_gpt"){ + return nyx_ums_type::NYX_UMS_EMUMMC_GPP; + } + return nyx_ums_type::NYX_UMS_SD_CARD; +} + void PayloadHandler::applyPayloadArgs(fastCFWSwitcher::Payload* payload){ PayloadType payloadType = getBinPayloadType(payload); @@ -98,6 +133,11 @@ void PayloadHandler::applyPayloadArgs(fastCFWSwitcher::Payload* payload){ hekateCFG->boot_cfg = BOOT_CFG_AUTOBOOT_EN; hekateCFG->autoboot = payload->getBootPos(); hekateCFG->autoboot_list = 0; + } else if(!payload->getUmsName().empty()){ + boot_cfg_t* hekateCFG = (boot_cfg_t*) &g_reboot_payload[HEKATE_AUTOBOOT_POS]; + hekateCFG->boot_cfg = BOOT_CFG_AUTOBOOT_EN; + hekateCFG->extra_cfg = EXTRA_CFG_NYX_UMS; + hekateCFG->ums = getHekateUMSId(payload->getUmsName()); // set ums target } break; }