📄 configdlg.cpp.svn-base
字号:
if(download_resource[i].compare)
config.total_download_file_len += dwSize;
}
}
return true;
}
bool LoadDefaultCfg()
{
HANDLE hFile = NULL;
config.chip_type = CHIP_3224;
config.bUBoot = true;
config.bAutoDownload = false;
config.bPiece_Select_Loop = true;
config.res_blocks = 25;
strcpy(config.mobile_type, "Anyka");
config.equipment_count = 1;
config.bOpenCom = false;
config.com_count = 1;
config.base_com = 1;
config.BaudRate = 38400;
config.ByteSize = 8;
config.Parity = 0;
config.StopBits = 0;
config.memory_type = MEMORY_TYPE_SDRAM;
config.total_download_file_len = 0;
strcpy(config.loadfile_path, "producer.bin");
config.loadfile_destination_address = 0x30600000;
strcpy(config.nandboot_path, "nandboot.bin");
strcpy(config.bios_path, "bios.bin");
config.bNandBoot = TRUE;
config.bHaveNandflash = true;
config.bios_main_version = 1;
config.bios_sub_version = 0;
config.bios_sub1_version = 0;
config.bios_start_address = 0x40000;
config.bios_end_address = 0x120000;
config.bios_backup_start_address = 0x120000;
config.bios_backup_end_address = 0x200000;
config.bios_run_address = 0x30600000;
config.download_file_count = 0;
/* config.download_files = (download_file * )malloc(sizeof(download_file) * config.download_file_count);
memset(config.download_files, 0, sizeof(download_file) * config.download_file_count);
config.download_files[0].compare = TRUE;
config.download_files[0].download_type = DOWNLOAD_TO_U;
strcpy(config.download_files[0].file_pc_path, "pda_nandbootd.bin");
strcpy(config.download_files[0].file_flash_path, "A:/pda_nandbootd.bin");
config.download_files[1].compare = TRUE;
config.download_files[1].download_type = DOWNLOAD_TO_U;
strcpy(config.download_files[1].file_pc_path, "pdaakresdata.bin");
strcpy(config.download_files[1].file_flash_path, "A:/pdaakresdata.bin");
config.set_register_count = 4;
config.set_registers = (set_register *) malloc(sizeof(set_register) * config.set_register_count);
memset(config.set_registers, 0, sizeof(set_register) * config.set_register_count);
config.set_registers[0].address = 0x20000000;
config.set_registers[0].value = 0xffffffff;
config.set_registers[1].address = 0x200b0000;
config.set_registers[1].value = 0x100f400;
config.set_registers[2].address = 0x20090020;
config.set_registers[2].value = 0x6004003;
config.set_registers[3].address = 0x20090060;
config.set_registers[3].value = 0x2;
*/
config.erase_count = 2;
config.erases = (T_ERASE_DATA *)malloc(sizeof(T_ERASE_DATA) * config.erase_count);
memset(config.erases, 0, sizeof(T_ERASE_DATA) * config.erase_count);
config.erases[0].type = ERASE_NANDFLASH;
config.erases[0].Start_Address = 0x0000000;
config.erases[0].End_Address = 0x00200000;
config.erases[1].type = ERASE_NANDFLASH;
config.erases[1].Start_Address = 0x00200000;
config.erases[1].End_Address = 0x0fffffff;
config.format_count = 2;
config.formats = (T_FORMAT_DATA *)malloc(sizeof(T_FORMAT_DATA) * config.format_count);
memset(config.formats, 0, sizeof(T_FORMAT_DATA) * config.format_count);
config.formats[0].Disk_Name = 'A';
config.formats[0].Start_Address = 0x00200000;
config.formats[0].End_Address = 0x01200000;
config.formats[1].Disk_Name = 'B';
config.formats[1].Start_Address = 0x01200000;
config.formats[1].End_Address = 0x01FFFFFF;
#ifdef DOWNLOAD_FAT_IMAGE
config.download_fat_image_count = 2;
config.images = (download_fat_image *)malloc(sizeof(download_fat_image) * config.download_fat_image_count);
memset(config.images, 0, sizeof(download_fat_image) * config.download_fat_image_count);
config.images[0].Disk_Name = 'A';
strcpy(config.images[0].file_pc_path, "flash_A.bin");
config.images[0].File_Size = 0x790614;
config.images[1].Disk_Name = 'B';
strcpy(config.images[1].file_pc_path, "flash_B.bin");
config.images[1].File_Size = 0x575238;
#else
config.download_fat_image_count = 0;
config.images = NULL;
#endif
config.system_clock = 60;
config.ram_size = 16;
config.ram_banks = 4;
config.ram_row = 12;
config.ram_column = 9;
config.power_off_gpio = 0xFF;
config.init_usb = INIT_USB_REGISTER;
config.init_usb_gpio_number = 5;
config.init_usb_register = 0x20063000;
config.init_usb_register_bit = 0x1;
//config.nandflash_parameter_count = 18;
//Get list number
int i = 0;
while (ERROR_CHIP_ID != SUPPORT_NAND_TABLE[i].chip_id )
{
i++;
}
config.nandflash_parameter_count = i ;
config.nandflash_parameter = (T_NAND_PHY_INFO *)malloc(sizeof(T_NAND_PHY_INFO) *
config.nandflash_parameter_count);
memset(config.nandflash_parameter, 0, sizeof(T_NAND_PHY_INFO) *
config.nandflash_parameter_count);
for( i = 0; i < config.nandflash_parameter_count; i++)
{
config.nandflash_parameter[i] = SUPPORT_NAND_TABLE[i];
}
return count_downloadfile_size();
}
void find_resource(char *resource_path, char *dest_path, BOOL compare)
{
if(download_resource == NULL || resource_path == NULL || dest_path == NULL)
return;
CString path = resource_path;
if(path.Right(1) != '*')
{
if(path.Right(1) != '\\')
path += __T("\\");
path += __T("*");
}
WIN32_FIND_DATA find_data;
HANDLE fp = FindFirstFile(path, &find_data );
if(fp != INVALID_HANDLE_VALUE)
{
while(FindNextFile(fp, &find_data ) != 0)
{
if(download_resource_count >= MAX_DOWNLOAD_FILES)
{
FindClose(fp);
return;
}
if(strcmp(find_data.cFileName, "..") == 0 || strcmp(find_data.cFileName, ".") == 0)
continue;
download_resource[download_resource_count].download_type = DOWNLOAD_TO_U;
download_resource[download_resource_count].compare = compare;
strcpy(download_resource[download_resource_count].file_pc_path, resource_path);
if(resource_path[strlen(resource_path) - 1] != '\\')
strcat(download_resource[download_resource_count].file_pc_path, "\\");
strcat(download_resource[download_resource_count].file_pc_path, find_data.cFileName);
strcpy(download_resource[download_resource_count].file_flash_path, dest_path);
if(download_resource[download_resource_count].file_flash_path[strlen(download_resource[download_resource_count].file_flash_path) - 1] != '/')
strcat(download_resource[download_resource_count].file_flash_path, "/");
//char *path = strstr(download_resource[download_resource_count].file_pc_path, original_path);
//if(path != NULL)
strcat(download_resource[download_resource_count].file_flash_path, find_data.cFileName);
download_resource_count++;
if(download_resource_count >= MAX_DOWNLOAD_FILES)
{
FindClose(fp);
return;
}
if((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
{
find_resource(download_resource[download_resource_count - 1].file_pc_path,
download_resource[download_resource_count - 1].file_flash_path, compare);
}
}
FindClose(fp);
}
}
bool open_config()
{
HANDLE hFile = NULL;
DWORD read_len = 0;
DWORD dwSize = 0;
DWORD nBufferLength = MAX_PATH;
char DirectoryBuffer[MAX_PATH];
::GetCurrentDirectory(nBufferLength, Current_DirectoryBuffer);
strcpy(DirectoryBuffer, Current_DirectoryBuffer);
strcat(DirectoryBuffer, "\\");
strcat(DirectoryBuffer, CONFIG_PATH);
config.total_download_file_len = 0;
hFile = CreateFile(DirectoryBuffer , GENERIC_READ , FILE_SHARE_READ , NULL ,
OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
hFile = CreateFile(DirectoryBuffer , GENERIC_WRITE | GENERIC_READ ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL ,
CREATE_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
return false;
}
char temp_buf[CONFIG_LEN * 2];
DWORD write_len;
memset(temp_buf, 0, CONFIG_LEN * 2);
WriteFile(hFile, temp_buf, CONFIG_LEN * 2 + 1, &write_len, NULL);
CloseHandle(hFile);
return false;
}
SetFileAttributes(DirectoryBuffer, FILE_ATTRIBUTE_NORMAL);
CFile configfile((int)hFile);
configfile.Read(&config.chip_type, sizeof(config.chip_type));
configfile.Read(&config.bUBoot, sizeof(config.bUBoot));
configfile.Read(&config.bAutoDownload, sizeof(config.bAutoDownload));
configfile.Read(&config.bPiece_Select_Loop, sizeof(config.bPiece_Select_Loop));
configfile.Read(&config.bNandBoot, sizeof(config.bNandBoot));
configfile.Read(&config.bHaveNandflash, sizeof(config.bHaveNandflash));
configfile.Read(&config.res_blocks, sizeof(config.res_blocks));
configfile.Read(&config.bHavePieceZero, sizeof(config.bHavePieceZero));
configfile.Read(&config.bHavePieceOne, sizeof(config.bHavePieceOne));
configfile.Read(&config.bHavePieceTwo, sizeof(config.bHavePieceTwo));
configfile.Read(&config.bHavePieceThree, sizeof(config.bHavePieceThree));
configfile.Read(config.nandboot_path, 255);
configfile.Read(config.bios_path, 255);
configfile.Read(&config.bios_main_version, sizeof(config.bios_main_version));
configfile.Read(&config.bios_sub_version, sizeof(config.bios_sub_version));
configfile.Read(&config.bios_start_address, sizeof(config.bios_start_address));
configfile.Read(&config.bios_end_address, sizeof(config.bios_end_address));
configfile.Read(&config.bios_backup_start_address, sizeof(config.bios_backup_start_address));
configfile.Read(&config.bios_backup_end_address, sizeof(config.bios_backup_end_address));
configfile.Read(&config.bios_run_address, sizeof(config.bios_run_address));
config.bios_main_version = MAIN_VERSION;
config.bios_sub_version = SUB_VERSION;
config.bios_sub1_version = SUB1_VERSION;
configfile.Read(config.mobile_type, 255);
configfile.Read(&config.equipment_count, sizeof(config.equipment_count));
configfile.Read(&config.com_count, sizeof(config.com_count));
if(config.equipment_count > MAX_DEVICE_NUM)
{
config.equipment_count = MAX_DEVICE_NUM;
}
if(config.com_count > MAX_DEVICE_NUM)
{
config.com_count = MAX_DEVICE_NUM;
}
configfile.Read(&config.bOpenCom, sizeof(config.bOpenCom));
configfile.Read(&config.base_com, sizeof(config.base_com));
configfile.Read(&config.BaudRate, sizeof(config.BaudRate));
configfile.Read(&config.memory_type, sizeof(config.memory_type));
configfile.Read(config.loadfile_path, 255);
configfile.Read(&config.loadfile_destination_address, sizeof(config.loadfile_destination_address));
configfile.Read(&config.set_register_count, sizeof(config.set_register_count));
int i = 0;
if(config.set_registers != NULL)
free(config.set_registers);
config.set_registers = (set_register *) malloc(sizeof(set_register) * config.set_register_count);
if(config.set_registers != NULL)
{
memset(config.set_registers, 0, sizeof(set_register) * config.set_register_count);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -