Skip to content

Commit

Permalink
Merge pull request OpenPLi#3680 from Dima73/pull
Browse files Browse the repository at this point in the history
  • Loading branch information
littlesat authored Apr 3, 2023
2 parents f864087 + fd0733c commit 1747813
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<item text="Restart enigma in standard mode" requires="InDebugMode" entryID="restart_enigma"><screen module="Standby" screen="TryQuitMainloop">3</screen></item>
<item text="Restart enigma in debug mode" requires="!InDebugMode" entryID="restart_enigma_debug"><screen module="Standby" screen="TryQuitMainloop">6</screen></item>
<item text="Multiboot image selector" entryID="multiboot" requires="canMultiBoot"><screen module="FlashImage" screen="MultibootSelection">1</screen></item>
<item level="2" text="Enable Kexec MultiBoot" entryID="enable_kexec_multiboot" requires="canKexec"><screen module="FlashImage" screen="KexecInit">1</screen></item>
<item text="Deep standby" requires="DeepstandbySupport" entryID="deep_standby"><screen module="Standby" screen="TryQuitMainloop">1</screen></item>
<item text="Shutdown" requires="!DeepstandbySupport" entryID="deep_standby"><screen module="Standby" screen="TryQuitMainloop">1</screen></item>
</menu>
Expand Down
1 change: 1 addition & 0 deletions lib/python/Components/SystemInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def getBootdevice():
SystemInfo["hasXcoreVFD"] = model in ("osmega", "spycat4k", "spycat4kmini", "spycat4kcombo") and fileCheck("/sys/module/brcmstb_%s/parameters/pt6302_cgram" % model)
SystemInfo["HasOfflineDecoding"] = model not in ("osmini", "osminiplus", "et7000mini", "et11000", "mbmicro", "mbtwinplus", "mbmicrov2", "et7000", "et8500")
SystemInfo["hasKexec"] = fileHas("/proc/cmdline", "kexec=1")
SystemInfo["canKexec"] = model in ("vusolo4k", "vuduo4k", "vuduo4kse", "vuultimo4k", "vuuno4k", "vuuno4kse", "vuzero4k") and not SystemInfo["hasKexec"] and fileExists("/usr/bin/kernel_auto.bin") and fileExists("/usr/bin/STARTUP.cpio.gz")
SystemInfo["MultibootStartupDevice"] = getMultibootStartupDevice()
SystemInfo["canMode12"] = "%s_4.boxmode" % model in cmdline and cmdline["%s_4.boxmode" % model] in ("1", "12") and "192M"
SystemInfo["canMultiBoot"] = getMultibootslots()
Expand Down
59 changes: 58 additions & 1 deletion lib/python/Screens/FlashImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from Components.ProgressBar import ProgressBar
from Components.SystemInfo import SystemInfo
from Tools.BoundFunction import boundFunction
from Tools.Directories import resolveFilename, SCOPE_PLUGINS
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, fileExists, pathExists
from Tools.Downloader import downloadWithProgress
from Tools.HardwareInfo import HardwareInfo
from Tools.Multiboot import getImagelist, getCurrentImage, getCurrentImageMode, deleteImage, restoreImages
Expand Down Expand Up @@ -551,3 +551,60 @@ def selectionChanged(self):
self["key_yellow"].setText(_("Restore deleted images"))
else:
self["key_yellow"].setText("")


class KexecInit(Screen):

model = HardwareInfo().get_device_model()
modelMtdRootKernel = model in ("vuduo4k", "vuduo4kse") and ["mmcblk0p9", "mmcblk0p6"] or model in ("vusolo4k", "vuultimo4k", "vuuno4k", "vuuno4kse") and ["mmcblk0p4", "mmcblk0p1"] or model == "vuzero4k" and ["mmcblk0p7", "mmcblk0p4"] or ["", ""]

STARTUP = "kernel=/zImage root=/dev/%s rootsubdir=linuxrootfs0" % modelMtdRootKernel[0] # /STARTUP
STARTUP_RECOVERY = "kernel=/zImage root=/dev/%s rootsubdir=linuxrootfs0" % modelMtdRootKernel[0] # /STARTUP_RECOVERY
STARTUP_1 = "kernel=/linuxrootfs1/zImage root=/dev/%s rootsubdir=linuxrootfs1" % modelMtdRootKernel[0] # /STARTUP_1
STARTUP_2 = "kernel=/linuxrootfs2/zImage root=/dev/%s rootsubdir=linuxrootfs2" % modelMtdRootKernel[0] # /STARTUP_2
STARTUP_3 = "kernel=/linuxrootfs3/zImage root=/dev/%s rootsubdir=linuxrootfs3" % modelMtdRootKernel[0] # /STARTUP_3

def __init__(self, session, *args):
Screen.__init__(self, session)
self.skinName = ["KexecInit", "Setup"]
self.setTitle(_("Kexec MultiBoot Manager"))
self["description"] = Label(_("Press Green key to enable MultiBoot!\n\nWill reboot within 10 seconds,\nunless you have eMMC slots to restore.\nRestoring eMMC slots can take from 1 -> 5 minutes per slot."))
self["key_green"] = StaticText(_("Init Vu+ MultiBoot"))
self["actions"] = ActionMap(["SetupActions"],
{
"save": self.RootInit,
"ok": self.close,
"cancel": self.close,
"menu": self.close,
}, -1)

def RootInit(self):
self["actions"].setEnabled(False) # This function takes time so disable the ActionMap to avoid responding to multiple button presses
if fileExists("/usr/bin/kernel_auto.bin") and fileExists("/usr/bin/STARTUP.cpio.gz"):
self.setTitle(_("Kexec MultiBoot Initialisation - will reboot after 10 seconds."))
self["description"].setText(_("Kexec MultiBoot Initialisation in progress!\n\nWill reboot after restoring any eMMC slots.\nThis can take from 1 -> 5 minutes per slot."))
with open("/STARTUP", 'w') as f:
f.write(self.STARTUP)
with open("/STARTUP_RECOVERY", 'w') as f:
f.write(self.STARTUP_RECOVERY)
with open("/STARTUP_1", 'w') as f:
f.write(self.STARTUP_1)
with open("/STARTUP_2", 'w') as f:
f.write(self.STARTUP_2)
with open("/STARTUP_3", 'w') as f:
f.write(self.STARTUP_3)
cmdlist = []
cmdlist.append("dd if=/dev/%s of=/zImage" % self.modelMtdRootKernel[1]) # backup old kernel
cmdlist.append("dd if=/usr/bin/kernel_auto.bin of=/dev/%s" % self.modelMtdRootKernel[1]) # create new kernel
cmdlist.append("mv /usr/bin/STARTUP.cpio.gz /STARTUP.cpio.gz") # copy userroot routine
Console().eBatch(cmdlist, self.RootInitEnd, debug=True)
else:
self.session.open(MessageBox, _("Unable to complete - Kexec Multiboot files missing!"), MessageBox.TYPE_INFO, timeout=10)
self.close()

def RootInitEnd(self, *args, **kwargs):
from Screens.Standby import TryQuitMainloop
for usbslot in range(1, 4):
if pathExists("/media/hdd/%s/linuxrootfs%s" % (self.model, usbslot)):
Console().ePopen("cp -R /media/hdd/%s/linuxrootfs%s . /" % (self.model, usbslot))
self.session.open(TryQuitMainloop, 2)

0 comments on commit 1747813

Please sign in to comment.