From 0954eb2b093b99f65765c34bb01a0c6eb7af99f1 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 2 Dec 2020 01:45:12 +0200 Subject: [PATCH] nyx: Use full shutdown based reboot on T210B01 That's because of how the system is exploited. --- bdk/utils/util.c | 17 +++++++++++++++++ bdk/utils/util.h | 1 + nyx/nyx_gui/frontend/gui.c | 15 ++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/bdk/utils/util.c b/bdk/utils/util.c index 7cdf09d..e5cd868 100644 --- a/bdk/utils/util.c +++ b/bdk/utils/util.c @@ -152,6 +152,23 @@ void reboot_rcm() bpmp_halt(); } +void reboot_full() +{ + sd_end(); + hw_reinit_workaround(false, 0); + + // Enable soft reset wake event. + u8 reg = i2c_recv_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_ONOFFCNFG2); + reg |= MAX77620_ONOFFCNFG2_SFT_RST_WK; + i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_ONOFFCNFG2, reg); + + // Do a soft reset. + i2c_send_byte(I2C_5, MAX77620_I2C_ADDR, MAX77620_REG_ONOFFCNFG1, MAX77620_ONOFFCNFG1_SFT_RST); + + while (true) + bpmp_halt(); +} + void power_off() { sd_end(); diff --git a/bdk/utils/util.h b/bdk/utils/util.h index 818ae39..20df76f 100644 --- a/bdk/utils/util.h +++ b/bdk/utils/util.h @@ -73,6 +73,7 @@ void msleep(u32 ms); void panic(u32 val); void reboot_normal(); void reboot_rcm(); +void reboot_full(); void power_off(); void exec_cfg(u32 *base, const cfg_op_t *ops, u32 num_ops); u32 crc32_calc(u32 crc, const u8 *buf, u32 len); diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index d086578..2e922ee 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -900,7 +900,10 @@ static lv_res_t _removed_sd_action(lv_obj_t *btns, const char *txt) switch (btnidx) { case 0: - reboot_rcm(); + if (h_cfg.t210b01) + reboot_full(); + else + reboot_rcm(); break; case 1: power_off(); @@ -951,9 +954,14 @@ static lv_res_t _reboot_action(lv_obj_t *btns, const char *txt) switch (btnidx) { case 0: - reboot_normal(); + if (h_cfg.t210b01) + reboot_full(); + else + reboot_normal(); break; case 1: + if (h_cfg.t210b01) + break; reboot_rcm(); break; } @@ -997,13 +1005,14 @@ static lv_res_t _create_mbox_reboot(lv_obj_t *btn) lv_obj_set_size(dark_bg, LV_HOR_RES, LV_VER_RES); static const char * mbox_btn_map[] = { "\221OFW", "\221RCM", "\221Cancel", "" }; + static const char * mbox_btn_map_t210b01[] = { "\221Reboot", "\221Cancel", "" }; lv_obj_t *mbox = lv_mbox_create(dark_bg, NULL); lv_mbox_set_recolor_text(mbox, true); lv_obj_set_width(mbox, LV_HOR_RES / 2); lv_mbox_set_text(mbox, "#FF8000 Choose where to reboot:#"); - lv_mbox_add_btns(mbox, mbox_btn_map, _reboot_action); + lv_mbox_add_btns(mbox, h_cfg.t210b01 ? mbox_btn_map_t210b01 : mbox_btn_map, _reboot_action); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_top(mbox, true);