Skip to content

Commit

Permalink
added support for ums target in hekate
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartie95 committed Mar 27, 2021
1 parent 989a8bd commit 5f12434
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion source/configParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand All @@ -42,6 +45,9 @@ namespace fastCFWSwitcher {
if(!bootId.empty()){
payload->setBootId(bootId);
}
if(!ums.empty()){
payload->setUmsName(ums);
}
return (Element*) payload;

}
Expand All @@ -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:
};
}
Expand Down Expand Up @@ -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;
}
Expand Down
11 changes: 10 additions & 1 deletion source/payload.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ namespace fastCFWSwitcher {
return autobootID;
}

std::string getUmsName(){
return umsName;
}

void setBootPos(int pos){
this->autobootPos = pos;
}
Expand All @@ -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;
};
}
40 changes: 40 additions & 0 deletions source/payloadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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;
}
Expand Down

0 comments on commit 5f12434

Please sign in to comment.