diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 1835e83a0..3fea909f2 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -603,6 +603,7 @@ flashupdate.cantopenfile kann Datei nicht öffnen flashupdate.cantopenmtd kann MTD nicht öffnen flashupdate.checkupdate_internet Online-Update flashupdate.checkupdate_local Lokales Update +flashupdate.choose_partition Partition wählen flashupdate.copy_image Kopiere Image in den Arbeitsspeicher flashupdate.createimage Image speichern flashupdate.createimage_add_env 'env' hinzufügen @@ -673,6 +674,8 @@ flashupdate.reallyflashmtd Wollen Sie den Flashvorgang wirklich durchführen?\n\ flashupdate.savesuccess Das Image wurde erfolgreich unter dem\nDateinamen %s gespeichert. flashupdate.selectimage Verfügbare Images und Updates flashupdate.settings Update-Einstellungen +flashupdate.start_ofgwrite Starte ofgwrite ... +flashupdate.start_selected_partition Starte ausgewählte Partition? flashupdate.titlereadflash Flash auslesen flashupdate.titlewriteflash Flash schreiben flashupdate.type_addon Erweiterung diff --git a/data/locale/english.locale b/data/locale/english.locale index 140497e61..0f8420fa6 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -603,6 +603,7 @@ flashupdate.cantopenfile can't open file flashupdate.cantopenmtd can't open MTD flashupdate.checkupdate_internet Online update flashupdate.checkupdate_local Local update +flashupdate.choose_partition Choose partition flashupdate.copy_image Copy Image to main memory flashupdate.createimage Save image flashupdate.createimage_add_env Add 'env' to image @@ -673,6 +674,8 @@ flashupdate.reallyflashmtd Do you really want to flash?\n\nIf a error occurs or flashupdate.savesuccess The image was successfully saved \nunder %s. flashupdate.selectimage Available images and updates flashupdate.settings Update settings +flashupdate.start_ofgwrite Starting ofgwrite ... +flashupdate.start_selected_partition Start chosen partition? flashupdate.titlereadflash Reading Flash flashupdate.titlewriteflash Writing Flash flashupdate.type_addon Addon diff --git a/src/gui/update.cpp b/src/gui/update.cpp index ffc1bb782..2f4c31040 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -620,20 +620,83 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) else if (fileType == 'Z') { showGlobalStatus(100); - ShowHint(LOCALE_MESSAGEBOX_INFO, "Start ofgwrite"); + + // get active partition + char c[2] = {0}; + FILE *f; + f = fopen("/sys/firmware/devicetree/base/chosen/kerneldev", "r"); + if (f) + { + if (fseek(f, -2, SEEK_END) == 0) + { + c[0] = fgetc(f); + printf("[update] Current partition: %s\n", c); + } + } + + // select partition + int selected = 0; + CMenuSelectorTarget *selector = new CMenuSelectorTarget(&selected); + + CMenuWidget m(LOCALE_FLASHUPDATE_CHOOSE_PARTITION, NEUTRINO_ICON_SETTINGS); + m.addItem(GenericMenuSeparator); + CMenuForwarder *mf; + + for (int i = 1; i < 4+1; i++) + { + bool active = !strcmp(c, to_string(i).c_str()); + std::string m_title = "Partition " + to_string(i); + mf = new CMenuForwarder(m_title, true, NULL, selector, to_string(i).c_str(), CRCInput::convertDigitToKey(i)); + mf->iconName_Info_right = active ? NEUTRINO_ICON_CHECKMARK : NULL; + m.addItem(mf, active); + } + + m.enableSaveScreen(true); + m.exec(NULL, ""); + + delete selector; + + printf("[update] Flash into partition %d\n", selected); + + int restart = CMsgBox::mbNo; + + std::string ofgwrite_options(""); + if (selected > 0 && strcmp(c, to_string(selected).c_str())) + { + // align ofgwrite options + ofgwrite_options = "-m" + to_string(selected); + printf("[update] ofgwrite_options: %s\n", ofgwrite_options.c_str()); + + // start selected partition? + restart = ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_SELECTED_PARTITION, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE); + if (restart == CMsgBox::mbrYes) + { + std::string startup_new = "/boot/STARTUP_" + to_string(selected); + printf("[update] Start selected partition %d (%s)\n", selected, startup_new.c_str()); +#ifndef DRYRUN + CFileHelpers fh; + fh.copyFile(startup_new.c_str(), "/boot/STARTUP"); +#endif + } + } + + ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_OFGWRITE); hide(); const char ofgwrite_tgz[] = "/bin/ofgwrite_tgz"; - printf("[update] calling %s %s %s\n", ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str() ); + printf("[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(3, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str()); -#endif + my_system(4, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str()); + /* - ofgwrite is killing Neutrino. - So we stay here and wait for our end. This avoids osd flickering. + TODO: fix osd-flickering + Neutrino is clearing framebuffer, so ofgwrite's gui is cleared too. */ - while (true) - sleep(1); + + if (restart == CMsgBox::mbrYes) + CNeutrinoApp::getInstance()->exec(NULL, "reboot"); +#endif + return menu_return::RETURN_EXIT_ALL; } #endif else // not image, install diff --git a/src/system/locals.h b/src/system/locals.h index 81a7698ef..523d111bc 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -630,6 +630,7 @@ typedef enum LOCALE_FLASHUPDATE_CANTOPENMTD, LOCALE_FLASHUPDATE_CHECKUPDATE_INTERNET, LOCALE_FLASHUPDATE_CHECKUPDATE_LOCAL, + LOCALE_FLASHUPDATE_CHOOSE_PARTITION, LOCALE_FLASHUPDATE_COPY_IMAGE, LOCALE_FLASHUPDATE_CREATEIMAGE, LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_ENV, @@ -700,6 +701,8 @@ typedef enum LOCALE_FLASHUPDATE_SAVESUCCESS, LOCALE_FLASHUPDATE_SELECTIMAGE, LOCALE_FLASHUPDATE_SETTINGS, + LOCALE_FLASHUPDATE_START_OFGWRITE, + LOCALE_FLASHUPDATE_START_SELECTED_PARTITION, LOCALE_FLASHUPDATE_TITLEREADFLASH, LOCALE_FLASHUPDATE_TITLEWRITEFLASH, LOCALE_FLASHUPDATE_TYPE_ADDON, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 6c2f37860..3ddaf873a 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -630,6 +630,7 @@ const char * locale_real_names[] = "flashupdate.cantopenmtd", "flashupdate.checkupdate_internet", "flashupdate.checkupdate_local", + "flashupdate.choose_partition", "flashupdate.copy_image", "flashupdate.createimage", "flashupdate.createimage_add_env", @@ -700,6 +701,8 @@ const char * locale_real_names[] = "flashupdate.savesuccess", "flashupdate.selectimage", "flashupdate.settings", + "flashupdate.start_ofgwrite", + "flashupdate.start_selected_partition", "flashupdate.titlereadflash", "flashupdate.titlewriteflash", "flashupdate.type_addon",