nx: Flash dummy super on clean install

Reference: https://github.com/jjpprrrr/device_xiaomi_sdm845-common/commit/03191c60c738c84b99bcc67e0c3856b4e9087876
Co-authored-by: Thomas Makin <halorocker89@gmail.com>
Co-authored-by: Tim Zimmermann <tim@linux4.de>
Change-Id: Ida93bd051185aeb22feba61d5aa5e5f6c0ec2c38
This commit is contained in:
tmakinandTim Zimmermann committed 2024-02-05 00:57:43 +00:00
1 parent 14af49d754
commit f8b5067dcc
5 files changed
+86

No files matched your search

+14
View File
@@ -33,3 +33,17 @@ $(CEC_XML_SYMLINK): $(LOCAL_INSTALLED_MODULE)
$(hide) ln -sf /data/vendor/permissions/android.hardware.hdmi.cec.xml $@
ALL_DEFAULT_INSTALLED_MODULES += $(CEC_XML_SYMLINK)
LPFLASH := $(HOST_OUT_EXECUTABLES)/lpflash$(HOST_EXECUTABLE_SUFFIX)
INSTALLED_SUPERIMAGE_DUMMY_TARGET := $(PRODUCT_OUT)/super_dummy.img
$(INSTALLED_SUPERIMAGE_DUMMY_TARGET): $(PRODUCT_OUT)/super_empty.img $(LPFLASH)
$(call pretty,"Target dummy super image: $@")
$(hide) touch $@
$(hide) echo $(CURDIR)
$(hide) $(LPFLASH) $(CURDIR)/$@ $(CURDIR)/$(PRODUCT_OUT)/super_empty.img
.PHONY: super_dummyimage
super_dummyimage: $(INSTALLED_SUPERIMAGE_DUMMY_TARGET)
INSTALLED_RADIOIMAGE_TARGET += $(INSTALLED_SUPERIMAGE_DUMMY_TARGET)
+1
View File
@@ -76,6 +76,7 @@ TARGET_RECOVERY_PIXEL_FORMAT := BGRA_8888
# Releasetools
TARGET_RELEASETOOLS_EXTENSIONS := device/nintendo/nx/releasetools
TARGET_RECOVERY_UPDATER_LIBS += librecovery_updater_nx
# Security Patch Level
VENDOR_SECURITY_PATCH := 2022-04-05
+23
View File
@@ -0,0 +1,23 @@
#
# Copyright (C) 2024 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.
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := librecovery_updater_nx
LOCAL_SRC_FILES := recovery_updater.cpp
LOCAL_STATIC_LIBRARIES += libedify libotautil libbase
include $(BUILD_STATIC_LIBRARY)
+47
View File
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: Apache-2.0
/**
* @name recovery_updater.cpp
* @author Thomas Makin
* @brief NX-specific edify updater command additions.
* @copyright 2024 The LineageOS Project
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <android-base/logging.h>
#include "edify/expr.h"
#include "otautil/error_code.h"
#define MAGIC_OFFSET 4096
#define MAGIC_SZ 4
#define MAGIC "gDla" // 67446c61
Value *CheckSuperFn(const char *name, State *state,
[[maybe_unused]] const std::vector<std::unique_ptr<Expr>> &argv)
{
FILE *fd = fopen("/dev/block/by-name/super", "r");
char read_magic[MAGIC_SZ+1];
if(!fd)
return ErrorAbort(state, kArgsParsingFailure, "%s(): Failed to get file", name);
fseek(fd, MAGIC_OFFSET, SEEK_SET);
fgets(read_magic, (MAGIC_SZ + 1), fd);
LOG(INFO) << name << ": magic read from file: " << read_magic;
fclose(fd);
if(!strcmp(read_magic, MAGIC))
return StringValue("SUCCESS");
return StringValue("");
}
void Register_librecovery_updater_nx()
{
RegisterFunction("nx.check_super", CheckSuperFn);
}
+1
View File
@@ -20,6 +20,7 @@ import re
import os
DTB_PART = '/dev/block/by-name/dtb'
SUPER_PART = '/dev/block/by-name/super'
NX_FILES = '/mnt/vendor/hos_data'
NX_BL_VERSION = '2022.10-g4f111ee6dc'