* This is a tree for all Nintendo Switch variants: `odin`, `modin`, `vali`, and `frig`. * `ro.hardware` will be NX on all variants with `ro.hardware.sku` being set per variant by u-boot. Changes are as follows: * At the moment the packaged DTB is only for `odin`, more to follow. * Note: We may make `modin`, `vail`, and `frig` device-tree-overlays on the `odin` base DTB to simplify things. * Use darcy's thermal config as it's the most lenient, and is a same SoC STB. * Unlike `icosa_sr` previously did, we will use the BCM HAL for BT over BTLinux, as A2DP is tested and verified, no need to deviate. Changes that will require follow-up commits to build out: * Update init to reflect nx's needs - will need more work to support devices other than `odin`. Removals are as follows: * Remove all non-nx device support files. Co-authored-by: Thomas Makin <halorocker89@gmail.com> Co-authored-by: Billy Laws <blaws05@gmail.com> Co-authored-by: Aaron Kling <webgeek1234@gmail.com> Co-authored-by: CTCaer <ctcaer@gmail.com> Co-authored-by: John Smith <nemui3353@gmail.com> Co-authored-by: langerhans <langerhans@users.noreply.github.com> Co-authored-by: Nolen Johnson <johnsonnolen@gmail.com> Change-Id: I9bab4d94c6e94a9c6e2a7cf04d16c4b76c0b6ac5
131 lines
6.0 KiB
Python
131 lines
6.0 KiB
Python
# Copyright (C) 2022 The LineageOS Project
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
#
|
|
|
|
""" Custom OTA commands for nx devices """
|
|
|
|
import common
|
|
import re
|
|
import os
|
|
|
|
APP_PART = '/dev/block/by-name/APP'
|
|
DTB_PART = '/dev/block/by-name/DTB'
|
|
STAGING_PART = '/dev/block/by-name/USP'
|
|
VBMETA_PART = '/dev/block/by-name/vbmeta'
|
|
VENDOR_PART = '/dev/block/by-name/vendor'
|
|
NX_SD = '/external_sd/switchroot/android/'
|
|
|
|
PUBLIC_KEY_PATH = '/sys/devices/7000f800.efuse/7000f800.efuse:efuse-burn/public_key'
|
|
FUSED_PATH = '/sys/devices/7000f800.efuse/7000f800.efuse:efuse-burn/odm_production_mode'
|
|
DTSFILENAME_PATH = '/proc/device-tree/nvidia,dtsfilename'
|
|
|
|
MODE_UNFUSED = '0x00000000\n'
|
|
MODE_FUSED = '0x00000001\n'
|
|
|
|
NX_ERISTA_PUBLIC_KEY = '0x7e39e100d1135918ceedfe5d66e66496eed21ecb3486d72095cc0b7c60b8bd4f\n'
|
|
NX_MARIKO_PUBLIC_KEY = '0x72b9db116837289e5bfa57bb1c69e2c8fa9697151aa975066381e7efa19fb0c9\n'
|
|
NX_BL_VERSION = '2020.04-03755-gf4d532d00d-rev3'
|
|
|
|
def FullOTA_PostValidate(info):
|
|
if 'INSTALL/bin/resize2fs_static' in info.input_zip.namelist():
|
|
info.script.AppendExtra('run_program("/tmp/install/bin/resize2fs_static", "' + APP_PART + '");');
|
|
info.script.AppendExtra('run_program("/tmp/install/bin/resize2fs_static", "' + VENDOR_PART + '");');
|
|
|
|
def FullOTA_Assertions(info):
|
|
if 'RADIO/foster_e.blob' in info.input_zip.namelist():
|
|
CopyBlobs(info.input_zip, info.output_zip)
|
|
AddBootloaderFlash(info, info.input_zip)
|
|
else:
|
|
AddBootloaderAssertion(info, info.input_zip)
|
|
|
|
def IncrementalOTA_Assertions(info):
|
|
FullOTA_Assertions(info)
|
|
|
|
def CopyBlobs(input_zip, output_zip):
|
|
for info in input_zip.infolist():
|
|
f = info.filename
|
|
if f.startswith("RADIO/") and (f.__len__() > len("RADIO/")):
|
|
fn = f[6:]
|
|
common.ZipWriteStr(output_zip, "firmware-update/" + fn, input_zip.read(f))
|
|
|
|
def AddBootloaderAssertion(info, input_zip):
|
|
android_info = input_zip.read("OTA/android-info.txt").decode('utf-8')
|
|
m = re.search(r"require\s+version-bootloader\s*=\s*(\S+)", android_info)
|
|
if m:
|
|
bootloaders = m.group(1).split("|")
|
|
if "*" not in bootloaders:
|
|
info.script.AssertSomeBootloader(*bootloaders)
|
|
info.metadata["pre-bootloader"] = m.group(1)
|
|
|
|
def AddBootloaderFlash(info, input_zip):
|
|
""" If device is fused """
|
|
info.script.AppendExtra('ifelse(')
|
|
info.script.AppendExtra(' read_file("' + FUSED_PATH + '") == "' + MODE_FUSED + '",')
|
|
info.script.AppendExtra(' (')
|
|
|
|
""" Fused nx """
|
|
info.script.AppendExtra(' ifelse(')
|
|
info.script.AppendExtra(' getprop("ro.hardware") == "nx",')
|
|
info.script.AppendExtra(' (')
|
|
info.script.AppendExtra(' ifelse(')
|
|
info.script.AppendExtra(' getprop("ro.bootloader") == "' + NX_BL_VERSION + '",')
|
|
info.script.AppendExtra(' (')
|
|
info.script.AppendExtra(' ui_print("Correct bootloader already installed for fused " + getprop(ro.hardware));')
|
|
info.script.AppendExtra(' ),')
|
|
info.script.AppendExtra(' ifelse(')
|
|
info.script.AppendExtra(' read_file("' + PUBLIC_KEY_PATH + '") == "' + NX_ERISTA_PUBLIC_KEY + '" || read_file("' + PUBLIC_KEY_PATH + '") == "' + NX_MARIKO_PUBLIC_KEY + '",')
|
|
info.script.AppendExtra(' (')
|
|
info.script.AppendExtra(' ui_print("Flashing updated bootloader for fused " + getprop(ro.hardware));')
|
|
info.script.AppendExtra(' package_extract_file("firmware-update/coreboot.rom", "' + NX_SD + 'coreboot.rom");')
|
|
info.script.AppendExtra(' package_extract_file("firmware-update/common.scr", "' + NX_SD + 'common.scr");')
|
|
info.script.AppendExtra(' package_extract_file("firmware-update/" + getprop(ro.hardware) + ".scr", "' + NX_SD + 'boot.scr");')
|
|
info.script.AppendExtra(' ),')
|
|
info.script.AppendExtra(' (')
|
|
info.script.AppendExtra(' ui_print("Unknown public key for nx detected.");')
|
|
info.script.AppendExtra(' ui_print("This is not supported. Please report to LineageOS Maintainer.");')
|
|
info.script.AppendExtra(' abort();')
|
|
info.script.AppendExtra(' )')
|
|
info.script.AppendExtra(' )')
|
|
info.script.AppendExtra(' );')
|
|
info.script.AppendExtra(' package_extract_file("install/" + tegra_get_dtbname(), "' + DTB_PART + '");')
|
|
info.script.AppendExtra(' )')
|
|
info.script.AppendExtra(' );')
|
|
|
|
info.script.AppendExtra(' ),')
|
|
|
|
""" If not fused """
|
|
info.script.AppendExtra(' (')
|
|
|
|
""" Unfused nx """
|
|
info.script.AppendExtra(' ifelse(')
|
|
info.script.AppendExtra(' getprop("ro.hardware") == "nx",')
|
|
info.script.AppendExtra(' (')
|
|
info.script.AppendExtra(' ifelse(')
|
|
info.script.AppendExtra(' getprop("ro.bootloader") == "' + NX_BL_VERSION + '",')
|
|
info.script.AppendExtra(' (')
|
|
info.script.AppendExtra(' ui_print("Correct bootloader already installed for unfused " + getprop(ro.hardware));')
|
|
info.script.AppendExtra(' ),')
|
|
info.script.AppendExtra(' (')
|
|
info.script.AppendExtra(' ui_print("This is an unfused nx. Many devlopers would kill for this unit.");')
|
|
info.script.AppendExtra(' ui_print("This is not supported. Please report to LineageOS Maintainer.");')
|
|
info.script.AppendExtra(' abort();')
|
|
info.script.AppendExtra(' )')
|
|
info.script.AppendExtra(' );')
|
|
info.script.AppendExtra(' package_extract_file("install/" + tegra_get_dtbname(), "' + DTB_PART + '");')
|
|
info.script.AppendExtra(' )')
|
|
info.script.AppendExtra(' );')
|
|
|
|
info.script.AppendExtra(' )')
|
|
info.script.AppendExtra(');')
|