mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 08:21:07 +02:00
update.cpp: fix flash bootselector for hd51, thx DboxOldie
Origin commit data
------------------
Commit: 99bed204c5
Author: Frankenstone <dampf_acc@online.de>
Date: 2019-05-22 (Wed, 22 May 2019)
This commit is contained in:
@@ -619,6 +619,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
#if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE
|
||||
else if (fileType == 'Z') // flashing image with ofgwrite
|
||||
{
|
||||
bool flashing = false;
|
||||
showGlobalStatus(100);
|
||||
|
||||
// create settings package
|
||||
@@ -639,18 +640,43 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
// get active partition
|
||||
char c[2] = {0};
|
||||
FILE *f;
|
||||
f = fopen("/sys/firmware/devicetree/base/chosen/kerneldev", "r");
|
||||
char line[1024];
|
||||
char *pch;
|
||||
// first check for hd51 new layout
|
||||
f = fopen("/sys/firmware/devicetree/base/chosen/bootargs", "r");
|
||||
if (f)
|
||||
{
|
||||
if (fseek(f, -2, SEEK_END) == 0)
|
||||
if (fgets (line , sizeof(line), f) != NULL)
|
||||
{
|
||||
c[0] = fgetc(f);
|
||||
if (strcmp(c, "l") == 0)
|
||||
c[0] = '1';
|
||||
dprintf(DEBUG_NORMAL, "[update] Current partition: %s\n", c);
|
||||
pch = strtok(line, " =");
|
||||
while (pch != NULL)
|
||||
{
|
||||
if (strncmp("linuxrootfs", pch, 11) == 0)
|
||||
{
|
||||
strncpy(c, pch + 11, 1);
|
||||
c[1] = '\0';
|
||||
dprintf(DEBUG_NORMAL, "[update] Current partition: %s\n", c);
|
||||
break;
|
||||
}
|
||||
pch = strtok(NULL, " =");
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
// if no new layout
|
||||
if (!atoi(c))
|
||||
{
|
||||
f = fopen("/sys/firmware/devicetree/base/chosen/kerneldev", "r");
|
||||
if (f)
|
||||
{
|
||||
if (fseek(f, -2, SEEK_END) == 0)
|
||||
{
|
||||
c[0] = fgetc(f);
|
||||
dprintf(DEBUG_NORMAL, "[update] Current partition: %s\n", c);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
// select partition
|
||||
int selected = 0;
|
||||
@@ -681,6 +707,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
std::string ofgwrite_options("");
|
||||
if (selected > 0 && strcmp(c, to_string(selected).c_str()))
|
||||
{
|
||||
flashing = true;
|
||||
// align ofgwrite options
|
||||
ofgwrite_options = "-m" + to_string(selected);
|
||||
dprintf(DEBUG_NORMAL, "[update] ofgwrite_options: %s\n", ofgwrite_options.c_str());
|
||||
@@ -699,15 +726,19 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
fh.copyFile(startup_new.c_str(), "/boot/STARTUP");
|
||||
#endif
|
||||
}
|
||||
} else if (selected > 0 && strcmp(c, to_string(selected).c_str()) == 0) {
|
||||
flashing = true;
|
||||
ofgwrite_options = "-m" + to_string(selected);
|
||||
}
|
||||
|
||||
ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_OFGWRITE);
|
||||
if (flashing)
|
||||
ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_OFGWRITE);
|
||||
hide();
|
||||
|
||||
const char ofgwrite_tgz[] = "/bin/ofgwrite_tgz";
|
||||
dprintf(DEBUG_NORMAL, "[update] calling %s %s %s %s\n", ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
|
||||
#ifndef DRYRUN
|
||||
my_system(4, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
|
||||
if (flashing)
|
||||
my_system(4, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
|
||||
|
||||
/*
|
||||
TODO: fix osd-flickering
|
||||
|
Reference in New Issue
Block a user