mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 16:31:05 +02:00
CFlashExpert: Use findMTDNumberFromName() to find mtdnumber
Origin commit data
------------------
Commit: b25b1c4fb5
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2013-09-28 (Sat, 28 Sep 2013)
This commit is contained in:
@@ -792,7 +792,7 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey)
|
|||||||
widget_id = MN_WIDGET_ID_MTDREAD_SELECTOR;
|
widget_id = MN_WIDGET_ID_MTDREAD_SELECTOR;
|
||||||
else if (actionkey == "writemtd")
|
else if (actionkey == "writemtd")
|
||||||
widget_id = MN_WIDGET_ID_MTDWRITE_SELECTOR;
|
widget_id = MN_WIDGET_ID_MTDWRITE_SELECTOR;
|
||||||
|
|
||||||
//generate mtd-selector
|
//generate mtd-selector
|
||||||
CMenuWidget* mtdselector = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, widget_id);
|
CMenuWidget* mtdselector = new CMenuWidget(LOCALE_SERVICEMENU_UPDATE, NEUTRINO_ICON_UPDATE, width, widget_id);
|
||||||
mtdselector->addIntroItems(LOCALE_FLASHUPDATE_MTDSELECTOR, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
|
mtdselector->addIntroItems(LOCALE_FLASHUPDATE_MTDSELECTOR, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
|
||||||
@@ -802,17 +802,18 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey)
|
|||||||
char sActionKey[20];
|
char sActionKey[20];
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
#ifdef BOXMODEL_APOLLO
|
#ifdef BOXMODEL_APOLLO
|
||||||
// disable write uboot / uldr, FIXME correct numbers
|
// disable write uboot / uldr
|
||||||
if ((actionkey == "writemtd") && (lx == 5 || lx == 6))
|
if ((actionkey == "writemtd") && (lx == mtdInfo->findMTDNumberFromName("u-boot") || lx == mtdInfo->findMTDNumberFromName("uldr")))
|
||||||
enabled = false;
|
enabled = false;
|
||||||
if ((actionkey == "readmtd") && (lx == 0)) {
|
// build jffs2 image from root0
|
||||||
|
if ((actionkey == "readmtd") && (lx == mtdInfo->findMTDNumberFromName("root0"))) {
|
||||||
CMenuForwarder *mf = new CMenuForwarderNonLocalized("root0", true, NULL, new CFlashExpertSetup(), NULL, CRCInput::convertDigitToKey(shortcut++));
|
CMenuForwarder *mf = new CMenuForwarderNonLocalized("root0", true, NULL, new CFlashExpertSetup(), NULL, CRCInput::convertDigitToKey(shortcut++));
|
||||||
mtdselector->addItem(mf);
|
mtdselector->addItem(mf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// disable write uboot
|
// disable write uboot
|
||||||
if ((actionkey == "writemtd") && (lx == 0))
|
if ((actionkey == "writemtd") && (lx == mtdInfo->findMTDNumberFromName("u-boot")))
|
||||||
enabled = false;
|
enabled = false;
|
||||||
#endif
|
#endif
|
||||||
sprintf(sActionKey, "%s%d", actionkey.c_str(), lx);
|
sprintf(sActionKey, "%s%d", actionkey.c_str(), lx);
|
||||||
@@ -934,11 +935,11 @@ int CFlashExpertSetup::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
|
|
||||||
if (actionKey == "readmtd0") {
|
if (actionKey == "readmtd0") {
|
||||||
CFlashExpert *cfe = CFlashExpert::getInstance();
|
CFlashExpert *cfe = CFlashExpert::getInstance();
|
||||||
|
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
||||||
bool skipImage = false;
|
bool skipImage = false;
|
||||||
if (cfe->createimage_other == 1) {
|
if (cfe->createimage_other == 1) {
|
||||||
char message[512] = {0};
|
char message[512] = {0};
|
||||||
// create image warning
|
// create image warning
|
||||||
CMTDInfo *mtdInfo = CMTDInfo::getInstance();
|
|
||||||
const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank";
|
const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank";
|
||||||
snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_WARNING), box, box);
|
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)
|
if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)
|
||||||
@@ -948,23 +949,23 @@ int CFlashExpertSetup::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
std::string uldrName = (std::string)UPDATEDIR + "/uldr.bin";
|
std::string uldrName = (std::string)UPDATEDIR + "/uldr.bin";
|
||||||
cfe->forceOtherFilename = true;
|
cfe->forceOtherFilename = true;
|
||||||
if (g_settings.flashupdate_createimage_add_uldr == 1)
|
if (g_settings.flashupdate_createimage_add_uldr == 1)
|
||||||
readMTDPart(2, uldrName);
|
readMTDPart(mtdInfo->findMTDNumberFromName("uldr"), uldrName);
|
||||||
#ifdef UBOOT_BIN
|
#ifdef UBOOT_BIN
|
||||||
std::string ubootName = (std::string)UPDATEDIR + "/u-boot.bin";
|
std::string ubootName = (std::string)UPDATEDIR + "/u-boot.bin";
|
||||||
if (g_settings.flashupdate_createimage_add_u_boot == 1)
|
if (g_settings.flashupdate_createimage_add_u_boot == 1)
|
||||||
readMTDPart(3, ubootName);
|
readMTDPart(mtdInfo->findMTDNumberFromName("u-boot"), ubootName);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENV_SPARE_BIN
|
#ifdef ENV_SPARE_BIN
|
||||||
std::string envName = (std::string)UPDATEDIR + "/env.bin";
|
std::string envName = (std::string)UPDATEDIR + "/env.bin";
|
||||||
if (g_settings.flashupdate_createimage_add_env == 1)
|
if (g_settings.flashupdate_createimage_add_env == 1)
|
||||||
readMTDPart(4, envName);
|
readMTDPart(mtdInfo->findMTDNumberFromName("env"), envName);
|
||||||
std::string spareName = (std::string)UPDATEDIR + "/spare.bin";
|
std::string spareName = (std::string)UPDATEDIR + "/spare.bin";
|
||||||
if (g_settings.flashupdate_createimage_add_spare == 1)
|
if (g_settings.flashupdate_createimage_add_spare == 1)
|
||||||
readMTDPart(5, spareName);
|
readMTDPart(mtdInfo->findMTDNumberFromName("spare"), spareName);
|
||||||
#endif
|
#endif
|
||||||
std::string kernelName = (std::string)UPDATEDIR + "/vmlinux.ub.gz";
|
std::string kernelName = (std::string)UPDATEDIR + "/vmlinux.ub.gz";
|
||||||
if (g_settings.flashupdate_createimage_add_kernel == 1)
|
if (g_settings.flashupdate_createimage_add_kernel == 1)
|
||||||
readMTDPart(6, kernelName);
|
readMTDPart(mtdInfo->findMTDNumberFromName("kernel"), kernelName);
|
||||||
cfe->forceOtherFilename = false;
|
cfe->forceOtherFilename = false;
|
||||||
cfe->otherFilename = "";
|
cfe->otherFilename = "";
|
||||||
|
|
||||||
@@ -1003,8 +1004,17 @@ int CFlashExpertSetup::showMenu()
|
|||||||
CMenuForwarder *m1 = new CMenuForwarder(LOCALE_FLASHUPDATE_CREATEIMAGE, true, NULL, this, "readmtd0", CRCInput::convertDigitToKey(0));
|
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,
|
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);
|
MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
||||||
|
#ifndef UBOOT_BIN
|
||||||
|
g_settings.flashupdate_createimage_add_u_boot = 0;
|
||||||
|
#endif
|
||||||
|
#ifdef UBOOT_BIN
|
||||||
CMenuOptionChooser *m3 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_U_BOOT, &g_settings.flashupdate_createimage_add_u_boot,
|
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);
|
MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true);
|
||||||
|
#endif
|
||||||
|
#ifndef ENV_SPARE_BIN
|
||||||
|
g_settings.flashupdate_createimage_add_env = 0;
|
||||||
|
g_settings.flashupdate_createimage_add_spare = 0;
|
||||||
|
#endif
|
||||||
#ifdef ENV_SPARE_BIN
|
#ifdef ENV_SPARE_BIN
|
||||||
CMenuOptionChooser *m4 = new CMenuOptionChooser(LOCALE_FLASHUPDATE_CREATEIMAGE_ADD_ENV, &g_settings.flashupdate_createimage_add_env,
|
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);
|
MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, false);
|
||||||
@@ -1024,7 +1034,9 @@ int CFlashExpertSetup::showMenu()
|
|||||||
rootfsSetup->addItem(m1); // create image
|
rootfsSetup->addItem(m1); // create image
|
||||||
rootfsSetup->addItem(s1);
|
rootfsSetup->addItem(s1);
|
||||||
rootfsSetup->addItem(m2); // include uldr
|
rootfsSetup->addItem(m2); // include uldr
|
||||||
|
#ifdef UBOOT_BIN
|
||||||
rootfsSetup->addItem(m3); // include u-boot
|
rootfsSetup->addItem(m3); // include u-boot
|
||||||
|
#endif
|
||||||
#ifdef ENV_SPARE_BIN
|
#ifdef ENV_SPARE_BIN
|
||||||
rootfsSetup->addItem(m4); // include env
|
rootfsSetup->addItem(m4); // include env
|
||||||
rootfsSetup->addItem(m5); // include spare
|
rootfsSetup->addItem(m5); // include spare
|
||||||
|
Reference in New Issue
Block a user