📄 multiportflashdownloadtool.cpp
字号:
if( FTHND_HANDLE_BUSY_NOW == ret )
{
Application->MessageBox( "Program is busy! Can not reload DA right now.", "Fail", MB_OK );
}
else
{
AnsiString as_msg = " Load DA file " + asFileName + " error ";
Application->MessageBox( as_msg.c_str(), "Fail", MB_OK );
}
return false;
}
lblDAFileName->Caption = asFileName;
return true;
}
#if 0
//--------------------------------------------------------------------------
bool TMainForm::OpenReadScatFile(AnsiString asMapFileName)
{
int ret;
unsigned short rom_count;
//ROM_INFO rom_info[MAX_LOAD_SECTIONS];
// load scatter
if(ret=DL_LoadScatter(g_DL_HANDLE, asMapFileName.c_str()))
{
if( FTHND_HANDLE_BUSY_NOW == ret )
{
Application->MessageBox( "Program is busy! Can not reload scat file right now.", "Fail", MB_OK );
}
else
{
Application->MessageBox( "Incorrect scatter file format!", "Fail", MB_OK );
}
return false;
}
lblScatFileName->Caption = asMapFileName;
if(!DL_GetCount(g_DL_HANDLE, &rom_count))
{
if( !DL_Rom_GetInfoAll(g_DL_HANDLE, rom_info, MAX_LOAD_SECTIONS) )
{
TListItem *p_list_item;
AnsiString as_reg_prefix;
lv->Items->Clear();
for( int i=0; i<rom_count; i++ )
{
p_list_item = lv->Items->Add();
p_list_item->Caption = rom_info[i].name;
p_list_item->Checked = true;
DL_Rom_SetEnableAttr(g_DL_HANDLE, i, p_list_item->Checked);
if( rom_info[i].addr_type == ABSOLUTE_ADDR )
{
as_reg_prefix = "";
}
else
{
as_reg_prefix = "+";
}
p_list_item->SubItems->Add( as_reg_prefix + "0x" + IntToHex((int)rom_info[i].region_addr, 8) );
p_list_item->SubItems->Add( "0x" + IntToHex((int)rom_info[i].begin_addr, 8) );
p_list_item->SubItems->Add( "0x" + IntToHex((int)rom_info[i].end_addr, 8) );
}
}
}
return true;
}
#endif
//---------------------------------------------------------------------------
bool TMainForm::OpenReadROMFile(AnsiString asLoadFileName)
{
#if 0
int ret;
// loading ROM Load
if(ret=DL_Rom_LoadByFilepath(g_DL_HANDLE, ROM_LOAD_INDEX, asLoadFileName.c_str()))
{
if( FTHND_HANDLE_BUSY_NOW == ret )
{
ShowMessage("Program is busy! Can not reload scat file right now.");
}
else
{
ShowMessage("Incorrect ROM LOAD");
}
return false;
}
lblROMFileName->Caption = asLoadFileName;
return true;
#endif
}
//---------------------------------------------------------------------------
bool TMainForm::OpenReadFATFile(AnsiString asFATFileName)
{
#if 0
int ret;
// if( cbType->ItemIndex == DOWNLOAD_ROM_AND_FAT_INDEX )
// {
// loading FAT file
// if(ret=DL_Rom_LoadByFilepath(g_DL_HANDLE, FAT_LOAD_INDEX, asFATFileName.c_str()))
// {
// if( FTHND_HANDLE_BUSY_NOW == ret )
// {
// ShowMessage("Program is busy! Can not reload scat file right now.");
// }
// else
// {
// ShowMessage("Incorrect FAT file");
// }
// return false;
// }
// }
lblFATFileName->Caption = asFATFileName;
return true;
#endif
}
#if 0
//---------------------------------------------------------------------------
bool TMainForm::LoadFATFile( void )
{
if( isFATFileLoaded == false )
{
int ret;
if(ret=DL_Rom_LoadByFilepath(g_DL_HANDLE, FAT_LOAD_INDEX, asFATFileName.c_str()))
{
if( FTHND_HANDLE_BUSY_NOW == ret )
{
Application->MessageBox( "Program is busy! Can not reload FAT file right now.", "Fail", MB_OK );
}
else
{
Application->MessageBox( "Incorrect FAT file, please check if scatter and FAT file are correct", "Fail", MB_OK );
}
return false;
}
isFATFileLoaded = true;
}
}
//---------------------------------------------------------------------------
bool TMainForm::OpenFATFile( void )
{
int iLastDel=0;
if (asFAT_Path.Length()>0)
{
OpenFATDialog->InitialDir = asFAT_Path;
}
if ( OpenFATDialog->Execute() ) // FAT file
{
if ( OpenReadFATFile( OpenFATDialog->FileName ))
{
asFATFileName = OpenFATDialog->FileName;
iLastDel = asFATFileName.LastDelimiter("\\:");
if ( iLastDel > 0)
{
asFAT_Path = asFATFileName.SubString(1, iLastDel-1 );
}
return true;
}
else
return false;
}
else
return false;
}
#endif
#if 0
//------------------------------------------------------------------------------
void TMainForm::LoadBootLoader( void )
{
int ret;
AnsiString as_bloader_file;
as_bloader_file = INIFileH.read_BootLoader( "MultiPortFlashDownloadProject.ini", Application->ExeName );
if( 0 < as_bloader_file.Length() )
{
if( FTHND_OK != (ret=BL_LoadByFilepath(m_DnParam.bl_handle, as_bloader_file.c_str())) )
{
if( FTHND_HANDLE_BUSY_NOW == ret )
{
Application->MessageBox( "Program is busy! Can not update setting right now.", "Fail", MB_OK );
}
else
{
AnsiString as_msg = " Load boot-loader \"" + as_bloader_file + "\" fail!";
Application->MessageBox( as_msg.c_str(), "Fail", MB_OK );
}
}
}
AnsiString as_BootLoaderEnable = INIFileH.read_BootLoaderEnable( "MultiPortFlashDownloadProject.ini", Application->ExeName );
if( as_BootLoaderEnable.AnsiCompareIC("no") == 0 )
{
BL_SetEnableAttr(m_DnParam.bl_handle, _FALSE);
lv->Items->Item[0]->Checked = false;
}
else
{
BL_SetEnableAttr(m_DnParam.bl_handle, _TRUE);
lv->Items->Item[0]->Checked = true;
}
}
//------------------------------------------------------------------------------
void TMainForm::Save_BootLoader( void )
{
BL_INFO bl_info;
if( FTHND_OK == BL_GetInfo(m_DnParam.bl_handle, &bl_info) )
{
INIFileH.write_BootLoader("MultiPortFlashDownloadProject.ini", Application->ExeName, bl_info.m_filepath);
if( bl_info.m_enable )
{
INIFileH.write_BootLoaderEnable("MultiPortFlashDownloadProject.ini", Application->ExeName, "yes");
}
else
{
INIFileH.write_BootLoaderEnable("MultiPortFlashDownloadProject.ini", Application->ExeName, "no");
}
}
}
#endif
//------------------------------------------------------------------------------
void __fastcall TMainForm::btnCOMDownloadClick( int index )
{
COM_PORT_HANDLE ComPortNo;
bool result;
if( (result=DownloadCommonFunction()) == false )
{
return;
}
// Get_Baudrate();
if( cbCOMArray[index]->Checked )
{
if( miEnableFDLog->Checked )
{
// access
TDateTime datetime;
TDateTime date = datetime.CurrentDate();
TDateTime time = datetime.CurrentTime();
sTime stime;
time.DecodeTime( &stime.hour, &stime.min, &stime.sec, &stime.msec);
MainForm->SetDnDate( index, date );
MainForm->SetDnStartTime( index, time );
MainForm->SetDnStartsTime( index, stime );
}
stopflag[index] = 0;
Disable_UIComponent();
// cbCOMArray[index]->Enabled = false;
// cbAutoPollingArray[index]->Enabled = false;
// btnCOMDownloadArray[index]->Enabled = false;
Disable_SpecificMsUI(index);
isStopTrigger[index] = false;
// status and timer handling
DownloadStatus[index] = DOWNLOAD_STATUS_RUNNING;
pbCOMArray[index]->Progress = 0;
DownLoadTimeSec[index] = 0;
TimerCOMArray[index]->Enabled = true;
m_DnParam.i_meta_handle = m_iMETA_handle_array[index];
ComPortNo.number = (index + m_TheFirstComNo);
A_Thread[index] = new TBOOT1(FALSE, hPostMsgDestHandle, ComPortNo, m_Baseband_chip_type,
External_clock_type, bCheckECOVersion, UART_baud_rate, bFormatNeeded, m_DnParam);
A_Thread[index]->FreeOnTerminate = true;
}
// new WaitForFinish(FALSE);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::btnSeperateDownloadClick(TObject *Sender)
{
TButton *bt = (TButton*)Sender;
m_bStartFactoryDefault[bt->Tag] = false;
btnCOMDownloadClick( bt->Tag );
}
//==============================================================================
bool TMainForm::DownloadCommonFunction( void )
{
int ret;
// flag
isShowNoFormatInfo = false;
isShowFileNotLoaded = false;
#ifndef SERVICE_CENTER
if( cbType->ItemIndex == FORMAT_INDEX )
{
i_FlashToolFunction = FLASHTOOL_FORMAT;
}
else
#endif
{
i_FlashToolFunction = FLASHTOOL_DOWNLOAD;
}
#ifndef SERVICE_CENTER
if( m_asType.AnsiCompareIC("Download ROM and Format") == 0 )
{
bFormatNeeded = true;
}
else
#endif
{
bFormatNeeded = false;
}
if( UpdateDAInfo() )
{
return false;
}
// check BootLoader
// if( OPERATION_NFB == m_DnParam.eOperation )
// {
// BL_INFO bl_info;
// if( FTHND_FILE_IS_UPDATED == BL_IsReady(m_DnParam.bl_handle, &bl_info, _TRUE) )
// {
// BL_LoadByFilepath(m_DnParam.bl_handle, bl_info.m_filepath);
// }
// }
// check multi load and ECO consistency
int HandleNumber;
if( 0 != DL_GetHandleNumber(m_DnParam.dl_handle_list, &HandleNumber) )
{
MainForm->sbMPDT->Panels->Items[0]->Text = " [DL_HANDLE] Get handle number fail";
Application->MessageBox( "[DL_HANDLE] Get handle number fail", "FAIL", MB_OK );
return false;
}
if( (HandleNumber >= 2) && (! miCheckECOversion->Checked) )
{
MainForm->sbMPDT->Panels->Items[0]->Text = " Please enable ECO version check for multiload download";
Application->MessageBox( "Please enable ECO version check for multiload download", "FAIL", MB_OK );
return false;
}
return true;
}
//---------------------------------------------------------------------------
UART_BAUDRATE TMainForm::Get_Baudrate( AnsiString as_baudrate )
{
UART_BAUDRATE baud_rate;
if ( m_asBaudrate.AnsiCompareIC("115200") == 0 )
{
baud_rate = UART_BAUD_115200;
}
else if ( m_asBaudrate.AnsiCompareIC("230400") == 0 )
{
baud_rate = UART_BAUD_230400;
}
else if( m_asBaudrate.AnsiCompareIC("460800") == 0 )
{
baud_rate = UART_BAUD_460800;
}
else if( m_asBaudrate.AnsiCompareIC("921600") == 0 )
{
baud_rate = UART_BAUD_921600;
}
else // default set to 460800
{
Application->MessageBox( "Baud Rate setting is wrong. Set Default 460800", "Notice", MB_OK );
baud_rate = UART_BAUD_460800;
}
return baud_rate;
}
//============================================================================
void TMainForm::Disable_UIComponent( void )
{
Disable_FileMenu();
Disable_FactoryDatabaseMenu();
Disable_OptionMenu();
Disable_DebugLoggingMenu();
Disable_OperationRadioButton();
Disable_FormatFatRangeRadioButton();
Disable_BaudrateComboBox();
Disable_TypeComboBox();
}
//----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -