杰理-7014配置

news2025/1/19 20:22:39

杰理-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

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【Python入门学习笔记】Python3超详细的入门学习笔记,非常详细(适合小白入门学习)

Python3基础 想要获取pdf或markdown格式的笔记文件点击以下链接获取 Python入门学习笔记点击我获取 1&#xff0c;Python3 基础语法 1-1 编码 默认情况下&#xff0c;Python 3 源码文件以 UTF-8 编码&#xff0c;所有字符串都是 unicode 字符串。 当然你也可以为源码文件指…

LabVIEW超声波局部放电检测系统开发

LabVIEW超声波局部放电检测系统开发 在高压电力系统中&#xff0c;局部放电(PD)是导致绝缘失效的主要原因之一。局部放电的检测对于确保电力系统的可靠运行至关重要。开发了一种基于LabVIEW软件的超声波局部放电检测系统的设计与实现。该系统利用数字信号处理技术&#xff0c;…

新型 Meterpreter 后门能够在图片中隐藏恶意代码

据Cyber Security News消息&#xff0c;ANY.RUN 沙盒分析了一种被称为Meterpreter 的新型后门恶意软件&#xff0c;能利用复杂的隐写技术将恶意有效载荷隐藏在看似无害的图片文件中。 基于Meterpreter的攻击从一个包含 PowerShell 脚本的 .NET 可执行文件开始&#xff0c;该脚…

AI免费插件 批量条码大师,支持100多种条码类型

没想到在网上看到一款和之前 悟空条码 类似的条码插件&#xff0c;叫批量条码大师&#xff0c;他做的比 悟空条码 功能更强&#xff0c;界面更美观&#xff0c;特分享出来给大家。 本插件采用了BWIPJS条码库&#xff0c;支持110种条码、二维码的生成; 支持批量生成&#xff0c;…

直接干免费?AI大模型的航海时代是真的要来了

5月里&#xff0c;在火山引擎Force原动力大会上&#xff0c;字节对外宣布豆包大模型正式开启对外服务&#xff0c;其使用价格仅为0.0008元/千tokens、0.005元/千tokens&#xff0c;较行业降幅达99.3%、95.8%&#xff0c;已经达到了行业价格的“地板价”&#xff0c;率先打响了降…

TXT文档拆分、合并、添加内容,修改内容、删除内容——首助编辑高手软件一招解决

下面这个TXT文档里面是一篇长篇小说&#xff0c;大家都知道一般小说文字内容是比较大的一个文件呢&#xff0c;想要拆分&#xff0c;拆分肯定是有方法呢&#xff0c;比如比较重统的方法手动一章一章复制出来&#xff0c;粘贴到另一个文档里面去粘贴&#xff0c;手动操作是不是很…

逆天工具一键修复图片,视频去码。简直不要太好用!

今天&#xff0c;我要向您推荐一款功能强大的本地部署软件&#xff0c;它能够在您的计算机上一键修复图片和视频&#xff0c;去除令人不悦的码赛克&#xff08;轻度马赛克&#xff09;。这款软件是开源的&#xff0c;并在GitHub上公开可用&#xff0c;您可以免费下载并使用。 …

全球高端奢侈瑜伽服市场霸主Lululemon在美股的股价还有巨大的上涨空间

来源&#xff1a;猛兽财经 作者&#xff1a;猛兽财经 一、Lululemon公司介绍 1.1、创立与起源&#xff1a; Lululemon(LULU)由Chip Wilson于1998年在加拿大温哥华创立。1.2、产品与市场定位&#xff1a; Lululemon起初以瑜伽裤起家&#xff0c;现已发展成为涵盖瑜伽、跑步、训…

结构体相关习题的补充

结构体相关习题的补充 题目1&#xff1a; 如有以下代码&#xff1a; struct student {int num;char name[32];float score; }stu;则下面的叙述不正确的是&#xff1a;( ) A.struct 是结构体类型的关键字 B.struct student 是用户定义的结构体类型 C.num, score 都是结构体…

低边驱动与高边驱动

一.高边驱动和低边驱动 低边驱动(LSD): 在电路的接地端加了一个可控开关&#xff0c;低边驱动就是通过闭合地线来控制这个开关的开关。容易实现&#xff08;电路也比较简单&#xff0c;一般由MOS管加几个电阻、电容&#xff09;、适用电路简化和成本控制的情况。 高边驱动&am…

备忘录--

备忘录 vue新建项目&#xff0c;body 大小占不了全屏 // 解决问题 // public/index.html 更改基础样式 html,body{height: 100%width: 100%&#xff1b;margin: 0;border: 0;padding: 0; }Element Plus 经典布局 参考 Element Plus 官网 <template><div class"…

堆排序详细理解

目录 一、前备知识 二、建堆 2.2.1 向上调整算法建堆 2.2.2 向下调整算法建堆 三、排序 3.1 常见问题 3.2 思路 3.3 源码 一、前备知识 详细图解请点击&#xff1a;二叉树的顺序实现-堆-CSDN博客 本文只附上向上/向下调整算法的源码 //交换 void Swap(int* p, int* …

数据安全之翼:天空卫士在汽车数据安全领域的卓越领航

近期&#xff0c;中国汽车网络安全与数据安全产业的积极倡导者谈思实验室发布首份《汽车网络与数据安全行业全景图》&#xff0c;天空卫士入选&#xff0c;并且位列榜首。 天空卫士在汽车数据安全领域有丰富的实践经验&#xff0c;曾为多家汽车行业用户提供数据安全产品与服务&…

Docker 私有仓库部署和管理

目录 一、案例一 概述 二、案例一 前置知识点 2.1、什么是 Docker Compose 2.2、什么是 Consul 三、案例一 使用 docker Compose 搭建 Consul 集群环境 3.1、案例实验环境 3.2、案例需求 四、案例实施 4.1、Docker 网络通信 1&#xff09;端口映射 2&#xf…

【Python】 如何将Python脚本打包为独立可执行文件

基本原理 在Python开发中&#xff0c;我们经常会遇到需要将脚本打包成可执行文件的情况。这样做的好处是&#xff0c;用户可以在没有安装Python环境的情况下运行程序&#xff0c;同时&#xff0c;程序的依赖项也会被打包进去&#xff0c;避免了因为环境不一致导致的问题。 Py…

C++ 混合运算的类型转换

一 混合运算和隐式转换 257 整型2 浮点5 行吗&#xff1f;成吗&#xff1f;中不中&#xff1f; C 中允许相关的数据类型进行混合运算。 相关类型。 尽管在程序中的数据类型不同&#xff0c;但逻辑上进行这种运算是合理的相关类型在混合运算时会自动进行类型转换&#xff0c;再…

Wpf 使用 Prism 实战开发Day30

登录界面设计 一.准备登录界面图片素材&#xff08;透明背景图片&#xff09; 1.把准备好的图片放在Images 文件夹下面&#xff0c;格式分别是.png和.ico 2.选中 login.png图片鼠标右键&#xff0c;选择属性。生成的操作选择>资源 3.MyTodo 应用程序右键&#xff0c;属性&a…

【简单介绍下Milvus,什么是Milvus?】

&#x1f308;个人主页: 程序员不想敲代码啊 &#x1f3c6;CSDN优质创作者&#xff0c;CSDN实力新星&#xff0c;CSDN博客专家 &#x1f44d;点赞⭐评论⭐收藏 &#x1f91d;希望本文对您有所裨益&#xff0c;如有不足之处&#xff0c;欢迎在评论区提出指正&#xff0c;让我们共…

YZW900规格书

title: “深圳市沃进科技有限公司” 深圳市沃进科技有限公司 TOP视图 特性 异地组网&#xff0c;远程访问有线/无线备份单模双卡备份5G转有线&#xff0c;5G转WIFI2.4G5.8G双频WIFI三网口&#xff0c;WAN/LAN可切换软硬件看门狗智能防掉线云平台、客户端远程管理安装支架安装铝…

JVM哪些区域可能出现内存溢出,哪些地方需要GC?

GC顾名思义也就是垃圾回收&#xff0c;有人的地方就有江湖&#xff0c;那有数据的地方也理应有垃圾回收&#xff0c;所以思考一下&#xff0c;沿着之前提到过的JVM内存分区&#xff0c;堆&#xff0c;栈&#xff0c;程序计数器&#xff0c;方法区 堆、栈、方法区…