From 139c7dfcad67d4e0447225a83f9d29bcfce66958 Mon Sep 17 00:00:00 2001 From: KazushiM <85604869+KazushiMe@users.noreply.github.com> Date: Fri, 30 Dec 2022 20:57:02 +0800 Subject: [PATCH] - oc_loader: pcv_erista: use 1963.5 MHz instead of 1989 - sys-clk-OC: update safe/unsafe frequencies (Erista CPU 1785/2091, Mariko CPU 1963/2397, Mariko GPU 998/1305); add 408/510 MHz CPU clocks; add unsafe toggle for Erista --- README.md | 13 +++++++--- .../loader/source/oc/pcv/pcv_erista.hpp | 2 +- Source/sys-clk-OC/README.md | 25 ++++++++++++------- Source/sys-clk-OC/build.sh | 2 +- Source/sys-clk-OC/common/src/clock_table.c | 2 ++ .../overlay/src/ui/gui/misc_gui.cpp | 3 ++- .../sysmodule/src/clock_manager.cpp | 4 +-- Source/sys-clk-OC/sysmodule/src/clocks.cpp | 25 +++++++++---------- Source/sys-clk-OC/sysmodule/src/config.cpp | 1 - 9 files changed, 46 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index a5f88766..e9073949 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,12 @@ Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. ## Features - Erista variant (HAC-001) + - CPU Overclock + - Safe: 1785 MHz + - Unsafe (due to the limit of board power draw or power IC): + - Enable "Allow Unsafe Frequencies" in overlay to unlock frequencies up to 2091 MHz + - See [README for sys-clk-OC](https://github.com/KazushiMe/Switch-OC-Suite/blob/master/Source/sys-clk-OC/README.md) + - DRAM Overclock - Safe: 1862.4 MHz - Unsafe: @@ -28,8 +34,8 @@ Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. - Mariko variant (HAC-001-01, HDH-001, HEG-001) - CPU / GPU Overclock - - Safe: 1963 / 921 MHz - - Unsafe: + - Safe: 1963 / 998 MHz + - Unsafe (due to the limit of board power draw or power IC): - Enable "Allow Unsafe Frequencies" in overlay to unlock frequencies up to 2397 / 1305 MHz - See [README for sys-clk-OC](https://github.com/KazushiMe/Switch-OC-Suite/blob/master/Source/sys-clk-OC/README.md) @@ -53,7 +59,8 @@ Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. - CPU & GPU frequency governor (Experimental) - Adjust frequency based on load. Might decrease power draw but can introduce stutters. Can be turned off for specific titles. -- Fast-charging (2A) toggle, set charge limit (20% - 100%) +- Fast-charging (0.5A/2A) toggle, set charge limit (20% - 100%) + - Hoag (Switch Lite) cannot use the fast-charging toggle feature for now [#56](https://github.com/KazushiMe/Switch-OC-Suite/issues/56). - Long-term use of charge limit may render the battery gauge inaccurate. Performing full cycles could help recalibration, or try [battery_desync_fix_nx](https://github.com/CTCaer/battery_desync_fix_nx). - Global profile diff --git a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_erista.hpp b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_erista.hpp index 16b3149d..f01fe4de 100644 --- a/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_erista.hpp +++ b/Source/Atmosphere/stratosphere/loader/source/oc/pcv/pcv_erista.hpp @@ -42,7 +42,7 @@ constexpr cpu_freq_cvb_table_t CpuCvbTableDefault[] = { constexpr cpu_freq_cvb_table_t CpuCvbTableAppend[] = { { 1887000, { 1235000 }, { 5100873, -279186, 4747 } }, - { 1989000, { 1235000 }, { 5100873, -279186, 4747 } }, + { 1963500, { 1235000 }, { 5100873, -279186, 4747 } }, { 2091000, { 1235000 }, { 5100873, -279186, 4747 } }, }; diff --git a/Source/sys-clk-OC/README.md b/Source/sys-clk-OC/README.md index 659ae0be..7bb5ceb3 100644 --- a/Source/sys-clk-OC/README.md +++ b/Source/sys-clk-OC/README.md @@ -7,11 +7,11 @@ Switch sysmodule allowing you to set cpu/gpu clocks according to the running app ### CPU clocks -* 2397 → approx. max for Mariko +* 2397 → approx. OC max for Mariko * 2295 * 2193 -* 2091 → max for Mariko (without overvolting – capped at 1120 mV) -* 1963 → official max for Mariko +* 2091 → OC max for Erista +* 1963 → official and safe max for Mariko * 1887 * 1785 → official boost mode, OC max for Erista * 1683 @@ -28,13 +28,12 @@ Switch sysmodule allowing you to set cpu/gpu clocks according to the running app ### GPU clocks -* ???? * 1305 → OC max for Mariko * 1267 → official max for Mariko * 1228 * 1152 * 1075 -* 998 +* 998 → safe max for Mariko due to power draw * 921 → OC max for Erista * 844 * 768 → official docked @@ -72,11 +71,19 @@ From Hekate Minerva module [sys_sdrammtc.c](https://github.com/CTCaer/hekate/blo To protect the battery from excessive strain, clocks requested from config may be capped before applying, depending on your current profile: -### Erista +### Erista (Safe) | | Handheld | Charging (USB) | Charging (Official) | Docked | |:-------:|:--------:|:--------------:|:-------------------:|:------:| | **MEM** | - | - | - | - | -| **CPU** | - | - | - | - | +| **CPU** | 1785 | 1785 | 1785 | 1785 | +| **GPU** | 460 | 768 | - | - | + + +### Erista (Unsafe allowed) +| | Handheld | Charging (USB) | Charging (Official) | Docked | +|:-------:|:--------:|:--------------:|:-------------------:|:------:| +| **MEM** | - | - | - | - | +| **CPU** | 1785 | - | - | - | | **GPU** | 460 | 768 | - | - | @@ -85,7 +92,7 @@ To protect the battery from excessive strain, clocks requested from config may b |:-------:|:--------:|:--------------:|:-------------------:|:------:| | **MEM** | - | - | - | - | | **CPU** | 1963 | 1963 | 1963 | 1963 | -| **GPU** | 921 | 921 | 921 | 921 | +| **GPU** | 998 | 998 | 998 | 998 | ### Mariko (Unsafe allowed) @@ -93,7 +100,7 @@ To protect the battery from excessive strain, clocks requested from config may b |:-------:|:--------:|:--------------:|:-------------------:|:------:| | **MEM** | - | - | - | - | | **CPU** | - | - | - | - | -| **GPU** | 921 | 1267 | - | - | +| **GPU** | 998 | - | - | - | ## Installation diff --git a/Source/sys-clk-OC/build.sh b/Source/sys-clk-OC/build.sh index 00acbc6a..2ffb7fb5 100755 --- a/Source/sys-clk-OC/build.sh +++ b/Source/sys-clk-OC/build.sh @@ -20,7 +20,7 @@ make -j$CORES popd > /dev/null mkdir -p "$DIST_DIR/atmosphere/contents/$TITLE_ID/flags" -cp -vf "$ROOT_DIR/sysmodule/out/sys-clk.nsp" "$DIST_DIR/atmosphere/contents/$TITLE_ID/exefs.nsp" +cp -vf "$ROOT_DIR/sysmodule/out/sys-clk-OC.nsp" "$DIST_DIR/atmosphere/contents/$TITLE_ID/exefs.nsp" >"$DIST_DIR/atmosphere/contents/$TITLE_ID/flags/boot2.flag" echo "*** manager ***" diff --git a/Source/sys-clk-OC/common/src/clock_table.c b/Source/sys-clk-OC/common/src/clock_table.c index 83df6655..3b798c9a 100644 --- a/Source/sys-clk-OC/common/src/clock_table.c +++ b/Source/sys-clk-OC/common/src/clock_table.c @@ -31,6 +31,8 @@ uint32_t g_freq_table_mem_hz[] = { }; uint32_t g_freq_table_cpu_hz[] = { + 408000000, + 510000000, 612000000, 714000000, 816000000, diff --git a/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.cpp b/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.cpp index bfdd9f13..f089f548 100644 --- a/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.cpp +++ b/Source/sys-clk-OC/overlay/src/ui/gui/misc_gui.cpp @@ -57,9 +57,10 @@ void MiscGui::listUI() this->listElement->addItem(new tsl::elm::CategoryHeader("Config")); if (this->isMariko) { - addConfigToggle(SysClkConfigValue_AllowUnsafeFrequencies); addConfigToggle(SysClkConfigValue_AutoCPUBoost); } + + addConfigToggle(SysClkConfigValue_AllowUnsafeFrequencies); addConfigToggle(SysClkConfigValue_SyncReverseNXMode); addConfigToggle(SysClkConfigValue_DisableFastCharging); addConfigToggle(SysClkConfigValue_GovernorExperimental); diff --git a/Source/sys-clk-OC/sysmodule/src/clock_manager.cpp b/Source/sys-clk-OC/sysmodule/src/clock_manager.cpp index dfa8457c..cecd70a4 100644 --- a/Source/sys-clk-OC/sysmodule/src/clock_manager.cpp +++ b/Source/sys-clk-OC/sysmodule/src/clock_manager.cpp @@ -216,9 +216,9 @@ bool ClockManager::RefreshContext() bool hasChanged = this->config->Refresh(); if (hasChanged) { this->rnxSync->ToggleSync(this->GetConfig()->GetConfigValue(SysClkConfigValue_SyncReverseNXMode)); + bool allowUnsafe = this->GetConfig()->GetConfigValue(SysClkConfigValue_AllowUnsafeFrequencies); + Clocks::SetAllowUnsafe(allowUnsafe); if (Clocks::GetIsMariko()) { - bool allowUnsafe = this->GetConfig()->GetConfigValue(SysClkConfigValue_AllowUnsafeFrequencies); - Clocks::SetAllowUnsafe(allowUnsafe); this->governor->SetCPUBoostHz(Clocks::GetNearestHz(SysClkModule_CPU, SysClkProfile_EnumMax, Clocks::boostCpuFreq)); this->governor->SetAutoCPUBoost(this->GetConfig()->GetConfigValue(SysClkConfigValue_AutoCPUBoost)); } diff --git a/Source/sys-clk-OC/sysmodule/src/clocks.cpp b/Source/sys-clk-OC/sysmodule/src/clocks.cpp index bc3e92cd..e6d7e257 100644 --- a/Source/sys-clk-OC/sysmodule/src/clocks.cpp +++ b/Source/sys-clk-OC/sysmodule/src/clocks.cpp @@ -24,33 +24,32 @@ void Clocks::GetRange(SysClkModule module, SysClkProfile profile, uint32_t** min if (module == SysClkModule_CPU) { *min = &g_freq_table_cpu_hz[0]; - if (!isMariko) - *max = &g_freq_table_cpu_hz[11]; // 1785 - else { - if (allowUnsafe) - *max = &g_freq_table_cpu_hz[17]; // 2397 - else - *max = &g_freq_table_cpu_hz[13]; // 1963 - } + if (isMariko) + *max = !allowUnsafe ? &g_freq_table_cpu_hz[15] : &g_freq_table_cpu_hz[19]; // 1963 / 2397 + else + *max = (!allowUnsafe || profile == SysClkProfile_Handheld) ? + &g_freq_table_cpu_hz[13] : &g_freq_table_cpu_hz[16]; // 1785 / 2091 + return; } if (module == SysClkModule_GPU) { *min = &g_freq_table_gpu_hz[0]; - if (isMariko && !allowUnsafe) { - *max = &g_freq_table_gpu_hz[11]; // 921 + if (isMariko) { + *max = (!allowUnsafe || profile == SysClkProfile_Handheld) ? + &g_freq_table_gpu_hz[12] : &g_freq_table_gpu_hz[17]; // 998 / 1305 return; } switch (profile) { case SysClkProfile_Handheld: - *max = isMariko ? &g_freq_table_gpu_hz[11] : &g_freq_table_gpu_hz[5]; // 921 / 460 + *max = &g_freq_table_gpu_hz[5]; // 460 break; case SysClkProfile_HandheldChargingUSB: - *max = isMariko ? &g_freq_table_gpu_hz[16] : &g_freq_table_gpu_hz[9]; // 1267 / 768 + *max = &g_freq_table_gpu_hz[9]; // 768 break; default: - *max = isMariko ? &g_freq_table_gpu_hz[17] : &g_freq_table_gpu_hz[11]; // 1305 / 921 + *max = &g_freq_table_gpu_hz[11]; // 921 break; } return; diff --git a/Source/sys-clk-OC/sysmodule/src/config.cpp b/Source/sys-clk-OC/sysmodule/src/config.cpp index 4890bde2..4d287ba8 100644 --- a/Source/sys-clk-OC/sysmodule/src/config.cpp +++ b/Source/sys-clk-OC/sysmodule/src/config.cpp @@ -70,7 +70,6 @@ void Config::Load() // Erista: Disable Mariko only features if (!Clocks::GetIsMariko()) { - this->configValues[SysClkConfigValue_AllowUnsafeFrequencies] = 0; this->configValues[SysClkConfigValue_AutoCPUBoost] = 0; }