📄 multiportflashdownloadtool.cpp
字号:
//if(asROMFileName.AnsiCompareIC("") != 0)
// {
// OpenReadROM_File(asROMFileName);
// iLastDel = asROMFileName.LastDelimiter("\\:");
// if ( asROMFileName.LastDelimiter("\\:") > 0)
// {
// asROM_Path = asROMFileName.SubString(1, iLastDel-1 );
// }
// }
//Load xxx.Bin(FAT)
//if(asFATFileName.AnsiCompareIC("") != 0)
// {
// OpenReadFAT_File(asFATFileName);
// iLastDel = asFATFileName.LastDelimiter("\\:");
// if ( asFATFileName.LastDelimiter("\\:") > 0)
// {
// asFAT_Path = asFATFileName.SubString(1, iLastDel-1 );
// }
//}
for(i=0; i<MAX_SUPPORT_PORT_NUM; i++)
{
DownloadStatus[i] = DOWNLOAD_STATUS_NOTRUNNING;
}
for(i=0; i<MAX_SUPPORT_PORT_NUM; i++)
{
isStopTrigger[i] = false;
}
for(i=0; i<MAX_SUPPORT_PORT_NUM; i++)
{
m_bStartFactoryDefault[i] = false;
}
// initalization
isFATFileLoaded = false;
i_FlashToolFunction = FLASHTOOL_DOWNLOAD;
// multibin
lvChanged.iChangedIndex = NO_CHANGE;
m_bCheckTgtResLayout = true;
m_bAutoLoadResByScat = true;
m_bCompareResProjectId = true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void __fastcall TMainForm::FormDestroy(TObject *Sender)
{
DeInitMETADll();
// DESTROY HANDLE
// BL_Unload( m_DnParam.bl_handle );
// BL_Destroy( &m_DnParam.bl_handle );
DA_Unload( g_DA_HANDLE );
DA_Destroy( &g_DA_HANDLE );
// DL_Rom_UnloadAll( g_DL_HANDLE );
// DL_Destroy( &g_DL_HANDLE );
for(int i=0; i<MAX_SUPPORT_LOAD_NUM+1; i++)
{
if( NULL != m_DnParam.p_dl_handle[i] )
{
DL_Rom_UnloadAll( *m_DnParam.p_dl_handle[i] );
DL_Destroy(m_DnParam.p_dl_handle[i]);
delete m_DnParam.p_dl_handle[i];
}
}
DL_DestroyList(&m_DnParam.dl_handle_list);
// Disable Debug
Brom_DebugOff();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormShow(TObject *Sender)
{
AnsiString as_AutoLoadResByScat;
MainForm->Left = 13;
MainForm->Top = 9;
// mutlibin
// as_AutoLoadResByScat = INIFileH.read_AutoLoadResByScat( "MultiPortFlashDownloadProject.ini", Application->ExeName );
// if( as_AutoLoadResByScat.AnsiCompareIC("false") == 0 )
//// {
// m_bAutoLoadResByScat = false;
// }
// else
// {
// m_bAutoLoadResByScat = true;
// }
Display_BROMDllLog();
Display_METADllLog();
Display_Operation();
Display_BasebandChip();
Display_ExternalClock();
Display_CheckECOVersion();
Display_CheckTargetResourceLayout();
Display_AutoLoadResByScat();
Display_CompareResProjectId();
Display_Baudrate();
Display_Type();
Display_DAFile();
Display_ComEnabled();
Display_AutoPollingEnabled();
Display_FormatFatRange();
//frmMultiLoad->Display_Scatter();
//frmMultiLoad->Display_LVSetting();
//Display_LVSetting();
// access
Display_DataSource();
Display_DBLogOption();
//as_Format_FAT_begin_address = INIFileH.read_Format_FAT_Begin_Address( "MultiPortFlashDownloadProject.ini", Application->ExeName );
// as_Format_FAT_length = INIFileH.read_Format_FAT_length( "MultiPortFlashDownloadProject.ini", Application->ExeName );
Read_FormatFATBeginAddress();
Read_FormatFATLength();
Read_NANDFormatFATBeginAddress();
Read_NANDFormatFATLength();
Read_EraseValidation();
Read_NandAcccon();
get_PullDownGPIO17();
InitMETADll();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
{
int i;
for(i=0; i<MAX_SUPPORT_PORT_NUM; i++)
{
ResetEvent( Flash_Download_Event[i] );
}
btnStopAllClick( this );
for(i=0; i<MAX_SUPPORT_PORT_NUM; i++)
{
if( DownloadStatus[i] == DOWNLOAD_STATUS_RUNNING )
{
WaitForSingleObject( Flash_Download_Event[i], 10000 );
}
}
// Save setting to .INI
//TIniFile *ini;
//ini = new TIniFile(
// ChangeFileExt( Application->ExeName, ".INI" ) );
// WriteFileSetting();
// INIFileH.write_Baudrate( "MultiPortFlashDownloadProject.ini", Application->ExeName, m_asBaudrate);
// stop all timer
for(i=0; i<MAX_SUPPORT_PORT_NUM; i++)
{
TimerCOMArray[i]->Enabled = false;
}
// save menu setting
Save_Operation();
Save_BasebandChip();
Save_ExternalClock();
Save_CheckECOVersion();
Save_BROMDllLog();
Save_METADllLog();
Save_Baudrate();
Save_ComEnabled();
Save_AutoPollingEnabled();
Save_Type();
Save_DAFile();
Save_FormatFatRange();
// Save_LVSetting();
// access
Save_DataSource();
Save_DBLogOption();
}
//---------------------------------------------------------------------------
void TMainForm::InitMETADll( void )
{
// initialize META
META_RESULT meta_ret;
for(int i=0; i<MAX_SUPPORT_PORT_NUM; i++ )
{
if( (meta_ret = META_GetAvailableHandle( &m_iMETA_handle_array[i] )) != META_SUCCESS )
{
AnsiString asMsg = "META_GetAvailableHandle(): ERROR: " + AnsiString(META_GetErrorString(meta_ret));
Application->MessageBox( asMsg.c_str(), "Fail", MB_OK );
return;
}
if( (meta_ret = META_Init_r( m_iMETA_handle_array[i], ErrorHandler )) != META_SUCCESS )
{
AnsiString asMsg = "META_Init_r(): ERROR: " + AnsiString(META_GetErrorString(meta_ret));
Application->MessageBox( asMsg.c_str(), "Fail", MB_OK );
return;
}
}
}
//---------------------------------------------------------------------------
void TMainForm::DeInitMETADll( void )
{
META_RESULT meta_ret;
for(int i=0; i<MAX_SUPPORT_PORT_NUM; i++ )
{
META_Deinit_r( &m_iMETA_handle_array[i] );
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::OpenDownloadAgentClick(TObject *Sender)
{
// FileOpenDownloadAgentExecute();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::OpenScatterClick(TObject *Sender)
{
// FileOpenScatExecute();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::OpenLoadClick(TObject *Sender)
{
//FileOpenROMExecute();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::tbOpenFATFileClick(TObject *Sender)
{
//OpenFATFile();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
bool TMainForm::FileOpenDownloadAgentExecute()
{
int iLD=0;
if(m_asDAPath.Length()>0)
{
dlgOpenDA->InitialDir = m_asDAPath;
}
if( dlgOpenDA->Execute() ) // *.bin file
{
if ( OpenReadDAFile( dlgOpenDA->FileName ))
{
m_asDAFileName = dlgOpenDA->FileName;
iLD = m_asDAFileName.LastDelimiter("\\:");
if ( iLD > 0)
{
m_asDAPath = m_asDAFileName.SubString(1, iLD-1 );
}
return true;
}
else
return false;
}
else
return false;
}
//--------------------------------------------------------------------------
int TMainForm::UpdateDAInfo( void )
{
int ret;
AnsiString as_msg;
AnsiString as_dapath;
DA_INFO da_info;
if( MT6208!=m_Baseband_chip_type && FTHND_OK!=(ret=DA_IsReady(g_DA_HANDLE, &da_info, _TRUE)) )
{
if( FTHND_FILE_IS_NOT_LOADED == ret || FTHND_FILE_IS_UPDATED == ret )
{
if( FTHND_OK != (ret=DA_LoadByFilepath(g_DA_HANDLE, da_info.filepath)) )
{
if( FTHND_DA_INVALID == ret )
{
as_dapath = da_info.filepath;
as_msg = " \"" + as_dapath + "\" is not a valid DA format!";
Application->MessageBox( as_msg.c_str(), "Fail", MB_OK );
return 1;
}
else
{
as_dapath = da_info.filepath;
as_msg = " Load DA \"" + as_dapath + "\" fail!";
Application->MessageBox( as_msg.c_str(), "Fail", MB_OK );
return 2;
}
}
}
else
{
as_dapath = da_info.filepath;
as_msg = " Check DA \"" + as_dapath + "\" fail!";
Application->MessageBox( as_msg.c_str(), "Fail", MB_OK );
return 3;
}
}
return 0;
}
#if 0
//--------------------------------------------------------------------------
bool TMainForm::FileOpenScatExecute()
{
int iLastDel=0;
if (asScat_Path.Length()>0)
{
OpenScatterDialog->InitialDir = asScat_Path;
}
if ( OpenScatterDialog->Execute() ) // *.bin file
{
if ( OpenReadScatFile( OpenScatterDialog->FileName ) )
{
asScatFileName = OpenScatterDialog->FileName;
iLastDel = asScatFileName.LastDelimiter("\\:");
if ( iLastDel > 0)
{
asScat_Path = asScatFileName.SubString(1, iLastDel-1 );
}
RedrawLVList();
// reopen bin
// if(asROMFileName.AnsiCompareIC("") != 0)
// {
// OpenReadROM_File(asROMFileName);
// }
// // reopen FAT
// #ifndef SERVICE_CENTER
// if( cbType->ItemIndex == DOWNLOAD_ROM_AND_FAT_INDEX )
// {
// isFATFileLoaded == false;
// LoadFATFile();
// }
// #endif
return true;
}
else
return false;
}
else
return false;
}
//-------------------------------------------------------------------------
bool TMainForm::FileOpenROMExecute()
{
int iLastDel=0;
if (asROM_Path.Length()>0)
{
OpenROMDialog->InitialDir = asROM_Path;
}
if ( OpenROMDialog->Execute() ) // *.bin file
{
if ( OpenReadROMFile( OpenROMDialog->FileName ))
{
asROMFileName = OpenROMDialog->FileName;
iLastDel = asROMFileName.LastDelimiter("\\:");
if ( iLastDel > 0)
{
asROM_Path = asROMFileName.SubString(1, iLastDel-1 );
}
return true;
}
else
return false;
}
else
return false;
}
#endif
//---------------------------------------------------------------------------
bool TMainForm::OpenReadDAFile( AnsiString asFileName)
{
int ret;
if(ret=DA_LoadByFilepath(g_DA_HANDLE, asFileName.c_str()))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -