Skip to content

Commit

Permalink
Actually save the OTP to otp.bin instead of opt.bin
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed May 8, 2024
1 parent 2a995e2 commit bf64de2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ void Utils::DumpOTPAndSeeprom() {
return;
}
std::string backupPathConsole = string_format(BACKUPS_DIRECTORY_FULL "/%s", serialId.c_str());
std::string backupPathConsoleOtpPath = backupPathConsole + "/opt.bin";
std::string backupPathConsoleOtpPath = backupPathConsole + "/otp.bin";
std::string backupPathConsoleSeepromPath = backupPathConsole + "/seeprom.bin";

if (!FSUtils::CreateSubfolder(backupPathConsole.c_str())) {
DEBUG_FUNCTION_LINE_WARN("Failed to create \"%s\"", backupPathConsole.c_str());
}

bool seepromExists = FSUtils::CheckFile(backupPathConsoleSeepromPath.c_str());
bool optExists = FSUtils::CheckFile(backupPathConsoleOtpPath.c_str());
bool otpExists = FSUtils::CheckFile(backupPathConsoleOtpPath.c_str());

if (!seepromExists) {
uint8_t data[0x200] = {};
Expand All @@ -99,7 +99,7 @@ void Utils::DumpOTPAndSeeprom() {
} else {
DEBUG_FUNCTION_LINE_VERBOSE("SEEPROM backup already exists");
}
if (!optExists) {
if (!otpExists) {
WiiUConsoleOTP otp = {};
if (Mocha_ReadOTP(&otp) != MOCHA_RESULT_SUCCESS) {
DEBUG_FUNCTION_LINE_WARN("Failed to read otp");
Expand All @@ -113,4 +113,10 @@ void Utils::DumpOTPAndSeeprom() {
} else {
DEBUG_FUNCTION_LINE_VERBOSE("OTP backup already exists");
}

// Remove wrong file with typo
std::string backupPathConsoleOTPPathTypo = backupPathConsole + "/opt.bin";
if (FSUtils::CheckFile(backupPathConsoleOTPPathTypo.c_str())) {
remove(backupPathConsoleOTPPathTypo.c_str());
}
}

0 comments on commit bf64de2

Please sign in to comment.