杰理-7014配置

杰理-7014配置

1.复制 7012A7 添加一个板级在这里插入图片描述在这里插入图片描述

在这里插入图片描述

2.根据自己的功能修改板级 & 以下修改(4M 7014f3)

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

download.bat 修改调用文件
在这里插入图片描述

0x3E0000计算方法
在这里插入图片描述

在这里插入图片描述

@echo off

@echo ********************************************************************************
@echo 			SDK BR28			
@echo ********************************************************************************
@echo %date%

cd %~dp0


copy ..\..\script.ver .
copy ..\..\uboot.boot .
copy ..\..\ota.bin .
::copy ..\..\ota_all.bin .
::copy ..\..\ota_nor.bin .
copy ..\..\tone.cfg .
copy ..\..\cfg_tool.bin .
copy ..\..\app.bin .
copy ..\..\br28loader.bin .
copy ..\..\user_api.bin .
copy ..\..\isd_config.ini .
copy ..\..\p11_code.bin .
::copy ..\..\config.dat .
copy ..\..\jl7014n.key .\default.key
copy ..\..\json.txt .
copy ..\..\eq_cfg_hw.bin .
copy ..\..\flash_params.bin .

cd ..\..\ui_resource
copy *.* ..\download\watch

cd %~dp0

cd ..\..\ui_upgrade
copy *.* ..\download\watch\ui_upgrade
cd %~dp0


..\..\json_to_res.exe json.txt
..\..\md5sum.exe app.bin md5.bin
set /p "themd5=" < "md5.bin"

..\..\packres.exe -keep-suffix-case JL.sty JL.res JL.str -n res -o JL
..\..\packres.exe -keep-suffix-case sidebar.sty sidebar.res sidebar.str sidebar.tab -n res -o sidebar
..\..\packres.exe -keep-suffix-case watch.sty watch.res watch.str watch.view watch.json -n res -o watch
..\..\packres.exe -keep-suffix-case F_ASCII.PIX ascii.res -n res -o font

::echo %1

set CHIPKEY=default.key

:: 8MBytes
..\..\fat_comm.exe -pad-backup2 -force-align-fat -out new_res.bin -image-size 4 -filelist  JL sidebar watch  font  -remove-empty -remove-bpb -mark-bad-after 0x3E0000 -address 0
:: 16MBytes
::..\..\fat_comm.exe -pad-backup2 -force-align-fat -out new_res.bin -image-size 16 -filelist  JL sidebar watch watch1 watch2 watch3 watch4 watch5 font  -remove-empty -remove-bpb -mark-bad-after 0xe60000 -address 0

IF %ERRORLEVEL% NEQ 0 goto exit_point

del /Q res.ori\*
del upgrade.zip
move JL res.ori\JL
move watch? res.ori\
move font res.ori\font

..\..\packres.exe -n res -o res.bin new_res.bin 0 -normal
::����flash�������ļ���ʾ��Ϊ����0xb00000��ַ����Ҫ������nor_up.ufw
::..\..\packres.exe -n res -o res.bin new_res.bin 0 nor_up.ufw 0xb00000 -normal


..\..\isd_download.exe -tonorflash -dev br28 -boot 0x120000 -div8 -wait 300 -uboot uboot.boot -app app.bin cfg_tool.bin -res ui_upgrade p11_code.bin config.dat tone.cfg eq_cfg_hw.bin -flash-params flash_params.bin -uboot_compress -key %CHIPKEY% -ex_api_bin user_api.bin -reboot 2500
::..\..\isd_download.exe -tonorflash -dev br28 -boot 0x120000 -div8 -wait 300 -uboot uboot.boot -app app.bin cfg_tool.bin -res p11_code.bin config.dat -uboot_compress -key %CHIPKEY% -ex_flash res.bin -ex_api_bin user_api.bin 
::-format all
::-ex_flash res.bin

:: -format all
::-reboot 2500
:: -key xxxx.key

::-format all
::-reboot 100


@rem ɾ����ʱ�ļ�-format all
if exist *.mp3 del *.mp3 
if exist *.PIX del *.PIX
if exist *.TAB del *.TAB
if exist *.res del *.res
if exist *.sty del *.sty
if exist *.str del *.str
if exist *.anim del *.anim
if exist *.view del *.view
if exist *.json del *.json



..\..\ufw_maker.exe -fw_to_ufw jl_isd.fw
copy jl_isd.ufw update.ufw
del jl_isd.ufw

::..\..\zip.exe -r upgrade.zip res.ori update.ufw
..\..\zip.exe -r upgrade.zip update.ufw

@REM ���������ļ������ļ�
::ufw_maker.exe -chip AC800X %ADD_KEY% -output config.ufw -res bt_cfg.cfg

::IF EXIST jl_693x.bin del jl_693x.bin 


@rem ��������˵��
@rem -format vm        //����VM ����
@rem -format cfg       //����BT CFG ����
@rem -format 0x3f0-2   //��ʾ�ӵ� 0x3f0 �� sector ��ʼ�������� 2 �� sector(��һ������Ϊ16���ƻ�10���ƶ��ɣ��ڶ�������������10����)

:exit_point

ping /n 2 127.1>null
IF EXIST null del null
::pause

isd_config.ini 配置

在这里插入图片描述

user_file_download.c

#include "app_config.h"
#include "typedef.h"
#include "fs.h"
#include "norflash.h"
#include "spi/nor_fs.h"
#include "rec_nor/nor_interface.h"
#include "update_loader_download.h"

#if (USER_FILE_UPDATE_V2_EN)
#define LOG_TAG "[UP_FILE_DNLD]"
#define LOG_INFO_ENABLE
#define LOG_ERROR_ENABLE
#include "system/debug.h"

#define ONCE_REQ_SIZE		(0x200)
#define FLASH_SECTOR_SIZE	(4096L)
#define __SECTOR_4K_ALIGN(len) (((len) + FLASH_SECTOR_SIZE -1 )/FLASH_SECTOR_SIZE * FLASH_SECTOR_SIZE)

#define FLASH_BLOCK_SIZE    (64*1024L)
#define __BLOCK_64K_ALIGN(len) (((len) + FLASH_BLOCK_SIZE -1 )/FLASH_BLOCK_SIZE * FLASH_BLOCK_SIZE)

#define USER_FILE_FLASH_ERASE_IN_4K           1
#define USER_FILE_FLASH_UPDATE_DEBUG_ENABLE   0

#define USER_FILE_FLASH_UPDATE_WRITE_TASK_NAME		"ex_f_update"

#define EX_FLASH_CHECK_EXIT_WIRTE_TASK_TIME		(100) // ms

typedef struct _user_file_base_info_t {
    struct list_head 	entry;
    user_chip_update_info_t *(*get_res_base_info)(void *priv,
            u32(**local_read_hdl)(void *buf, u32 addr, u32 len),
            u32(**local_write_hdl)(void *buf, u32 addr, u32 len),
            u32(**local_erase_hdl)(u32 cmd, u32 addr));
    int (*user_chip_release_opt)(user_chip_update_info_t *update_info);
    void *priv;
} user_file_base_info_t;

typedef struct _user_file_update_info_t {
    struct list_head 	list;
    update_op_api_t *file_ops;
    u8 *buf;
    u8 exit_write_task_flag;
    u8 en;
} user_file_update_info_t;

typedef struct _program_info_t {
    u32 remote_file_begin;
    u32 remote_file_length;
    u32 local_program_addr;
    u32(*remote_file_read)(void *buf, u32 addr, u32 len);
    u32(*local_write_hdl)(void *buf, u32 addr, u32 len);
    u32(*local_erase_hdl)(u32 cmd, u32 addr);
    u8 *buf;
} program_info_t;

static u32 g_once_req_size = ONCE_REQ_SIZE;
static u16 g_exit_opt_timer_hdl = 0;

#define USER_FILE_UPDATE_SEMAPHORE_WAIT_TIME  (500)
static volatile int g_user_file_update_timeout = USER_FILE_UPDATE_SEMAPHORE_WAIT_TIME;

static user_file_update_info_t *user_info = NULL;
#define __this (user_info)

extern struct list_head *reserve_file_update_init(void *priv, u8 type, u8 *file_name, int (*update_info_get)(u8 type, user_chip_update_info_t *info, void *priv));
extern struct list_head *ext_flash_file_update_init(void *priv, u8 type, u8 *file_name, int (*update_info_get)(u8 type, user_chip_update_info_t *info, void *priv));
extern struct list_head *nand_flash_file_update_init(void *priv, u8 type, u8 *file_name, int (*update_info_get)(u8 type, user_chip_update_info_t *info, void *priv));
extern struct list_head *nand_zone_file_update_init(void *priv, u8 type, u8 *file_name, int (*update_info_get)(u8 type, user_chip_update_info_t *info, void *priv));

static u32 remote_file_read(void *buf, u32 addr, u32 len)
{
    u32 ret = 0;
    if (__this && __this->file_ops) {
        putchar('%');
        __this->file_ops->f_seek(NULL, SEEK_SET, addr);
        if ((u16) - 1 == __this->file_ops->f_read(NULL, buf, len)) {
            ret = (u32) - 1;
        }
    }

    return ret;
}

static int user_file_update_init(void *priv, update_op_api_t *file_ops, u8 type, u8 *file_name, int (*update_info_get)(u8 type, user_chip_update_info_t *info, void *priv))
{
    int ret = -1;
    struct list_head *update_entry = NULL;

    update_entry = ext_flash_file_update_init(priv, type, file_name, update_info_get);

    if (NULL == update_entry) {
        update_entry = reserve_file_update_init(priv, type, file_name, update_info_get);
    }
#if TCFG_NANDFLASH_DEV_ENABLE
    if (NULL == update_entry) {
        update_entry = nand_flash_file_update_init(priv, type, file_name, update_info_get);
    }

    if (NULL == update_entry) {
        update_entry = nand_zone_file_update_init(priv, type, file_name, update_info_get);
    }
#endif
    if (update_entry && file_ops) {
        if (NULL == __this) {
            // 分配、初始化
            __this = zalloc(sizeof(user_file_update_info_t));
            if (NULL == __this) {
                printf("%s, alloc fail\n", __func__);
                goto _ERR_RET;
            }
            INIT_LIST_HEAD(&__this->list);
            __this->file_ops = file_ops;
            __this->en = 1;
            g_user_file_update_timeout = USER_FILE_UPDATE_SEMAPHORE_WAIT_TIME;
#if SMART_BOX_EN
            extern void app_smartbox_prepare_update_ex_flash(void);
            app_smartbox_prepare_update_ex_flash();
#endif
        }
        // 入链表
        list_add_tail(update_entry, &__this->list);
        ret = 0;
    }

_ERR_RET:
    return ret;
}

static int user_file_update_get_len(void)
{
    // 遍历链表,获取获取并累加所有长度
    int user_file_total_len = 0;
    user_file_base_info_t *base_info = NULL;
    user_chip_update_info_t *update_info_entry = NULL;
    if (__this && !list_empty(&__this->list)) {
        list_for_each_entry(base_info, &__this->list, entry) {
            if (base_info->get_res_base_info && base_info->priv) {
                update_info_entry = base_info->get_res_base_info(base_info->priv, NULL, NULL, NULL);
                if (update_info_entry) {
                    user_file_total_len += update_info_entry->len;
                }
            }
        }
    }
    return user_file_total_len;
}

typedef struct _ex_update_exit_write_opt_t {
    void *priv;
    bool (*condition)(void *priv);
    u32 check_period; // ms
    u16 timer_hdl;
} user_update_exit_write_opt;

typedef struct _user_file_update_write_info_t {
    OS_SEM write_sem;
    OS_SEM write_finish_sem;
    u16 write_len;
    u32 write_offset;
    u32 write_program_addr;
    int ret;
    u32(*write_hdl)(void *buf, u32 addr, u32 len);
    u32(*erase_hdl)(u32 cmd, u32 addr);
    u8 *write_buf;
    user_update_exit_write_opt exit_opt;
    u8 en;
} user_file_update_write_info_t;

static bool exit_write_condition(user_file_update_write_info_t *write_info)
{
    if (write_info) {
        if (write_info->exit_opt.condition) {
            return write_info->exit_opt.condition(write_info->exit_opt.priv);
        }
    }
    return false;
}

static void exit_write_opt_prepare(user_file_update_write_info_t *write_info);
static void exit_write_opt_func(void *priv)
{
    user_file_update_write_info_t *write_info = (user_file_update_write_info_t *)priv;
    if (g_exit_opt_timer_hdl && write_info) {
        if (exit_write_condition(write_info)) {
            // post消息到write结束任务等待
            os_sem_post(&write_info->write_sem);
        } else {
            g_exit_opt_timer_hdl = 0;
            exit_write_opt_prepare(write_info);
        }
    }
}

static void exit_write_opt_prepare(user_file_update_write_info_t *write_info)
{
    if (write_info && (0 == g_exit_opt_timer_hdl)) {
        if (0 == write_info->exit_opt.check_period) {
            write_info->exit_opt.check_period = EX_FLASH_CHECK_EXIT_WIRTE_TASK_TIME;
        }
        g_exit_opt_timer_hdl = sys_timeout_add((void *)write_info, exit_write_opt_func, write_info->exit_opt.check_period);
    }
}

static void exit_write_finsh_opt(user_file_update_write_info_t *write_info)
{
    if (write_info) {
        if (g_exit_opt_timer_hdl) {
            sys_timeout_del(g_exit_opt_timer_hdl);
            g_exit_opt_timer_hdl = 0;
        }
    }
}

static void user_file_update_write_task_exit(user_file_update_write_info_t *write_info)
{
    exit_write_finsh_opt(write_info);
    if (0 == write_info->ret) {
        os_sem_pend(&write_info->write_finish_sem, 0);
    }
    if (write_info->write_buf) {
        free(write_info->write_buf);
    }
    task_kill(USER_FILE_FLASH_UPDATE_WRITE_TASK_NAME);
}

#if USER_FILE_FLASH_UPDATE_DEBUG_ENABLE
static u32(*debug_read_func)(void *buf, u32 addr, u32 len) = NULL;
static void flash_info_debug_func(void *buf, u32 addr, u32 len)
{
    // 记录远端传过来的crc
    u16 crc = CRC16((u8 *)buf, len);
    // 打印地址、长度、crc信息
    printf("%x,%x,%x", addr, len, crc);
    // 清除buffer
    memset((u8 *)buf, 0, len);
    // 从flash中读出刚写入的数据计算crc
    if (debug_read_func) {
        debug_read_func(buf, addr, len);
        // 校验flash的数据
        if (crc != CRC16((u8 *)buf, len)) {
            printf("%s, %d >>>>>>>>>>>>>>>>>error : %x, %x, %x, %x\n", __func__, __LINE__, addr, len, crc, CRC16((u8 *)buf, len));
        }
    }
}
#endif

extern void flash_erase_by_blcok_n_sector(u32 start_addr, u32 len, int (*erase_hdl)(int cmd, u32 addr));
static void user_file_update_write_task(void *p)
{
    user_file_update_write_info_t *write_info = (user_file_update_write_info_t *)p;
    u8 begin_flag = 1;
    u32 tmp_addr = 0;
    u32 cur_erase_len = 0;
    u32 cur_erase_unit = 0;
#if USER_FILE_FLASH_ERASE_IN_4K
    u32 erase_addr = __SECTOR_4K_ALIGN(write_info->write_program_addr);
#else
    u32 erase_addr = __BLOCK_64K_ALIGN(write_info->write_program_addr);
#endif
    write_info->en = 1;

    // 检测是否退出写线程timeout定时器
    // exit_write_opt_prepare(write_info);

    while (0 == write_info->ret) {

        if (os_sem_pend(&write_info->write_sem, g_user_file_update_timeout)) {
            printf("%s timeout\n", __func__);
            write_info->ret = -1;
            break;
        }

        // 如果退出条件满足,则结束写流程,并返回错误
        if (exit_write_condition(write_info)) {
            printf("%s, exit right now\n", __func__);
            write_info->ret = -1;
            break;
        }

        /* if (write_info->write_buf) { */
        /*     memcpy(write_info->write_buf, __this->buf, write_info->write_len); */
        /* } */

        if (write_info->erase_hdl) {
#if USER_FILE_FLASH_ERASE_IN_4K
            cur_erase_len = __SECTOR_4K_ALIGN(write_info->write_len);
            tmp_addr = (write_info->write_offset) / FLASH_SECTOR_SIZE * FLASH_SECTOR_SIZE;
            cur_erase_unit = FLASH_SECTOR_SIZE;
#else
            cur_erase_len = __BLOCK_64K_ALIGN(write_info->write_len);
            tmp_addr = (write_info->write_offset) / FLASH_BLOCK_SIZE * FLASH_BLOCK_SIZE;
            cur_erase_unit = FLASH_BLOCK_SIZE;
#endif
            // 防止当前升级数据只有一包,而且大小小于擦除单位的情况下,不擦除导致升级失败
            if (erase_addr != tmp_addr || begin_flag) {
                if (erase_addr > tmp_addr) {
                    cur_erase_len = erase_addr - tmp_addr;
                }
                erase_addr = tmp_addr;
                log_info("erase_addr:%x len:%d\n", erase_addr, cur_erase_len);
                flash_erase_by_blcok_n_sector(erase_addr, cur_erase_len, write_info->erase_hdl);
                begin_flag = 0;
            }
        }

        if (write_info->write_hdl && write_info->write_buf) {
            if (write_info->write_len != write_info->write_hdl(write_info->write_buf, write_info->write_offset, write_info->write_len)) {
                log_error("write addr:%x len:%x err\n", write_info->write_offset, write_info->write_len);
                write_info->ret = -2;
                break;
            }
        } else {
            log_error("%s basic interface err\n");
            write_info->ret = -1;
            break;
        }

#if USER_FILE_FLASH_UPDATE_DEBUG_ENABLE
        flash_info_debug_func(write_info->write_buf, write_info->write_offset, write_info->write_len);
#endif

        if (write_info->write_offset == write_info->write_program_addr) {
            break;
        }

        if (0 == write_info->ret) {
            os_sem_post(&write_info->write_finish_sem);
        }

        /* if (write_info->write_offset == write_info->write_program_addr) { */
        /*     break; */
        /* } */
    }

    os_sem_post(&write_info->write_finish_sem);
    while (1) {
        os_time_dly(10);
    }
}

static int user_file_update_write_data(user_file_update_write_info_t *write_info, u32 offset, u16 data_len)
{
    if (0 == write_info->ret) {
        os_sem_pend(&write_info->write_finish_sem, 0);
    }
    write_info->write_offset = offset;
    write_info->write_len = data_len;
    if (write_info->write_buf) {
        memcpy(write_info->write_buf, __this->buf, write_info->write_len);
    }
    os_sem_post(&write_info->write_sem);
    return write_info->ret;
}

static bool user_file_write_task_exit_condition(void *priv)
{
    return __this->exit_write_task_flag;
}

static int user_file_update_write_task_active(user_file_update_write_info_t *write_info, program_info_t *info)
{
    memset(write_info, 0, sizeof(user_file_update_write_info_t));

    write_info->write_buf = zalloc(g_once_req_size);
    if (NULL == write_info->write_buf) {
        printf("%s alloc fail\n");
        return -1;
    }

    if (info->local_write_hdl) {
        write_info->write_hdl = info->local_write_hdl;
    }
    if (info->local_erase_hdl) {
        write_info->erase_hdl = info->local_erase_hdl;
    }

    write_info->write_program_addr = info->local_program_addr;
    os_sem_create(&write_info->write_sem, 0);
    os_sem_create(&write_info->write_finish_sem, 1);

    // 指定写任务立即退出条件
    write_info->exit_opt.condition = user_file_write_task_exit_condition;
    // 检测是否退出写线程timeout定时器
    exit_write_opt_prepare(write_info);

    task_create(user_file_update_write_task, (void *)write_info, USER_FILE_FLASH_UPDATE_WRITE_TASK_NAME);

    // 保证先创建写线程再进行外挂flash升级
    u32 create_timeout_cnt = USER_FILE_UPDATE_SEMAPHORE_WAIT_TIME / 10;
    while ((0 == write_info->en) && (--create_timeout_cnt)) {
        os_time_dly(10);
    }
    if (0 == create_timeout_cnt) {
        printf("%s, create task timeout\n", __func__);
        write_info->ret = -1;
        return -1;
    }
    return 0;
}

static int user_file_flash_program_loop(program_info_t *info)
{
    int ret = 0;
    u32 remain_len;
    u32 remote_addr;
    u32 local_addr;

    u32 erase_addr = __SECTOR_4K_ALIGN(info->local_program_addr);
    u32 cur_erase_len = 0;
    /* if (info->local_erase_hdl) { */
    /*     remain_len = __SECTOR_4K_ALIGN(info->remote_file_length); */
    /*     local_addr = __SECTOR_4K_ALIGN(info->local_program_addr); */
    /*     flash_erase_by_blcok_n_sector(local_addr, remain_len, info->local_erase_hdl); */
    /* } */

    remain_len = info->remote_file_length;
    remote_addr = info->remote_file_begin;
    local_addr = info->local_program_addr;

    u32 tmp_addr = 0;
    u16 r_len = 0;

    user_file_update_write_info_t write_info;
    ret = user_file_update_write_task_active(&write_info, info);
    if (ret) {
        goto _ERR_RET;
    }

    do {
        r_len = (remain_len % g_once_req_size) ? (remain_len % g_once_req_size) : g_once_req_size;
        remain_len -= r_len;

        if (info->remote_file_read && info->buf && (0 == write_info.ret)) {
            ret = info->remote_file_read(info->buf, remote_addr + remain_len, r_len);
            if (ret != 0) {
                log_error("read addr:%x len:%x err\n", remote_addr + remain_len, r_len);
                ret = -1;
                break;
            }
        }

        if (0 == write_info.ret) {
            ret = user_file_update_write_data(&write_info, local_addr + remain_len, r_len);
        }

        if (ret) {
            log_error("write err\n");
            break;
        }
    } while (remain_len);
_ERR_RET:
    if (write_info.ret) {
        ret = write_info.ret;
    }
    user_file_update_write_task_exit(&write_info);
    return ret;
}

extern u16 calc_crc16_with_init_val(u16 init_crc, u8 *ptr, u16 len);
static u16 user_file_flash_local_file_verify(u8 *buf, u32 addr, u32 len, u32(*read_func)(u8 *buf, u32 addr, u32 len))
{
    u16 crc_temp = 0;
    u16 r_len;

    log_info("verify-addr:%x len:%x\n", addr, len);
    while (len) {
        r_len = (len > g_once_req_size) ? g_once_req_size : len;

        if (read_func) {
#if TCFG_NANDFLASH_DEV_ENABLE
            if (0 == (addr % (128 * 1024))) {
                u8 tmp_buf = 0;
                remote_file_read(&tmp_buf, 0, 1);
            }
#endif
            read_func(buf, addr, r_len);
        }
        crc_temp = calc_crc16_with_init_val(crc_temp, buf, r_len);

        addr += r_len;
        len -= r_len;
    }

    return crc_temp;
}

static int user_file_download_all_res_loop(program_info_t *info, user_chip_update_info_t *update_info_entry, u32(*verify_data_read_func)(void *buf, u32 addr, u32 len))
{
    int ret = 0;
    u16 offset = 0;
    u16 files_info_len = 0;
    user_chip_update_info_t *update_info = NULL;

    if (0 == update_info_entry->len) {
        return ret;
    }

#if USER_FILE_FLASH_UPDATE_DEBUG_ENABLE
    if (verify_data_read_func) {
        debug_read_func = verify_data_read_func;
    }
#endif

    if (update_info_entry->priv) {
        update_info = (user_chip_update_info_t *)update_info_entry->priv;
        files_info_len = update_info_entry->files_info_len;
    } else {
        update_info = update_info_entry;
    }

    do {
        info->remote_file_begin = update_info->addr;
        info->remote_file_length = update_info->len;
        info->local_program_addr = update_info->dev_addr;
        ret = user_file_flash_program_loop(info);
        if (ret) {
            ret = -1;
            break;
        }

        if (update_info->crc != \
            user_file_flash_local_file_verify(__this->buf, update_info->dev_addr, update_info->len, verify_data_read_func)) {
            log_error("update crc verify err\n");
            ret = -2;
            break;
        } else {
            log_info("update crc verify succ\n");
        }

        if (files_info_len) {
            update_info++;
            offset += sizeof(user_chip_update_info_t);
        }
    } while (files_info_len > offset);

    return ret;
}

static int user_file_download_loop(void *priv)
{
    int ret = 0;
    user_file_base_info_t *n = NULL;
    user_file_base_info_t *base_info = NULL;
    user_chip_update_info_t *update_info_entry = NULL;
    u32(*verify_data_read_func)(void *buf, u32 addr, u32 len) = NULL;
    program_info_t info;
    if (0 == __this->en) {
        ret = -1;
        goto _ERR_RET;
    }
    __this->buf = zalloc(g_once_req_size);
    if (NULL == __this->buf) {
        ret = -1;
        goto _ERR_RET;
    }

    info.remote_file_read = remote_file_read;
    info.buf = __this->buf;
    // 遍历链表,升级成功就把对应节点删掉,可以做到不重复升级的效果,但对应的内存要是否掉
    list_for_each_entry_safe(base_info, n, &__this->list, entry) {
        if (base_info->get_res_base_info && base_info->priv) {
            update_info_entry = base_info->get_res_base_info(base_info->priv, &verify_data_read_func, &info.local_write_hdl, &info.local_erase_hdl);
            // 遍历、升级所有的res资源
            ret = user_file_download_all_res_loop(&info, update_info_entry, verify_data_read_func);
            if (0 == ret) {
                if (base_info->user_chip_release_opt) {
                    base_info->user_chip_release_opt(update_info_entry);
                }
                /* user_file_update_release_each_entry(update_info_entry); */
                list_del(&base_info->entry);
                free(base_info);
                base_info = NULL;
            } else {
                break;
            }
        }
    }

_ERR_RET:
    __this->exit_write_task_flag = 0;
    if (__this->buf) {
        free(__this->buf);
        __this->buf = NULL;
        g_once_req_size = ONCE_REQ_SIZE;
    }
    return ret;
}

static int user_file_update_release(void *priv)
{
    user_file_base_info_t *base_info = NULL;
    user_file_base_info_t *n = NULL;
    user_chip_update_info_t *update_info_entry = NULL;
    // 遍历链表,获取所有元素,并逐个free
    if (__this && !list_empty(&__this->list)) {
        list_for_each_entry_safe(base_info, n, &__this->list, entry) {
            if (base_info->get_res_base_info && base_info->priv) {
                update_info_entry = base_info->get_res_base_info(base_info->priv, NULL, NULL, NULL);
                if (base_info->user_chip_release_opt) {
                    base_info->user_chip_release_opt(update_info_entry);
                }
                /* user_file_update_release_each_entry(update_info_entry); */
                list_del(&base_info->entry);
                free(base_info);
                base_info = NULL;
            }
        }
        free(__this);
        __this = NULL;
    }
    return 0;
}

const static user_chip_update_v2_t user_file_update_ins = {
    .retry_cnt = 2,
    .update_init = user_file_update_init,
    .update_get_len = user_file_update_get_len,
    .update_loop = user_file_download_loop,
    .update_release = user_file_update_release,
};

void user_file_flash_update_once_req_size_set(u32 pack_size)
{
    g_once_req_size	= pack_size;
}

void user_file_flash_read_timeout_set(int read_timeout)
{
    g_user_file_update_timeout = read_timeout;
}

void user_file_flash_update_len_clear(void)
{
    if (__this) {
        __this->en = 0;
    }
}

void user_file_exit_write_task(void)
{
    if (__this) {
        __this->exit_write_task_flag = 1;
    }
}

void user_file_flash_file_download_init(void)
{
    register_user_chip_update_v2_handle(&user_file_update_ins);
}

#else

void user_file_flash_file_download_init(void)
{

}

#endif

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/667850.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【Linux】开发工具入门指南,轻松掌握你的开发利器

开发工具 1. 软件包管理器yum1.1 软件包安装方式1.2 yum的"三板斧"1.3 yum的周边 2. 开发工具3. 编辑器vim4. 编译器gcc、g5. 项目自动化构建工具make、Makefile6. 进度条小程序7. 调试器gdb 1. 软件包管理器yum 1.1 软件包安装方式 源代码安装&#xff1a;用户手动…

vue中大屏可视化适配所有屏幕大小

1. 外部盒子 .screenBox {width: 100vw;height: 100vh;background: url("/assets/images/bg.png") no-repeat;background-size: cover; }2.比例盒子 外层盒子css定义 .boxScale {width: 1920px;height: 1080px;background-color: orange;transform-origin: left top;…

分享一个在linux中运行通义千问的方法

分享一个在linux中和通义千问交互的方法 效果展示: 整体步骤 分享一个在linux中和通义千问交互的方法效果展示:一、在阿里云appflow控制台创建连接流1、通过以下地址,在灵积平台创建个API-KEY,用于通义千问的连接凭证2、点击连接流-创建连接流3、第一步选择webhook4.第二步…

电磁兼容整改时磁环怎么选型

电磁兼容整改时磁环怎么选型 磁环的选型错误磁环特性纳米微晶磁环磁环选型示例磁环选型 一条线缆两端都有设备&#xff0c;那磁环应该放在哪里&#xff1f; 我们怎么样来选择这个磁环&#xff0c;通过磁环的吸收作用&#xff0c;让辐射的强度和传导发射的这个强度衰减更大的那我…

OpenCASCADE入门(2)——openCasCade7.6.0版本的exe方式安装,vs2017环境配置,编译和使用draw

3rd party Components | Open CASCADE Technology 目录 引出安装好vs2017和occt7.6设置环境变量 启动occt和编译关于custom.bat批处理文件双击运行 打开draw使用方式一&#xff1a;双击draw.bat批处理vs设置启动项 总结其他自定义信号和槽1.自定义信号2.自定义槽3.建立连接4.进…

【Vue】v-for中的key

文章目录 一、引入问题二、分析问题 一、引入问题 语法&#xff1a; key属性 "唯一值" 作用&#xff1a;给列表项添加的唯一标识。便于Vue进行列表项的正确排序复用。 为什么加key&#xff1a;Vue 的默认行为会尝试原地修改元素&#xff08;就地复用&#xff09;…

盘点那些对公关理解的误区

逢年过节回老家&#xff0c;亲朋好友都会问&#xff0c;你在北京做什么工作啊&#xff1f;小马识途营销顾问有几次说是做公关的&#xff0c;得到的回应很怪异&#xff0c;“那你酒量一定不错”“就是经常去酒店的那种吗&#xff1f;”“公关小姐&#xff1f;公关先生&#xff1…

[有监督学习]4.详细图解支持向量机

支持向量机 支持向量机&#xff08;Support Vector Machine&#xff0c;SVM&#xff09;是一种应用范围非常广泛的算法&#xff0c;既可以用于分类&#xff0c;也可以用于回归。 本节将介绍如何将线性支持向量机应用于二元分类问题&#xff0c;以间隔&#xff08;margin&#…

提升船舶安全性与效率:隔离驱动芯片的应用

随着科技的不断发展&#xff0c;船舶行业也在不断迎来新的技术革新&#xff0c;其中隔离驱动芯片作为一种关键的电子元件&#xff0c;在船舶领域发挥着重要作用。本文将深入探讨隔离驱动芯片在船舶领域的应用及其技术特点。 隔离驱动芯片提升船舶系统安全性 船舶作为大型交通工…

View->Bitmap缩放到自定义ViewGroup的任意区域(Matrix方式绘制Bitmap)

Bitmap缩放和平移 加载一张Bitmap可能为宽高相同的正方形&#xff0c;也可能为宽高不同的矩形缩放方向可以为中心缩放&#xff0c;左上角缩放&#xff0c;右上角缩放&#xff0c;左下角缩放&#xff0c;右下角缩放Bitmap中心缩放&#xff0c;包含了缩放和平移两个操作&#xf…

Java进阶学习笔记32——Calendar

为什么要学习Calendar&#xff1f; 原来的方法&#xff1a; 使用Calendar 从API文档中&#xff0c;可以看到Calendar是一个抽象类&#xff0c;抽象类是不能创建对象&#xff0c;不能直接使用的。 package cn.ensource.d3_time;import java.util.Calendar; import java.util.Da…

基于Raspi的Opencv-Python开发笔记

本文所有未强调 “windows终端” 的 “终端”字眼&#xff0c;都是默认树莓派的终端 系统版本 系统版本有必要强调一下&#xff0c;因为不同版本很多操作需要修改 在终端输入uname -a Release就是版本号&#xff0c;Codename是版本名 以下操作仅在此版本验证可行 使能摄像…

传感器和变送器的区别介绍

从它的名称来看&#xff0c;传与感二字。传是指传输&#xff0c;感是指感知。实际上是先有感知&#xff0c;其次转换&#xff0c;最后传输。因此传输是目的&#xff0c;转换是手段&#xff0c;感知是基础。把能够将被测变量&#xff08;温度、压力、液位、流量&#xff09;感知…

内存管理【C++】

内存分布 C中的内存区域主要有以下5种 栈&#xff08;堆栈&#xff09;&#xff1a;存放非静态局部变量/函数参数/函数返回值等等&#xff0c;栈是向下增长的【地址越高越先被使用】。栈区内存的开辟和销毁由系统自动执行 堆&#xff1a;用于程序运行时动态内存分配&#xff…

C++入门3——类与对象2(类的6个默认成员函数)

目录 1.类的6个默认成员函数 2. 构造函数 2.1 构造函数的概念 2.2 构造函数的特性 3. 析构函数 3.1 析构函数的概念 3.2 析构函数的特性 4.拷贝构造函数 4.1 拷贝构造函数的概念 4.2 拷贝构造函数的特性 5.赋值运算符重载函数 5.1运算符重载函数 5.2 赋值运算符重…

docker一键部署EFK系统(elasticsearch filebeat kibana metricbeat es-head)

EFK日志系统搭建 EFK日志系统介绍功能需求搭建elasticsearch集群规划前提部署核对证书及权限 EFK日志系统介绍 Elasticsearch 是一个实时的、分布式的可扩展的搜索引擎&#xff0c;允许进行全文、结构化搜索&#xff0c;它通常用于索引和搜索大量日志数据&#xff0c;也可用于…

Vue3-路由详解

文章目录 路由对路由的理解安装 Vue Router基本切换效果两个注意点路由器工作模式to的两种写法命名路由嵌套路由路由传参query参数params参数 路由的props配置replace属性编程式导航重定向 更多相关内容可查看 路由 附git地址&#xff1a;https://gitee.com/its-a-little-bad/…

打印机的ip不同且连不上

打印机的ip不同且连不上 1.问题分析2.修改网段3.验证网络 1.问题分析 主要是打印机的网段和电脑不在同一个网段 2.修改网段 3.验证网络

CATO原理中的数学与魔术(十一)——Parity Principle及其应用二:集合的可视化...

早点关注我&#xff0c;精彩不错过&#xff01; 上篇文章中&#xff0c;我们已经进入了CATO原理魔术介绍的深水区&#xff0c;是第3个系列Parity Principle中集合性质的章节&#xff0c;聊到了关于张数和求和集合性质&#xff0c;并对性质之间的偏序关系&#xff0c;性质之间的…

基于单片机的微型嵌入式温度测量仪的设计与实现分析

摘要 &#xff1a; 作为信息技术中重要的技术手段之一嵌入式单片机系统已经被应用到越来越多不同的行业领域中。如&#xff0c;各种手持监测设备、智能家电设备等。当前展开对单片机的微型嵌入式温度测量仪的设计和实现研究&#xff0c;从微型嵌入式单片机相关理论入手&#xf…