update.cpp: fix flash bootselector for hd51, thx DboxOldie

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
Frankenstone
2019-05-22 18:54:17 +01:00
committed by Thilo Graf
parent 6ed8c3b909
commit 123c723e11

View File

@@ -635,6 +635,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
#if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE #if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE
else if (fileType == 'Z') // flashing image with ofgwrite else if (fileType == 'Z') // flashing image with ofgwrite
{ {
bool flashing = false;
showGlobalStatus(100); showGlobalStatus(100);
// create settings package // create settings package
@@ -655,6 +656,32 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
// get active partition // get active partition
char c[2] = {0}; char c[2] = {0};
FILE *f; FILE *f;
char line[1024];
char *pch;
// first check for hd51 new layout
f = fopen("/sys/firmware/devicetree/base/chosen/bootargs", "r");
if (f)
{
if (fgets (line , sizeof(line), f) != NULL)
{
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"); f = fopen("/sys/firmware/devicetree/base/chosen/kerneldev", "r");
if (f) if (f)
{ {
@@ -665,6 +692,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
} }
fclose(f); fclose(f);
} }
}
// select partition // select partition
int selected = 0; int selected = 0;
@@ -695,6 +723,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
std::string ofgwrite_options(""); std::string ofgwrite_options("");
if (selected > 0 && strcmp(c, to_string(selected).c_str())) if (selected > 0 && strcmp(c, to_string(selected).c_str()))
{ {
flashing = true;
// align ofgwrite options // align ofgwrite options
ofgwrite_options = "-m" + to_string(selected); ofgwrite_options = "-m" + to_string(selected);
dprintf(DEBUG_NORMAL, "[update] ofgwrite_options: %s\n", ofgwrite_options.c_str()); dprintf(DEBUG_NORMAL, "[update] ofgwrite_options: %s\n", ofgwrite_options.c_str());
@@ -713,14 +742,18 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
fh.copyFile(startup_new.c_str(), "/boot/STARTUP"); fh.copyFile(startup_new.c_str(), "/boot/STARTUP");
#endif #endif
} }
} else if (selected > 0 && strcmp(c, to_string(selected).c_str()) == 0) {
flashing = true;
ofgwrite_options = "-m" + to_string(selected);
} }
if (flashing)
ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_OFGWRITE); ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_OFGWRITE);
hide(); hide();
const char ofgwrite_tgz[] = "/bin/ofgwrite_tgz"; 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()); 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 #ifndef DRYRUN
if (flashing)
my_system(4, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str()); my_system(4, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
/* /*