Misc gui in sys-clk overlay updated, HOS 15.0.0 test passed
Extracting nca... 79c6b910fe436a85496d3b822f23b8b9.nca (ptm) -> /Volumes/RAMDISK/ptm/ e11685a3958d1f25a8f44f54126b10ff.nca (pcv) -> /Volumes/RAMDISK/pcv/ Converting nca to elf... Building... Patching... Patching pcv for Erista... CpuClkOSLimit Count: 1 CpuVoltLimit* Count: 14 MemClkOSLimit Count: 32 MemVoltHOS Count: 2 MemClkPllmLimit Count: 2 in void ams::ldr::oc::pcv::Erista::Patch(uintptr_t, size_t) Saving to "/Volumes/RAMDISK/pcv/main.elf.erista"... Patching pcv for Mariko... CpuClkOSLimit Count: 1 CpuClkOfficial Count: 1 GpuClkOfficial Count: 1 CpuVoltOfficial Count: 13 MemClkOSLimit Count: 32 GpuClkPllLimit Count: 1 MemClkPllmLimit Count: 2 GpuAsmPattern Count: 2 in void ams::ldr::oc::pcv::Mariko::Patch(uintptr_t, size_t) Saving to "/Volumes/RAMDISK/pcv/main.elf.mariko"... Passed! Patching ptm (Mariko Only)... cpuPtmBoost Count: 2 memPtmMax Count: 9 memPtmAlt Count: 7 in void ams::ldr::oc::ptm::Patch(uintptr_t, size_t) Saving to "/Volumes/RAMDISK/ptm/main.elf.mariko"... Passed!
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) [](https://gitter.im/Switch-OC-Suite/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
Overclocking suite for Nintendo Switch™ Horizon OS (HOS) running on Atmosphere CFW.
|
||||
Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW.
|
||||
|
||||
This project will not be actively maintained or regularly updated along with Atmosphere CFW.
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ int main(int argc, char** argv) {
|
||||
void* mariko_buf = malloc(file_size);
|
||||
std::memcpy(mariko_buf, file_buffer, file_size);
|
||||
|
||||
printf("Patching %s (Mariko Only)...", ptm_opt);
|
||||
printf("Patching %s (Mariko Only)...\n", ptm_opt);
|
||||
ams::ldr::oc::ptm::Patch(reinterpret_cast<uintptr_t>(mariko_buf), file_size);
|
||||
if (save_patched) {
|
||||
char* exec_path_mariko = reinterpret_cast<char *>(malloc(exec_path_patched_len));
|
||||
|
||||
@@ -90,10 +90,11 @@ void MiscGui::listUI()
|
||||
});
|
||||
this->listElement->addItem(this->backlightToggle);
|
||||
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader("Battery & Charging Info"));
|
||||
this->listElement->addItem(new tsl::elm::CategoryHeader("Info"));
|
||||
this->listElement->addItem(new tsl::elm::CustomDrawer([this](tsl::gfx::Renderer *renderer, s32 x, s32 y, s32 w, s32 h) {
|
||||
renderer->drawString(this->infoOutput, false, x, y + 20, SMALL_TEXT_SIZE, DESC_COLOR);
|
||||
}), SMALL_TEXT_SIZE * 13 + 20);
|
||||
renderer->drawString(this->infoNames, false, x, y + 20, SMALL_TEXT_SIZE, DESC_COLOR);
|
||||
renderer->drawString(this->infoVals, false, x + 120, y + 20, SMALL_TEXT_SIZE, VALUE_COLOR);
|
||||
}), SMALL_TEXT_SIZE * 12 + 20);
|
||||
}
|
||||
|
||||
void MiscGui::refresh() {
|
||||
@@ -119,6 +120,6 @@ void MiscGui::refresh() {
|
||||
this->backlightToggle->setState(lblstatus);
|
||||
|
||||
I2cGetInfo(this->i2cInfo);
|
||||
PrintInfo(this->infoOutput, sizeof(this->infoOutput));
|
||||
UpdateInfo(this->infoVals, sizeof(this->infoVals));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,20 +108,6 @@ class MiscGui : public BaseMenuGui
|
||||
ChargeInfoFlags Flags; //Unknown flags
|
||||
} ChargeInfo;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Max17050Reg_Current = 0x0A,
|
||||
Max17050Reg_AvgCurrent = 0x0B,
|
||||
Max17050Reg_Cycle = 0x17,
|
||||
} Max17050Reg;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Max77812Reg_CPUVolt = 0x26,
|
||||
Max77812Reg_GPUVolt = 0x23,
|
||||
Max77812Reg_DRAMVolt = 0x25,
|
||||
} Max77812Reg;
|
||||
|
||||
typedef struct {
|
||||
float batCurrent;
|
||||
u32 cpuVolt = 620;
|
||||
@@ -141,7 +127,6 @@ class MiscGui : public BaseMenuGui
|
||||
}
|
||||
|
||||
serviceDispatchOut(psmGetServiceSession(), 17, *(this->chargeInfo));
|
||||
psmIsEnoughPowerSupplied(&(this->isEnoughPowerSupplied));
|
||||
|
||||
psmExit();
|
||||
smExit();
|
||||
@@ -157,12 +142,7 @@ class MiscGui : public BaseMenuGui
|
||||
return PsmIsChargerConnected() && ((this->chargeInfo->unk_x14 >> 8) & 1);
|
||||
}
|
||||
|
||||
bool PsmIsEnoughPowerSupplied()
|
||||
{
|
||||
return this->isEnoughPowerSupplied;
|
||||
}
|
||||
|
||||
Result I2cReadRegHandler(u8 reg, I2cDevice dev, u16 *out)
|
||||
Result I2cRead_OutU16(u8 reg, I2cDevice dev, u16 *out)
|
||||
{
|
||||
// ams::fatal::srv::StopSoundTask::StopSound()
|
||||
// I2C Bus Communication Reference: https://www.ti.com/lit/an/slva704/slva704.pdf
|
||||
@@ -195,53 +175,83 @@ class MiscGui : public BaseMenuGui
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result I2cRead_OutU8(u8 reg, I2cDevice dev, u8 *out)
|
||||
{
|
||||
struct { u8 reg; } __attribute__((packed)) cmd;
|
||||
struct { u8 val; } __attribute__((packed)) rec;
|
||||
|
||||
I2cSession _session;
|
||||
|
||||
Result res = i2cOpenSession(&_session, dev);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
cmd.reg = reg;
|
||||
res = i2csessionSendAuto(&_session, &cmd, sizeof(cmd), I2cTransactionOption_All);
|
||||
if (res)
|
||||
{
|
||||
i2csessionClose(&_session);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = i2csessionReceiveAuto(&_session, &rec, sizeof(rec), I2cTransactionOption_All);
|
||||
if (res)
|
||||
{
|
||||
i2csessionClose(&_session);
|
||||
return res;
|
||||
}
|
||||
|
||||
*out = rec.val;
|
||||
i2csessionClose(&_session);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void I2cGetInfo(I2cInfo* i2cInfo)
|
||||
{
|
||||
smInitialize();
|
||||
i2cInitialize();
|
||||
u16 data = 0;
|
||||
|
||||
// Read max17050 furl gauge regs. Sense resistor and CGain are from Hekate, too lazy to query configuration from reg
|
||||
// Max17050 fuel gauge regs. Sense resistor and CGain are from Hekate, too lazy to query configuration from reg
|
||||
constexpr float SenseResistor = 5.; // in uOhm
|
||||
constexpr float CGain = 1.99993;
|
||||
constexpr u8 Max17050Reg_Current = 0x0A;
|
||||
// constexpr u8 Max17050Reg_AvgCurrent = 0x0B;
|
||||
// constexpr u8 Max17050Reg_Cycle = 0x17;
|
||||
u16 tmp = 0;
|
||||
if (R_SUCCEEDED(I2cRead_OutU16(Max17050Reg_Current, I2cDevice_Max17050, &tmp)))
|
||||
i2cInfo->batCurrent = (s16)tmp * (1.5625 / (SenseResistor * CGain));
|
||||
|
||||
auto I2cRead_Max77812_M_VOUT = [this](u8 reg)
|
||||
{
|
||||
constexpr float SenseResistor = 5.; // in uOhm
|
||||
constexpr float CGain = 1.99993;
|
||||
constexpr u32 MIN_MV = 250;
|
||||
constexpr u32 MV_STEP = 5;
|
||||
constexpr u8 RESET_VAL = 0x78;
|
||||
|
||||
if (R_SUCCEEDED(I2cReadRegHandler(Max17050Reg_Current, I2cDevice_Max17050, &data)))
|
||||
i2cInfo->batCurrent = (s16)data * (1.5625 / (SenseResistor * CGain));
|
||||
}
|
||||
u8 tmp = RESET_VAL;
|
||||
// Retry 3 times if received RESET_VAL
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (R_FAILED(I2cRead_OutU8(reg, I2cDevice_Max77812_2, &tmp)))
|
||||
return 0u;
|
||||
if (tmp != RESET_VAL)
|
||||
break;
|
||||
usleep(10);
|
||||
}
|
||||
|
||||
// Read max77812 volt regs
|
||||
{
|
||||
auto ConvertToMVolt = [](u32 *out, u16 data)
|
||||
{
|
||||
constexpr u32 MinMVolt = 250;
|
||||
constexpr u32 StepMVolt = 5;
|
||||
constexpr u32 VoltMask = 0xFF;
|
||||
return tmp * MV_STEP + MIN_MV;
|
||||
};
|
||||
|
||||
u32 mvolt = (data & VoltMask) * StepMVolt + MinMVolt;
|
||||
|
||||
// Ignore 850 mV as it is questionable
|
||||
if (mvolt == 850)
|
||||
return;
|
||||
|
||||
*out = mvolt;
|
||||
};
|
||||
|
||||
if (R_SUCCEEDED(I2cReadRegHandler(Max77812Reg_CPUVolt, I2cDevice_Max77812_2, &data)))
|
||||
ConvertToMVolt(&(i2cInfo->cpuVolt), data);
|
||||
|
||||
if (R_SUCCEEDED(I2cReadRegHandler(Max77812Reg_GPUVolt, I2cDevice_Max77812_2, &data)))
|
||||
ConvertToMVolt(&(i2cInfo->gpuVolt), data);
|
||||
|
||||
if (R_SUCCEEDED(I2cReadRegHandler(Max77812Reg_DRAMVolt, I2cDevice_Max77812_2, &data)))
|
||||
ConvertToMVolt(&(i2cInfo->dramVolt), data);
|
||||
}
|
||||
constexpr u8 Max77812Reg_CPUVolt = 0x26;
|
||||
constexpr u8 Max77812Reg_GPUVolt = 0x23;
|
||||
constexpr u8 Max77812Reg_DRAMVolt = 0x25;
|
||||
i2cInfo->cpuVolt = I2cRead_Max77812_M_VOUT(Max77812Reg_CPUVolt);
|
||||
i2cInfo->gpuVolt = I2cRead_Max77812_M_VOUT(Max77812Reg_GPUVolt);
|
||||
i2cInfo->dramVolt = I2cRead_Max77812_M_VOUT(Max77812Reg_DRAMVolt);
|
||||
|
||||
i2cExit();
|
||||
smExit();
|
||||
}
|
||||
|
||||
void PrintInfo(char* out, size_t outsize)
|
||||
void UpdateInfo(char* out, size_t outsize)
|
||||
{
|
||||
float chargerVoltLimit = (float)chargeInfo->ChargerVoltageLimit / 1000;
|
||||
float chargerCurrLimit = (float)chargeInfo->ChargerCurrentLimit / 1000;
|
||||
@@ -263,20 +273,18 @@ class MiscGui : public BaseMenuGui
|
||||
i2cInfo->batCurrent, i2cInfo->batCurrent * (float)chargeInfo->VoltageAvg / 1000'000);
|
||||
|
||||
snprintf(out, outsize,
|
||||
"%s"
|
||||
"\nCharger: %s%s"
|
||||
"\nBattery: %.3fV %.2f\u00B0C"
|
||||
"\nCurrent Limit: +%umA, -%umA"
|
||||
"\nCharging Limit: +%umA%s"
|
||||
"\nRaw Charge: %.2f%%"
|
||||
"\nBattery Age: %.2f%%"
|
||||
"\nPower Role: %s"
|
||||
"\nCurrent Flow: %s\n"
|
||||
"\nCPU Volt: %dmV"
|
||||
"\nGPU Volt: %dmV"
|
||||
"\nDRAM Volt: %dmV"
|
||||
"%s%s\n"
|
||||
"%.3fV %.2f\u00B0C\n"
|
||||
"+%umA, -%umA\n"
|
||||
"+%umA%s\n"
|
||||
"%.2f%%\n"
|
||||
"%.2f%%\n"
|
||||
"%s\n"
|
||||
"%s\n\n"
|
||||
"%dmV\n"
|
||||
"%dmV\n"
|
||||
"%dmV\n"
|
||||
,
|
||||
PsmIsEnoughPowerSupplied() ? "Enough Power Supplied" : "",
|
||||
ChargeInfoChargerTypeToStr(chargeInfo->ChargerType), chargWattsInfo,
|
||||
(float)chargeInfo->VoltageAvg / 1000,
|
||||
(float)chargeInfo->BatteryTemperature / 1000,
|
||||
@@ -311,20 +319,14 @@ class MiscGui : public BaseMenuGui
|
||||
lblInitialize();
|
||||
lblGetBacklightSwitchStatus(&lblstatus);
|
||||
if (shouldSwitch)
|
||||
{
|
||||
if (lblstatus) {
|
||||
lblSwitchBacklightOff(0);
|
||||
} else {
|
||||
lblSwitchBacklightOn(0);
|
||||
}
|
||||
}
|
||||
lblstatus ? lblSwitchBacklightOff(0) : lblSwitchBacklightOn(0);
|
||||
lblExit();
|
||||
smExit();
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
Discharging,
|
||||
NotCharging,
|
||||
ChargingPaused,
|
||||
SlowCharging,
|
||||
FastCharging
|
||||
} BatteryState;
|
||||
@@ -334,7 +336,7 @@ class MiscGui : public BaseMenuGui
|
||||
return Discharging;
|
||||
|
||||
if (!PsmIsCharging())
|
||||
return NotCharging;
|
||||
return ChargingPaused;
|
||||
|
||||
return chargeInfo->ChargeCurrentLimit > 768 ? FastCharging : SlowCharging;
|
||||
}
|
||||
@@ -342,7 +344,7 @@ class MiscGui : public BaseMenuGui
|
||||
const char* getBatteryStateIcon() {
|
||||
switch (getBatteryState()) {
|
||||
case Discharging: return "\u25c0"; // ◀
|
||||
case NotCharging: return "\u2016"; // ‖
|
||||
case ChargingPaused: return "| |";
|
||||
case SlowCharging: return "\u25b6"; // ▶
|
||||
case FastCharging: return "\u25b6\u25b6"; // ▶▶
|
||||
default: return "?";
|
||||
@@ -361,8 +363,9 @@ class MiscGui : public BaseMenuGui
|
||||
ChargeInfo* chargeInfo;
|
||||
I2cInfo* i2cInfo;
|
||||
LblBacklightSwitchStatus lblstatus = LblBacklightSwitchStatus_Disabled;
|
||||
bool isEnoughPowerSupplied = false;
|
||||
char infoOutput[800] = "";
|
||||
|
||||
const char* infoNames = "Charger:\nBattery:\nCurrent Limit:\nCharging Limit:\nRaw Charge:\nBattery Age:\nPower Role:\nCurrent Flow:\n\nCPU Volt:\nGPU Volt:\nDRAM Volt:";
|
||||
char infoVals[300] = "";
|
||||
char chargingLimitBarDesc[30] = "";
|
||||
u8 frameCounter = 60;
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
fw_dir="/Volumes/RAM/NX-14.0.0/"
|
||||
tmp_dir="/Volumes/RAM/"
|
||||
repack_out_dir="/Volumes/RAM/out/"
|
||||
fw_dir="/Volumes/RAMDISK/NX-15.0.0/"
|
||||
tmp_dir="/Volumes/RAMDISK/"
|
||||
repack_out_dir="/Volumes/RAMDISK/out/"
|
||||
oc_test_dir="$HOME/Source/Switch-OC-Suite/Source/Atmosphere/stratosphere/loader/source/oc"
|
||||
prodkeys="$HOME/.switch/prod.keys"
|
||||
hactool_exe="$HOME/Source/hactool/hactool"
|
||||
|
||||
Reference in New Issue
Block a user