541 lines
14 KiB
C
541 lines
14 KiB
C
|
|
|||
|
|
|||
|
//#include "Include.h"
|
|||
|
//#include "x_file.h"
|
|||
|
#include <string.h>
|
|||
|
#include <stdio.h>
|
|||
|
#include <stdlib.h>
|
|||
|
#include "res_mgr.h"
|
|||
|
#include "ff.h"
|
|||
|
|
|||
|
#include "./led/bsp_led.h"
|
|||
|
#include "./flash/bsp_qspi_flash.h"
|
|||
|
|
|||
|
/*============================================================================*/
|
|||
|
|
|||
|
/*flash<73><68>sd<73><64><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>*/
|
|||
|
FATFS flash_fs;
|
|||
|
FATFS sd_fs; /* Work area (file system object) for logical drives */
|
|||
|
|
|||
|
//SD<53><44>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
char src_dir[512]= RESOURCE_DIR;
|
|||
|
|
|||
|
static FIL file_temp; /* file objects */
|
|||
|
static char full_file_name[512];
|
|||
|
static char line_temp[512];
|
|||
|
static uint8_t state = QSPI_ERROR;
|
|||
|
uint32_t loop = 0;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>л<EFBFBD><EFBFBD>ļ<EFBFBD>
|
|||
|
* @param check_name[in] Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>,ȫ·<EFBFBD><EFBFBD>
|
|||
|
* @param ignore_file[in] ignore<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ·<EFBFBD><EFBFBD>
|
|||
|
* @retval 1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>0<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
uint8_t Is_Ignore(char *check_name, char *ignore_file)
|
|||
|
{
|
|||
|
FRESULT result;
|
|||
|
uint32_t i;
|
|||
|
|
|||
|
char *ignore_file_dir;
|
|||
|
char *dir_ptr ;
|
|||
|
char *full_path;
|
|||
|
|
|||
|
result = f_open(&file_temp, ignore_file, FA_OPEN_EXISTING | FA_READ);
|
|||
|
|
|||
|
if(result == FR_NO_FILE)
|
|||
|
{
|
|||
|
BURN_DEBUG("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
ignore_file_dir = malloc(512);
|
|||
|
full_path = malloc(512);
|
|||
|
|
|||
|
if(ignore_file_dir == NULL || full_path == NULL)
|
|||
|
{
|
|||
|
BURN_ERROR("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mallocʱ<EFBFBD>ڴ治<EFBFBD>㣡");
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
/* <20>õ<EFBFBD>ignore<72>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ڵ<EFBFBD>Ŀ¼ */
|
|||
|
strcpy(ignore_file_dir, ignore_file);
|
|||
|
dir_ptr = strrchr(ignore_file_dir, '/');
|
|||
|
*(dir_ptr) = '\0';
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> */
|
|||
|
for(i=0;1;i++)
|
|||
|
{
|
|||
|
/* <20><>һ<EFBFBD>к<EFBFBD><D0BA>Ե<EFBFBD><D4B5>ļ<EFBFBD><C4BC><EFBFBD> */
|
|||
|
f_gets(line_temp, sizeof(line_temp), &file_temp);
|
|||
|
/* ע<><D7A2><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
if(line_temp[0] == '#')
|
|||
|
continue;
|
|||
|
|
|||
|
/* <20>滻<EFBFBD><E6BBBB><EFBFBD>س<EFBFBD> */
|
|||
|
line_temp[strlen(line_temp)-1] = '\0';
|
|||
|
|
|||
|
/* ƴ<>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7> */
|
|||
|
sprintf(full_path, "%s/%s",ignore_file_dir,line_temp);
|
|||
|
|
|||
|
// BURN_DEBUG("full_path=%s,\r\ncheck_name=%s\r\n",
|
|||
|
// full_path,
|
|||
|
// check_name);
|
|||
|
/* <20>Ƚ<EFBFBD><C8BD>Ƿ<EFBFBD>һ<EFBFBD><D2BB> */
|
|||
|
if(strcasecmp(check_name,full_path) == 0)
|
|||
|
{
|
|||
|
f_close(&file_temp);
|
|||
|
free(ignore_file_dir);
|
|||
|
free(full_path);
|
|||
|
|
|||
|
return 1;
|
|||
|
}
|
|||
|
/* <20>ѵ<EFBFBD><D1B5>ļ<EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD> */
|
|||
|
if(f_eof(&file_temp) != 0 )
|
|||
|
{
|
|||
|
f_close(&file_temp);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
free(ignore_file_dir);
|
|||
|
free(full_path);
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* @brief Make_Catalog <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԴĿ¼<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD><EFBFBD>ݹ麯<EFBFBD><EFBFBD>
|
|||
|
* @param path[in]:<EFBFBD><EFBFBD>Դ·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD>㹻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飬
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param clear: 0 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ԭ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @note <EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>clear<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>ݹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ1.
|
|||
|
* @retval result:<EFBFBD>ļ<EFBFBD>ϵͳ<EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
FRESULT Make_Catalog (char* path,uint8_t clear)
|
|||
|
{
|
|||
|
FRESULT res; //<2F><><EFBFBD><EFBFBD><EFBFBD>ڵݹ<DAB5><DDB9><EFBFBD><EFBFBD>̱<EFBFBD><CCB1>ĵı<C4B5><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
|||
|
FILINFO fno;
|
|||
|
DIR dir;
|
|||
|
int i;
|
|||
|
char *fn; // <20>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
|
|||
|
/* <20><>¼<EFBFBD><C2BC>ַƫ<D6B7><C6AB><EFBFBD><EFBFBD>Ϣ */
|
|||
|
static uint32_t resource_addr = CATALOG_SIZE ;
|
|||
|
uint32_t addr_temp = 0;
|
|||
|
|
|||
|
#if _USE_LFN
|
|||
|
/* <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>֧<EFBFBD><D6A7> */
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ2<D2AA><32><EFBFBD>ֽڱ<D6BD><DAB1><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>*/
|
|||
|
static char lfn[_MAX_LFN*2 + 1];
|
|||
|
fno.lfname = lfn;
|
|||
|
fno.lfsize = sizeof(lfn);
|
|||
|
#endif
|
|||
|
|
|||
|
if(clear == 0)
|
|||
|
{
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>Ϣ<EFBFBD>ļ<EFBFBD>catalog.txt...\r\n");
|
|||
|
|
|||
|
/* <20><>һ<EFBFBD><D2BB>ִ<EFBFBD><D6B4>Make_Catalog<6F><67><EFBFBD><EFBFBD>ʱɾ<CAB1><C9BE><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>¼<EFBFBD><C2BC>Ϣ<EFBFBD>ļ<EFBFBD> */
|
|||
|
f_unlink(BURN_INFO_NAME_FULL);
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>Ŀ¼
|
|||
|
res = f_opendir(&dir, path);
|
|||
|
if (res == FR_OK)
|
|||
|
{
|
|||
|
i = strlen(path);
|
|||
|
for (;;)
|
|||
|
{
|
|||
|
//<2F><>ȡĿ¼<C4BF>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD>
|
|||
|
res = f_readdir(&dir, &fno);
|
|||
|
//Ϊ<><CEAA>ʱ<EFBFBD><CAB1>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ȡ<EFBFBD><C8A1><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (res != FR_OK || fno.fname[0] == 0) break;
|
|||
|
#if _USE_LFN
|
|||
|
fn = *fno.lfname ? fno.lfname : fno.fname;
|
|||
|
#else
|
|||
|
fn = fno.fname;
|
|||
|
#endif
|
|||
|
//<2F><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ǰĿ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (*fn == '.') continue;
|
|||
|
//Ŀ¼<C4BF><C2BC><EFBFBD>ݹ<EFBFBD><DDB9><EFBFBD>ȡ
|
|||
|
if (fno.fattrib & AM_DIR)
|
|||
|
{
|
|||
|
//<2F>ϳ<EFBFBD><CFB3><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>
|
|||
|
sprintf(&path[i], "/%s", fn);
|
|||
|
|
|||
|
BURN_INFO("-------------------------------------");
|
|||
|
BURN_INFO("<EFBFBD>ļ<EFBFBD><EFBFBD>У<EFBFBD>%s",path);
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>ignore<72>ļ<EFBFBD><C4BC>м<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
if(Is_Ignore(path, IGNORE_NAME_FULL) == 1)
|
|||
|
{
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>У<EFBFBD>%s",path);
|
|||
|
continue;
|
|||
|
}
|
|||
|
//<2F>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
res = Make_Catalog(path,1);
|
|||
|
path[i] = 0;
|
|||
|
//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
|
|||
|
if (res != FR_OK)
|
|||
|
break;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
uint32_t file_size;
|
|||
|
|
|||
|
/* <20><><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<C4BF>ļ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD> */
|
|||
|
if(strcasecmp(fn,BURN_INFO_NAME) == 0 ||
|
|||
|
strcasecmp(fn,IGNORE_NAME) == 0)
|
|||
|
continue;
|
|||
|
|
|||
|
/* <20>õ<EFBFBD>ȫ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> */
|
|||
|
sprintf(full_file_name, "%s/%s",path, fn);
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>ignore<72>ļ<EFBFBD><C4BC>м<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
if(Is_Ignore(full_file_name, IGNORE_NAME_FULL) == 1)
|
|||
|
{
|
|||
|
BURN_INFO("-------------------------------------");
|
|||
|
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>%s",full_file_name);
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
f_open(&file_temp, full_file_name, FA_OPEN_EXISTING | FA_READ);
|
|||
|
file_size = f_size(&file_temp);
|
|||
|
f_close(&file_temp);
|
|||
|
|
|||
|
BURN_INFO("-------------------------------------");
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD>Դ<EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>:%s", full_file_name); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD>Դ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>:%s", fn); //<2F>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>С:%d", file_size); //<2F>ļ<EFBFBD><C4BC><EFBFBD>С
|
|||
|
BURN_INFO("Ҫ<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD>Ƶ<EFBFBD>ַ:%d<><64><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>ַ:%d",
|
|||
|
resource_addr,
|
|||
|
resource_addr + RESOURCE_BASE_ADDR ); //<2F>ļ<EFBFBD><C4BC><EFBFBD>Ҫ<EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԴĿ¼
|
|||
|
|
|||
|
f_open(&file_temp, BURN_INFO_NAME_FULL, FA_OPEN_ALWAYS |FA_WRITE | FA_READ);
|
|||
|
|
|||
|
f_lseek(&file_temp, f_size(&file_temp));
|
|||
|
/* ÿ<><C3BF><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>¼ռ5<D5BC><35> */
|
|||
|
f_printf(&file_temp, "%s\n", full_file_name); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
f_printf(&file_temp, "%s\n", fn); //<2F>ļ<EFBFBD><C4BC><EFBFBD>
|
|||
|
f_printf(&file_temp, "%d\n", file_size); //<2F>ļ<EFBFBD><C4BC><EFBFBD>С
|
|||
|
f_printf(&file_temp, "%d\n\n", resource_addr); //<2F>ļ<EFBFBD><C4BC><EFBFBD>Ҫ<EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԴĿ¼(δ<><CEB4><EFBFBD>ϻ<EFBFBD><CFBB><EFBFBD>ַ)
|
|||
|
|
|||
|
f_close(&file_temp);
|
|||
|
|
|||
|
/* <20><><EFBFBD>е<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣬ƫ<E3A3AC><C6AB><EFBFBD>ļ<EFBFBD>+4096<39><36><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>С */
|
|||
|
// addr_temp = (uint32_t)(file_size+4096)/4096;
|
|||
|
// addr_temp = (uint32_t)addr_temp*4096;
|
|||
|
//
|
|||
|
// resource_addr += addr_temp; /* ƫ<><C6AB><EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>С */
|
|||
|
|
|||
|
resource_addr += file_size; /* ƫ<><C6AB><EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>С */
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ض<EFBFBD><D8B6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7> */
|
|||
|
}//else
|
|||
|
} //for
|
|||
|
}
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Ϣ */
|
|||
|
if(clear == 0)
|
|||
|
{
|
|||
|
BURN_INFO("-------------------------------------\r\n");
|
|||
|
/* ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱresource_addr<64><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>β<EFBFBD><CEB2>ַ */
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С:%d <20><><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>", resource_addr );
|
|||
|
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>ռ<EFBFBD>õĵ<EFBFBD>ַ<EFBFBD>ռ<EFBFBD>:%d - %d",
|
|||
|
RESOURCE_BASE_ADDR,
|
|||
|
resource_addr + RESOURCE_BASE_ADDR );
|
|||
|
}
|
|||
|
|
|||
|
return res;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡĿ¼<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>
|
|||
|
* @param catalog_name[in] <EFBFBD>洢<EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param file_index <EFBFBD><EFBFBD>file_index<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
|||
|
* @param dir[out] Ҫ<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>FLASH<EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD>Ϣ
|
|||
|
* @param full_file_name[out] <EFBFBD><EFBFBD>file_index<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>е<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ȫ·<EFBFBD><EFBFBD>
|
|||
|
* @retval 1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>β<EFBFBD><EFBFBD>0Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
uint8_t Read_CatalogInfo(uint32_t file_index,
|
|||
|
CatalogTypeDef *dir,
|
|||
|
char *full_name)
|
|||
|
{
|
|||
|
uint32_t i;
|
|||
|
|
|||
|
f_open(&file_temp, BURN_INFO_NAME_FULL, FA_OPEN_EXISTING | FA_READ);
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD>ǰN<C7B0><4E>,ÿ<><C3BF><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>¼5<C2BC><35> */
|
|||
|
for(i=0;i<file_index*5;i++)
|
|||
|
{
|
|||
|
f_gets(line_temp, sizeof(line_temp), &file_temp);
|
|||
|
}
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>β*/
|
|||
|
if(f_eof(&file_temp) != 0 )
|
|||
|
return 1;
|
|||
|
|
|||
|
/* <20>ļ<EFBFBD>ȫ·<C8AB><C2B7> */
|
|||
|
f_gets(line_temp, sizeof(line_temp), &file_temp);
|
|||
|
memcpy(full_name, line_temp, strlen(line_temp)+1);
|
|||
|
/* <20>滻<EFBFBD><E6BBBB><EFBFBD>س<EFBFBD> */
|
|||
|
full_name[strlen(full_name)-1] = '\0';
|
|||
|
|
|||
|
/* <20>ļ<EFBFBD><C4BC><EFBFBD> */
|
|||
|
f_gets(line_temp, sizeof(line_temp), &file_temp);
|
|||
|
memcpy(dir->name, line_temp, strlen(line_temp)> (sizeof(CatalogTypeDef)-8) ? (sizeof(CatalogTypeDef)-8):strlen(line_temp)+1 );
|
|||
|
dir->name[strlen(dir->name)-1] = '\0';
|
|||
|
|
|||
|
/* <20>ļ<EFBFBD><C4BC><EFBFBD>С */
|
|||
|
f_gets(line_temp, sizeof(line_temp), &file_temp);
|
|||
|
dir->size = atoi(line_temp);
|
|||
|
|
|||
|
/* <20>ļ<EFBFBD>Ҫ<EFBFBD><D2AA>¼<EFBFBD><C2BC>λ<EFBFBD><CEBB> */
|
|||
|
f_gets(line_temp, sizeof(line_temp), &file_temp);
|
|||
|
dir->offset = atoi(line_temp);
|
|||
|
|
|||
|
f_close(&file_temp);
|
|||
|
|
|||
|
BURN_DEBUG("ful name=%s,\r\nname=%s,\r\nsize=%d,\r\noffset=%d\r\n",
|
|||
|
full_name,
|
|||
|
dir->name,
|
|||
|
dir->size,
|
|||
|
dir->offset
|
|||
|
);
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>¼Ŀ¼<EFBFBD><EFBFBD>FLASH<EFBFBD><EFBFBD>
|
|||
|
* @param catalog_name <EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ŀ¼<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @note ʹ<EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>Ҫȷ<EFBFBD><EFBFBD>flash<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|||
|
* @retval 1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>β<EFBFBD><EFBFBD>0Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void Burn_Catalog(void)
|
|||
|
{
|
|||
|
CatalogTypeDef dir;
|
|||
|
uint8_t i;
|
|||
|
uint8_t is_end;
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD>Ŀ¼<C4BF>ļ<EFBFBD> */
|
|||
|
for(i=0;1;i++)
|
|||
|
{
|
|||
|
is_end = Read_CatalogInfo(i,
|
|||
|
&dir,
|
|||
|
full_file_name);
|
|||
|
/* <20>ѱ<EFBFBD><D1B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD> */
|
|||
|
if(is_end !=0)
|
|||
|
break;
|
|||
|
loop = 0;
|
|||
|
|
|||
|
if(sizeof(dir) == 0)break;//Ϊ0ʱ<30><CAB1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/* <20><>dir<69><72>Ϣ<EFBFBD><CFA2>¼<EFBFBD><C2BC>FLASH<53><48> */
|
|||
|
state = BSP_QSPI_Write((uint8_t*)&dir,RESOURCE_BASE_ADDR + sizeof(dir)*i,sizeof(dir));
|
|||
|
if(state != QSPI_OK)
|
|||
|
{
|
|||
|
BURN_ERROR("Burn_Catalog QSPI_Write ERROR");
|
|||
|
BURN_ERROR("loop=%d",loop);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param catalog_name <EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ŀ¼<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @note ʹ<EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>Ҫȷ<EFBFBD><EFBFBD>flash<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|||
|
* @retval <EFBFBD>ļ<EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
FRESULT Burn_Content(void)
|
|||
|
{
|
|||
|
CatalogTypeDef dir;
|
|||
|
uint8_t i;
|
|||
|
uint8_t is_end;
|
|||
|
|
|||
|
FRESULT result;
|
|||
|
UINT bw; /* File R/W count */
|
|||
|
uint32_t write_addr=0;
|
|||
|
uint8_t tempbuf[256];
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD>Ŀ¼<C4BF>ļ<EFBFBD> */
|
|||
|
for(i=0;1;i++)
|
|||
|
{
|
|||
|
is_end = Read_CatalogInfo(i,
|
|||
|
&dir,
|
|||
|
full_file_name);
|
|||
|
/* <20>ѱ<EFBFBD><D1B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD> */
|
|||
|
if(is_end !=0)
|
|||
|
break;
|
|||
|
|
|||
|
BURN_INFO("-------------------------------------");
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>%s",full_file_name);
|
|||
|
LED_BLUE;
|
|||
|
|
|||
|
result = f_open(&file_temp,full_file_name,FA_OPEN_EXISTING | FA_READ);
|
|||
|
if(result != FR_OK)
|
|||
|
{
|
|||
|
BURN_ERROR("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>");
|
|||
|
LED_RED;
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLASHд<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
|
|||
|
|
|||
|
write_addr = dir.offset + RESOURCE_BASE_ADDR;
|
|||
|
loop = 0;
|
|||
|
while(result == FR_OK)
|
|||
|
{
|
|||
|
loop++;
|
|||
|
result = f_read( &file_temp, tempbuf, 256, &bw);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
if(result!=FR_OK) //ִ<>д<EFBFBD><D0B4><EFBFBD>
|
|||
|
{
|
|||
|
BURN_ERROR("<EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>result = %d",result);
|
|||
|
LED_RED;
|
|||
|
return result;
|
|||
|
}
|
|||
|
if(bw == 0)break;//Ϊ0ʱ<30><CAB1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
state = BSP_QSPI_Write(tempbuf,write_addr,bw); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ⲿflash<73><68>
|
|||
|
if(state != QSPI_OK)
|
|||
|
{
|
|||
|
BURN_ERROR("Burn_Content QSPI_Write ERROR");
|
|||
|
BURN_ERROR("loop=%d bw =%d",loop,bw);
|
|||
|
|
|||
|
}
|
|||
|
write_addr+=bw;
|
|||
|
if(bw !=256)break;
|
|||
|
}
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
|
|||
|
f_close(&file_temp);
|
|||
|
}
|
|||
|
|
|||
|
BURN_INFO("************************************");
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>");
|
|||
|
|
|||
|
return FR_OK;
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* @brief У<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param catalog_name <EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ŀ¼<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @retval <EFBFBD>ļ<EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
*/
|
|||
|
FRESULT Check_Resource(void)
|
|||
|
{
|
|||
|
|
|||
|
CatalogTypeDef dir;
|
|||
|
uint8_t i;
|
|||
|
uint8_t is_end;
|
|||
|
int offset;
|
|||
|
|
|||
|
FRESULT result;
|
|||
|
UINT bw; /* File R/W count */
|
|||
|
uint32_t read_addr=0,j=0;
|
|||
|
uint8_t tempbuf[256],flash_buf[256];
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD>Ŀ¼<C4BF>ļ<EFBFBD> */
|
|||
|
for(i=0;1;i++)
|
|||
|
{
|
|||
|
is_end = Read_CatalogInfo(i,
|
|||
|
&dir,
|
|||
|
full_file_name);
|
|||
|
/* <20>ѱ<EFBFBD><D1B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD> */
|
|||
|
if(is_end !=0)
|
|||
|
break;
|
|||
|
|
|||
|
/* <20><>FLASH<53><48>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD>Ӧ<EFBFBD><D3A6>offset */
|
|||
|
offset = GetResOffset(dir.name);
|
|||
|
if(offset == -1)
|
|||
|
{
|
|||
|
LED_RED;
|
|||
|
BURN_INFO("У<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLASH<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>%s <20><>Ŀ¼",dir.name);
|
|||
|
return FR_NO_FILE;
|
|||
|
}
|
|||
|
else
|
|||
|
dir.offset = offset + RESOURCE_BASE_ADDR;
|
|||
|
|
|||
|
BURN_INFO("-------------------------------------");
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>%s",full_file_name);
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s ",dir.name);
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD>ݾ<EFBFBD><EFBFBD>Ե<EFBFBD>ַ<EFBFBD><EFBFBD>%d ",dir.offset);
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С<EFBFBD><EFBFBD>%d ",dir.size);
|
|||
|
|
|||
|
result = f_open(&file_temp,full_file_name,FA_OPEN_EXISTING | FA_READ);
|
|||
|
if(result != FR_OK)
|
|||
|
{
|
|||
|
BURN_ERROR("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>");
|
|||
|
LED_RED;
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
read_addr = dir.offset;
|
|||
|
|
|||
|
f_lseek(&file_temp,0);
|
|||
|
loop = 0;
|
|||
|
while(result == FR_OK)
|
|||
|
{
|
|||
|
loop++;
|
|||
|
result = f_read( &file_temp, tempbuf, 256, &bw);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
if(result!=FR_OK) //ִ<>д<EFBFBD><D0B4><EFBFBD>
|
|||
|
{
|
|||
|
BURN_ERROR("<EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>");
|
|||
|
LED_RED;
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
if(bw == 0)break;//Ϊ0ʱ<30><CAB1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
state = BSP_QSPI_FastRead(flash_buf,read_addr,bw); //<2F><>FLASH<53>ж<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
if(state != QSPI_OK)
|
|||
|
{
|
|||
|
BURN_ERROR("Check_Resource BSP_QSPI_Read ERROR");
|
|||
|
BURN_ERROR("loop=%d bw =%d",loop,bw);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
read_addr+=bw;
|
|||
|
|
|||
|
for(j=0;j<bw;j++)
|
|||
|
{
|
|||
|
if(tempbuf[j] != flash_buf[j])
|
|||
|
{
|
|||
|
BURN_ERROR("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>");
|
|||
|
BURN_ERROR("j=%d ",j);
|
|||
|
BURN_ERROR("tempbuf");
|
|||
|
BURN_DEBUG_ARRAY(tempbuf,bw);
|
|||
|
BURN_ERROR("flash_buf");
|
|||
|
BURN_DEBUG_ARRAY(flash_buf,bw);
|
|||
|
LED_RED;
|
|||
|
return FR_INT_ERR;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if(bw !=256)break;//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>β
|
|||
|
}
|
|||
|
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
LED_BLUE;
|
|||
|
|
|||
|
f_close(&file_temp);
|
|||
|
}
|
|||
|
|
|||
|
LED_GREEN;
|
|||
|
BURN_INFO("************************************");
|
|||
|
BURN_INFO("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>");
|
|||
|
return FR_OK;
|
|||
|
}
|
|||
|
|
|||
|
/*********************************************END OF FILE**********************/
|
|||
|
|