www.pudn.com > FlashTool_src_v2.9.1006.zip > frm_FormatOption.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: * --------- * frm_FormatOption.cpp * * Project: * -------- * Flash tool set * * Description: * ------------ * Form of format option * * Author: * ------- * Amos Hsu (mtk00539) * *============================================================================== * HISTORY * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! *------------------------------------------------------------------------------ * $Revision: 1.7 $ * $Modtime: Nov 11 2005 11:28:14 $ * $Log: //mtkvs01/vmdata/flash_tool/archives/frm_FormatOption.cpp-arc $ * * Rev 1.7 Nov 19 2005 00:58:00 mtk00539 * 1. [FlashTool][New] Adapt new BROM_DLL&DA v2.7.1011. * Resolution for 150: [FlashTool v2.7.1011][New] Add UID Secure Booting feature and Bug Fix. * * Rev 1.6 Oct 19 2005 14:47:24 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.5 May 24 2005 20:03:38 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.4 Jun 16 2004 16:38:14 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.3 May 14 2004 17:03:58 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.2 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.1 Jun 03 2003 22:24:54 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. * *------------------------------------------------------------------------------ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! *============================================================================== *******************************************************************************/ //--------------------------------------------------------------------------- #include#pragma hdrstop #include "main.h" #include "frm_FormatOption.h" #include "DL_Go.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TFormatOption *FormatOption; //--------------------------------------------------------------------------- __fastcall TFormatOption::TFormatOption(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TFormatOption::OnShow(TObject *Sender) { if(g_FormatValidation) { m_FormatValidation->Checked = true; } else { m_FormatValidation->Checked = false; } if( NOR_OPERATION == g_OperationMethod ) { FormatStartAddr->Text = "0x" + IntToHex((int)g_ulFormatStartAddr, 8); FormatLength->Text = "0x" + IntToHex((int)g_ulFormatLength, 8); } else { FormatStartAddr->Text = "0x" + IntToHex((int)g_ulNandFormatStartAddr, 8); FormatLength->Text = "0x" + IntToHex((int)g_ulNandFormatLength, 8); } // save the original groupbox height m_Original_GroupBox_Height = GroupBox1->Height; m_Original_Form_Height = Height; m_Original_Panel_ManualFormat1_Top = m_Panel_ManualFormat1->Top; m_Original_Panel_ManualFormat2_Top = m_Panel_ManualFormat2->Top; m_Original_Panel_ManualFormat2_Height = m_Panel_ManualFormat2->Height; m_Original_Panel_ResetToFactoryDefault1_Top = m_Panel_ResetToFactoryDefault1->Top; m_Original_Panel_ResetToFactoryDefault2_Top = m_Panel_ResetToFactoryDefault2->Top; if(bCallFromFormatButton) { GroupBox1->Height = m_Panel_ManualFormat1->Height+m_Panel_ManualFormat2->Height+m_Panel_ResetToFactoryDefault1->Height+m_Panel_ResetToFactoryDefault2->Height+36; Height = GroupBox1->Height+40; m_Panel_ResetToFactoryDefault1->Top = m_Panel_DisableFormat1->Top; m_Panel_ResetToFactoryDefault2->Top = m_Panel_ResetToFactoryDefault1->Top+m_Panel_ResetToFactoryDefault1->Height-1; m_Panel_ManualFormat1->Top = m_Panel_ResetToFactoryDefault2->Top+m_Panel_ResetToFactoryDefault2->Height+12; m_Panel_ManualFormat2->Top = m_Panel_ManualFormat1->Top+m_Panel_ManualFormat1->Height-1; m_Panel_ManualFormat1->Visible = true; m_Panel_ManualFormat2->Visible = true; m_Panel_AutoFormat1->Visible = false; m_Panel_AutoFormat2->Visible = false; m_Panel_DisableFormat1->Visible = false; m_Panel_DisableFormat2->Visible = false; m_Panel_ResetToFactoryDefault1->Visible = true; m_Panel_ResetToFactoryDefault2->Visible = true; switch(g_FormatOption) { case MANUAL_FORMAT: m_Radio_ManualFormatClick(Sender); break; case RESET_TO_FACTORY: default: m_Radio_ResetToFactoryDefaultClick(Sender); break; } m_Group_EraseFlag->ItemIndex = 0; } else { m_Panel_ManualFormat1->Visible = true; m_Panel_ManualFormat2->Visible = true; m_Panel_AutoFormat1->Visible = true; m_Panel_AutoFormat2->Visible = true; m_Panel_DisableFormat1->Visible = true; m_Panel_DisableFormat2->Visible = true; m_Panel_ResetToFactoryDefault1->Visible = true; m_Panel_ResetToFactoryDefault2->Visible = true; switch(g_FormatAfterDownloadOption) { case RESET_TO_FACTORY: m_Radio_ResetToFactoryDefaultClick(Sender); break; case AUTO_FORMAT: m_Radio_AutoFormatClick(Sender); break; case MANUAL_FORMAT: m_Radio_ManualFormatClick(Sender); break; case DISABLE_FORMAT: default: m_Radio_DisableFormatClick(Sender); break; } } if( bCallFromFormatButton && !(NOR_OPERATION==g_OperationMethod) && g_bEnableAdvanceOption ) { m_Group_EraseFlag->Visible = true; } else { m_Panel_ManualFormat2->Height -= (m_Group_EraseFlag->Height+10); GroupBox1->Height -= (m_Group_EraseFlag->Height+10); Height -= (m_Group_EraseFlag->Height+10); m_Group_EraseFlag->Visible = false; } Visible = true; } //--------------------------------------------------------------------------- void __fastcall TFormatOption::btn_FormatOKClick(TObject *Sender) { if( NOR_OPERATION == g_OperationMethod ) { g_ulFormatStartAddr = strtoul(FormatStartAddr->Text.c_str(), NULL, 16); g_ulFormatLength = strtoul(FormatLength->Text.c_str(), NULL, 16); } else { g_ulNandFormatStartAddr = strtoul(FormatStartAddr->Text.c_str(), NULL, 16); g_ulNandFormatLength = strtoul(FormatLength->Text.c_str(), NULL, 16); } if(!bCallFromFormatButton) { if(m_Radio_ResetToFactoryDefault->Checked) { g_FormatAfterDownloadOption = RESET_TO_FACTORY; }else if(m_Radio_AutoFormat->Checked) { g_FormatAfterDownloadOption = AUTO_FORMAT; } else if(m_Radio_ManualFormat->Checked) { g_FormatAfterDownloadOption = MANUAL_FORMAT; } else { g_FormatAfterDownloadOption = DISABLE_FORMAT; } MainForm->updateMenuItem(); } else { if(m_Radio_ResetToFactoryDefault->Checked) { g_FormatOption = RESET_TO_FACTORY; } else { g_FormatOption = MANUAL_FORMAT; } switch(m_Group_EraseFlag->ItemIndex) { case 1: g_EraseFlag = NUTL_FORCE_ERASE; break; case 2: g_EraseFlag = NUTL_MARK_BAD_BLOCK; break; case 0: default: g_EraseFlag = NUTL_ERASE; } if( MT6205 != g_BBCHIP_TYPE ) MainForm->start_DL(true); else Form_DL_GO->ShowModal(); } Hide(); } //--------------------------------------------------------------------------- void __fastcall TFormatOption::btn_FormatCancelClick(TObject *Sender) { Hide(); } //--------------------------------------------------------------------------- void __fastcall TFormatOption::m_Radio_ManualFormatClick(TObject *Sender) { m_Radio_DisableFormat->Checked = false; m_Radio_ResetToFactoryDefault->Checked = false; m_Radio_AutoFormat->Checked = false; m_Radio_ManualFormat->Checked = true; } //--------------------------------------------------------------------------- void __fastcall TFormatOption::m_Radio_AutoFormatClick(TObject *Sender) { m_Radio_DisableFormat->Checked = false; m_Radio_ResetToFactoryDefault->Checked = false; m_Radio_AutoFormat->Checked = true; m_Radio_ManualFormat->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TFormatOption::m_Radio_DisableFormatClick(TObject *Sender) { m_Radio_DisableFormat->Checked = true; m_Radio_ResetToFactoryDefault->Checked = false; m_Radio_AutoFormat->Checked = false; m_Radio_ManualFormat->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TFormatOption::m_Radio_ResetToFactoryDefaultClick(TObject *Sender) { m_Radio_DisableFormat->Checked = false; m_Radio_ResetToFactoryDefault->Checked = true; m_Radio_AutoFormat->Checked = false; m_Radio_ManualFormat->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TFormatOption::FormClose(TObject *Sender, TCloseAction &Action) { Hide(); } //--------------------------------------------------------------------------- void __fastcall TFormatOption::Hide() { Visible = false; // restore the original groupbox height GroupBox1->Height = m_Original_GroupBox_Height; Height = m_Original_Form_Height; m_Panel_ManualFormat1->Top = m_Original_Panel_ManualFormat1_Top; m_Panel_ManualFormat2->Top = m_Original_Panel_ManualFormat2_Top; m_Panel_ManualFormat2->Height = m_Original_Panel_ManualFormat2_Height; m_Panel_ResetToFactoryDefault1->Top = m_Original_Panel_ResetToFactoryDefault1_Top; m_Panel_ResetToFactoryDefault2->Top = m_Original_Panel_ResetToFactoryDefault2_Top; } //--------------------------------------------------------------------------- void __fastcall TFormatOption::m_FormatValidationClick(TObject *Sender) { if(m_FormatValidation->Checked) { g_FormatValidation = true; } else { g_FormatValidation = false; } } //---------------------------------------------------------------------------