From 9cfe8122479ce936e65dbc8201edc2b61be8e7d9 Mon Sep 17 00:00:00 2001 From: KazushiM <85604869+KazushiMe@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:27:04 +0800 Subject: [PATCH] Run [page minifier](https://www.npmjs.com/package/minify) locally before deployment --- ...ploy_configurator.yml => deploy_pages.yml} | 15 +- pages/build.sh | 13 +- pages/dist/index.html | 404 +---------------- pages/dist/main.js | 406 +----------------- pages/src/index.html | 2 +- pages/src/main.ts | 3 +- 6 files changed, 17 insertions(+), 826 deletions(-) rename .github/workflows/{deploy_configurator.yml => deploy_pages.yml} (55%) diff --git a/.github/workflows/deploy_configurator.yml b/.github/workflows/deploy_pages.yml similarity index 55% rename from .github/workflows/deploy_configurator.yml rename to .github/workflows/deploy_pages.yml index e01792b7..54e3bfc8 100644 --- a/.github/workflows/deploy_configurator.yml +++ b/.github/workflows/deploy_pages.yml @@ -1,5 +1,5 @@ # Simple workflow for deploying static content to GitHub Pages -name: Deploy static content to Pages (Configurator) +name: Deploy static content to Pages on: # Runs on pushes targeting the default branch @@ -32,22 +32,11 @@ jobs: uses: actions/checkout@v3 - name: Setup Pages uses: actions/configure-pages@v2 - - name: HTML/CSS/JS Minifier - # You may pin to the exact commit or the version. - # uses: devatherock/minify-js@a25175eaf2c438680b21b73882d4837418e9d58b - uses: devatherock/minify-js@v1.0.3 - with: - # File to minify or a folder containing files to minify. By default, all files in current folder and its subfolders will be minified - directory: './pages/dist' # optional - # Path where the minified files will be saved. By default, the minified files will be saved in the original file path - output: './pages/dist_min' # optional - # Indicates if the output files should have the suffix '.min' added after the name. Default is true - add_suffix: false # optional - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: # Upload entire repository - path: './pages/dist_min' + path: './pages/dist' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v1 diff --git a/pages/build.sh b/pages/build.sh index a3fbff59..3fa553df 100755 --- a/pages/build.sh +++ b/pages/build.sh @@ -1,6 +1,15 @@ #!/bin/bash +[ -d "./tmp" ] || mkdir ./tmp [ -d "./dist" ] || mkdir ./dist -cp -Rf ./src/*.html ./dist/ + # README_HTML=`pandoc -f gfm -t html5 ../README.md` -tsc ./src/main.ts --outDir ./dist/ -lib es2015,dom -t es2015 + +cp -Rf ./src/*.html ./tmp/ +tsc ./src/main.ts --outDir ./tmp/ -lib es2015,dom -t es2015 + +for FILE in ./tmp/*; do + minify "${FILE}" > "./dist/${FILE/.\/tmp\/}" +done + +rm -fr ./tmp \ No newline at end of file diff --git a/pages/dist/index.html b/pages/dist/index.html index 45262af2..4059701a 100644 --- a/pages/dist/index.html +++ b/pages/dist/index.html @@ -1,403 +1 @@ - - - - - - - Switch OC Suite | Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. Licensed under GPL v2. - - - - - - - -
- -
-
-

Switch OC Suite

-

Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. Licensed under GPL v2.

-
-
-
-
-
-
-
-
-

Read Me

-

🚨DISCLAIMER: THIS IS PROVIDED AS IS. USE AT YOUR OWN RISK!🚨

-
-
  • - Overclocking in general will shorten the lifespan of some - hardware components. YOU ARE RESPONSIBLE for any problem or - potential damage if unsafe frequencies are ENABLED in - sys-clk-OC. Issues like asking for bypassing limit will BE IGNORED OR - CLOSED WITHOUT REPLY. -
  • -
  • - Due to HorizonOS design, instabilities from unsafe RAM clocks may - cause filesystem corruption. Always make backup before enabling - DRAM OC. -
  • -
    - - -

    Features

    -
    - For Erista variant (HAC-001) -
      -
    • CPU Overclock (Safe: 1785 MHz) -
        -
      • Unsafe -
          -
        • Due to the limit of board power draw or power IC
        • -
        • Unlockable frequencies up to 2091 MHz
        • -
        • See README - for sys-clk-OC
        • -
        -
      • -
      -
    • -
    • DRAM Overclock (Safe: 1862.4 MHz)
    • -
    -
    -
    - For Mariko variant (HAC-001-01, HDH-001, HEG-001) -
      -
    • CPU / GPU Overclock (Safe: 1963 / 998 MHz) -
        -
      • Unsafe -
          -
        • Due to the limit of board power draw or power IC
        • -
        • Unlockable frequencies up to 2397 / 1305 MHz or 2295 / 1267 MHz
        • -
        • See README - for sys-clk-OC
        • -
        -
      • -
      -
    • -
    • DRAM Overclock (Safe: 1996.8 MHz)
    • -
    -
    -
    - Modded sys-clk and ReverseNX-RT -
      -
    • Auto CPU Boost -
        -
      • For faster game loading
      • -
      • Enable CPU Boost (1785 MHz) when CPU Core#3 (System Core) is - stressed (mainly I/O operations).
      • -
      • Effective only when charger is connected.
      • -
      -
    • -
    • 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.
      • -
      -
    • -
    • Set charging current (100 mA - 2000 mA) and charging limit (20% - - 100%) -
        -
      • Long-term use of charge limit may render the battery gauge - inaccurate. Performing full cycles could help recalibration, or try battery_desync_fix_nx.
      • -
      -
    • -
    • Global Profile -
        -
      • Designated a dummy title id 0xA111111111111111.
      • -
      • Priority: "Temp overrides" > "Application profile" > "Global - profile" > "System default".
      • -
      -
    • -
    • Sync ReverseNX Mode -
        -
      • No need to change clocks manually after toggling modes in ReverseNX - (-RT and -Tool)
      • -
      -
    • -
    -
    -
    - System Settings (Optional) - See system_settings.md -
    -

    Installation

    -
      -
    1. Download latest release.
    2. -
    3. Copy all files in SdOut to the root of SD card.
    4. -
    5. Grab x.x.x_loader.kip for your Atmosphere version, rename it to loader.kip and - place it in /atmosphere/kips/.
    6. -
    7. Customization via online loader configurator -
      - Default config - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      DefaultsMarikoErista
      CPU OC2397 MHz Max2091 MHz Max
      CPU Boost1785 MHzN/A
      CPU Volt1235 mV Max1235 mV Max
      GPU OC1305 MHz MaxN/A
      RAM OC1996 MHz Max1862 MHz Max
      RAM VoltDisabledDisabled
      RAM TimingAuto-AdjustedDisabled
      -
      -
    8. -
    9. Hekate-ipl bootloader Only -
        -
      • Add kip1=atmosphere/kips/loader.kip to boot entry - section in bootloader/hekate_ipl.ini.
      • -
      -
    10. -
    -
    - Deprecated: patching sysmodules manually -
      -
    • This method is only served as reference as it could damage your MMC file system if not handled - properly.
    • -
    • Patched sysmodules would be persistent until pcv or ptm was updated in new HOS (normally in - x.0.0). -
    • -
    • Tools: - -
    • -
    -
      -
    1. Dump prod.keys with Lockpick_RCM
    2. -
    3. Dump HOS firmware with TegraExplorer
    4. -
    5. Configure and run test_patch.sh to generate patched pcv & ptm sysmodules in nca
    6. -
    7. Replace nca in SYSTEM:/Contents/registered/ with TegraExplorer
    8. -
    9. ValidateAcidSignature() should be stubbed to allow unsigned sysmodules to load (a.k.a. - loader_patch) -
    10. -
    -
    -
    - How to build this project -
      -
    1. Grab necessary patches from the repo, then compile sys-clk, ReverseNX-RT and Atmosphere loader with - devkitpro.
    2. -
    3. Before compiling Atmosphere loader, run patch.py in - Atmosphere/stratosphere/loader/source/ to insert oc module into loader sysmodule. -
    4. -
    5. When compilation is done, uncompress the kip to make it work with configurator: - hactool -t kip1 Atmosphere/stratosphere/loader/out/nintendo_nx_arm64_armv8a/release/loader.kip --uncompress=./loader.kip -
    6. -
    -
    -

    Frequently Asked Questions

    -
    - How to enable unsafe frequencies in sys-clk-OC? -
  • Above all else, you should know what "unsafe" means and issues might arise.
  • -
  • See the end of README in sys-clk-OC. Add this line allow_unsafe_freq=1 into - /config/sys-clk/config.ini -
  • -
    -
    - I would like to bypass limit enforced in sys-clk to improve handheld performance without charger - connected. -
  • Never will it be implemented here, or work out of the box.
  • -
  • You have to modify the code yourself for your own use. If you are to share modified binaries you have - made based on this project publicly, make sure to comply with GPL v2 licenses.
  • -
    - - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -

    Configurator

    -

    Configure frequencies and voltages to suit your hardware and preferences.

    -
    -
    - - -
    - -
    - - -
    -
    -
    - - - - - \ No newline at end of file +Switch OC Suite | Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. Licensed under GPL v2.

    Switch OC Suite

    Overclocking suite for Horizon OS (HOS) running on Atmosphere CFW. Licensed under GPL v2.

    Read Me

    🚨DISCLAIMER: THIS IS PROVIDED AS IS. USE AT YOUR OWN RISK!🚨

  • Overclocking in general will shorten the lifespan of some hardware components. YOU ARE RESPONSIBLE for any problem or potential damage if unsafe frequencies are ENABLED in sys-clk-OC. Issues like asking for bypassing limit will BE IGNORED OR CLOSED WITHOUT REPLY.
  • Due to HorizonOS design, instabilities from unsafe RAM clocks may cause filesystem corruption. Always make backup before enabling DRAM OC.
  • Features

    For Erista variant (HAC-001)
    • CPU Overclock (Safe: 1785 MHz)
      • Unsafe
        • Due to the limit of board power draw or power IC
        • Unlockable frequencies up to 2091 MHz
        • See README for sys-clk-OC
    • DRAM Overclock (Safe: 1862.4 MHz)
    For Mariko variant (HAC-001-01, HDH-001, HEG-001)
    • CPU / GPU Overclock (Safe: 1963 / 998 MHz)
      • Unsafe
        • Due to the limit of board power draw or power IC
        • Unlockable frequencies up to 2397 / 1305 MHz or 2295 / 1267 MHz
        • See README for sys-clk-OC
    • DRAM Overclock (Safe: 1996.8 MHz)
    Modded sys-clk and ReverseNX-RT
    • Auto CPU Boost
      • For faster game loading
      • Enable CPU Boost (1785 MHz) when CPU Core#3 (System Core) is stressed (mainly I/O operations).
      • Effective only when charger is connected.
    • 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.
    • Set charging current (100 mA - 2000 mA) and charging limit (20% - 100%)
      • Long-term use of charge limit may render the battery gauge inaccurate. Performing full cycles could help recalibration, or try battery_desync_fix_nx.
    • Global Profile
      • Designated a dummy title id 0xA111111111111111.
      • Priority: "Temp overrides" > "Application profile" > "Global profile" > "System default".
    • Sync ReverseNX Mode
      • No need to change clocks manually after toggling modes in ReverseNX (-RT and -Tool)
    System Settings (Optional)See system_settings.md

    Installation

    1. Download latest release.
    2. Copy all files in SdOut to the root of SD card.
    3. Grab x.x.x_loader.kip for your Atmosphere version, rename it to loader.kip and place it in /atmosphere/kips/.
    4. Customization via online loader configurator
      Default config
      DefaultsMarikoErista
      CPU OC2397 MHz Max2091 MHz Max
      CPU Boost1785 MHzN/A
      CPU Volt1235 mV Max1235 mV Max
      GPU OC1305 MHz MaxN/A
      RAM OC1996 MHz Max1862 MHz Max
      RAM VoltDisabledDisabled
      RAM TimingAuto-AdjustedDisabled
    5. Hekate-ipl bootloader Only
      • Add kip1=atmosphere/kips/loader.kip to boot entry section in bootloader/hekate_ipl.ini.
    Deprecated: patching sysmodules manually
    • This method is only served as reference as it could damage your MMC file system if not handled properly.
    • Patched sysmodules would be persistent until pcv or ptm was updated in new HOS (normally in x.0.0).
    • Tools:
    1. Dump prod.keys with Lockpick_RCM
    2. Dump HOS firmware with TegraExplorer
    3. Configure and run test_patch.sh to generate patched pcv & ptm sysmodules in nca
    4. Replace nca in SYSTEM:/Contents/registered/ with TegraExplorer
    5. ValidateAcidSignature() should be stubbed to allow unsigned sysmodules to load (a.k.a. loader_patch)
    How to build this project
    1. Grab necessary patches from the repo, then compile sys-clk, ReverseNX-RT and Atmosphere loader with devkitpro.
    2. Before compiling Atmosphere loader, run patch.py in Atmosphere/stratosphere/loader/source/ to insert oc module into loader sysmodule.
    3. When compilation is done, uncompress the kip to make it work with configurator: hactool -t kip1 Atmosphere/stratosphere/loader/out/nintendo_nx_arm64_armv8a/release/loader.kip --uncompress=./loader.kip

    Frequently Asked Questions

    How to enable unsafe frequencies in sys-clk-OC?
  • Above all else, you should know what "unsafe" means and issues might arise.
  • See the end of README in sys-clk-OC. Add this line allow_unsafe_freq=1 into /config/sys-clk/config.ini
  • I would like to bypass limit enforced in sys-clk to improve handheld performance without charger connected.
  • Never will it be implemented here, or work out of the box.
  • You have to modify the code yourself for your own use. If you are to share modified binaries you have made based on this project publicly, make sure to comply with GPL v2 licenses.
  • Configurator

    Configure frequencies and voltages to suit your hardware and preferences.

    diff --git a/pages/dist/main.js b/pages/dist/main.js index baa6e5fd..c49edabf 100644 --- a/pages/dist/main.js +++ b/pages/dist/main.js @@ -1,405 +1 @@ -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -/* Config: Cust */ -const CUST_REV = 3; -var buffer; -var CustPlatform; -(function (CustPlatform) { - CustPlatform[CustPlatform["Undefined"] = 0] = "Undefined"; - CustPlatform[CustPlatform["Erista"] = 1] = "Erista"; - CustPlatform[CustPlatform["Mariko"] = 2] = "Mariko"; - CustPlatform[CustPlatform["All"] = 3] = "All"; -})(CustPlatform || (CustPlatform = {})); -; -class CustEntry { - constructor(id, name, platform, size, desc, defval, minmax = [0, 1000000], step = 1, zeroable = true) { - this.id = id; - this.name = name; - this.platform = platform; - this.size = size; - this.desc = desc; - this.defval = defval; - this.min = minmax[0]; - this.max = minmax[1]; - this.step = step; - this.zeroable = zeroable; - } - ; - validate() { - let tip = new ErrorToolTip(this.id); - tip.clear(); - if (Number.isNaN(this.value) || !this.value) { - tip.setMsg(`Invalid value: Not a number`); - tip.show(); - return false; - } - if (this.zeroable && this.value == 0) - return true; - if (this.value < this.min || this.value > this.max) { - tip.setMsg(`Expected range: [${this.min}, ${this.max}], got ${this.value}.`); - tip.show(); - return false; - } - if (this.value % this.step != 0) { - tip.setMsg(`${this.value} % ${this.step} ≠ 0`); - tip.show(); - return false; - } - return true; - } - ; - getInputElement() { - return document.getElementById(this.id); - } - updateValueFromElement() { - this.value = Number(this.getInputElement().value); - } - isAvailableFor(platform) { - return platform === CustPlatform.Undefined || this.platform === platform || this.platform === CustPlatform.All; - } - createElement() { - let form = document.getElementById("form"); - let input = this.getInputElement(); - if (!input) { - let grid = document.createElement("div"); - grid.classList.add("grid", "cust-element"); - // Label and input - input = document.createElement("input"); - input.min = String(this.zeroable ? 0 : this.min); - input.max = String(this.max); - input.id = this.id; - input.type = "number"; - input.step = String(this.step); - let label = document.createElement("label"); - label.setAttribute("for", this.id); - label.innerHTML = this.name; - label.appendChild(input); - grid.appendChild(label); - // Description in blockquote style - let desc = document.createElement("blockquote"); - desc.innerHTML = this.desc; - desc.setAttribute("for", this.id); - grid.appendChild(desc); - form.appendChild(grid); - let tooltip = new ErrorToolTip(this.id); - tooltip.addChangeListener(); - } - input.value = String(this.value); - } - setElementDefaultValue() { - document.getElementById(this.id).value = String(this.defval); - } - removeElement() { - let input = this.getInputElement(); - if (input) { - input.parentElement.parentElement.remove(); - } - } - showElement() { - let input = this.getInputElement(); - if (input) { - input.parentElement.parentElement.style.removeProperty("display"); - } - } - hideElement() { - let input = this.getInputElement(); - if (input) { - input.parentElement.parentElement.style.setProperty("display", "none"); - } - } -} -var CustTable = [ - new CustEntry("mtcConf", "DRAM Timing", CustPlatform.Mariko, 2, "
  • 0: AUTO_ADJ_MARIKO_SAFE: Auto adjust timings for LPDDR4 ≤3733 Mbps specs, 8Gb density. (Default)
  • \ -
  • 1: AUTO_ADJ_MARIKO_4266: Auto adjust timings for LPDDR4X 4266 Mbps specs, 8Gb density.
  • \ -
  • 2: NO_ADJ_ALL: No timing adjustment for both Erista and Mariko. Might achieve better performance on Mariko but lower maximum frequency is expected.", 0, [0, 2], 1), - new CustEntry("marikoCpuMaxClock", "Mariko CPU Max Clock in kHz", CustPlatform.Mariko, 4, "
  • System default: 1785000
  • \ -
  • 2397000 might be unreachable for some SoCs.
  • ", 2397000, [1785000, 3000000], 1), - new CustEntry("marikoCpuBoostClock", "Mariko CPU Boost Clock in kHz", CustPlatform.Mariko, 4, "
  • System default: 1785000
  • \ -
  • Boost clock will be applied when applications request higher CPU frequency for quicker loading.
  • \ -
  • This will be set regardless of whether sys-clk is enabled.
  • ", 1785000, [1020000, 3000000], 1, false), - new CustEntry("marikoCpuMaxVolt", "Mariko CPU Max Voltage in mV", CustPlatform.Mariko, 4, "
  • System default: 1120
  • \ -
  • Acceptable range: 1100 ≤ x ≤ 1300
  • ", 1235, [1100, 1300], 5), - new CustEntry("marikoGpuMaxClock", "Mariko GPU Max Clock in kHz", CustPlatform.Mariko, 4, "
  • System default: 921600
  • \ -
  • Tegra X1+ official maximum: 1267200
  • \ -
  • 1305600 might be unreachable for some SoCs.
  • ", 1305600, [768000, 1536000], 100), - new CustEntry("marikoEmcMaxClock", "Mariko RAM Max Clock in kHz", CustPlatform.Mariko, 4, "
  • Values should be ≥ 1600000, and divided evenly by 3200.
  • \ -
  • WARNING: RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM
  • ", 1996800, [1600000, 2400000], 3200), - new CustEntry("marikoEmcVddqVolt", "EMC Vddq (Mariko Only) Voltage in uV", CustPlatform.Mariko, 4, "
  • Acceptable range: 550000 ≤ x ≤ 650000
  • \ -
  • Value should be divided evenly by 5000
  • \ -
  • Default: 600000
  • \ -
  • Not enabled by default.
  • \ -
  • This will not work without sys-clk-OC.
  • ", 0, [550000, 650000], 5000), - new CustEntry("eristaCpuMaxVolt", "Erista CPU Max Voltage in mV", CustPlatform.Erista, 4, "
  • Acceptable range: 1100 ≤ x ≤ 1300
  • ", 1235, [1100, 1300], 1), - new CustEntry("eristaEmcMaxClock", "Erista RAM Max Clock in kHz", CustPlatform.Erista, 4, "
  • Values should be ≥ 1600000, and divided evenly by 3200.
  • \ -
  • WARNING: RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM
  • ", 1862400, [1600000, 2400000], 3200), - new CustEntry("commonEmcMemVolt", "EMC Vddq (Erista Only) & RAM Vdd2 Voltage in uV", CustPlatform.All, 4, "
  • Acceptable range: 1100000 ≤ x ≤ 1250000, and it should be divided evenly by 12500.
  • \ -
  • Erista Default (HOS): 1125000 (bootloader: 1100000)
  • \ -
  • Mariko Default: 1100000 (It will not work without sys-clk-OC)
  • \ -
  • Not enabled by default
  • ", 0, [1100000, 1250000], 12500), -]; -function FindMagicOffset(buffer) { - let view = new DataView(buffer); - for (let i = 0; i < view.byteLength; i += 4) { - if (view.getUint32(i, true) == 0x54535543) { // "CUST" - return i; - } - } - throw new Error("Invalid loader.kip file"); -} -class ErrorToolTip { - constructor(id, msg) { - this.id = id; - this.element = document.getElementById(id); - if (msg) { - this.setMsg(msg); - } - } - ; - setMsg(msg) { - this.message = msg; - } - show() { - if (this.element) { - this.element.setAttribute("aria-invalid", "true"); - if (this.message) { - this.element.setAttribute("title", this.message); - this.element.parentElement.setAttribute("data-tooltip", this.message); - this.element.parentElement.setAttribute("data-placement", "top"); - } - } - } - ; - clear() { - if (this.element) { - this.element.removeAttribute("aria-invalid"); - this.element.removeAttribute("title"); - this.element.parentElement.removeAttribute("data-tooltip"); - this.element.parentElement.removeAttribute("data-placement"); - } - } - addChangeListener() { - if (this.element) { - this.element.addEventListener('change', (_evt) => { - let obj = CustTable.filter((obj) => { return obj.id === this.id; })[0]; - obj.value = Number(this.element.value); - obj.validate(); - }); - } - } -} -; -function SaveCust(buffer) { - let view = new DataView(buffer); - let storage = {}; - CustTable.forEach(i => { - i.updateValueFromElement(); - if (!i.validate() || !i.value) { - document.getElementById(i.id).focus(); - throw new Error(`Invalid ${i.name}`); - } - if (!i.offset) { - document.getElementById(i.id).focus(); - throw new Error(`Failed to get offset for ${i.name}`); - ; - } - switch (i.size) { - case 2: - view.setUint16(i.offset, i.value, true); - break; - case 4: - view.setUint32(i.offset, i.value, true); - break; - default: - document.getElementById(i.id).focus(); - throw new Error(`Unknown size at ${i.name}`); - } - storage[i.id] = i.value; - }); - storage["custRev"] = CUST_REV; - localStorage.setItem("last_saved", JSON.stringify(storage)); - let a = document.createElement("a"); - a.href = window.URL.createObjectURL(new Blob([buffer], { type: "application/octet-stream" })); - a.download = "loader.kip"; - a.click(); -} -function LastSaved() { - let storage = localStorage.getItem("last_saved"); - if (!storage) { - return false; - } - let sObj = JSON.parse(storage); - if (!sObj["custRev"] || sObj["custRev"] != CUST_REV) { - localStorage.removeItem("last_saved"); - return false; - } - return true; -} -function CustNavTabsInit() { - const custNavTabs = Array.from(document.querySelectorAll(`nav[role="tab-control"] > button`)); - custNavTabs.forEach(i => { - i.removeAttribute("disabled"); - let platform = Number(i.getAttribute("data-filter")); - i.addEventListener('click', (_evt) => { - const unfocusedClasses = ["outline", "secondary"]; - i.classList.remove(...unfocusedClasses); - custNavTabs.filter(j => j != i).forEach(k => k.classList.add(...unfocusedClasses)); - CustTable.forEach(e => { - if (e.isAvailableFor(platform)) { - e.showElement(); - } - else { - e.hideElement(); - } - }); - }); - }); -} -function UpdateHTMLForm() { - CustTable.forEach(i => i.createElement()); - let default_btn = document.getElementById("load_default"); - default_btn.removeAttribute("disabled"); - default_btn.addEventListener('click', () => { - CustTable.forEach(i => i.setElementDefaultValue()); - }); - let last_btn = document.getElementById("load_saved"); - if (LastSaved()) { - last_btn.style.removeProperty("display"); - last_btn.removeAttribute("disabled"); - last_btn.addEventListener('click', () => { - // Load last saved from localStorage - JSON.parse(localStorage.getItem("last_saved")) - .filter((key) => key != "custRev") - .forEach((key) => document.getElementById(key).value = key); - }); - } - else { - last_btn.style.setProperty("display", "none"); - } - let save_btn = document.getElementById("save"); - save_btn.removeAttribute("disabled"); - save_btn.addEventListener('click', () => { - try { - SaveCust(buffer); - } - catch (e) { - console.log(e); - alert(e); - } - }); -} -function ParseCust(magicOffset, buffer) { - let view = new DataView(buffer); - let offset = magicOffset + 4; - let rev = view.getUint16(offset, true); - offset += 2; - if (rev != CUST_REV) { - throw new Error(`Unsupported custRev, expected: ${CUST_REV}, got ${rev}`); - } - document.getElementById("cust_rev").innerHTML = `Cust V${CUST_REV} is loaded.`; - CustTable.forEach(i => { - i.offset = offset; - switch (i.size) { - case 2: - i.value = view.getUint16(offset, true); - break; - case 4: - i.value = view.getUint32(offset, true); - break; - default: - document.getElementById(i.id).focus(); - throw new Error("Unknown size at " + i); - } - offset += i.size; - i.validate(); - }); -} -const fileInput = document.getElementById("file"); -fileInput.addEventListener('change', (event) => { - let reader = new FileReader(); - reader.readAsArrayBuffer(event.target.files[0]); - reader.onloadend = (progEvent) => { - if (progEvent.target.readyState === FileReader.DONE) { - buffer = (progEvent.target.result); - try { - let offset = FindMagicOffset(buffer); - CustTable.forEach(i => i.removeElement()); - ParseCust(offset, buffer); - CustNavTabsInit(); - UpdateHTMLForm(); - } - catch (e) { - console.log(e); - alert(e); - fileInput.value = ""; - } - } - }; -}); -function fetchRelease() { - return __awaiter(this, void 0, void 0, function* () { - try { - const responseFromSuite = yield fetch('https://api.github.com/repos/KazushiMe/Switch-OC-Suite/releases/latest', { - method: 'GET', - headers: { - Accept: 'application/json', - }, - }); - if (!responseFromSuite.ok) { - throw new Error(`Failed to fetch latest release info from GitHub: ${responseFromSuite.status}`); - } - const resultFromSuite = yield responseFromSuite.json(); - const latestVerFromSuite = resultFromSuite.tag_name; - const amsVer = latestVerFromSuite.split(".").slice(0, 3).join("."); - const loaderKip = resultFromSuite.assets.filter((obj) => { - return obj.name.endsWith("loader.kip"); - })[0]; - const sdOut = resultFromSuite.assets.filter((obj) => { - return obj.name.endsWith(".zip"); - })[0]; - const amsReleaseUrl = `https://github.com/Atmosphere-NX/Atmosphere/releases/tags/${amsVer}`; - let info = { - OCSuiteVer: latestVerFromSuite, - LoaderKipUrl: loaderKip.browser_download_url, - LoaderKipTime: loaderKip.updated_at, - SdOutZipUrl: sdOut.browser_download_url, - SdOutZipTime: sdOut.updated_at, - AMSVer: amsVer, - AMSUrl: amsReleaseUrl - }; - return info; - } - catch (e) { - console.log(e); - alert(e); - } - }); -} -function updateDownloadUrls() { - return __awaiter(this, void 0, void 0, function* () { - const updateHref = (id, name, url) => { - let element = document.getElementById(id); - element.innerHTML = name; - element.removeAttribute("aria-busy"); - element.setAttribute("href", url); - }; - let info = yield fetchRelease(); - if (info) { - const loaderKipName = `loader.kip ${info.OCSuiteVer}
    ${info.LoaderKipTime}`; - updateHref("loader_kip_btn", loaderKipName, info.LoaderKipUrl); - const sdOutName = `SdOut.zip ${info.OCSuiteVer}
    ${info.SdOutZipTime}`; - updateHref("sdout_zip_btn", sdOutName, info.SdOutZipUrl); - const amsName = `Atmosphere-NX ${info.AMSVer}`; - updateHref("ams_btn", amsName, info.AMSUrl); - } - }); -} -addEventListener('DOMContentLoaded', (_evt) => __awaiter(this, void 0, void 0, function* () { - yield updateDownloadUrls(); -})); +var __awaiter=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))((function(l,r){function n(e){try{o(a.next(e))}catch(e){r(e)}}function s(e){try{o(a.throw(e))}catch(e){r(e)}}function o(e){var t;e.done?l(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(n,s)}o((a=a.apply(e,t||[])).next())}))};const CUST_REV=3;var buffer,CustPlatform;!function(e){e[e.Undefined=0]="Undefined",e[e.Erista=1]="Erista",e[e.Mariko=2]="Mariko",e[e.All=3]="All"}(CustPlatform||(CustPlatform={}));class CustEntry{constructor(e,t,i,a,l,r,n=[0,1e6],s=1,o=!0){this.id=e,this.name=t,this.platform=i,this.size=a,this.desc=l,this.defval=r,this.min=n[0],this.max=n[1],this.step=s,this.zeroable=o}validate(){let e=new ErrorToolTip(this.id);return e.clear(),Number.isNaN(this.value)||!this.value?(e.setMsg("Invalid value: Not a number"),e.show(),!1):!(!this.zeroable||0!=this.value)||(this.valuethis.max?(e.setMsg(`Expected range: [${this.min}, ${this.max}], got ${this.value}.`),e.show(),!1):this.value%this.step==0||(e.setMsg(`${this.value} % ${this.step} ≠ 0`),e.show(),!1))}getInputElement(){return document.getElementById(this.id)}updateValueFromElement(){this.value=Number(this.getInputElement().value)}isAvailableFor(e){return e===CustPlatform.Undefined||this.platform===e||this.platform===CustPlatform.All}createElement(){let e=this.getInputElement();if(!e){let t=document.createElement("div");t.classList.add("grid","cust-element"),e=document.createElement("input"),e.min=String(this.zeroable?0:this.min),e.max=String(this.max),e.id=this.id,e.type="number",e.step=String(this.step);let i=document.createElement("label");i.setAttribute("for",this.id),i.innerHTML=this.name,i.appendChild(e),t.appendChild(i);let a=document.createElement("blockquote");a.innerHTML=this.desc,a.setAttribute("for",this.id),t.appendChild(a),document.getElementById("form").appendChild(t),new ErrorToolTip(this.id).addChangeListener()}e.value=String(this.value)}setElementDefaultValue(){document.getElementById(this.id).value=String(this.defval)}removeElement(){let e=this.getInputElement();e&&e.parentElement.parentElement.remove()}showElement(){let e=this.getInputElement();e&&e.parentElement.parentElement.style.removeProperty("display")}hideElement(){let e=this.getInputElement();e&&e.parentElement.parentElement.style.setProperty("display","none")}}var CustTable=[new CustEntry("mtcConf","DRAM Timing",CustPlatform.Mariko,2,"
  • 0: AUTO_ADJ_MARIKO_SAFE: Auto adjust timings for LPDDR4 ≤3733 Mbps specs, 8Gb density. (Default)
  • 1: AUTO_ADJ_MARIKO_4266: Auto adjust timings for LPDDR4X 4266 Mbps specs, 8Gb density.
  • 2: NO_ADJ_ALL: No timing adjustment for both Erista and Mariko. Might achieve better performance on Mariko but lower maximum frequency is expected.",0,[0,2],1),new CustEntry("marikoCpuMaxClock","Mariko CPU Max Clock in kHz",CustPlatform.Mariko,4,"
  • System default: 1785000
  • 2397000 might be unreachable for some SoCs.
  • ",2397e3,[1785e3,3e6],1),new CustEntry("marikoCpuBoostClock","Mariko CPU Boost Clock in kHz",CustPlatform.Mariko,4,"
  • System default: 1785000
  • Boost clock will be applied when applications request higher CPU frequency for quicker loading.
  • This will be set regardless of whether sys-clk is enabled.
  • ",1785e3,[102e4,3e6],1,!1),new CustEntry("marikoCpuMaxVolt","Mariko CPU Max Voltage in mV",CustPlatform.Mariko,4,"
  • System default: 1120
  • Acceptable range: 1100 ≤ x ≤ 1300
  • ",1235,[1100,1300],5),new CustEntry("marikoGpuMaxClock","Mariko GPU Max Clock in kHz",CustPlatform.Mariko,4,"
  • System default: 921600
  • Tegra X1+ official maximum: 1267200
  • 1305600 might be unreachable for some SoCs.
  • ",1305600,[768e3,1536e3],100),new CustEntry("marikoEmcMaxClock","Mariko RAM Max Clock in kHz",CustPlatform.Mariko,4,"
  • Values should be ≥ 1600000, and divided evenly by 3200.
  • WARNING: RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM
  • ",1996800,[16e5,24e5],3200),new CustEntry("marikoEmcVddqVolt","EMC Vddq (Mariko Only) Voltage in uV",CustPlatform.Mariko,4,"
  • Acceptable range: 550000 ≤ x ≤ 650000
  • Value should be divided evenly by 5000
  • Default: 600000
  • Not enabled by default.
  • This will not work without sys-clk-OC.
  • ",0,[55e4,65e4],5e3),new CustEntry("eristaCpuMaxVolt","Erista CPU Max Voltage in mV",CustPlatform.Erista,4,"
  • Acceptable range: 1100 ≤ x ≤ 1300
  • ",1235,[1100,1300],1),new CustEntry("eristaEmcMaxClock","Erista RAM Max Clock in kHz",CustPlatform.Erista,4,"
  • Values should be ≥ 1600000, and divided evenly by 3200.
  • WARNING: RAM overclock could be UNSTABLE if timing parameters are not suitable for your DRAM
  • ",1862400,[16e5,24e5],3200),new CustEntry("commonEmcMemVolt","EMC Vddq (Erista Only) & RAM Vdd2 Voltage in uV",CustPlatform.All,4,"
  • Acceptable range: 1100000 ≤ x ≤ 1250000, and it should be divided evenly by 12500.
  • Erista Default (HOS): 1125000 (bootloader: 1100000)
  • Mariko Default: 1100000 (It will not work without sys-clk-OC)
  • Not enabled by default
  • ",0,[11e5,125e4],12500)];function FindMagicOffset(e){let t=new DataView(e);for(let e=0;e{let t=CustTable.filter((e=>e.id===this.id))[0];t.value=Number(this.element.value),t.validate()}))}}function SaveCust(e){let t=new DataView(e),i={};CustTable.forEach((e=>{if(e.updateValueFromElement(),!e.validate()||!e.value)throw document.getElementById(e.id).focus(),new Error(`Invalid ${e.name}`);if(!e.offset)throw document.getElementById(e.id).focus(),new Error(`Failed to get offset for ${e.name}`);switch(e.size){case 2:t.setUint16(e.offset,e.value,!0);break;case 4:t.setUint32(e.offset,e.value,!0);break;default:throw document.getElementById(e.id).focus(),new Error(`Unknown size at ${e.name}`)}i[e.id]=e.value})),i.custRev=3,localStorage.setItem("last_saved",JSON.stringify(i));let a=document.createElement("a");a.href=window.URL.createObjectURL(new Blob([e],{type:"application/octet-stream"})),a.download="loader.kip",a.click()}function LastSaved(){let e=localStorage.getItem("last_saved");if(!e)return!1;let t=JSON.parse(e);return!(!t.custRev||3!=t.custRev)||(localStorage.removeItem("last_saved"),!1)}function CustNavTabsInit(){const e=Array.from(document.querySelectorAll('nav[role="tab-control"] > button'));e.forEach((t=>{t.removeAttribute("disabled");let i=Number(t.getAttribute("data-filter"));t.addEventListener("click",(a=>{const l=["outline","secondary"];t.classList.remove(...l),e.filter((e=>e!=t)).forEach((e=>e.classList.add(...l))),CustTable.forEach((e=>{e.isAvailableFor(i)?e.showElement():e.hideElement()}))}))}))}function UpdateHTMLForm(){CustTable.forEach((e=>e.createElement()));let e=document.getElementById("load_default");e.removeAttribute("disabled"),e.addEventListener("click",(()=>{CustTable.forEach((e=>e.setElementDefaultValue()))}));let t=document.getElementById("load_saved");LastSaved()?(t.style.removeProperty("display"),t.removeAttribute("disabled"),t.addEventListener("click",(()=>{JSON.parse(localStorage.getItem("last_saved")).filter((e=>"custRev"!=e)).forEach((e=>document.getElementById(e).value=e))}))):t.style.setProperty("display","none");let i=document.getElementById("save");i.removeAttribute("disabled"),i.addEventListener("click",(()=>{try{SaveCust(buffer)}catch(e){console.log(e),alert(e)}}))}function ParseCust(e,t){let i=new DataView(t),a=e+4,l=i.getUint16(a,!0);if(a+=2,3!=l)throw new Error(`Unsupported custRev, expected: 3, got ${l}`);document.getElementById("cust_rev").innerHTML="Cust V3 is loaded.",CustTable.forEach((e=>{switch(e.offset=a,e.size){case 2:e.value=i.getUint16(a,!0);break;case 4:e.value=i.getUint32(a,!0);break;default:throw document.getElementById(e.id).focus(),new Error("Unknown size at "+e)}a+=e.size,e.validate()}))}const fileInput=document.getElementById("file");function fetchRelease(){return __awaiter(this,void 0,void 0,(function*(){try{const e=yield fetch("https://api.github.com/repos/KazushiMe/Switch-OC-Suite/releases/latest",{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch latest release info from GitHub: ${e.status}`);const t=yield e.json(),i=t.tag_name,a=i.split(".").slice(0,3).join("."),l=t.assets.filter((e=>e.name.endsWith("loader.kip")))[0],r=t.assets.filter((e=>e.name.endsWith(".zip")))[0],n=`https://github.com/Atmosphere-NX/Atmosphere/releases/tags/${a}`;return{OCSuiteVer:i,LoaderKipUrl:l.browser_download_url,LoaderKipTime:l.updated_at,SdOutZipUrl:r.browser_download_url,SdOutZipTime:r.updated_at,AMSVer:a,AMSUrl:n}}catch(e){console.log(e),alert(e)}}))}function updateDownloadUrls(){return __awaiter(this,void 0,void 0,(function*(){const e=(e,t,i)=>{let a=document.getElementById(e);a.innerHTML=t,a.removeAttribute("aria-busy"),a.setAttribute("href",i)};let t=yield fetchRelease();if(t){e("loader_kip_btn",`loader.kip ${t.OCSuiteVer}
    ${t.LoaderKipTime}`,t.LoaderKipUrl);e("sdout_zip_btn",`SdOut.zip ${t.OCSuiteVer}
    ${t.SdOutZipTime}`,t.SdOutZipUrl);e("ams_btn",`Atmosphere-NX ${t.AMSVer}`,t.AMSUrl)}}))}fileInput.addEventListener("change",(e=>{let t=new FileReader;t.readAsArrayBuffer(e.target.files[0]),t.onloadend=e=>{if(e.target.readyState===FileReader.DONE){buffer=e.target.result;try{let e=FindMagicOffset(buffer);CustTable.forEach((e=>e.removeElement())),ParseCust(e,buffer),CustNavTabsInit(),UpdateHTMLForm()}catch(e){console.log(e),alert(e),fileInput.value=""}}}})),addEventListener("DOMContentLoaded",(e=>__awaiter(this,void 0,void 0,(function*(){yield updateDownloadUrls()})))); diff --git a/pages/src/index.html b/pages/src/index.html index 45262af2..ca71172a 100644 --- a/pages/src/index.html +++ b/pages/src/index.html @@ -380,7 +380,7 @@
    diff --git a/pages/src/main.ts b/pages/src/main.ts index 3e327081..62a5f225 100644 --- a/pages/src/main.ts +++ b/pages/src/main.ts @@ -72,7 +72,6 @@ class CustEntry { } createElement() { - let form = document.getElementById("form")!; let input = this.getInputElement(); if (!input) { let grid = document.createElement("div"); @@ -97,7 +96,7 @@ class CustEntry { desc.setAttribute("for", this.id); grid.appendChild(desc); - form.appendChild(grid); + document.getElementById("form")!.appendChild(grid); let tooltip = new ErrorToolTip(this.id); tooltip.addChangeListener();