diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 03957d35e..38ffcefd6 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -466,6 +466,16 @@ flashupdate.cantopenfile kann Datei nicht öffnen flashupdate.cantopenmtd kann MTD nicht öffnen flashupdate.checkupdate_internet Online nach Updates suchen flashupdate.checkupdate_local Lokales Update +flashupdate.createimage Image speichern +flashupdate.createimage_add_env 'env' hinzufügen +flashupdate.createimage_add_kernel 'kernel' hinzufügen +flashupdate.createimage_add_spare 'spare' hinzufügen +flashupdate.createimage_add_u_boot 'u-boot' hinzufügen +flashupdate.createimage_add_uldr 'uldr' hinzufügen +flashupdate.createimage_menu Aktuelle Software sichern +flashupdate.createimage_options Einstellungen +flashupdate.createimage_other Image für %s STB erstellen +flashupdate.createimage_warning Nachfolgend wird ein Image für die %s STB erstellt.\nDieses Image wird auch nur auf einer %s STB lauffähig sein!\n \nTrotzdem fortsetzten? flashupdate.currentversion_sep Installierte Version flashupdate.currentversiondate Datum flashupdate.currentversiontime Uhrzeit diff --git a/data/locale/english.locale b/data/locale/english.locale index df3a18081..2142125b2 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -466,6 +466,16 @@ flashupdate.cantopenfile can't open file flashupdate.cantopenmtd can't open MTD flashupdate.checkupdate_internet Check for online updates flashupdate.checkupdate_local Local update +flashupdate.createimage Save image +flashupdate.createimage_add_env Add 'env' to image +flashupdate.createimage_add_kernel Add 'kernel' to image +flashupdate.createimage_add_spare Add 'spare' to image +flashupdate.createimage_add_u_boot Add 'u-boot' to image +flashupdate.createimage_add_uldr Add 'uldr' to image +flashupdate.createimage_menu Save current software +flashupdate.createimage_options Options +flashupdate.createimage_other Create image for %s STB +flashupdate.createimage_warning Now an image for the %s STB is created.\nThis image will also run on only one %s STB!\n \nNevertheless continued? flashupdate.currentversion_sep Current version flashupdate.currentversiondate Date flashupdate.currentversiontime Time diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 8c7376789..f1da1d298 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -542,6 +543,11 @@ CFlashExpert::CFlashExpert() { selectedMTD = -1; width = w_max (40, 10); +#ifdef BOXMODEL_APOLLO + forceOtherFilename = false; + otherFilename = ""; + createimage_other = 0; +#endif } CFlashExpert* CFlashExpert::getInstance() @@ -653,10 +659,13 @@ void CFlashExpert::readmtdJFFS2(std::string &filename) } std::string path = "/"; - CMTDInfo *MTDInfo = CMTDInfo::getInstance(); - int esize = MTDInfo->getMTDEraseSize(MTDInfo->findMTDsystem()); + int eSize = CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem()); + if (createimage_other == 1) { + if (eSize == 0x40000) eSize = 0x20000; + else if (eSize == 0x20000) eSize = 0x40000; + } CMkfsJFFS2 mkfs; - mkfs.makeJffs2Image(path, filename, esize, 0, 0, __LITTLE_ENDIAN, true, true, &progress, &v_devtable); + mkfs.makeJffs2Image(path, filename, eSize, 0, 0, __LITTLE_ENDIAN, true, true, &progress, &v_devtable); progress.hide(); char message[500]; @@ -673,8 +682,17 @@ void CFlashExpert::readmtd(int preadmtd) std::string timeStr = getNowTimeStr("_%Y%m%d_%H%M"); std::string tankStr = ""; #ifdef BOXMODEL_APOLLO - if ((preadmtd == 0) && (CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem()) == 0x40000)) - tankStr = ".256k"; + int eSize = CMTDInfo::getInstance()->getMTDEraseSize(CMTDInfo::getInstance()->findMTDsystem()); + if (preadmtd == 0) { + if (createimage_other == 0) { + if (eSize == 0x40000) tankStr = ".256k"; + if (eSize == 0x20000) tankStr = ""; + } + else if (createimage_other == 1) { + if (eSize == 0x40000) tankStr = ""; + if (eSize == 0x20000) tankStr = ".256k"; + } + } #endif if (g_settings.softupdate_name_mode_backup == CExtUpdate::SOFTUPDATE_NAME_HOSTNAME_TIME) filename = (std::string)g_settings.update_dir + "/" + mtdInfo->getMTDName(preadmtd) + timeStr + "_" + hostName + tankStr + ".img"; @@ -696,6 +714,9 @@ void CFlashExpert::readmtd(int preadmtd) #ifndef BOXMODEL_APOLLO if ((std::string)g_settings.update_dir == "/tmp") skipCheck = true; +#else + if (forceOtherFilename) + filename = otherFilename; #endif if ((!skipCheck) && (!checkSize(preadmtd, filename))) return; @@ -718,7 +739,12 @@ void CFlashExpert::readmtd(int preadmtd) sprintf(message, g_Locale->getText(LOCALE_FLASHUPDATE_SAVESUCCESS), filename.c_str()); sleep(1); hide(); +#ifdef BOXMODEL_APOLLO + if (!forceOtherFilename) + ShowHintUTF(LOCALE_MESSAGEBOX_INFO, message); +#else ShowHintUTF(LOCALE_MESSAGEBOX_INFO, message); +#endif } } @@ -779,6 +805,11 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey) // disable write uboot / uldr, FIXME correct numbers if ((actionkey == "writemtd") && (lx == 5 || lx == 6)) enabled = false; + if ((actionkey == "readmtd") && (lx == 0)) { + CMenuForwarder *mf = new CMenuForwarderNonLocalized("root0", true, NULL, new CFlashExpertSetup(), NULL, CRCInput::convertDigitToKey(shortcut++)); + mtdselector->addItem(mf); + continue; + } #else // disable write uboot if ((actionkey == "writemtd") && (lx == 0)) @@ -875,3 +906,137 @@ int CFlashExpert::exec(CMenuTarget* parent, const std::string & actionKey) hide(); return res; } + +#ifdef BOXMODEL_APOLLO +CFlashExpertSetup::CFlashExpertSetup() +{ + width = w_max (40, 10); +} + +void CFlashExpertSetup::readMTDPart(int mtd, const std::string &fileName) +{ + CFlashExpert *cfe = CFlashExpert::getInstance(); + if (file_exists(fileName.c_str())) + unlink(fileName.c_str()); + cfe->otherFilename = fileName; + cfe->readmtd(mtd); + sync(); +} + +#define UBOOT_BIN +//#define ENV_SPARE_BIN + +int CFlashExpertSetup::exec(CMenuTarget* parent, const std::string &actionKey) +{ +#define UPDATEDIR "/var/update" + if (parent) + parent->hide(); + + if (actionKey == "readmtd0") { + CFlashExpert *cfe = CFlashExpert::getInstance(); + bool skipImage = false; + if (cfe->createimage_other == 1) { + char message[512] = {0}; + // create image warning + CMTDInfo *mtdInfo = CMTDInfo::getInstance(); + const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank"; + snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_WARNING), box, box); + if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) + skipImage = true; + } + if (!skipImage) { + std::string uldrName = (std::string)UPDATEDIR + "/uldr.bin"; + cfe->forceOtherFilename = true; + if (g_settings.flashupdate_createimage_add_uldr == 1) + readMTDPart(2, uldrName); +#ifdef UBOOT_BIN + std::string ubootName = (std::string)UPDATEDIR + "/u-boot.bin"; + if (g_settings.flashupdate_createimage_add_u_boot == 1) + readMTDPart(3, ubootName); +#endif +#ifdef ENV_SPARE_BIN + std::string envName = (std::string)UPDATEDIR + "/env.bin"; + if (g_settings.flashupdate_createimage_add_env == 1) + readMTDPart(4, envName); + std::string spareName = (std::string)UPDATEDIR + "/spare.bin"; + if (g_settings.flashupdate_createimage_add_spare == 1) + readMTDPart(5, spareName); +#endif + std::string kernelName = (std::string)UPDATEDIR + "/vmlinux.ub.gz"; + if (g_settings.flashupdate_createimage_add_kernel == 1) + readMTDPart(6, kernelName); + cfe->forceOtherFilename = false; + cfe->otherFilename = ""; + + cfe->readmtd(0); + + if (g_settings.flashupdate_createimage_add_uldr == 1) + unlink(uldrName.c_str()); +#ifdef UBOOT_BIN + if (g_settings.flashupdate_createimage_add_u_boot == 1) + unlink(ubootName.c_str()); +#endif +#ifdef ENV_SPARE_BIN + if (g_settings.flashupdate_createimage_add_env == 1) + unlink(envName.c_str()); + if (g_settings.flashupdate_createimage_add_spare == 1) + unlink(spareName.c_str()); +#endif + if (g_settings.flashupdate_createimage_add_kernel == 1) + unlink(kernelName.c_str()); + sync(); + } + + cfe->createimage_other = 0; + return menu_return::RETURN_EXIT_ALL; + } + return showMenu(); +} + +int CFlashExpertSetup::showMenu() +{ + CFlashExpert *cfe = CFlashExpert::getInstance(); + CMenuWidget *rootfsSetup = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, MN_WIDGET_ID_MTDREAD_ROOT0); + rootfsSetup->addIntroItems(LOCALE_FLASHUPDATE_CREATEIMAGE_MENU); + + CMenuSeparator *s1 = new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_FLASHUPDATE_CREATEIMAGE_OPTIONS); + CMenuForwarder *m1 = new CMenuForwarder(LOCALE_FLASHUPDATE_CREATEIMAGE, true, NULL, this, "readmtd0", CRCInput::convertDigitToKey(0)); + CMenuOptionChooser *m2 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_ULDR, &g_settings.flashupdate_createimage_add_uldr, + MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true); + CMenuOptionChooser *m3 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_U_BOOT, &g_settings.flashupdate_createimage_add_u_boot, + MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true); +#ifdef ENV_SPARE_BIN + CMenuOptionChooser *m4 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_ENV, &g_settings.flashupdate_createimage_add_env, + MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, false); + CMenuOptionChooser *m5 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_SPARE, &g_settings.flashupdate_createimage_add_spare, + MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, false); +#endif + CMenuOptionChooser *m6 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_KERNEL, &g_settings.flashupdate_createimage_add_kernel, + MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true); + + + CMTDInfo *mtdInfo = CMTDInfo::getInstance(); + const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank"; + char mText[512] = {0}; + snprintf(mText, sizeof(mText)-1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_OTHER), box); + CMenuOptionChooser *m7 = new CMenuOptionChooser(mText, &(cfe->createimage_other), MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true); + + rootfsSetup->addItem(m1); // create image + rootfsSetup->addItem(s1); + rootfsSetup->addItem(m2); // include uldr + rootfsSetup->addItem(m3); // include u-boot +#ifdef ENV_SPARE_BIN + rootfsSetup->addItem(m4); // include env + rootfsSetup->addItem(m5); // include spare +#endif + rootfsSetup->addItem(m6); // include kernel + rootfsSetup->addItem(GenericMenuSeparatorLine); + rootfsSetup->addItem(m7); // create image for other STB + + int res = rootfsSetup->exec (NULL, ""); + delete rootfsSetup; + + cfe->createimage_other = 0; + return res; +} +#endif // BOXMODEL_APOLLO diff --git a/src/gui/update.h b/src/gui/update.h index 2ae06f958..05bb4cfe9 100644 --- a/src/gui/update.h +++ b/src/gui/update.h @@ -79,19 +79,40 @@ class CFlashExpert : public CProgressWindow int showFileSelector(const std::string & actionkey); bool checkSize(int mtd, std::string &backupFile); - void readmtd(int readmtd); #ifdef BOXMODEL_APOLLO bool readDevtableFile(std::string &devtableFile, CMkfsJFFS2::v_devtable_t &v_devtable); void readmtdJFFS2(std::string &filename); #endif public: +#ifdef BOXMODEL_APOLLO + bool forceOtherFilename; + std::string otherFilename; + int createimage_other; +#endif CFlashExpert(); static CFlashExpert* getInstance(); int exec(CMenuTarget* parent, const std::string & actionKey); void writemtd(const std::string & filename, int mtdNumber); + void readmtd(int readmtd); }; +#ifdef BOXMODEL_APOLLO +class CFlashExpertSetup : public CMenuTarget +{ + private: + int width; + + int showMenu(); + void readMTDPart(int mtd, const std::string &fileName); + + public: + CFlashExpertSetup(); +// ~CFlashExpertSetup(); + + int exec(CMenuTarget* parent, const std::string &actionKey); +}; +#endif // BOXMODEL_APOLLO #endif diff --git a/src/neutrino.cpp b/src/neutrino.cpp index eb6cd06cd..dfd8a9cb7 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -663,6 +663,12 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.softupdate_name_mode_apply = configfile.getInt32( "softupdate_name_mode_apply", CExtUpdate::SOFTUPDATE_NAME_DEFAULT); g_settings.softupdate_name_mode_backup = configfile.getInt32( "softupdate_name_mode_backup", CExtUpdate::SOFTUPDATE_NAME_DEFAULT); + g_settings.flashupdate_createimage_add_uldr = configfile.getInt32( "flashupdate_createimage_add_uldr", 1); + g_settings.flashupdate_createimage_add_u_boot = configfile.getInt32( "flashupdate_createimage_add_u_boot", 0); + g_settings.flashupdate_createimage_add_env = configfile.getInt32( "flashupdate_createimage_add_env", 0); + g_settings.flashupdate_createimage_add_spare = configfile.getInt32( "flashupdate_createimage_add_spare", 0); + g_settings.flashupdate_createimage_add_kernel = configfile.getInt32( "flashupdate_createimage_add_kernel", 1); + strcpy(g_settings.softupdate_url_file, configfile.getString("softupdate_url_file", "/var/etc/update.urls").c_str()); strcpy(g_settings.softupdate_proxyserver, configfile.getString("softupdate_proxyserver", "" ).c_str()); strcpy(g_settings.softupdate_proxyusername, configfile.getString("softupdate_proxyusername", "" ).c_str()); @@ -1103,6 +1109,12 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32 ("softupdate_name_mode_apply", g_settings.softupdate_name_mode_apply); configfile.setInt32 ("softupdate_name_mode_backup", g_settings.softupdate_name_mode_backup); + configfile.setInt32("flashupdate_createimage_add_uldr", g_settings.flashupdate_createimage_add_uldr); + configfile.setInt32("flashupdate_createimage_add_u_boot", g_settings.flashupdate_createimage_add_u_boot); + configfile.setInt32("flashupdate_createimage_add_env", g_settings.flashupdate_createimage_add_env); + configfile.setInt32("flashupdate_createimage_add_spare", g_settings.flashupdate_createimage_add_spare); + configfile.setInt32("flashupdate_createimage_add_kernel", g_settings.flashupdate_createimage_add_kernel); + configfile.setString("softupdate_proxyserver" , g_settings.softupdate_proxyserver ); configfile.setString("softupdate_proxyusername" , g_settings.softupdate_proxyusername ); configfile.setString("softupdate_proxypassword" , g_settings.softupdate_proxypassword ); diff --git a/src/neutrino_menue.h b/src/neutrino_menue.h index 686fba91b..db23a4254 100644 --- a/src/neutrino_menue.h +++ b/src/neutrino_menue.h @@ -158,6 +158,7 @@ enum MN_WIDGET_ID MN_WIDGET_ID_MTDREAD_SELECTOR, MN_WIDGET_ID_MTDWRITE_SELECTOR, MN_WIDGET_ID_FILESELECTOR, + MN_WIDGET_ID_MTDREAD_ROOT0, //software update MN_WIDGET_ID_SOFTWAREUPDATE, diff --git a/src/system/locals.h b/src/system/locals.h index b6c9d6d31..cd9eaa275 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -493,6 +493,16 @@ typedef enum LOCALE_FLASHUPDATE_CANTOPENMTD, LOCALE_FLASHUPDATE_CHECKUPDATE_INTERNET, LOCALE_FLASHUPDATE_CHECKUPDATE_LOCAL, + LOCALE_FLASHUPDATE_CREATEIMAGE, + LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_ENV, + LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_KERNEL, + LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_SPARE, + LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_U_BOOT, + LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_ULDR, + LOCALE_FLASHUPDATE_CREATEIMAGE_MENU, + LOCALE_FLASHUPDATE_CREATEIMAGE_OPTIONS, + LOCALE_FLASHUPDATE_CREATEIMAGE_OTHER, + LOCALE_FLASHUPDATE_CREATEIMAGE_WARNING, LOCALE_FLASHUPDATE_CURRENTVERSION_SEP, LOCALE_FLASHUPDATE_CURRENTVERSIONDATE, LOCALE_FLASHUPDATE_CURRENTVERSIONTIME, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 198e82d27..09faabf4b 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -493,6 +493,16 @@ const char * locale_real_names[] = "flashupdate.cantopenmtd", "flashupdate.checkupdate_internet", "flashupdate.checkupdate_local", + "flashupdate.createimage", + "flashupdate.createimage_add_env", + "flashupdate.createimage_add_kernel", + "flashupdate.createimage_add_spare", + "flashupdate.createimage_add_u_boot", + "flashupdate.createimage_add_uldr", + "flashupdate.createimage_menu", + "flashupdate.createimage_options", + "flashupdate.createimage_other", + "flashupdate.createimage_warning", "flashupdate.currentversion_sep", "flashupdate.currentversiondate", "flashupdate.currentversiontime", diff --git a/src/system/mtdutils/mkfs.jffs2.cpp b/src/system/mtdutils/mkfs.jffs2.cpp index c82b4cfaf..33ea6ffe0 100644 --- a/src/system/mtdutils/mkfs.jffs2.cpp +++ b/src/system/mtdutils/mkfs.jffs2.cpp @@ -1162,7 +1162,7 @@ bool CMkfsJFFS2::makeJffs2Image(std::string& path, progressBar = progress; hardlinks.rb_node = NULL; -// printf("[%s] erase_block_size: 0x%X\n", __FUNCTION__, eraseBlockSize); + printf("[%s] erase_block_size: 0x%X\n", __FUNCTION__, eraseBlockSize); classInit(); char *cwd; diff --git a/src/system/settings.h b/src/system/settings.h index 006202c84..13417a945 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -482,6 +482,12 @@ struct SNeutrinoSettings int apply_settings; int apply_kernel; + int flashupdate_createimage_add_uldr; + int flashupdate_createimage_add_u_boot; + int flashupdate_createimage_add_env; + int flashupdate_createimage_add_spare; + int flashupdate_createimage_add_kernel; + //BouquetHandling int bouquetlist_mode;