初版
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,93 @@
|
||||
#ifndef __DEV_MANAGER_H__
|
||||
#define __DEV_MANAGER_H__
|
||||
|
||||
#include "system/includes.h"
|
||||
#include "typedef.h"
|
||||
#include "fs/fs.h"
|
||||
#include "dev_reg.h"
|
||||
|
||||
enum {
|
||||
DEV_MANAGER_ADD_OK = 0x0,
|
||||
DEV_MANAGER_ADD_IN_LIST_AREADY,
|
||||
DEV_MANAGER_ADD_ERR_PARM,
|
||||
DEV_MANAGER_ADD_ERR_NOMEM,
|
||||
DEV_MANAGER_ADD_ERR_NOT_FOUND,
|
||||
DEV_MANAGER_ADD_ERR_MOUNT_FAIL,
|
||||
};
|
||||
|
||||
|
||||
// struct __dev;
|
||||
///设备节点结构体
|
||||
struct __dev {
|
||||
struct list_head entry;
|
||||
struct __dev_reg *parm;//设备参数
|
||||
struct imount *fmnt;
|
||||
volatile u8 valid;//有效设备标记, 这里有效是指是否有可播放文件
|
||||
volatile u32 active_stamp;///活动设备时间戳,通过时间戳记录当前最后活动设备
|
||||
};
|
||||
|
||||
|
||||
//dev_manager增加设备节点
|
||||
int dev_manager_add(char *logo);
|
||||
//dev_manager删除设备节点
|
||||
int dev_manager_del(char *logo);
|
||||
//dev_manager获取设备总数
|
||||
u32 dev_manager_get_total(u8 valid);
|
||||
//dev_manager通过设备节点检查设备是否在设备链表中
|
||||
struct __dev *dev_manager_check(struct __dev *dev);
|
||||
//dev_manager通过逻辑盘符检查设备是否在设备链表中
|
||||
struct __dev *dev_manager_check_by_logo(char *logo);
|
||||
//dev_manager查找第一个设备
|
||||
struct __dev *dev_manager_find_first(u8 valid);
|
||||
//dev_manager查找最后一个设备
|
||||
struct __dev *dev_manager_find_last(u8 valid);
|
||||
//dev_manager查找参数设备的前一个设备
|
||||
struct __dev *dev_manager_find_prev(struct __dev *dev, u8 valid);
|
||||
//dev_manager查找参数设备的后一个设备
|
||||
struct __dev *dev_manager_find_next(struct __dev *dev, u8 valid);
|
||||
//dev_manager查找最后活动设备
|
||||
struct __dev *dev_manager_find_active(u8 valid);
|
||||
//dev_manager查找指定逻辑盘符对应的设备
|
||||
struct __dev *dev_manager_find_spec(char *logo, u8 valid);
|
||||
//dev_manager查找指定序号设备
|
||||
struct __dev *dev_manager_find_by_index(u32 index, u8 valid);
|
||||
//dev_manager设定指定设备节点设备有效
|
||||
void dev_manager_set_valid(struct __dev *dev, u8 flag);
|
||||
//dev_manager设定指定设备节点设备为最后活动设备
|
||||
void dev_manager_set_active(struct __dev *dev);
|
||||
//dev_manager设定指定逻辑盘符的设备有效
|
||||
void dev_manager_set_valid_by_logo(char *logo, u8 flag);
|
||||
//dev_manager设定指定逻辑盘符的设备为最后活动设备
|
||||
void dev_manager_set_active_by_logo(char *logo);
|
||||
//dev_manager获取指定设备节点的逻辑盘符
|
||||
char *dev_manager_get_logo(struct __dev *dev);
|
||||
//获取物理设备节点的逻辑盘符(去掉_rec后缀)
|
||||
char *dev_manager_get_phy_logo(struct __dev *dev);
|
||||
//获取录音文件夹设备节点的逻辑盘符(追加_rec后缀)
|
||||
char *dev_manager_get_rec_logo(struct __dev *dev);
|
||||
//dev_manager获取指定设备节点的文件系统根目录
|
||||
char *dev_manager_get_root_path(struct __dev *dev);
|
||||
//dev_manager获取指定逻辑盘符的设备的文件系统根目录
|
||||
char *dev_manager_get_root_path_by_logo(char *logo);
|
||||
//dev_manager通过设备节点获取设备mount信息
|
||||
struct imount *dev_manager_get_mount_hdl(struct __dev *dev);
|
||||
//dev_manager通过设备节点检查设备是否在线
|
||||
int dev_manager_online_check(struct __dev *dev, u8 valid);
|
||||
//dev_manager通过逻辑盘符检查设备是否在线
|
||||
int dev_manager_online_check_by_logo(char *logo, u8 valid);
|
||||
//通过逻辑盘符判断设备是否在设备链表中
|
||||
struct __dev *dev_manager_list_check_by_logo(char *logo);
|
||||
//检查链表中没有挂载的设备并重新挂载
|
||||
void dev_manager_list_check_mount(void);
|
||||
//设备挂载
|
||||
int dev_manager_mount(char *logo);
|
||||
//设备卸载
|
||||
int dev_manager_unmount(char *logo);
|
||||
|
||||
//dev_manager初始化
|
||||
void dev_manager_init(void);
|
||||
|
||||
void dev_manager_var_init();
|
||||
|
||||
#endif//__DEV_MANAGER_H__
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
#ifdef SUPPORT_MS_EXTENSIONS
|
||||
#pragma bss_seg(".dev_reg.data.bss")
|
||||
#pragma data_seg(".dev_reg.data")
|
||||
#pragma const_seg(".dev_reg.text.const")
|
||||
#pragma code_seg(".dev_reg.text")
|
||||
#endif
|
||||
#include "dev_reg.h"
|
||||
#include "app_config.h"
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 设备配置表
|
||||
@param 具体配置项请看struct __dev_reg结构体描述
|
||||
@return
|
||||
@note 注意:
|
||||
例如logo逻辑盘符sd0_rec/sd1_rec/udisk_rec是做录音文件夹区分使用的,
|
||||
在定义新的设备逻辑盘发的时候, 注意避开"_rec"后缀作为设备逻辑盘符
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
const struct __dev_reg dev_reg[] = {
|
||||
#if defined TCFG_CODE_FLASH_ENABLE && TCFG_CODE_FLASH_ENABLE
|
||||
//内置flash
|
||||
{
|
||||
/*logo*/ SDFILE_DEV,
|
||||
/*name*/ NULL,
|
||||
/*storage_path*/ SDFILE_MOUNT_PATH,
|
||||
/*root_path*/ SDFILE_RES_ROOT_PATH,
|
||||
/*fs_type*/ "sdfile",
|
||||
},
|
||||
#endif
|
||||
#if FLASH_INSIDE_REC_ENABLE
|
||||
//内置录音
|
||||
{
|
||||
/*logo*/ "rec_sdfile",
|
||||
/*name*/ NULL,
|
||||
/*storage_path*/ "mnt/rec_sdfile",
|
||||
/*root_path*/ "mnt/rec_sdfile/C/",
|
||||
/*fs_type*/ "rec_sdfile",
|
||||
},
|
||||
#endif
|
||||
#if (TCFG_SD0_ENABLE)
|
||||
//sd0
|
||||
{
|
||||
/*logo*/ "sd0",
|
||||
/*name*/ "sd0",
|
||||
/*storage_path*/ "storage/sd0",
|
||||
/*root_path*/ "storage/sd0/C/",
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if (TCFG_SD1_ENABLE)
|
||||
//sd1
|
||||
{
|
||||
/*logo*/ "sd1",
|
||||
/*name*/ "sd1",
|
||||
/*storage_path*/ "storage/sd1",
|
||||
/*root_path*/ "storage/sd1/C/",
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if (TCFG_UDISK_ENABLE)
|
||||
//u盘
|
||||
{
|
||||
/*logo*/ "udisk0",
|
||||
/*name*/ "udisk0",
|
||||
/*storage_path*/ "storage/udisk0",
|
||||
/*root_path*/ "storage/udisk0/C/",
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if (TCFG_SD0_ENABLE && TCFG_RECORD_FOLDER_DEV_ENABLE)
|
||||
//sd0录音文件夹分区
|
||||
{
|
||||
/*logo*/ "sd0_rec",
|
||||
/*name*/ "sd0",
|
||||
/*storage_path*/ "storage/sd0",
|
||||
/*root_path*/ "storage/sd0/C/"REC_FOLDER_NAME,
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if (TCFG_SD1_ENABLE && TCFG_RECORD_FOLDER_DEV_ENABLE)
|
||||
//sd1录音文件夹分区
|
||||
{
|
||||
/*logo*/ "sd1_rec",
|
||||
/*name*/ "sd1",
|
||||
/*storage_path*/ "storage/sd1",
|
||||
/*root_path*/ "storage/sd1/C/"REC_FOLDER_NAME,
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if (TCFG_UDISK_ENABLE && TCFG_RECORD_FOLDER_DEV_ENABLE)
|
||||
//u盘录音文件夹分区
|
||||
{
|
||||
/*logo*/ "udisk0_rec",
|
||||
/*name*/ "udisk0",
|
||||
/*storage_path*/ "storage/udisk0",
|
||||
/*root_path*/ "storage/udisk0/C/"REC_FOLDER_NAME,
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if TCFG_NOR_FAT
|
||||
//外挂fat分区
|
||||
{
|
||||
/*logo*/ "fat_nor",
|
||||
/*name*/ "fat_nor",
|
||||
/*storage_path*/ "storage/fat_nor",
|
||||
/*root_path*/ "storage/fat_nor/C/",
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if TCFG_NOR_FS
|
||||
//外挂flash资源分区
|
||||
{
|
||||
/*logo*/ "res_nor",
|
||||
/*name*/ "res_nor",
|
||||
/*storage_path*/ "storage/res_nor",
|
||||
/*root_path*/ "storage/res_nor/C/",
|
||||
/*fs_type*/ "nor_sdfile",
|
||||
},
|
||||
#endif
|
||||
#if TCFG_NOR_REC
|
||||
///外挂录音分区
|
||||
{
|
||||
/*logo*/ "rec_nor",
|
||||
/*name*/ "rec_nor",
|
||||
/*storage_path*/ "storage/rec_nor",
|
||||
/*root_path*/ "storage/rec_nor/C/",
|
||||
/*fs_type*/ "rec_fs",
|
||||
},
|
||||
#endif
|
||||
{
|
||||
/*logo*/ "nor_ui",
|
||||
/*name*/ "nor_ui",
|
||||
/*storage_path*/ "storage/nor_ui",
|
||||
/*root_path*/ "storage/nor_ui/C/",
|
||||
/*fs_type*/ "nor_sdfile",
|
||||
},
|
||||
#if TCFG_VIR_UDISK_ENABLE
|
||||
// 虚拟U盘
|
||||
{
|
||||
/*logo*/ "vir_udisk0",
|
||||
/*name*/ "vir_udisk0",
|
||||
/*storage_path*/ "storage/vir_udisk0",
|
||||
/*root_path*/ "storage/vir_udisk0/C/",
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if TCFG_VIRFAT_FLASH_ENABLE
|
||||
//flash 虚拟fat
|
||||
{
|
||||
/*logo*/ "virfat_flash",
|
||||
/*name*/ "virfat_flash",
|
||||
/*storage_path*/ "storage/virfat_flash",
|
||||
/*root_path*/ "storage/virfat_flash/C/",
|
||||
/*fs_type*/ "sdfile_fat",
|
||||
},
|
||||
#endif
|
||||
#if TCFG_SDFILE_INSERT_FLASH_ENABLE || TCFG_SDFILE_EXTERN_FLASH_ENABLE
|
||||
// 用于存储JL font sidebar
|
||||
{
|
||||
/*logo*/ "res_nor_mode",
|
||||
/*name*/ "res_nor_mode",
|
||||
/*storage_path*/ "storage/res_nor_mode",
|
||||
/*root_path*/ "storage/res_nor_mode/C/",
|
||||
/*fs_type*/ "ex_sdfile",
|
||||
},
|
||||
#endif
|
||||
#if (defined TCFG_NANDFLASH_DEV_ENABLE && TCFG_NANDFLASH_DEV_ENABLE)
|
||||
{
|
||||
/*logo*/ "nandflash_ftl",
|
||||
/*name*/ "nandflash_ftl",
|
||||
/*storage_path*/ "storage/nandflash_ftl",
|
||||
/*root_path*/ "storage/nandflash_ftl/C/",
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if (defined TCFG_NANDFLASH_FAT_ENABLE && TCFG_NANDFLASH_FAT_ENABLE)
|
||||
//外挂fat分区
|
||||
{
|
||||
/*logo*/ TCFG_NANDFLASH_FAT_ROOT,
|
||||
/*name*/ TCFG_NANDFLASH_FAT_ROOT,
|
||||
/*storage_path*/ "storage/"TCFG_NANDFLASH_FAT_ROOT,
|
||||
/*root_path*/ "storage/"TCFG_NANDFLASH_FAT_ROOT"/C/",
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
#if (defined TCFG_NANDFLASH_UI_FAT_ENABLE&&TCFG_NANDFLASH_UI_FAT_ENABLE )
|
||||
//外挂fat分区
|
||||
{
|
||||
/*logo*/ TCFG_NANDFLASH_UI_FAT_LOGO,
|
||||
/*name*/ TCFG_NANDFLASH_UI_FAT_LOGO,
|
||||
/*storage_path*/ "storage/"TCFG_NANDFLASH_UI_FAT_LOGO,
|
||||
/*root_path*/ "storage/"TCFG_NANDFLASH_UI_FAT_LOGO"/C/",
|
||||
/*fs_type*/ "fat",
|
||||
},
|
||||
#endif
|
||||
//<新加设备参数请在reg end前添加!!
|
||||
//<reg end
|
||||
{
|
||||
/*logo*/ NULL,
|
||||
/*name*/ NULL,
|
||||
/*storage_path*/ NULL,
|
||||
/*root_path*/ NULL,
|
||||
/*fs_type*/ NULL,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef __DEV_REG_H__
|
||||
#define __DEV_REG_H__
|
||||
|
||||
#include "system/includes.h"
|
||||
#include "typedef.h"
|
||||
|
||||
///设备参数控制句柄
|
||||
struct __dev_reg {
|
||||
char *logo;//设备选择使用的逻辑盘符
|
||||
char *name;//设备名称,底层匹配设备节点使用
|
||||
char *storage_path;//设备路径,文件系统mount时使用
|
||||
char *root_path;//设备文件系统根目录
|
||||
char *fs_type;//文件系统类型,如:fat, sdfile
|
||||
};
|
||||
|
||||
|
||||
extern const struct __dev_reg dev_reg[];
|
||||
|
||||
#endif//__DEV_REG_H__
|
||||
|
||||
|
||||
@@ -0,0 +1,362 @@
|
||||
#ifdef SUPPORT_MS_EXTENSIONS
|
||||
#pragma bss_seg(".dev_update.data.bss")
|
||||
#pragma data_seg(".dev_update.data")
|
||||
#pragma const_seg(".dev_update.text.const")
|
||||
#pragma code_seg(".dev_update.text")
|
||||
#endif
|
||||
#include "dev_update.h"
|
||||
#include "dev_manager.h"
|
||||
#include "update/update.h"
|
||||
#include "update/update_loader_download.h"
|
||||
#include "app_config.h"
|
||||
#include "btcontroller_modules.h"
|
||||
#include "trim.h"
|
||||
|
||||
#if TCFG_DEV_UPDATE_EN
|
||||
|
||||
#if defined(CONFIG_SD_UPDATE_ENABLE) || defined(CONFIG_USB_UPDATE_ENABLE)
|
||||
#define DEV_UPDATE_EN 1
|
||||
#else
|
||||
#define DEV_UPDATE_EN 0
|
||||
#endif
|
||||
|
||||
#define STR(x) #x
|
||||
#define STRCHANGE(x) STR(x)
|
||||
|
||||
|
||||
extern bool uart_update_send_update_ready(char *file_path);
|
||||
extern bool get_uart_update_sta(void);
|
||||
extern void latch_reset(void);
|
||||
|
||||
static char update_path[48] = {0};
|
||||
extern const char updata_file_name[];
|
||||
|
||||
struct __update_dev_reg {
|
||||
char *logo;
|
||||
int type;
|
||||
union {
|
||||
UPDATA_SD sd;
|
||||
UPDATE_UDISK udisk;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
||||
#if TCFG_SD0_ENABLE
|
||||
static struct __update_dev_reg sd0_update = {
|
||||
.logo = "sd0",
|
||||
.type = SD0_UPDATA,
|
||||
.u.sd.control_type = SD_CONTROLLER_0,
|
||||
#ifdef TCFG_SD0_PORT_CMD
|
||||
.u.sd.control_io_clk = TCFG_SD0_PORT_CLK,
|
||||
.u.sd.control_io_cmd = TCFG_SD0_PORT_CMD,
|
||||
.u.sd.control_io_dat = TCFG_SD0_PORT_DA0,
|
||||
#else
|
||||
#if (TCFG_SD0_PORTS=='A')
|
||||
.u.sd.control_io = SD0_IO_A,
|
||||
#elif (TCFG_SD0_PORTS=='B')
|
||||
.u.sd.control_io = SD0_IO_B,
|
||||
#elif (TCFG_SD0_PORTS=='C')
|
||||
.u.sd.control_io = SD0_IO_C,
|
||||
#elif (TCFG_SD0_PORTS=='D')
|
||||
.u.sd.control_io = SD0_IO_D,
|
||||
#elif (TCFG_SD0_PORTS=='E')
|
||||
.u.sd.control_io = SD0_IO_E,
|
||||
#elif (TCFG_SD0_PORTS=='F')
|
||||
.u.sd.control_io = SD0_IO_F,
|
||||
#endif
|
||||
#endif
|
||||
.u.sd.power = 1,
|
||||
};
|
||||
#endif//TCFG_SD0_ENABLE
|
||||
|
||||
#if TCFG_SD1_ENABLE
|
||||
static const struct __update_dev_reg sd1_update = {
|
||||
.logo = "sd1",
|
||||
.type = SD1_UPDATA,
|
||||
.u.sd.control_type = SD_CONTROLLER_1,
|
||||
#if (TCFG_SD1_PORTS=='A')
|
||||
.u.sd.control_io = SD1_IO_A,
|
||||
#else
|
||||
.u.sd.control_io = SD1_IO_B,
|
||||
#endif
|
||||
.u.sd.power = 1,
|
||||
|
||||
};
|
||||
#endif//TCFG_SD1_ENABLE
|
||||
|
||||
#if TCFG_UDISK_ENABLE
|
||||
static const struct __update_dev_reg udisk_update = {
|
||||
.logo = "udisk0",
|
||||
.type = USB_UPDATA,
|
||||
};
|
||||
#endif//TCFG_UDISK_ENABLE
|
||||
|
||||
|
||||
static const struct __update_dev_reg *update_dev_list[] = {
|
||||
#if TCFG_UDISK_ENABLE
|
||||
&udisk_update,
|
||||
#endif//TCFG_UDISK_ENABLE
|
||||
#if TCFG_SD0_ENABLE
|
||||
&sd0_update,
|
||||
#endif//
|
||||
#if TCFG_SD1_ENABLE
|
||||
&sd1_update,
|
||||
#endif//TCFG_SD1_ENABLE
|
||||
};
|
||||
|
||||
void *dev_update_get_parm(int type)
|
||||
{
|
||||
struct __update_dev_reg *parm = NULL;
|
||||
for (int i = 0; i < ARRAY_SIZE(update_dev_list); i++) {
|
||||
if (update_dev_list[i]->type == type) {
|
||||
parm = (struct __update_dev_reg *)update_dev_list[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (parm == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (parm->type == USB_UPDATA) {
|
||||
return (void *)&parm->u.udisk;
|
||||
}
|
||||
return (void *)&parm->u.sd;
|
||||
}
|
||||
|
||||
|
||||
struct strg_update {
|
||||
void *fd;
|
||||
char *update_path;
|
||||
};
|
||||
static struct strg_update strg_update = {0};
|
||||
#define __this (&strg_update)
|
||||
|
||||
static u16 strg_f_open(void)
|
||||
{
|
||||
if (!__this->update_path) {
|
||||
printf("file path err ");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (__this->fd) {
|
||||
return true;
|
||||
/* fclose(__this->fd);
|
||||
__this->fd = NULL; */
|
||||
}
|
||||
__this->fd = fopen(__this->update_path, "r");
|
||||
if (!__this->fd) {
|
||||
printf("file open err ");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static u16 strg_f_read(void *fp, u8 *buff, u16 len)
|
||||
{
|
||||
if (!__this->fd) {
|
||||
return (u16) - 1;
|
||||
}
|
||||
|
||||
len = fread(buff, len, 1, __this->fd);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int strg_f_seek(void *fp, u8 type, u32 offset)
|
||||
{
|
||||
if (!__this->fd) {
|
||||
return (int) - 1;
|
||||
}
|
||||
|
||||
int ret = fseek(__this->fd, offset, type);
|
||||
/* return 0; // 0k */
|
||||
return ret;
|
||||
}
|
||||
static u16 strg_f_stop(u8 err)
|
||||
{
|
||||
if (__this->fd) {
|
||||
fclose(__this->fd);
|
||||
__this->fd = NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int strg_update_set_file_path_and_hdl(char *update_path, void *fd)
|
||||
{
|
||||
__this->update_path = update_path;
|
||||
__this->fd = fd;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static const update_op_api_t strg_dev_update_op = {
|
||||
.f_open = strg_f_open,
|
||||
.f_read = strg_f_read,
|
||||
.f_seek = strg_f_seek,
|
||||
.f_stop = strg_f_stop,
|
||||
};
|
||||
|
||||
void update_param_ext_fill(UPDATA_PARM *p, u8 ext_type, u8 *ext_data, u8 ext_len);
|
||||
static void dev_update_param_private_handle(UPDATA_PARM *p)
|
||||
{
|
||||
// cppcheck-suppress unreadVariable
|
||||
u16 up_type = p->parm_type;
|
||||
|
||||
#ifdef CONFIG_SD_UPDATE_ENABLE
|
||||
if ((up_type == SD0_UPDATA) || (up_type == SD1_UPDATA)) {
|
||||
int sd_start = (u32)p->parm_priv;
|
||||
void *sd = NULL;
|
||||
sd = dev_update_get_parm(up_type);
|
||||
if (sd) {
|
||||
#if defined(TCFG_SD0_POWER_PORT)
|
||||
sprintf((char *)&sd0_update.u.sd.io_det_func, "P%c%02d", TCFG_SD0_POWER_PORT / 16 + 'A', TCFG_SD0_POWER_PORT % 16);
|
||||
sd0_update.u.sd.power = 0;
|
||||
printf(">>>[test]:sd0_update.u.sd.io_det_func = %s, power = %d\n", (char *)&sd0_update.u.sd.io_det_func, sd0_update.u.sd.power);
|
||||
#endif
|
||||
memcpy((void *)sd_start, sd, UPDATE_PRIV_PARAM_LEN);
|
||||
} else {
|
||||
memset((void *)sd_start, 0, UPDATE_PRIV_PARAM_LEN);
|
||||
}
|
||||
|
||||
char io_port_stirng[4 * 3 + 1] = {0};
|
||||
sprintf(&io_port_stirng[0], "P%c%02d", TCFG_SD0_PORT_CLK / 16 + 'A', TCFG_SD0_PORT_CLK % 16);
|
||||
sprintf(&io_port_stirng[4], "P%c%02d", TCFG_SD0_PORT_CMD / 16 + 'A', TCFG_SD0_PORT_CMD % 16);
|
||||
sprintf(&io_port_stirng[8], "P%c%02d", TCFG_SD0_PORT_DA0 / 16 + 'A', TCFG_SD0_PORT_DA0 % 16);
|
||||
update_param_ext_fill(p, EXT_SD_IO_INFO, (u8 *)io_port_stirng, sizeof(io_port_stirng));
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_UPDATE_ENABLE
|
||||
if (up_type == USB_UPDATA) {
|
||||
printf("usb updata ");
|
||||
UPDATE_UDISK *usb_start = (UPDATE_UDISK *)p->parm_priv;
|
||||
memset((void *)usb_start, 0, UPDATE_PRIV_PARAM_LEN);
|
||||
void *usb = dev_update_get_parm(up_type);
|
||||
if (usb) {
|
||||
memcpy((void *)usb_start, usb, UPDATE_PRIV_PARAM_LEN);
|
||||
#ifdef CONFIG_CPU_BR27
|
||||
usb_start->u.param.rx_ldo_trim = trim_get_usb_rx_ldo();
|
||||
usb_start->u.param.tx_ldo_trim = trim_get_usb_tx_ldo();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_UPDATE_JUMP_TO_MASK
|
||||
memcpy(p->file_patch, STRCHANGE(CONFIG_SD_LATCH_IO), 32);
|
||||
#else
|
||||
memcpy(p->file_patch, updata_file_name, strlen(updata_file_name));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void dev_update_before_jump_handle(int up_type)
|
||||
{
|
||||
#if CONFIG_UPDATE_JUMP_TO_MASK
|
||||
y_printf(">>>[test]:latch reset update\n");
|
||||
latch_reset();
|
||||
#else
|
||||
cpu_reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void dev_update_state_cbk(int type, u32 state, void *priv)
|
||||
{
|
||||
update_ret_code_t *ret_code = (update_ret_code_t *)priv;
|
||||
|
||||
switch (state) {
|
||||
case UPDATE_CH_EXIT:
|
||||
if ((0 == ret_code->stu) && (0 == ret_code->err_code)) {
|
||||
update_mode_api_v2(type,
|
||||
dev_update_param_private_handle,
|
||||
dev_update_before_jump_handle);
|
||||
} else {
|
||||
printf("update fail, cpu reset!!!\n");
|
||||
cpu_reset();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
u16 dev_update_check(char *logo)
|
||||
{
|
||||
if ((update_success_boot_check() == true) || !CONFIG_UPDATE_STORAGE_DEV_EN) {
|
||||
return UPDATA_NON;
|
||||
}
|
||||
struct __dev *dev = dev_manager_find_spec(logo, 0);
|
||||
if (dev) {
|
||||
#if DEV_UPDATE_EN
|
||||
//<查找设备升级配置
|
||||
struct __update_dev_reg *parm = NULL;
|
||||
for (int i = 0; i < ARRAY_SIZE(update_dev_list); i++) {
|
||||
if (0 == strcmp(update_dev_list[i]->logo, logo)) {
|
||||
parm = (struct __update_dev_reg *)update_dev_list[i];
|
||||
}
|
||||
}
|
||||
if (parm == NULL) {
|
||||
printf("dev update without parm err!!!\n");
|
||||
return UPDATA_PARM_ERR;
|
||||
}
|
||||
|
||||
//最新设备升级只支持fat32(省flash空间),此处截断
|
||||
struct vfs_partition *part = fget_partition((const char *)dev_manager_get_root_path(dev));
|
||||
if (part) {
|
||||
// fs_type: 1为fat12 、2 为fat16 、3为fat32 、4为exfat
|
||||
if (part->fs_type != 3) {
|
||||
printf(">>>[test]:dev update only support fat32 !!!\n");
|
||||
return UPDATA_PARM_ERR;
|
||||
}
|
||||
} else {
|
||||
printf(">>>[test]:dev part err!!!\n");
|
||||
return UPDATA_PARM_ERR;
|
||||
}
|
||||
|
||||
//<尝试按照路径打开升级文件
|
||||
char *updata_file = (char *)updata_file_name;
|
||||
if (*updata_file == '/') {
|
||||
updata_file ++;
|
||||
}
|
||||
memset(update_path, 0, sizeof(update_path));
|
||||
sprintf(update_path, "%s%s", dev_manager_get_root_path(dev), updata_file);
|
||||
printf("update_path: %s\n", update_path);
|
||||
FILE *fd = fopen(update_path, "r");
|
||||
if (!fd) {
|
||||
//没有升级文件, 继续跑其他解码相关的流程
|
||||
printf("open update file err!!!\n");
|
||||
return UPDATA_DEV_ERR;
|
||||
}
|
||||
|
||||
#if(TCFG_UPDATE_UART_IO_EN) && (TCFG_UPDATE_UART_ROLE)
|
||||
uart_update_send_update_ready(update_path);
|
||||
while (get_uart_update_sta()) {
|
||||
os_time_dly(10);
|
||||
}
|
||||
#else
|
||||
//进行升级
|
||||
strg_update_set_file_path_and_hdl(update_path, (void *)fd);
|
||||
|
||||
update_mode_info_t info = {
|
||||
.type = parm->type,
|
||||
.state_cbk = dev_update_state_cbk,
|
||||
.p_op_api = &strg_dev_update_op,
|
||||
.task_en = 0,
|
||||
};
|
||||
app_active_update_task_init(&info);
|
||||
|
||||
#endif
|
||||
#endif//DEV_UPDATE_EN
|
||||
}
|
||||
return UPDATA_READY;
|
||||
}
|
||||
|
||||
#else // TCFG_dev_UPDATE_EN
|
||||
|
||||
u16 dev_update_check(char *logo)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *dev_update_get_parm(int type)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // TCFG_dev_UPDATE_EN
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef __DEV_UPDATE_H__
|
||||
#define __DEV_UPDATE_H__
|
||||
|
||||
#include "typedef.h"
|
||||
#include "system/includes.h"
|
||||
|
||||
void *dev_update_get_parm(int type);
|
||||
u16 dev_update_check(char *logo);
|
||||
|
||||
#endif//__DEV_UPDATE_H__
|
||||
Reference in New Issue
Block a user