* Software update: Rework preparing the flash process

- Finish all unnecessary threads and processes before the flash process
- Use flash.start to stop other (user-defined) processes
This commit is contained in:
Michael Liebmann
2013-06-08 14:45:26 +02:00
parent d74ce0da45
commit c26fd64759
10 changed files with 81 additions and 28 deletions

View File

@@ -463,7 +463,6 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
printf("[update] flash/install filename %s type %c\n", filename.c_str(), fileType);
#endif
if(fileType < '3') {
CNeutrinoApp::getInstance()->exec(NULL, "savesettings");
//flash it...
if (g_settings.apply_settings) {
if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes)

View File

@@ -62,8 +62,6 @@ CExtUpdate::CExtUpdate()
imgFilename = "";
mtdRamError = "";
mtdNumber = -1;
MTDBufSize = 0xFFFF;
MTDBuf = new char[MTDBufSize];
backupList = CONFIGDIR "/settingsupdate.conf";
defaultBackup = CONFIGDIR;
@@ -84,8 +82,6 @@ CExtUpdate::CExtUpdate()
CExtUpdate::~CExtUpdate()
{
if (MTDBuf != NULL)
delete[] MTDBuf;
if(FileHelpers)
delete[] FileHelpers;
copyList.clear();
@@ -107,7 +103,7 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str
if (modus & RESET_UNLOAD) {
umount(mountPkt.c_str());
my_system(2,"rmmod", mtdramDriver.c_str());
// my_system(2,"rmmod", mtdramDriver.c_str());
}
if (modus & RESET_FD1)
close(fd1);
@@ -272,6 +268,8 @@ bool CExtUpdate::applySettings()
}
}
int MTDBufSize = 0xFFFF;
char *MTDBuf = new char[MTDBufSize];
// copy image to mtdblock
if (MTDBuf == NULL)
return ErrorReset(RESET_UNLOAD, "malloc error");
@@ -362,6 +360,8 @@ bool CExtUpdate::applySettings()
if(hintBox)
hintBox->hide();
delete[] MTDBuf;
MTDBuf = NULL;
sync();
return true;
}

View File

@@ -46,8 +46,6 @@ class CExtUpdate
std::string imgFilename;
std::string mtdRamError;
int mtdNumber;
int MTDBufSize;
char *MTDBuf;
int fd1, fd2;
FILE *f1;
std::string mtdramDriver;

View File

@@ -34,6 +34,7 @@ class CProgress_StatusViewer
virtual unsigned int getGlobalStatus(void) = 0;
virtual void showLocalStatus(const unsigned int prog) = 0;
virtual void showStatusMessageUTF(const std::string & text) = 0;
virtual void paint();
};
#endif

View File

@@ -119,6 +119,8 @@ void CProgressWindow::showLocalStatus(const unsigned int prog)
#ifdef VFD_UPDATE
CVFD::getInstance()->showProgressBar2(local_progress);
#else
CVFD::getInstance()->showPercentOver(local_progress);
#endif // VFD_UPDATE
}

View File

@@ -57,13 +57,12 @@ class CProgressWindow : public CMenuTarget, public CProgress_StatusViewer
//----------------------------
virtual void paint();
public:
CProgressWindow();
void setTitle(const neutrino_locale_t title);
virtual void hide();
virtual void paint();
virtual int exec( CMenuTarget* parent, const std::string & actionKey );

View File

@@ -148,7 +148,7 @@ extern cAudio * audioDecoder;
cPowerManager *powerManager;
cCpuFreqManager * cpuFreq;
void stop_daemons(bool stopall = true);
void stop_daemons(bool stopall = true, bool for_flash = false);
void stop_video(void);
// uncomment if you want to have a "test" menue entry (rasc)
@@ -3554,11 +3554,20 @@ bool CNeutrinoApp::changeNotify(const neutrino_locale_t OptionName, void * /*dat
return false;
}
void CNeutrinoApp::stopDaemonsForFlash()
{
stop_daemons(false, true);
}
/**************************************************************************************
* Main programm - no function here *
**************************************************************************************/
void stop_daemons(bool stopall)
void stop_daemons(bool stopall, bool for_flash)
{
CVFD::getInstance()->Clear();
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
CVFD::getInstance()->ShowText("Stop daemons...");
dvbsub_close();
tuxtxt_stop();
tuxtxt_close();
@@ -3574,7 +3583,7 @@ void stop_daemons(bool stopall)
}
printf("httpd shutdown done\n");
CStreamManager::getInstance()->Stop();
if(stopall) {
if(stopall && !for_flash) {
printf("timerd shutdown\n");
if (g_Timerd)
g_Timerd->shutdown();
@@ -3589,15 +3598,16 @@ void stop_daemons(bool stopall)
#endif
tuxtx_stop_subtitle();
printf("zapit shutdown\n");
if(!stopall && g_settings.hdmi_cec_mode && g_settings.hdmi_cec_standby){
if(!for_flash && !stopall && g_settings.hdmi_cec_mode && g_settings.hdmi_cec_standby){
videoDecoder->SetCECMode((VIDEO_HDMI_CEC_MODE)0);
}
delete &CMoviePlayerGui::getInstance();
CZapit::getInstance()->Stop();
printf("zapit shutdown done\n");
CVFD::getInstance()->Clear();
if(stopall) {
if (!for_flash)
CVFD::getInstance()->Clear();
if(stopall && !for_flash) {
if (cpuFreq) {
cpuFreq->SetCpuFreq(g_settings.cpufreq * 1000 * 1000);
delete cpuFreq;
@@ -3614,6 +3624,13 @@ void stop_daemons(bool stopall)
}
cs_deregister_messenger();
}
if (for_flash) {
delete CRecordManager::getInstance();
delete videoDemux;
my_system(NEUTRINO_ENTER_FLASH_SCRIPT);
}
CVFD::getInstance()->ShowText("Stop daemons done");
}
void stop_video()

View File

@@ -138,7 +138,6 @@ private:
void radioMode( bool rezap = true );
void scartMode( bool bOnOff );
void standbyMode( bool bOnOff, bool fromDeepStandby = false );
void saveEpg(bool cvfd_mode);
void getAnnounceEpgName(CTimerd::RecordingInfo * eventinfo, std::string &name);
void ExitRun(const bool write_si = true, int retcode = 0);
@@ -233,6 +232,9 @@ public:
void showInfo(void);
CConfigFile* getConfigFile() {return &configfile;};
bool SDTreloadChannels;
void saveEpg(bool cvfd_mode);
void stopDaemonsForFlash();
};
#endif

View File

@@ -38,7 +38,7 @@
#include <linux/version.h>
#include <global.h>
#include <neutrino.h>
CFlashTool::CFlashTool()
{
@@ -155,6 +155,8 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
ssize_t filesize;
int globalProgressBegin = 0;
CNeutrinoApp::getInstance()->saveEpg(false);
if(statusViewer)
statusViewer->showLocalStatus(0);
@@ -190,10 +192,12 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
if(statusViewer) {
if(globalProgressEndErase!=-1)
statusViewer->showGlobalStatus(globalProgressEndErase);
statusViewer->showLocalStatus(0);
statusViewer->showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_PROGRAMMINGFLASH)); // UTF-8
}
#ifndef VFD_UPDATE
CVFD::getInstance()->ShowText("Write Flash");
#endif
if( (fd = open( mtdDevice.c_str(), O_WRONLY )) < 0 ) {
ErrorMessage = g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD);
@@ -262,6 +266,7 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
// FIXME error message
if (fsize)
return false;
CVFD::getInstance()->ShowText("Flash OK.");
return true;
}
@@ -297,12 +302,18 @@ bool CFlashTool::erase(int globalProgressEnd)
return false;
}
printf("sectionsd shutdown\n");
CEitManager::getInstance()->Stop();
printf("sectionsd shutdown done\n");
CNeutrinoApp::getInstance()->stopDaemonsForFlash();
if(statusViewer)
#ifndef VFD_UPDATE
CVFD::getInstance()->ShowText("Erase Flash");
#endif
if(statusViewer) {
globalProgressBegin = statusViewer->getGlobalStatus();
statusViewer->paint();
statusViewer->showLocalStatus(0);
statusViewer->showGlobalStatus(globalProgressBegin);
}
lerase.length = meminfo.erasesize;
@@ -329,17 +340,15 @@ bool CFlashTool::erase(int globalProgressEnd)
continue;
}
}
if(ioctl( fd, MEMERASE, &lerase) != 0)
{
ErrorMessage = g_Locale->getText(LOCALE_FLASHUPDATE_ERASEFAILED);
close(fd);
return false;
}
printf( "Erasing %u Kbyte @ %x -- %2u %% complete.\n",
meminfo.erasesize/1024, lerase.start,
prog /* lerase.start*100/meminfo.size */);
printf( "Erasing %u Kbyte @ 0x%08X -- %2u %% complete.\n", meminfo.erasesize/1024, lerase.start, prog);
}
printf("\n");
close(fd);
return true;
@@ -376,7 +385,6 @@ bool CFlashTool::check_md5( const std::string & filename, const std::string & sm
void CFlashTool::reboot()
{
::sync();
::reboot(RB_AUTOBOOT);
::exit(0);
}