Skip to content

Commit

Permalink
Workaround (v2) for no kexec-hardboot kernels
Browse files Browse the repository at this point in the history
* MultiROM support for no kexec-hardboot enabled kernels.
  It has been tested on the HTC One M7, M8 and M9 successfully.

* This commit is the TWRP recovery portion, which adds
  (1) various settings in TWRP->MultiROM-Settings
  (2) properly restores primary kernel if needed
  the real code is in multirom https://github.com/nkk71/multirom

* This is an updated and more reliable version of the initial
  WIP nkk71/multirom@6ae88fe

Note:
* The following build flag needs to be added in BoardConfig:
  MR_ALLOW_NKK71_NOKEXEC_WORKAROUND := true
  • Loading branch information
nkk71 committed Apr 9, 2016
1 parent a54c04e commit 21ff5ee
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Android.mk
Expand Up @@ -352,6 +352,10 @@ ifeq ($(TARGET_RECOVERY_IS_MULTIROM), true)
#TODO
LOCAL_CFLAGS += -DTW_DEFAULT_ROTATION=0

ifeq ($(MR_ALLOW_NKK71_NOKEXEC_WORKAROUND),true)
LOCAL_CFLAGS += -DMR_ALLOW_NKK71_NOKEXEC_WORKAROUND
endif

ifneq ($(MR_RD_ADDR),)
LOCAL_CFLAGS += -DMR_RD_ADDR=$(MR_RD_ADDR)
endif
Expand Down
4 changes: 4 additions & 0 deletions gui/Android.mk
Expand Up @@ -74,6 +74,10 @@ endif
#MultiROM
ifeq ($(TARGET_RECOVERY_IS_MULTIROM), true)
LOCAL_CFLAGS += -DTARGET_RECOVERY_IS_MULTIROM

ifeq ($(MR_ALLOW_NKK71_NOKEXEC_WORKAROUND),true)
LOCAL_CFLAGS += -DMR_ALLOW_NKK71_NOKEXEC_WORKAROUND
endif
endif

LOCAL_C_INCLUDES += bionic system/core/libpixelflinger/include
Expand Down
16 changes: 16 additions & 0 deletions gui/action.cpp
Expand Up @@ -1942,6 +1942,14 @@ int GUIAction::multirom_settings(std::string arg)
DataManager::SetValue("tw_multirom_current", cfg.current_rom);
DataManager::SetValue("tw_multirom_auto_boot_rom", cfg.auto_boot_rom);
DataManager::SetValue("tw_multirom_auto_boot_type", (cfg.auto_boot_type & MROM_AUTOBOOT_LAST));
#ifdef MR_ALLOW_NKK71_NOKEXEC_WORKAROUND
DataManager::SetValue("tw_multirom_allow_nkk71_nokexec", cfg.allow_nkk71_nokexec & 0x3F);
DataManager::SetValue("tw_multirom_allow_nkk71_nokexec_internal", (cfg.allow_nkk71_nokexec & 0x40) ? 1 : 0);
DataManager::SetValue("tw_multirom_allow_nkk71_nokexec_restore", (cfg.allow_nkk71_nokexec & 0x80) ? 1 : 0);
#else
DataManager::SetValue("tw_multirom_allow_nkk71_nokexec_na", 1); //no-kexec workaround is disabled in this build
DataManager::SetValue("tw_multirom_allow_nkk71_nokexec", 0);
#endif
DataManager::SetValue("tw_multirom_colors", cfg.colors);
DataManager::SetValue("tw_multirom_brightness", cfg.brightness);
DataManager::SetValue("tw_multirom_enable_adb", cfg.enable_adb);
Expand Down Expand Up @@ -1976,6 +1984,14 @@ int GUIAction::multirom_settings_save(std::string arg)
break;
}
cfg.auto_boot_rom = DataManager::GetStrValue("tw_multirom_auto_boot_rom");
#ifdef MR_ALLOW_NKK71_NOKEXEC_WORKAROUND
cfg.allow_nkk71_nokexec = DataManager::GetIntValue("tw_multirom_allow_nkk71_nokexec");
if (cfg.allow_nkk71_nokexec != 0)
{
cfg.allow_nkk71_nokexec += (DataManager::GetIntValue("tw_multirom_allow_nkk71_nokexec_internal") == 1) ? 0x40 : 0;
cfg.allow_nkk71_nokexec += (DataManager::GetIntValue("tw_multirom_allow_nkk71_nokexec_restore") == 1) ? 0x80 : 0;
}
#endif
cfg.colors = DataManager::GetIntValue("tw_multirom_colors");
cfg.brightness = DataManager::GetIntValue("tw_multirom_brightness");
cfg.enable_adb = DataManager::GetIntValue("tw_multirom_enable_adb");
Expand Down
263 changes: 263 additions & 0 deletions gui/themes_multirom/1080x1920/multirom.xml
Expand Up @@ -738,8 +738,27 @@
<listitem name="Enable advanced kernel logging + history">
<data variable="tw_multirom_enable_kmsg_logging"/>
</listitem>
- <listitem name="Enable No-KEXEC Workaround">
<data variable="tw_multirom_allow_nkk71_nokexec"/>
</listitem>
</listbox>

<action>
<condition var1="tw_multirom_allow_nkk71_nokexec_na"/>
<condition var1="tw_multirom_allow_nkk71_nokexec" op="!=" var2="0"/>
<actions>
<action function="set">tw_multirom_allow_nkk71_nokexec=0</action>
<action function="overlay">multirom_nokexec_not_implemented</action>
</actions>
</action>

<button style="button_quarter_width">
<condition var1="tw_multirom_allow_nkk71_nokexec" op="!=" var2="0"/>
<placement x="%tab4_col4_x%" y="%row20_y%"/> <!-- ideally (%row19a_y%+%row20_y%/2 -->
<text>ADV</text>
<action function="overlay">multirom_nokexec_settings</action>
</button>

<text style="text_m_accent">
<placement x="%indent%" y="%row7_y%"/>
<text>Screen Brightness: %tw_multirom_brightness%</text>
Expand Down Expand Up @@ -777,6 +796,250 @@
</action>
</page>

<!-- beg of nkk71 nokexec overlays -->
<page name="multirom_nokexec_not_implemented">
<fill color="%semi_transparent%">
<placement x="0" y="0" w="%screen_width%" h="%screen_height%"/>
</fill>

<fill color="%background_color%">
<placement x="%indent%" y="row5_y" w="%content_width%" h="%dialog_height%"/>
</fill>

<text style="text_m_fail">
<placement x="%center_x%" y="%row5_y%" placement="5"/>
<text>No-KEXEC Workaround</text>
</text>
<text style="text_m_fail">
<placement x="%center_x%" y="%row6_y%" placement="5"/>
<text>is not implemented in this version of MultiROM</text>
</text>

<text style="text_m">
<placement x="%center_x%" y="%row7a_y%" placement="5"/>
<text>The no-kexec workaround is not an officially supported</text>
</text>

<text style="text_m">
<placement x="%center_x%" y="%row8a_y%" placement="5"/>
<text>method. Therefore it is up to the device maintainer to</text>
</text>

<text style="text_m">
<placement x="%center_x%" y="%row9a_y%" placement="5"/>
<text>decide whether to allow this functionality, as it may not</text>
</text>

<text style="text_m">
<placement x="%center_x%" y="%row10a_y%" placement="5"/>
<text>function on all devices, and needs proper testing.</text>
</text>

<text style="text_m_accent">
<placement x="%center_x%" y="%row12_y%" placement="5"/>
<text>The preferred method (and only one in this case) is</text>
</text>

<text style="text_m_accent">
<placement x="%center_x%" y="%row13_y%" placement="5"/>
<text>to use a kexec-hardboot enabled kernel In Primary ROM</text>
</text>

<button style="button_third_width">
<placement x="%dialog_button_x%" y="%row14_y%"/>
<text>{@ok_btn=OK}</text>
<actions>
<action function="overlay"/>
<action function="page">multirom_settings</action>
</actions>
</button>

<fill color="#000000">
<placement x="0" y="row25_y" w="%screen_width%" h="%navbar_height"/>
</fill>

<button>
<condition var1="tw_samsung_navbar" op="!=" var2="1"/>
<placement x="%back_button_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="back"/>
<condition var1="tw_busy" var2="0"/>
<actions>
<action function="overlay"/>
<action function="page">multirom_settings</action>
</actions>
</button>

<button>
<condition var1="tw_samsung_navbar" op="=" var2="1"/>
<placement x="%back_button_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="console"/>
<condition var1="tw_busy" var2="0"/>
<action function="overlay">slideout</action>
</button>

<button>
<placement x="%center_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="home"/>
<condition var1="tw_busy" var2="0"/>
<actions>
<action function="overlay"/>
<action function="key">home</action>
</actions>
</button>

<button>
<condition var1="tw_samsung_navbar" op="!=" var2="1"/>
<placement x="%console_button_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="console"/>
<condition var1="tw_busy" var2="0"/>
<action function="overlay">slideout</action>
</button>

<button>
<condition var1="tw_samsung_navbar" op="=" var2="1"/>
<placement x="%console_button_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="back"/>
<condition var1="tw_busy" var2="0"/>
<actions>
<action function="overlay"/>
<action function="page">multirom_settings</action>
</actions>
</button>

<action>
<touch key="power+voldown"/>
<action function="screenshot"/>
</action>
</page>

<page name="multirom_nokexec_settings">
<fill color="%semi_transparent%">
<placement x="0" y="0" w="%screen_width%" h="%screen_height%"/>
</fill>

<fill color="%background_color%">
<placement x="%indent%" y="row5_y" w="%content_width%" h="%dialog_height%"/>
</fill>

<listbox>
<placement x="%col1_x_left%" y="%row5_y%" w="%content_overlay_width%" h="%partitionlist_storage_height%"/>
<data name="tw_multirom_allow_nkk71_nokexec"/>
<listitem name="Use no-kexec only when needed">1</listitem>
<listitem name="... but also ask for confirmation before booting">2</listitem>
<listitem name="Ask whether to kexec or use no-kexec on booting">4</listitem>
<listitem name="Always force using no-kexec workaround">8</listitem>
</listbox>

<button>
<placement x="%col1_x_left%" y="%row5_y%" textplacement="6"/>
<font resource="font_m" color="%text_color%"/>
<condition var1="tw_multirom_allow_nkk71_nokexec" op="!=" var2="0"/>
<text>Enable no-kexec workaround</text>
<image resource="checkbox_true"/>
<actions>
<action function="overlay"/>
<action function="set">tw_multirom_allow_nkk71_nokexec=0</action>
</actions>
</button>

<button style="button_third_width">
<placement x="%dialog_button_x%" y="%row5_y%"/> <!-- ideally (%row4a_y%+%row5_y%)/2 -->
<text>Info</text>
<actions>
<action function="page">multirom_nokexec_info</action>
</actions>
</button>

<!--
not implemented
<button>
<placement x="%col1_x_left%" y="%row12a_y%" textplacement="6"/>
<font resource="font_m" color="%text_color%"/>
<condition var1="tw_multirom_allow_nkk71_nokexec_internal" op="==" var2="0"/>
<text>Allow kexec’ing into Internal</text>
<image resource="checkbox_false"/>
<action function="set">tw_multirom_allow_nkk71_nokexec_internal=1</action>
</button>
<button>
<placement x="%col1_x_left%" y="%row12a_y%" textplacement="6"/>
<font resource="font_m" color="%text_color%"/>
<condition var1="tw_multirom_allow_nkk71_nokexec_internal" op="!=" var2="0"/>
<text>Allow kexec’ing into Internal</text>
<image resource="checkbox_true"/>
<actions>
<action function="set">tw_multirom_allow_nkk71_nokexec_internal=0</action>
</actions>
</button>
-->

<button style="button_third_width">
<placement x="%dialog_button_x%" y="%row14_y%"/>
<text>{@ok_btn=OK}</text>
<actions>
<action function="overlay"/>
<action function="page">multirom_settings</action>
</actions>
</button>

<fill color="#000000">
<placement x="0" y="row25_y" w="%screen_width%" h="%navbar_height"/>
</fill>

<button>
<condition var1="tw_samsung_navbar" op="!=" var2="1"/>
<placement x="%back_button_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="back"/>
<condition var1="tw_busy" var2="0"/>
<actions>
<action function="overlay"/>
<action function="page">multirom_settings</action>
</actions>
</button>

<button>
<condition var1="tw_samsung_navbar" op="=" var2="1"/>
<placement x="%back_button_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="console"/>
<condition var1="tw_busy" var2="0"/>
<action function="overlay">slideout</action>
</button>

<button>
<placement x="%center_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="home"/>
<condition var1="tw_busy" var2="0"/>
<actions>
<action function="overlay"/>
<action function="key">home</action>
</actions>
</button>

<button>
<condition var1="tw_samsung_navbar" op="!=" var2="1"/>
<placement x="%console_button_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="console"/>
<condition var1="tw_busy" var2="0"/>
<action function="overlay">slideout</action>
</button>

<button>
<condition var1="tw_samsung_navbar" op="=" var2="1"/>
<placement x="%console_button_x%" y="%navbar_btn_y%" placement="4"/>
<image resource="back"/>
<condition var1="tw_busy" var2="0"/>
<actions>
<action function="overlay"/>
<action function="page">multirom_settings</action>
</actions>
</button>

<action>
<touch key="power+voldown"/>
<action function="screenshot"/>
</action>
</page>
<!-- end of nkk71 nokexec overlays -->

<page name="multirom_settings_autoboot">
<template name="page"/>

Expand Down

0 comments on commit 21ff5ee

Please sign in to comment.