📄 form_multiload.cpp
字号:
// {
// p_dl_handle = MainForm->Get_DlHandle(i);
// if( MainForm->Get_NFBSelected() )
// {
// LoadBootLoader( i );
// }
//
// m_asROMFileName[i] = m_INIFileH.read_ROM( "MultiPortFlashDownloadProject.ini", Application->ExeName, i+1 );
//
// if( m_asROMFileName[i].AnsiCompareIC("") != 0 )
// {
// if(ret=DL_Rom_LoadByFilepath(*p_dl_handle, 0, m_asROMFileName[i].c_str()))
// {
// if( FTHND_HANDLE_BUSY_NOW == ret )
// {
// Application->MessageBox( "Program is busy! Can not update setting right now.", "Fail", MB_OK );
// return;
// }
// else if( FTHND_SCAT_REGION_IS_OVERLAP == ret )
// {
// AnsiString as_msg = "\"" + m_asROMFileName[i] + "\" is too large and causes region overlap!";
// Application->MessageBox( as_msg.c_str(), "Fail", MB_OK );
// return;
// }
// else
// {
// AnsiString as_msg = " Load file \"" + m_asROMFileName[i] + "\" fail!";
// Application->MessageBox( as_msg.c_str(), "Fail", MB_OK );
// return;
// }
// }
//
// iLD = m_asROMFileName[i].LastDelimiter("\\:");
// if ( iLD > 0)
// {
// m_asROMPath[i] = m_asROMFileName[i].SubString(1, iLD-1 );
// }
//
// // auto load boot loader
// // if( MainForm->Get_NFBSelected() )
// // {
// // BL_AutoLoad(*p_bl_handle, m_asROMFileName[i].c_str(), "*_BOOTLOADER_*.bin");
// // }
//
// // auto load download bin files
// if( MainForm->Get_AutoLoadResByScatFlag() )
// {
// if( MainForm->Get_NFBSelected() )
// {
// DL_AutoLoadByScatRegionName(*p_dl_handle, m_asROMFileName[i].c_str(), NORMAL_ROM|RESOURCE_BIN|JUMPTABLE_BIN);
// }
// else
// {
// DL_AutoLoadByScatRegionName(*p_dl_handle, m_asROMFileName[i].c_str(), RESOURCE_BIN|JUMPTABLE_BIN);
// }
// }
// }
//
// #ifndef SERVICE_CENTER
// AnsiString as_LV_FAT_index;
// m_asFATFileName[i] = m_INIFileH.read_FAT( "MultiPortFlashDownloadProject.ini", Application->ExeName, i+1 );
// as_LV_FAT_index = m_INIFileH.read_LV_FAT_index( "MultiPortFlashDownloadProject.ini", Application->ExeName, i+1 );
// m_iLV_FAT_index[i] = as_LV_FAT_index.ToInt();
// if( m_iLV_FAT_index[i]>=1 && MainForm->Get_Type() == DOWNLOAD_ROM_AND_FAT_INDEX )
// {
// if( m_asFATFileName[i].AnsiCompareIC("") != 0 )
// {
// if(ret=DL_Rom_LoadByFilepath( *p_dl_handle, m_iLV_FAT_index[i], m_asFATFileName[i].c_str()))
// {
// if( FTHND_HANDLE_BUSY_NOW == ret )
// {
// Application->MessageBox( "Program is busy! Can not update setting right now.", "Fail", MB_OK );
// return;
// }
// else if( FTHND_SCAT_REGION_IS_OVERLAP == ret )
// {
// AnsiString as_msg = "\"" + m_asFATFileName[i] + "\" is too large and causes region overlap!";
// Application->MessageBox( as_msg.c_str(), "Fail", MB_OK );
// return;
// }
// else
// {
// AnsiString as_msg = " Load file \"" + m_asFATFileName[i] + "\" fail!";
// Application->MessageBox( as_msg.c_str(), "Fail", MB_OK );
// return;
// }
// }
//
// iLD = m_asFATFileName[i].LastDelimiter("\\:");
// if ( iLD > 0)
// {
// m_asFATPath[i] = m_asFATFileName[i].SubString(1, iLD-1 );
// }
// }
// }
// #endif
//
// RedrawLVList( i, p_dl_handle );
// }
//
//}
//------------------------------------------------------------------------------
//void TfrmMultiLoad::Save_LVSetting( void )
//{
// DL_HANDLE_T* p_dl_handle;
// for( int i=0; i<MAX_SUPPORT_LOAD_NUM; i++ )
// {
// if( MainForm->Get_NFBSelected() )
// {
// BL_INFO bl_info;
// p_dl_handle = MainForm->Get_DlHandle(i);
// // BL_GetInfo( *p_bl_handle, &bl_info );
// DL_BL_GetInfo( *p_dl_handle, &bl_info );
// m_INIFileH.write_BootLoader( "MultiPortFlashDownloadProject.ini", Application->ExeName, i+1, bl_info.m_filepath);
// if( _TRUE == bl_info.m_enable )
// {
// m_INIFileH.write_BootLoaderEnable( "MultiPortFlashDownloadProject.ini", Application->ExeName, i+1, "yes");
// }
// else
// {
// m_INIFileH.write_BootLoaderEnable( "MultiPortFlashDownloadProject.ini", Application->ExeName, i+1, "no");
// }
// }
//
// m_INIFileH.write_ROM( "MultiPortFlashDownloadProject.ini", Application->ExeName, i+1, m_asROMFileName[i]);
// #ifndef SERVICE_CENTER
// m_INIFileH.write_FAT( "MultiPortFlashDownloadProject.ini", Application->ExeName, i+1, m_asFATFileName[i]);
// m_INIFileH.write_LV_FAT_index( "MultiPortFlashDownloadProject.ini", Application->ExeName, i+1, IntToStr(m_iLV_FAT_index));
// #endif
// }
//
//
// #if 0
// AnsiString as_reg_prefix;
//
// m_INIFileH.write_LV_count( "MultiPortFlashDownloadProject.ini", Application->ExeName, "rom_info_count", lv->Items->Count );
//
// for(int i=0; i<lv->Items->Count; i++)
// {
// write_LV_name( "MultiPortFlashDownloadProject.ini", Application->ExeName, "rom_info_name" + IntToStr(i), rom_info[i].name);
// }
//
// for(int i=0; i<lv->Items->Count; i++)
// {
// if( ABSOLUTE_ADDR == rom_info[i].addr_type )
// {
// as_reg_prefix = "";
// }
// else
// {
// as_reg_prefix = "+";
// }
// write_LV_region_addr( "MultiPortFlashDownloadProject.ini", Application->ExeName, "rom_info_region_addr" + IntToStr(i), as_reg_prefix + "0x" + IntToHex((int)rom_info[i].region_addr, 8));
// }
//
// for(int i=0; i<lv->Items->Count; i++)
// {
// write_LV_begin_addr( "MultiPortFlashDownloadProject.ini", Application->ExeName, "rom_info_begin_addr" + IntToStr(i), "0x" + IntToHex((int)rom_info[i].begin_addr, 8) );
// }
//
// for(int i=0; i<lv->Items->Count; i++)
// {
// write_LV_end_addr( "MultiPortFlashDownloadProject.ini", Application->ExeName, "rom_info_end_addr" + IntToStr(i), "0x" + IntToHex((int)rom_info[i].end_addr, 8) );
// }
//
// for(int i=0; i<lv->Items->Count; i++)
// {
// write_LV_location( "MultiPortFlashDownloadProject.ini", Application->ExeName, "rom_info_end_addr" + IntToStr(i), rom_info[i].filepath );
// }
// #endif
//}
//------------------------------------------------------------------------------
void TfrmMultiLoad::LoadBootLoader( int idx, DL_HANDLE_T* p_dl_handle )
{
int ret;
AnsiString as_bloader_file;
// DL_HANDLE_T* p_dl_handle = MainForm->Get_DlHandle( idx );
as_bloader_file = m_INIFileH.read_BootLoader( "MultiPortFlashDownloadProject.ini", Application->ExeName, idx+1 );
if( 0 < as_bloader_file.Length() )
{
// if( FTHND_OK != (ret=BL_LoadByFilepath(m_DnParam.bl_handle, as_bloader_file.c_str())) )
if( FTHND_OK != (ret=DL_BL_LoadByFilepath(*p_dl_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 = m_INIFileH.read_BootLoaderEnable( "MultiPortFlashDownloadProject.ini", Application->ExeName, idx+1 );
if( as_BootLoaderEnable.AnsiCompareIC("no") == 0 )
{
// BL_SetEnableAttr(m_DnParam.bl_handle, _FALSE);
DL_BL_SetEnableAttr( *p_dl_handle, _FALSE );
// m_lv[idx]->Items->Item[0]->Checked = false;
}
else
{
//BL_SetEnableAttr(m_DnParam.bl_handle, _TRUE);
DL_BL_SetEnableAttr( *p_dl_handle, _TRUE );
//m_lv[idx]->Items->Item[0]->Checked = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmMultiLoad::btnScatFileClick(TObject *Sender)
{
TButton *btn = (TButton*)Sender;
FileOpenScatExecute( (int) btn->Tag );
}
//--------------------------------------------------------------------------
bool TfrmMultiLoad::FileOpenScatExecute( int idx )
{
int iLD=0;
int ret;
DL_HANDLE_T *p_temp_dl_handle = new DL_HANDLE_T;
DL_Create(p_temp_dl_handle);
DL_HANDLE_T *p_dl_handle = MainForm->Get_DlHandle(idx);
DL_HANDLE_LIST_T *p_dl_handle_list = MainForm->Get_DlHandleList();
if( m_asScatPath[idx].Length()>0 )
{
m_dlgOpenScatter[idx]->InitialDir = m_asScatPath[idx];
}
if ( m_dlgOpenScatter[idx]->Execute() ) // *.bin file
{
if ( OpenReadScatFile( m_dlgOpenScatter[idx]->FileName, idx, p_temp_dl_handle ) )
{
m_asScatFileName[idx] = m_dlgOpenScatter[idx]->FileName;
iLD = m_asScatFileName[idx].LastDelimiter("\\:");
if ( iLD > 0)
{
m_asScatPath[idx] = m_asScatFileName[idx].SubString(1, iLD-1 );
}
if( MainForm->Get_AutoLoadResByScatFlag() )
{
ret = DL_AutoLoadByScatRegionName(*p_temp_dl_handle, m_dlgOpenScatter[idx]->FileName.c_str(), NORMAL_ROM|RESOURCE_BIN|JUMPTABLE_BIN);
if( ret != 0 )
{
Application->MessageBox( "Automatic load by scatter region name fail", "FAIL", MB_OK );
Destroy_DLHandle( p_temp_dl_handle );
return false;
}
}
// update handle list
if( NULL != p_dl_handle ) // not new handle
{
ret = DL_CheckHandleSameSWVersionInList( *p_dl_handle_list, *p_temp_dl_handle );
if( 0 == ret ) // no same S/W version in list
{
if( 0 != DL_CheckHandleInList( *p_dl_handle_list, *p_dl_handle ) ) // handle in list
{
ret = DL_DeleteHandleFromList( *p_dl_handle_list, *p_dl_handle );
if( ret != 0 )
{
Application->MessageBox( "Delete handle from list fail", "FAIL", MB_OK );
return false;
}
}
Destroy_DLHandle( p_dl_handle );
p_dl_handle = p_temp_dl_handle;
MainForm->Set_DlHandle( idx, p_dl_handle );
ret = DL_AddHandleToList( *p_dl_handle_list, *p_dl_handle );
{
if( ret != 0 )
{
Application->MessageBox( "Add handle to list fail", "FAIL", MB_OK );
return false;
}
}
m_lblScatFileName[idx]->Caption = m_dlgOpenScatter[idx]->FileName;
}
else // same S/W in handle list
{
Destroy_DLHandle( p_temp_dl_handle );
Application->MessageBox( "Has same S/W in handle list", "NOTICE", MB_OK );
return false;
}
}
else // new handle
{
p_dl_handle = p_temp_dl_handle;
ret = DL_AddHandleToList( *p_dl_handle_list, *p_dl_handle );
{
if( ret != 0 )
{
Application->MessageBox( "Add handle to list fail", "FAIL", MB_OK );
return false;
}
}
m_lblScatFileName[idx]->Caption = m_dlgOpenScatter[idx]->FileName;
Destroy_DLHandle( p_temp_dl_handle );
}
RedrawLVList( idx, p_dl_handle );
return true;
}
else
return false;
}
else
return false;
}
//--------------------------------------------------------------------------
bool TfrmMultiLoad::OpenReadScatFile(AnsiString asMapFileName, int idx, DL_HANDLE_T *p_dl_handle )
{
int ret;
unsigned short rom_count;
if(ret=DL_LoadScatter(*p_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;
}
#if 0
m_lblScatFileName[idx]->Caption = asMapFileName;
if(!DL_GetCount(*p_dl_handle, &rom_count))
{
ROM_INFO rom_info[MAX_LOAD_SECTIONS];
if( !DL_Rom_GetInfoAll(*p_dl_handle, rom_info, MAX_LOAD_SECTIONS) )
{
TListItem *p_list_item;
AnsiString as_reg_prefix;
m_lv[idx]->Items->Clear();
for( int i=0; i<rom_count; i++ )
{
p_list_item = m_lv[idx]->Items->Add();
p_list_item->Caption = rom_info[i].name;
p_list_item->Checked = true;
DL_Rom_SetEnableAttr(*p_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) );
}
}
}
#endif
return true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -