📄 tboot_1.cpp
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2002
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* tboot_1.cpp
*
* Project:
* --------
* Flash tool set
*
* Description:
* ------------
* a thread
* 1.write command to Boot ROM
* 2.then jump to execute download agent
*
* Author:
* -------
* FZ Hsu (mtk00303)
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Revision: 1.37 $
* $Modtime: Jan 13 2006 21:45:40 $
* $Log: //mtkvs01/vmdata/flash_tool/archives/tboot_1.cpp-arc $
*
* Aug 11 2006 mtk01413
* [STP100001053] FlashTool v2.9.1004 release
* Bug fixes:
* 1. [BROM_DLL] Fix Test DA download fail on MT6205/MT6205B.
*
* Jul 21 2006 mtk01413
* [STP100001021] FlashTool v2.9.1002 release
*
*
* Jun 12 2006 mtk01413
* [STP100000922] FlashTool v2.9.1001 release
* New features:
* 1. [FlashTool/BROM_DLL] Support Multi-Load Autodetection Download.
*
*
* May 24 2006 mtk01413
* [STP100000879] FlashTool v2.8.1001 release
* 1. [FlashTool][NEW] Support 6229 Download, add m_emi_gen_c in DRAM setting
* 2. [FlashTool][BUG_FIX] Fix a bug to prevent Scroll back to Page1 when redrawing Test DA message.
*
*
* Mar 22 2006 mtk00539
* [STP100000703] FlashTool v2.7.1017
* [FlashTool] Use known BBCHIP_TYPE and EXT_CLOCK to increase start command hit rate in "Reset to Factory Default" procedure.
*
* Rev 1.37 Jan 14 2006 00:49:58 mtk00539
* Bug fixes:
* 1. [FlashTool] Fix scatter file path doesn't update on UI.
*
* Enhancements:
* 1. [FlashTool] Record normal mode and test mode DA path separatedly.
* Resolution for 159: [FlashTool v2.7.1015]
*
* Rev 1.36 Jan 04 2006 14:23:30 mtk00539
* 1. [FlashTool] Fix NFI CS1 device takes no effect problem while selecting "enable NFI-CS1" flag.
* Resolution for 158: [FlashTool v2.7.1014][New] Support Spansion MirrorBit Buffer-Program method.
*
* Rev 1.35 Dec 29 2005 10:57:26 mtk00539
* 1. [FlashTool] Add download history feature.
* Resolution for 156: [FlashTool v2.7.1013][BUG FIX] Fix BootROM start command failure while manually selecting NMT6226 or MT6227 baseband chip.
*
* Rev 1.34 Oct 19 2005 14:47:26 mtk00539
* 1. [FlashTool][New] Adapt new BROM_DLL&DA v2.7.1008.
* Resolution for 141: [FlashTool v2.7.1008][New] Support NFB download and many new features.
*
* Rev 1.33 May 24 2005 20:03:42 mtk00539
* 1. [FlashTool][New] Reset FAT to factory default setting.
* 2. [FlashTool][New] Option to enable/disable resource project id comparison.
* Resolution for 116: [FlashTool v2.6.1012][New] Reset FAT to factory default setting.
*
* Rev 1.32 Feb 16 2005 17:27:44 mtk00539
* 1. [FlashTool][New] Adapt new BROM_DLL&DA v2.4.1009 to support SPANSION S71AL016D and SHARP LRS18C8A flash.
* 2. [FlashTool][Enhance] Allow to setup EMI setting in TestMode.
* 3. [FlashTool][Enhance] Keep TestMode unless you disable it. In order to allow users to do test continuously.
* 4. [FlashTool][Enhance] Add CTRL+S hot-key to save TestMode log into file.
* Resolution for 106: [FlashTool v2.6.1009][New] Adapt new BROM_DLL&DA v2.4.1009 to support SPANSION S71AL016D and SHARP LRS18C8A flash.
*
* Rev 1.31 Nov 30 2004 14:22:42 mtk00539
* Modify the skip auto-format warning message.
* Resolution for 100: [FlashTool v2.6.1008][New] Adapt new BROM_DLL&DA v2.4.1008 to enable/disable speed-up baudrate in BootROM stage.
*
* Rev 1.30 Nov 25 2004 09:59:00 mtk00539
* tboot_1::InitProgress() should not intialize g_ProgressTimeSec = 0 while bUpdateFinishBytes is false.
* Resolution for 100: [FlashTool v2.6.1008][New] Adapt new BROM_DLL&DA v2.4.1008 to enable/disable speed-up baudrate in BootROM stage.
*
* Rev 1.29 Nov 22 2004 14:30:12 mtk00539
* 1. [FlashTool][New] Adapt new BROM_DLL&DA v2.4.1008 to enable/disable speed-up baudrate in BootROM stage.
* Resolution for 100: [FlashTool v2.6.1008][New] Adapt new BROM_DLL&DA v2.4.1008 to enable/disable speed-up baudrate in BootROM stage.
*
* Rev 1.28 Nov 05 2004 10:40:04 mtk00539
* 1. [FlashTool][New] Adapt new BROM_DLL&DA v2.4.1007 to support S/W compatible mechanism for MT6218B_FN and MT6218B_GN and some enhancement.
* Resolution for 97: [FlashTool v2.6.1007][New] Adapt new BROM_DLL&DA v2.4.1007 to support S/W compatible mechanism for MT6218B_FN and MT6218B_GN and some enhancement.
*
* Rev 1.27 Oct 29 2004 11:49:22 mtk00539
* 1. [FlashTool][New] Adapt new BROM_DLL&DA v2.4.1006 to fix AM49DL3208GT & S71PL032J download fail problem and some enhancement.
* 2. [FlashTool][New] Add auto-detect base band chip type flag.
* Resolution for 1: META MAUI v1.0
*
* Rev 1.26 Sep 17 2004 17:04:08 mtk00539
* process new error code FT_DA_HW_ERROR
* Resolution for 91: [FlashTool v2.6.1005][New] Adapt new BROM_DLL&DA v2.4.1005 to fix MT6217 download fail problem.
*
* Rev 1.25 Aug 03 2004 22:42:28 mtk00539
* remove unnecessar include files
*
* Rev 1.24 Aug 03 2004 15:07:06 mtk00539
* [FlashTool v2.6.1002][New] Adapt with BROM_DLL v2.4.1002 and many enhancement.
*
* Reason:
* 1. [FlashTool][New] Adapt new BROM_DLL v2.4.1002 for many features and bug fix.
* 2. [FlashTool][Enhance] Display external SRAM size of target NOR flash MCP.
*
* How to verify this SCR?
* 1. use FlashTool to verify.
* Resolution for 84: [FlashTool v2.6.1002][New] Adapt with BROM_DLL v2.4.1002 and many enhancement.
*
* Rev 1.23 Jul 19 2004 11:13:26 mtk00539
* add baudrate full sync count option
* Resolution for 82: [FlashTool v2.6.1001][New] Adapt with BROM_DLL v2.4.1001 and many enhancement.
*
* Rev 1.22 Jul 19 2004 02:10:56 mtk00539
* 1. [FlashTool][New] Adapt new BROM_DLL v2.4.1001 for many features and bug fix.
* 2. [FlashTool][Enhance] Export COM port read/write timeout setting.
* 3. [FlashTool][Enhance] Change EMI setting to 32 bits.
* Resolution for 82: [FlashTool v2.6.1001][New] Adapt with BROM_DLL v2.4.1001 and many enhancement.
*
* Rev 1.21 Jun 16 2004 16:38:12 mtk00539
* 1. [FlashTool][Enhance] Re-org format option panel to prevent users confused.
* 2. [FlashTool][Enhance] Do not close OK window when operation is done.
* Resolution for 78: [FlashTool v2.5.1013][Enhance] Re-org format option panel to prevent users confused.
*
* Rev 1.20 May 26 2004 21:54:58 mtk00539
* [FlashTool][New] Using BROM_DLL_v2.3.1005 new feature to add BootROM stage callback function to disable vibrator to avoid MT6218B series board layout issue.
* Resolution for 74: [FlashTool v2.5.1011][New] Add new flag to pull down GPIO17.
*
* Rev 1.19 May 21 2004 15:54:54 mtk00539
* 1. [FlashTool][BUF FIX] fix incorrect error message of resource detection.
* Resolution for 71: [FlashTool v2.5.1010][BUF FIX] fix incorrect error message of resource detection.
*
* Rev 1.18 May 17 2004 12:58:14 mtk00539
* [New] keep old interfaces of Boot_META, Boot_FlashTool & Brom_Verify
* Resolution for 69: [BootRom v2.3.1002][BUG FIX] fix RB_HANDLE deadlock.
*
* Rev 1.17 May 14 2004 17:04:22 mtk00539
* 1. [FlashTool][New] add CTRL+ALT+O hot-key to toggle Advanced Option Mode.
* 2. [FlashTool][New] add FAT auto format mechanism.
* 3. [FlashTool][New] add DA auto selection mechanism.
* 4. [FlashTool][New] add STOP button.
* 5. [FlashTool][Enhance] start timer when BootROM start cmd pass.
* 6. [FlashTool][New] display flash info in status bar hint.
* 7. [FlashTool][New] display format range info in format progress bar hint.
* 8. [FlashTool][New] record the DA, Scatter and DL path separately.
* Resolution for 68: [FlashTool v2.5.1009][New] add FAT auto format, DA auto selection mechanism and lots of enhancements.
*
* Rev 1.16 Mar 29 2004 14:20:16 mtk00539
* [New] add baseband chip ECO revision checking flag for FlashDownload.
* Resolution for 65: [FlashTool v2.5.1008][New] add baseband chip ECO revision checking flag for FlashDownload.
*
* Rev 1.15 Mar 12 2004 19:07:48 mtk00539
* change log format
*
* Rev 1.14 Mar 09 2004 21:06:56 mtk00539
* [Enhance] adapt new Boot_FlashTool interface.
*
* Rev 1.13 Mar 02 2004 00:28:20 mtk00539
* 1. [FlashTool][Enhance] automatically select bbchip according to rom bbchip id..
* 2. [FlashTool][Enhance] automatically load all the resource files.
* 3. [FlashTool][Enhance] display resource and jump table information.
* 4. [FlashTool][New] add MT6219 support.
* Resolution for 54: [FlashTool v2.5.1006][Enhance] bbchip id detection and resource autoload.
*
* Rev 1.12 Feb 05 2004 13:40:36 mtk00539
* adapt to BROM DLL v2.2.1001
* Resolution for 47: [FlashTool v2.5.1001][New] support multiple concatanated bin files download.
*
* Rev 1.11 Nov 14 2003 15:48:48 mtk00539
* add SOC feature.
* Resolution for 35: [BootRom v2.1.1005][New] Add SOC feature.
*
* Rev 1.10 Oct 18 2003 14:06:20 mtk00539
* 1. modify for MT6218B boot rom verification.
* 2. change version info.
* Resolution for 31: [BootRom v2.1.1002][BUG FIX] Fix DA checksum error on Windows ME and 2000.
*
* Rev 1.9 Sep 26 2003 11:37:16 mtk00539
* check new return code
* Resolution for 28: [BootRom v2.1.1001][New] See the reasons below.
* Resolution for 29: [FlashTool v2.4.1001][New] See the reasons below.
*
* Rev 1.8 Sep 25 2003 14:03:28 mtk00539
* adapt brom.dll v2.1.1001, please see SCR(29) for more details.
* Resolution for 29: [FlashTool v2.4.1001][New] See the reasons below.
*
* Rev 1.7 Jul 09 2003 13:36:06 mtk00539
* 1. reduce default timeout period and read/write incomplete retry times.
* 2. increase version to 2.3.1002
* Resolution for 14: [BootRom v2.0.1004] fine tune for high speed download card behavior.
*
* Rev 1.6 Jun 30 2003 19:19:36 mtk00539
* 1. [FlashTool][Add Features] Split flashtool function into brom.dll
* 2. [FlashTool][Add Features] Format function: users can format any range you want without downloading procedure.
* 3. [FlashTool][Add Features] Report format percentage.
* 4. [FlashTool][Add Features] Check format range.
* 5. [FlashTool][Add Features] Merge FlashTool for Pluto version.
* 6. [FlashTool][Add Features] Runtime debug log: you can press (CTRL+ALT+T) to enable/disable debug log whenever you want.
* 7. [FlashTool][Add Features] Forcedly Stop hot-key: you can forcedly stop FlashTool by pressing CTRL+Z.
* 8. [FlashTool][BUG FIXED] Fix FlashTool MEM_CMD end_addr bug, FlashTool should use (begin_addr+length-1) as end_addr.
* Resolution for 11: [FlashTool v2.3.1001][New Version] Split flashtool function into brom.dll
*
* Rev 1.5 Jun 03 2003 22:24:56 mtk00539
* 1. extend timeout to 10 sec for large image download in boot_2.cpp
* 2. disable unnecesssary debug hot-key.
* 3. add shift+ctrl+A for Jensen's DA debug tool kit.
* 4. enable build number, and start from 1003.
* 5. save baseband chip type, mcu frequency and auto-memory wait state setup flag to ini file.
* 6. add DA_SET_REG_CMD command and remove FINISH_CMD, so that release power key could be issued from FlashTool, not hardcoded in DA.
* 7. add DA_MCU_FREQ_CMD command, so that we don't have to select different DA while switching frequency.
* 8. add new flash MB84VD23280FA-70 for Chicago project.
* 9. remove DEVICE_CMD, DA will check flash automatically and report the flash type to PC.
* 10. add DA_FORMAT_CMD command to support range format.
* 11. display flash type on FlashTool.
* 12. merge the DOWNLOAD.H header file, both FlashTool and DA will use the same header file.
* 13. modify SPEED_CMD handshake by adding a sync mechanism to detect whether if the speed change is done by both sides.
* Resolution for 7: [FlashTool v2.2.1003][AddFeature] Enhanced for KLM and Chicago project.
*
* Rev 1.4 May 22 2003 19:23:58 mtk00539
* support brom.lib v1.0.1010
* Resolution for 6: [FlashTool v2.2][AddFeature] Support 6205/6205B at 13MHz, 26MHz and 52MHz.
*
* Rev 1.3 May 20 2003 16:22:30 mtk00539
* Support 6205/6205B at 13MHz, 26MHz and 52MHz
* Resolution for 6: [FlashTool v2.2][AddFeature] Support 6205/6205B at 13MHz, 26MHz and 52MHz.
*
* Rev 1.2 Nov 20 2002 19:52:58 mtk00303
* update for reference phone
*
* Rev 1.1 Jul 26 2002 11:52:20 admin
* ver 0726
*
* Rev 1.0 Jul 20 2002 19:26:16 admin
* Initial revision.
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "tboot_1.h"
#include "main.h"
#include "ok_wnd.h"
#include "com_util.h"
#include "flashtool.h"
#include "DA_Option.h"
#include "meta.h"
#pragma package(smart_init)
//#define SKIP 1
//---------------------------------------------------------------------------
// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall Unit4::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
__fastcall tboot_1::tboot_1(bool CreateSuspended )
: TThread(CreateSuspended)
{
}
//---------------------------------------------------------------------------
void _fastcall tboot_1::ShowMsg()
{
ShowMessage( asMsg );
}
void _fastcall tboot_1::InitProgress() {
MainForm->CGauge1->Hint = progress_hint;
MainForm->CGauge1->ForeColor = progress_forecolor;
MainForm->CGauge1->Progress = progress_percentage;
if(bUpdateFinishBytes) {
g_ProgressTimeSec = 0;
MainForm->sb_Main->Panels->Items[0]->Text = IntToStr(progress_finished_bytes) + " Bytes / 0 Bps";
}
}
void _fastcall tboot_1::SyncInitProgress() {
Synchronize(InitProgress);
}
void _fastcall tboot_1::UpdateProgress() {
unsigned int Bps;
float KBps;
AnsiString rate;
MainForm->CGauge1->Progress = progress_percentage;
if(bUpdateFinishBytes) {
g_DisplayFinishedBytes = progress_finished_bytes;
if( 0 >= g_ProgressTimeSec ) {
rate = "0 Bps";
}
else if( 1024 < (Bps=progress_finished_bytes/g_ProgressTimeSec) ) {
KBps = Bps;
rate = FloatToStrF( KBps/1024, ffFixed, 7, 2) + " KBps";
}
else {
rate = IntToStr(Bps) + " Bps";
}
MainForm->sb_Main->Panels->Items[0]->Text = IntToStr(progress_finished_bytes) + " Bytes / " + rate;
}
}
void _fastcall tboot_1::SyncUpdateProgress() {
Synchronize(UpdateProgress);
}
void _fastcall tboot_1::DisplayFlashType() {
ConvertDAReportToString(&da_report, m_strStorageHint, sizeof(m_strStorageHint), m_strHWDetectionReport, sizeof(m_strHWDetectionReport));
MainForm->HWStatusBarUpdate(&da_report, m_strStorageHint, m_strHWDetectionReport);
}
void _fastcall tboot_1::SyncDisplayFlashType() {
Synchronize(DisplayFlashType);
}
void _fastcall tboot_1::SyncShowMsg() {
Synchronize(ShowMsg);
}
void _fastcall tboot_1::ShowOK_Form()
{
Form_OK->Visible = true;
StopTimer();
}
void _fastcall tboot_1::StopTimer() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -