目录
修改的文件:
文件修改说明:
1. recovery.cpp
2. mt_boot.c
3. platform.c
4. codegen.dws
这个修改主要是在多个文件中增加了一个选项,当设备在恢复模式下并且特定的GPIO引脚被设置时,设备将进行强制的工厂重置。
修改的文件:
- bootable/recovery/recovery.cpp
- vendor/mediatek/proprietary/bootable/bootloader/lk/app/mt_boot/mt_boot.c
- vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/platform.c
- vendor/mediatek/proprietary/bootable/bootloader/lk/target/XX8735/dct/dct/codegen.dws
- vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/XX8735/dct/dct/codegen.dws
文件修改说明:
1. recovery.cpp
在这个文件中,增加了一个函数is_need_force_factory_reset()
,该函数会检查/proc/cmdline
中是否存在force_reset
参数。如果存在,那么在恢复模式下,设备将进行强制的工厂重置。
2. mt_boot.c
在这个文件中,在恢复模式下检查了GPIO71的状态。如果GPIO71的状态为0,那么将在命令行参数中增加force_reset
。
3. platform.c
在这个文件中,也检查了GPIO71的状态。如果GPIO71的状态为0,那么将设备的启动模式设置为恢复模式。文章来源:https://www.toymoban.com/news/detail-581785.html
4. codegen.dws
这两个二进制文件被修改,但由于它们是二进制文件,无法提供具体的修改内容(实际上是笔记忘记截图了) 就是用dct mtk专用的gpio 修改工具把gpio 改吧改吧就欧克了。
文章来源地址https://www.toymoban.com/news/detail-581785.html
---
bootable/recovery/recovery.cpp | 28 +++++++++++++++++-
.../bootloader/lk/app/mt_boot/mt_boot.c | 8 ++++-
.../bootloader/lk/platform/mt6735/platform.c | 4 +++
.../lk/target/XX8735/dct/dct/codegen.dws | Bin 29887 -> 29887 bytes
.../custom/XX8735/dct/dct/codegen.dws | Bin 29938 -> 29887 bytes
5 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/bootable/recovery/recovery.cpp b/bootable/recovery/recovery.cpp
index 736423e3644..823635b1872 100755
--- a/bootable/recovery/recovery.cpp
+++ b/bootable/recovery/recovery.cpp
@@ -116,6 +116,8 @@ static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
static const char *TEMPORARY_INSTALL_FILE = "/tmp/last_install";
static const char *LAST_KMSG_FILE = "/cache/recovery/last_kmsg";
static const char *LAST_LOG_FILE = "/cache/recovery/last_log";
+
+static const char *COMMAND_LINE="/proc/cmdline";
// We will try to apply the update package 5 times at most in case of an I/O error or
// bspatch | imgpatch error.
static const int RETRY_LIMIT = 4;
@@ -137,7 +139,7 @@ static bool has_cache = false;
static bool has_nvdata = false;
RecoveryUI* ui = nullptr;
-bool modified_flash = false;
+bool modified_flash = true;
std::string stage;
const char* reason = nullptr;
struct selabel_handle* sehandle;
@@ -1359,6 +1361,23 @@ static void log_failure_code(ErrorCode code, const char *update_package) {
LOG(INFO) << log_content;
}
+int is_need_force_factory_reset()
+{
+ char param[1024];
+ int fd, ret;
+ char *s=NULL;
+
+ memset(param,0,1024);
+ fd= open("/proc/cmdline", O_RDONLY);
+ ret = read(fd, (char*)param, 1024);
+ printf("cmdline=%s\n",param);
+ s = strstr(param,"force_reset");
+ if(s!= NULL)
+ return 1;
+ else
+ return 0;
+}
+
int main(int argc, char **argv) {
// We don't have logcat yet under recovery; so we'll print error on screen and
// log to stdout (which is redirected to recovery.log) as we used to do.
@@ -1422,6 +1441,11 @@ int main(int argc, char **argv) {
int retry_count = 0;
bool security_update = false;
+ if(args.size() == 1 && is_need_force_factory_reset() == 1){
+ should_wipe_data = true;
+ should_wipe_cache=true;
+ printf("exec wipe_data \n");
+ }
int arg;
int option_index;
while ((arg = getopt_long(args_to_parse.size(), args_to_parse.data(), "", OPTIONS,
@@ -1466,6 +1490,8 @@ int main(int argc, char **argv) {
}
}
+ //check_usbboot();
+
printf("locale is [%s]\n", locale.c_str());
printf("stage is [%s]\n", stage.c_str());
printf("reason is [%s]\n", reason);
diff --git a/vendor/mediatek/proprietary/bootable/bootloader/lk/app/mt_boot/mt_boot.c b/vendor/mediatek/proprietary/bootable/bootloader/lk/app/mt_boot/mt_boot.c
index 55e5b07f6f2..ca1272c99cc 100755
--- a/vendor/mediatek/proprietary/bootable/bootloader/lk/app/mt_boot/mt_boot.c
+++ b/vendor/mediatek/proprietary/bootable/bootloader/lk/app/mt_boot/mt_boot.c
@@ -70,7 +70,7 @@
#include <iothread.h>
#include <RoT.h>
#include <odm_mdtbo.h> // for load_overlay_dtbo()
-
+#include <platform/mt_gpio.h>
#include <profiling.h>
#include <rnd.h>
@@ -2322,6 +2322,12 @@ int boot_linux_from_storage(void)
}
}
+ if (g_boot_mode == RECOVERY_BOOT) {
+ if(mt_get_gpio_in(GPIO71) == 0){
+ cmdline_append("force_reset");
+ }
+ }
+
/* pass the meta_log_disable to user space logger, default is enable */
if (is_meta_log_disable && (is_meta_log_disable() == 1)) {
cmdline_append("androidboot.meta_log_disable=1");
diff --git a/vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/platform.c b/vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/platform.c
index 86b91982c49..8558d001389 100755
--- a/vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/platform.c
+++ b/vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6735/platform.c
@@ -652,6 +652,10 @@ static void lk_boot_mode_select(void)
boot_mode_select();
+ if(mt_get_gpio_in(GPIO71) == 0){
+ g_boot_mode = RECOVERY_BOOT;
+ }
+
#ifdef CFG_DTB_EARLY_LOADER_SUPPORT
/* reload dtb when boot mode = recovery */
if ((g_boot_mode == RECOVERY_BOOT) && (bldr_load_dtb("recovery") < 0))
diff --git a/vendor/mediatek/proprietary/bootable/bootloader/lk/target/XX8735/dct/dct/codegen.dws b/vendor/mediatek/proprietary/bootable/bootloader/lk/target/XX8735/dct/dct/codegen.dws
index c9abb1bee0fb5c20e775dea9edabe6a4357b2ef8..b6c155e31d9c2720249aee4a1c8a55df1e1a2866 100755
GIT binary patch
delta 34
scmV+-0Nww;=>fm#0k8ralWzn-lS>d7ldlX!lh7dqlb}o-v%VVvS@XsX2LJ#7
delta 49
zcmV-10M7rv=>fm#0k8ralfWMYlfD}ek{u9}AQ=dgARP#kuq-5#a3@5Q&>;kqpiCUI
Hz8e8q%^(qn
diff --git a/vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/XX8735/dct/dct/codegen.dws b/vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/XX8735/dct/dct/codegen.dws
index 1d72e4a55831802a51a1be0da022bb3c563e0eb4..17f6b28bac9fa453429ea36d21625c1fdbe82ca7 100755
GIT binary patch
delta 78
zcmezLl5zh_#tr|ZCMQU;OwMO<nCvZ}GC9CTV6uQD&*Xjqj>&q`5|i!SRVFt$2u%JV
htpR2qkP(@DK!#<qf+WY}cXkq!KZx;fo+A?$0RVCv8|VN4
delta 109
zcmdo0lJV0^#tr|ZCV!BznEXIclEW*+(LFxI*?TghkisNcp2-I89Fwc0H70)$<b=w(
lcp}T4bQPE!&nST`?+=lem?X<GSwWIxvVyGE<{X*e2mmY*B69!$
--
2.29.0
到了这里,关于Android Mediatek 增加Recovery模式下读cmdline的强制工厂重置选项的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!