ota更新
authorp15692025051 <846603105@qq.com>
Fri, 15 Aug 2025 06:00:40 +0000 (14:00 +0800)
committerp15692025051 <846603105@qq.com>
Fri, 15 Aug 2025 06:00:40 +0000 (14:00 +0800)
23 files changed:
2.code/1.sdk/apps/BK_app/BK_drive/bk_audio.c
2.code/1.sdk/apps/BK_app/BK_drive/bk_uart.c
2.code/1.sdk/apps/BK_app/BK_drive/mic2dac.c
2.code/1.sdk/apps/BK_app/BK_drive/mic2dac.h
2.code/1.sdk/apps/BK_app/bk_app.c
2.code/1.sdk/apps/common/device/norflash/inside_norflash.c
2.code/1.sdk/apps/common/include/norflash_sfc.h
2.code/1.sdk/apps/common/update/lc_flash_ufw_update.c
2.code/1.sdk/apps/watch/board/br28/board_7014f5_demo/board_7014f5_demo.c
2.code/1.sdk/apps/watch/board/br28/board_7014f5_demo/board_7014f5_demo_cfg.h
2.code/1.sdk/apps/watch/common/task_table.c
2.code/1.sdk/cpu/br28/audio_dec/audio_dec_bt.c
2.code/1.sdk/cpu/br28/tools/download/watch/download.bat
2.code/1.sdk/cpu/br28/tools/download/watch/download_insert.bat
2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/JL [deleted file]
2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/font [deleted file]
2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch [deleted file]
2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch1 [deleted file]
2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch2 [deleted file]
2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch3 [deleted file]
2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch4 [deleted file]
2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch5 [deleted file]
2.code/1.sdk/cpu/br28/tools/isd_config_rule.c

index 3947dcd..87c0ded 100644 (file)
@@ -29,7 +29,7 @@ extern struct audio_adc_hdl adc_hdl;
 
 extern u8 bt_connect;
 static uint8_t BT_state = 0;
-static uint8_t mic2dac_demo_state = 0;
+static uint8_t local_audio_state = 0;
 
 //采样率
 #define ALINK_DEMO_SAMPLE_RATE  16000
@@ -450,7 +450,7 @@ int audio_link_demo_RX_data(char *data, int len)
         cbuf_write_updata(dac_cbuffer, len );
         if(BT_state == 1)
             esco_enc_resume();//通知耳机有数据要编码
-        else if(mic2dac_demo_state == 1)
+        else if(local_audio_state == 1)
             audio_decoder_updata();//通知本地播放要更新数据了
     }
     return    wlen;
@@ -470,8 +470,17 @@ int read_iis_play_data(char *data, int len)
 
 
 
-
-
+void open_bt_audio(void)//打开蓝牙通话
+{
+    __set_bt_esco_by_watch(1);
+    user_emitter_cmd_prepare(USER_CTRL_CONN_SCO,0,NULL);
+    user_emitter_cmd_prepare(USER_CTRL_HFP_CALL_LAST_NO,0,NULL);
+    gpio_direction_output(TCFG_AUDIO_DAC_PA_PORT, 0); //
+}
+void close_bt_audio(void)
+{
+    user_emitter_cmd_prepare(USER_CTRL_HFP_CALL_HANGUP,0,NULL);
+}
 
 //extern void uart_demo();
 
@@ -489,16 +498,15 @@ void bk_audio_open()
 
     bk_iis_open();
     if(bt_connect){//蓝牙耳机
-        if(mic2dac_demo_state == 1)//如果连了蓝牙,而且本地录音和音频已经打开,就关闭一次
+        if(local_audio_state == 1)//如果连了蓝牙,而且本地录音和音频已经打开,就关闭一次
         {
-            mic2dac_demo_stop();
-            mic2dac_demo_state = 0;
+            close_local_audio();
+            local_audio_state = 0;
         }
         if(!BT_state){//打开蓝牙通话
             BT_state = 1;
-            __set_bt_esco_by_watch(1);
-            user_emitter_cmd_prepare(USER_CTRL_CONN_SCO,0,NULL);
-            user_emitter_cmd_prepare(USER_CTRL_HFP_CALL_LAST_NO,0,NULL);
+            open_bt_audio();
+            
             printf("打开蓝牙通道!!!!!!!!!");
             printf("打开蓝牙通道!!!!!!!!!");
             printf("打开蓝牙通道!!!!!!!!!");
@@ -510,17 +518,17 @@ void bk_audio_open()
     }else{
         if(BT_state == 1)//如果打开了蓝牙耳机通道,关一次通话
         {
-            user_emitter_cmd_prepare(USER_CTRL_HFP_CALL_HANGUP,0,NULL);
+            close_bt_audio();
         }
         printf("打开本地通道!!!!!!!!!");
         printf("打开本地通道!!!!!!!!!");
         printf("打开本地通道!!!!!!!!!");
-        mic2dac_demo_start();
-        mic2dac_demo_state = 1;
+        open_local_audio();
+        local_audio_state = 1;
         BT_state=0;
     }
     
-    //mic2dac_demo_start();
+    //open_local_audio();
     return ;
 }
 
@@ -529,15 +537,15 @@ void bk_audio_close()
     bk_IIS_close();
     if(BT_state ==1)
     {
-        user_emitter_cmd_prepare(USER_CTRL_HFP_CALL_HANGUP,0,NULL);
+        close_bt_audio();
         BT_state = 0;
     }
-    if(mic2dac_demo_state == 1)
+    if(local_audio_state == 1)
     {
-        mic2dac_demo_state = 0;
-        mic2dac_demo_stop();
+        local_audio_state = 0;
+        close_local_audio();
     }
-    //mic2dac_demo_stop();
+    //close_local_audio();
    //audio_adc_mic_close_demo();
 }
 
index ac3a9a1..411bc4f 100644 (file)
@@ -21,6 +21,163 @@ static int uart_timer_id = 0;
 static int uart_timer_count = 0;
 static void uart_timer_cb(void *p);
 #define uart_read_buf_len 1024*4
+
+/**
+ * @brief Base64 字符到索引的映射表
+ * 用于快速查询 Base64 字符对应的 6 位数值(索引)
+ * 无效字符标记为 -1,填充字符 '=' 单独处理
+ */
+static const int base64_decoder[256] = {
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,  // '+'=62, '/'=63
+    52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,  // 0-9 对应 52-61
+    -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,  // A-Z 对应 0-25
+    15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
+    -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,  // a-z 对应 26-51
+    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
+    // 剩余字符均为无效字符
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+};
+
+/**
+ * @brief 计算 Base64 解码后的字节长度
+ * @param encoded 输入的 Base64 编码字符串
+ * @return 解码后的字节长度,若输入为 NULL 则返回 0
+ */
+size_t base64_decoded_length(const char *encoded) {
+    if (encoded == NULL) return 0;
+
+    size_t encoded_len = strlen(encoded);
+    size_t padding = 0;
+
+    // 统计填充字符 '=' 的数量(最多 2 个)
+    if (encoded_len >= 1 && encoded[encoded_len - 1] == '=') padding++;
+    if (encoded_len >= 2 && encoded[encoded_len - 2] == '=') padding++;
+
+    // 公式:Base64 每 4 个字符对应 3 个字节,减去填充字符数量
+    return (encoded_len * 6 / 8) - padding;
+}
+
+/**
+ * @brief Base64 解码核心函数
+ * @param encoded 输入的 Base64 编码字符串
+ * @param decoded 输出的解码后字节数组(需提前分配内存)
+ * @param decoded_len 输出参数,接收解码后的字节长度
+ * @return 0 表示成功,-1 表示失败
+ */
+int base64_decode(const char *encoded, unsigned char *decoded, size_t *decoded_len) {
+    // 参数合法性检查
+    if (encoded == NULL || decoded == NULL || decoded_len == NULL) {
+        return -1;
+    }
+
+    size_t encoded_len = strlen(encoded);
+    *decoded_len = base64_decoded_length(encoded);  // 计算输出长度
+
+    unsigned char trio[4];  // 存储 4 个 Base64 字符对应的 6 位值
+    int count = 0;          // 计数已读取的 Base64 字符数(0-4)
+    size_t out_idx = 0;     // 输出字节数组的索引
+
+    for (size_t i = 0; i < encoded_len; i++) {
+        char c = encoded[i];
+        int val;
+
+        // 跳过空白字符(如空格、换行等,部分编码可能包含)
+        if (isspace((unsigned char)c)) {
+            continue;
+        }
+
+        // 处理填充字符 '='
+        if (c == '=') {
+            val = 0;  // 填充字符按 0 处理
+        } else {
+            val = base64_decoder[(unsigned char)c];
+            // 检查无效字符
+            if (val == -1) {
+                printf("无效的 Base64 字符: '%c' (ASCII: %d)\n", c, c);
+                return -1;
+            }
+        }
+
+        // 存储当前字符的 6 位值
+        trio[count++] = val;
+
+        // 每 4 个字符一组进行解码(Base64 编码的基本单位)
+        if (count == 4) {
+            // 第 1 个字节:前 6 位的前 2 位 + 第 2 个 6 位的前 4 位
+            decoded[out_idx++] = (trio[0] << 2) | (trio[1] >> 4);
+
+            // 第 2 个字节:第 2 个 6 位的后 2 位 + 第 3 个 6 位的前 4 位
+            // 若第 3 个字符是填充符,则不生成该字节
+            if (encoded[i - 1] != '=') {
+                decoded[out_idx++] = (trio[1] << 4) | (trio[2] >> 2);
+            }
+
+            // 第 3 个字节:第 3 个 6 位的后 2 位 + 第 4 个 6 位的全部 6 位
+            // 若第 4 个字符是填充符,则不生成该字节
+            if (encoded[i] != '=') {
+                decoded[out_idx++] = (trio[2] << 6) | trio[3];
+            }
+
+            count = 0;  // 重置计数器,处理下一组
+        }
+    }
+
+    // 检查是否有未处理的不完整组(理论上 Base64 编码长度应为 4 的倍数)
+    if (count != 0) {
+        printf("Base64 编码长度不是 4 的倍数,可能存在格式错误\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+// // Base64解码表
+// static int base64_decode_value(char c) {
+//     if (c >= 'A' && c <= 'Z') return c - 'A';
+//     if (c >= 'a' && c <= 'z') return c - 'a' + 26;
+//     if (c >= '0' && c <= '9') return c - '0' + 52;
+//     if (c == '+') return 62;
+//     if (c == '/') return 63;
+//     return -1;
+// }
+
+// // Base64解码函数
+// unsigned char *base64_decode(const char *data, size_t input_length, size_t *output_length) {
+//     // 计算填充字符数量
+//     size_t padding = 0;
+//     if (input_length >= 1 && data[input_length - 1] == '=') padding++;
+//     if (input_length >= 2 && data[input_length - 2] == '=') padding++;
+
+//     // 计算输出长度
+//     *output_length = 3 * (input_length / 4) - padding;
+//     unsigned char *decoded_data = malloc(*output_length);
+//     if (decoded_data == NULL) return NULL;
+
+//     for (size_t i = 0, j = 0; i < input_length;) {
+//         int sextet_a = base64_decode_value(data[i++]);
+//         int sextet_b = base64_decode_value(data[i++]);
+//         int sextet_c = base64_decode_value(data[i++]);
+//         int sextet_d = base64_decode_value(data[i++]);
+
+//         uint32_t triple = (sextet_a << 18) | (sextet_b << 12) | (sextet_c << 6) | sextet_d;
+
+//         if (j < *output_length) decoded_data[j++] = (triple >> 16) & 0xFF;
+//         if (j < *output_length) decoded_data[j++] = (triple >> 8) & 0xFF;
+//         if (j < *output_length) decoded_data[j++] = triple & 0xFF;
+//     }
+
+//     return decoded_data;
+// }
+
 static void uart_irq_func(int uart_num, enum uart_event_v1 event)
 {
     if (event & UART_EVENT_TX_DONE) {
@@ -82,19 +239,16 @@ void bk_uart_task(void *p)
             int r = uart_recv_blocking(ut, uart_dma_buf, 512, 10);
             if (r > 0) {
                 memcpy(uart_data+uart_data_len,(u8 *)uart_dma_buf,r);
-                log_info("分段数据!***len:%d uart_data_len:%d*****", r,uart_data_len);
+                //log_info("分段数据!***len:%d uart_data_len:%d*****", r,uart_data_len);
                 uart_data_len+=r;
                 if(parse_uart_data(uart_data)==0)
                 {
-                    log_info("完整数据!***len:%d*****\ndata :", uart_data_len);
-                    // for(int i = 0;i<uart_data_len;i++)
-                    // {
-                    //     putchar(uart_data[i]);
-                    // }
+                    log_info("完整数据!len:%d\ndata :", uart_data_len);
+                    
                     uart_data_len = 0;
 
                     memset(uart_data,0,uart_read_buf_len);
-                    log_info("完整数据!***end :");
+                    //log_info("完整数据!***end :");
                 }
             }
             
@@ -121,44 +275,7 @@ void bk_uart_task(void *p)
         }
     }
 }
-//串口线程
-// void bk_uart_task(void *p)
-// {
-    
 
-    
-    
-//     while (1) {
-//         //continue;
-//         os_sem_pend(&uart_callback, 0);
-//         if(uart_timer_id == 0)//有数据启动定时器
-//             uart_timer_id = sys_timer_add(NULL, uart_timer_cb, 10);
-//         uart_timer_count = 0;
-//         if(uart_data_len+512>uart_read_buf_len)
-//         {
-//             uart_data_len = 0;
-//         }
-//         int r = uart_recv_blocking(ut, uart_dma_buf, 512, 10);
-//         if (r > 0) {
-//             memcpy(uart_data+uart_data_len,(u8 *)uart_dma_buf,r);
-//             log_info("分段数据!***len:%d uart_data_len:%d*****\ndata :%s\n", r,uart_data_len,(u8 *)uart_data+uart_data_len);
-//             uart_data_len+=r;
-//             if(parse_uart_data(uart_data)==0)
-//             {
-//                 log_info("完整数据!***len:%d*****\ndata :\n", uart_data_len);
-//                 for(int i = 0;i<uart_data_len;i++)
-//                 {
-//                     putchar(*((u8 *)uart_data+i));
-//                 }
-//                 uart_data_len = 0;
-
-//                 memset(uart_data,0,uart_read_buf_len);
-//             }
-           
-
-//         }
-//     }
-// }
 static void uart_timer_cb(void *p)//有串口数据后10ms一次回调
 {
     
@@ -241,7 +358,8 @@ void bk_uart_init()
     }
 
     uart_dump();
-    int err = os_task_create(bk_uart_task, NULL, 31, 512, 256, "bk_uart_task");
+    //int err = os_task_create(bk_uart_task, NULL, 31, 512, 256, "bk_uart_task");
+     int err =task_create(bk_uart_task, NULL, "bk_uart_task");
     if (err != OS_ERR_NONE) {
         r_printf("creat fail %x\n", err);
     }
@@ -270,6 +388,7 @@ int uart_send_AI_key_even(void)
         return -1;
     }
     // 打印JSON字符串
+    printf("JSON数据: %s\n", json_string);
     uart_send_blocking(ut, json_string, strlen(json_string), 20);
     // 释放内存
     cJSON_free(json_string);
@@ -287,7 +406,6 @@ int uart_send_PWR_key_even(void)
         return -1;
     }
     // 添加字符串字段 "event"
-
     cJSON_AddStringToObject(root, "event", "AI_PWR_PRESS");
     // 将JSON对象转换为字符串
     char *json_string = cJSON_Print(root);
@@ -482,16 +600,60 @@ int uart_send_ack(void)
     cJSON_Delete(root);
     return 0;
 }
+int uart_send_error(void)
+{
+    cJSON *root = cJSON_CreateObject();
+    if (root == NULL) {
+        printf( "Failed to create JSON object\n");
+        return -1;
+    }
+    // 添加字符串字段 "event"
+    cJSON_AddStringToObject(root, "event", "error");
+    // 将JSON对象转换为字符串
+    char *json_string = cJSON_Print(root);
+    if (json_string == NULL) {
+        printf( "Failed to print JSON\n");
+        cJSON_Delete(root);
+        return -1;
+    }
+    // 打印JSON字符串
+    //printf("JSON数据: %s\n", json_string);
+    uart_send_blocking(ut, json_string, strlen(json_string), 20);
+    // 释放内存
+    cJSON_free(json_string);
+    cJSON_Delete(root);
+    return 0;
+}
 extern void updata_fd_close(void);
-extern int updata_write(char *data,int len);
+extern int updata_write(char *data,int offset ,int len);
 extern void updata_fd_open(char *reserved_area_name);
+void print_hex(char *data ,int len)
+{
+    char hex_str[4]={0};
+    for(int i=0;i<len;i++)
+    {
+        int data_tmp = 0 ;
+        data_tmp = data[i]&0xff;
+        //printf("%02X ",data_tmp);
+        snprintf(hex_str,4,"%02X ",data_tmp);
+        putchar(hex_str[0]);
+        putchar(hex_str[1]);
+        putchar(hex_str[2]);
+        //putchar('-');
+        // int count = 1000;
+        // while(count--)
+        // {}
+    }
+}
 ////*************解析****************//////
 
+int ota_data_len = 0;
 int parse_uart_data(char *json_string)
 {
     int ret = 0;
     cJSON *root = cJSON_Parse(json_string);
     char ack_flag = 0;
+    int error_flag = 0;
     if (root == NULL) {
         // const char *error_ptr = cJSON_GetErrorPtr();
         // if (error_ptr != NULL) {
@@ -502,7 +664,7 @@ int parse_uart_data(char *json_string)
     
     cJSON *event = cJSON_GetObjectItemCaseSensitive(root, "event");
     if (cJSON_IsString(event) && (event->valuestring != NULL)) {
-        printf("解析结果: event = %s json_string:%s\n", event->valuestring,json_string);
+        printf("解析结果: event = %s\n", event->valuestring);
         // if(strcmp(event->valuestring,"AI_start"))//ai开始
         // {
 
@@ -527,27 +689,97 @@ int parse_uart_data(char *json_string)
         {
             //led_close();
         }
+        
         if(!strcmp(event->valuestring,"ota_start"))//ota开始
         {
-            updata_fd_open("UPDATE/11.txt");
+            updata_fd_open("UPDATE");
             ack_flag = 1;
-
+            ota_data_len = 0;
         }
         if(!strcmp(event->valuestring,"ota_data"))//ota接收数据
         {
             //updata_fd_open("UPDATE");
-            //updata_write();
-            ack_flag = 1;
-
+            cJSON *update_json = cJSON_GetObjectItemCaseSensitive(root, "update");
+            cJSON *offset_json = cJSON_GetObjectItemCaseSensitive(root, "offset");
+            cJSON *checksum_json = cJSON_GetObjectItemCaseSensitive(root, "checksum");
+            if(update_json && offset_json && checksum_json)
+            {
+                char *update = update_json->valuestring ;
+                if( cJSON_IsString(update_json)&& (update != NULL)) 
+                {
+                    int offset = offset_json->valueint;
+                    unsigned char checksum = checksum_json->valueint;
+                    unsigned char loc_checksum = 0;
+                    size_t decoded_len = base64_decoded_length(update);
+                    printf("decoded_len:%d",decoded_len);
+                    unsigned char *decoded = (unsigned char *)malloc(decoded_len + 1);
+                    if (decoded) {
+                        if (base64_decode(update, decoded, &decoded_len) == 0) {
+                            decoded[decoded_len] = '\0';
+                            // 对每个字节进行异或运算
+                            for (size_t i = 0; i < decoded_len; i++) {
+                                loc_checksum ^= decoded[i];
+                            }
+                            printf("ota_data_len:%d,offset:%d,本地校验: %d,4G校验:%d,base64_decode:data:\n",ota_data_len,offset,loc_checksum,checksum);
+                            //print_hex(decoded,decoded_len);
+                            if(checksum!=loc_checksum)
+                            {
+                                printf("异或校验失败!!!!!!!!!!!!!!!!!!");
+                                printf("异或校验失败!!!!!!!!!!!!!!!!!!");
+                                printf("异或校验失败!!!!!!!!!!!!!!!!!!");
+                                printf("异或校验失败!!!!!!!!!!!!!!!!!!");
+                                error_flag = 1;
+                            }else
+                            {
+                                if(updata_write(decoded,offset,decoded_len)!=decoded_len)
+                                {
+                                    error_flag = 1;
+                                    printf("flash 写入失败!!!!!");
+                                    printf("flash 写入失败!!!!!");
+                                    printf("flash 写入失败!!!!!");
+                                }else
+                                    ota_data_len+=decoded_len;
+                            }
+                            free(decoded);
+                        }
+                        ack_flag = 1;
+                        
+                    }else
+                    {
+                        printf("parse_uart_data:分配内存失败");
+                    }
+                    // printf("update:%d");
+                    // for(int i = 0;i<strlen(update);i++)
+                    // {
+                    //     putchar(update[i]);
+                    // }
+                    // printf("update:end");
+                    // size_t  out_len = 0;
+                    // unsigned char *decoded = base64_decode(update,strlen(update),&out_len);
+                    // if(decoded){
+  
+                    //         //decoded[decoded_len] = '\0';
+                    //         updata_write(decoded,out_len);
+                    //         printf("base64_decode:data:");
+                    //         print_hex(decoded,out_len);
+                    //         free(decoded);
+                    //         ack_flag = 1;
+                    // }
+                }
+                
+                
+            }
         }
         if(!strcmp(event->valuestring,"ota_end"))//ota结束
         {
+            ack_flag = 1;
             updata_fd_close();
             extern void lc_flash_update_ufw_init(char *reserved_area_name);
             lc_flash_update_ufw_init("UPDATE");
-            ack_flag = 1;
+            
 
         }
+
         if(!strcmp(event->valuestring,"switch_bt_state")) //收到4g传过来的ble开关状态 0 打开蓝牙扫描 1关闭蓝牙扫描
         {
             // {
@@ -637,12 +869,16 @@ int parse_uart_data(char *json_string)
             printf("获取当前连接蓝牙耳机的状态");
             send_bt_connect_state();
         }
-        if(ack_flag == 1)
+        if(error_flag == 0 && ack_flag == 1)
         {
             ack_flag = 0;
             uart_send_ack();
         }
-        
+        if(error_flag == 1)
+        {
+            error_flag = 0;
+            uart_send_error();
+        }
     }
     
     cJSON_Delete(root);
index 787f11f..7dc5849 100644 (file)
@@ -223,10 +223,10 @@ static int usr_pcmdec_wait_res_handler(struct audio_res_wait *wait, int event)
 }
 
 /*******************************************************************************************
-//成功返回 0 ; 不成功返回 其他;
+//æ\89\93å¼\80æ\9c¬å\9c°é\80\9aé\81\93æ\88\90å\8a\9fè¿\94å\9b\9e 0 ; ä¸\8dæ\88\90å\8a\9fè¿\94å\9b\9e å\85¶ä»\96;
 *******************************************************************************************/
 #include "app_main.h"
-int mic2dac_demo_start(void)
+int open_local_audio(void)
 {
     u16 ladc_sr = 16000;
     u8 ladc_gain = 19;
@@ -235,7 +235,7 @@ int mic2dac_demo_start(void)
     if(!(mci2dac_hdl)){
         mci2dac_hdl = zalloc(sizeof(usr_mic2dac_hd));
     }
-
+    gpio_direction_output(TCFG_AUDIO_DAC_PA_PORT, 1); //拉高pa,防止出问题
     if(mci2dac_hdl){
         //open mic
         if(audio_mic_open(&mci2dac_hdl->mic_ch, ladc_sr, ladc_gain) == 0){
@@ -279,7 +279,7 @@ int mic2dac_demo_start(void)
 /*******************************************************************************************
 //成功返回 0 ; 不成功返回 其他;
 *******************************************************************************************/
-int mic2dac_demo_stop(void)
+int close_local_audio(void)
 {
     mic_debug("[%s]!",__FUNCTION__);
     if(mci2dac_hdl){
@@ -318,37 +318,16 @@ u8 get_mic2dac_status(void)
 void mic_2_dac_test_deal(void)
 {
     if(!get_mic2dac_status()){
-        mic2dac_demo_start();
+        open_local_audio();
     }else{
 
-        mic2dac_demo_stop();
+        close_local_audio();
     }
 }
 /*******************************************************************************************
 
 *******************************************************************************************/
-static u8 mic2dac_idle_query()
-{
-    static u8 printf_flag = 0 ;
-    if((mci2dac_hdl)&&(mci2dac_hdl->status == MIC2DAC_STATUS_START)){
-        if(printf_flag == 0){
-            mic_debug("busy", __FUNCTION__);
-            printf_flag = 1;
-        }
-
-        return 0;
-    }
-    if(printf_flag){
-        printf_flag =0;
-    }
-    return 1;
-}
-
-
-REGISTER_LP_TARGET(mic2dac_lp_target) = {
-    .name = "mic2dac_demo",
-    .is_idle = mic2dac_idle_query,
-};
+// 
 
 #endif
 
index 84745a8..fbce64c 100644 (file)
@@ -20,8 +20,8 @@ enum {
 };
 
 u8 get_mic2dac_status(void);
-int mic2dac_demo_start(void);
-int mic2dac_demo_stop(void);
+int open_local_audio(void);
+int close_local_audio(void);
 //告诉解码器要更新数据了
 void audio_decoder_updata(void);
 #endif
\ No newline at end of file
index f72d75b..6bfbc86 100644 (file)
@@ -127,6 +127,9 @@ void AI_VC_1S_cb(void *p)
         log_info("%s:该休眠了 !!!!!!",__FUNCTION__);
         gpio_write(IO_PORTB_03,0);
         bk_app_send_smg(AI_CLOSE,NULL,0);
+    }else
+    {
+        gpio_write(IO_PORTB_03,1);//响应4G唤醒
     }
 }
 //vc开始
@@ -350,28 +353,26 @@ void bk_app_init(void)
     // while(1)
     // ;
     // 启用VAD时初始化
-    struct VadConfig conf;
-    conf.sil_threshold = 63;
-    conf.energy_threshold = 10000;
-    conf.min_speech_length = 240;
-    conf.silence_detect_length = 300;
-    conf.rule1_min_tailing_silence = 480;
-    conf.rule2_min_tailing_silence = 960;
-    conf.rule3_min_tailing_silence = 960;
-    conf.vad_log_level = 0;
-    init_vad(&conf);
+    // struct VadConfig conf;
+    // conf.sil_threshold = 63;
+    // conf.energy_threshold = 10000;
+    // conf.min_speech_length = 240;
+    // conf.silence_detect_length = 300;
+    // conf.rule1_min_tailing_silence = 480;
+    // conf.rule2_min_tailing_silence = 960;
+    // conf.rule3_min_tailing_silence = 960;
+    // conf.vad_log_level = 0;
+    // init_vad(&conf);
+    // //err = os_task_create(bk_ALG_task, NULL, 31, 1024*8, 255, "bk_ALG_task");
+    // err = task_create(bk_ALG_task, NULL, "bk_ALG_task");
+
     err = os_task_create(bk_app_task, NULL, 31, 512, 255, "bk_app_task");
-    //err = os_task_create(bk_ALG_task, NULL, 31, 1024*8, 255, "bk_ALG_task");
-    err = task_create(bk_ALG_task, NULL, "bk_ALG_task");
     //int err = task_create(bk_app_task, NULL, "bk_app_task");
     if (err != OS_ERR_NONE) {
         r_printf("creat fail %x\n", err);
     }
     //AI_VC_1S_id = sys_timer_add(NULL, AI_VC_1S_cb, 1000);
-    printf("这是升级后的固件!!!!!!!!!!!!!!!!!!!!!!");
-    printf("这是升级后的固件!!!!!!!!!!!!!!!!!!!!!!");
-    printf("这是升级后的固件!!!!!!!!!!!!!!!!!!!!!!");
-    printf("这是升级后的固件!!!!!!!!!!!!!!!!!!!!!!");
+
 
 }
 
index 7a7d5a2..e19b63b 100644 (file)
@@ -98,7 +98,7 @@ static int norflash_verify_part(struct norflash_partition *p)
 
 static int _norflash_init(const char *name, struct norflash_sfc_dev_platform_data *pdata)
 {
-    log_info("norflash_sfc_init >>>>");
+    log_info("norflash_sfc_init >>>>:%s",pdata->path);
     if (pdata->path) {
         FILE *fp = fopen(pdata->path, "r");
         if (!fp) {
@@ -187,6 +187,7 @@ static int norflash_sfc_fs_dev_read(struct device *device, void *buf, u32 len, u
 static int norflash_sfc_fs_dev_write(struct device *device, void *buf, u32 len, u32 offset)
 {
     u32 rets;//, reti;
+    //printf("norflash_sfc_fs_dev_write:device:%d,len:%d,offset:%d",device,len,offset);
     __asm__ volatile("%0 = rets":"=r"(rets));
     int reg = 0;
     struct norflash_partition *part = device->private_data;
@@ -202,7 +203,9 @@ static int norflash_sfc_fs_dev_write(struct device *device, void *buf, u32 len,
     /* norflash_mutex_enter(); */
     ASSERT(!cpu_in_irq());
     ASSERT(!cpu_irq_disabled());
+    //printf("norflash_sfc_fs_dev_write2");
     reg =  norflash_write(NULL, buf, len, offset);//写操作里面已经集合的互斥,这里仅仅检查中断
+    //printf("norflash_sfc_fs_dev_write3:reg:%d",reg);
     /* norflash_mutex_exit(); */
     return reg;
 }
@@ -218,7 +221,7 @@ static int norflash_sfc_fs_dev_ioctl(struct device *device, u32 cmd, u32 arg)
     __asm__ volatile("%0 = rets":"=r"(rets));
     struct norflash_partition *part = device->private_data;
     struct sfc_no_enc_wr   *no_enc_wr;
-    int reg;
+    int reg = 0;
     if (!part) {
         log_error("norflash partition invalid\n");
         return -EFAULT;
@@ -301,3 +304,300 @@ const struct device_operations inside_norflash_fs_dev_ops = {
     .ioctl  = norflash_sfc_fs_dev_ioctl,
     .close  = norflash_sfc_fs_dev_close,
 };
+
+
+#define FLASH_CACHE_ENABLE             1
+
+#if FLASH_CACHE_ENABLE
+static u32 flash_cache_addr;
+static u8 *flash_cache_buf = NULL; //缓存4K的数据,与flash里的数据一样。
+static u8 flash_cache_is_dirty;
+static u16 flash_cache_timer;
+
+#define FLASH_CACHE_SYNC_T_INTERVAL     60
+
+#endif
+
+
+static int norflash_fat_fs_dev_init(const struct dev_node *node, void *arg)
+{
+    struct norflash_sfc_dev_platform_data *pdata = arg;
+    int ret =  _norflash_init(node->name, pdata);
+   return ret;
+}
+
+static int norflash_fat_fs_dev_open(const char *name, struct device **device, void *arg)
+{
+    struct norflash_partition *part;
+    part = norflash_find_part(name);
+    if (!part) {
+        log_error("no norflash partition is found\n");
+        return -ENODEV;
+    }
+    *device = &part->device;
+    (*device)->private_data = part;
+    if (atomic_read(&part->device.ref)) {
+        return 0;
+    }
+#if FLASH_CACHE_ENABLE
+    /* ASSERT(flash_cache_buf, "flash_cache_buf is not only\n"); */
+    if(!flash_cache_buf){
+        flash_cache_buf = (u8 *)malloc(4096);
+        flash_cache_addr = 4096;//先给一个大于4096的数
+    }
+    norflash_sfc_fs_dev_read(*device, flash_cache_buf,4096,0);
+    flash_cache_addr = 0;
+#endif
+
+    return 0;//_norflash_open(arg);
+}
+
+
+
+static int norflash_fat_fs_dev_close(struct device *device)
+{
+#if FLASH_CACHE_ENABLE
+
+    norflash_mutex_enter();
+    if (flash_cache_is_dirty) {
+        flash_cache_is_dirty = 0;
+        norflash_sfc_fs_dev_ioctl(device,IOCTL_ERASE_SECTOR, flash_cache_addr);
+        norflash_sfc_fs_dev_write(device, flash_cache_buf,4096,flash_cache_addr);
+        /* _norflash_sfc_ioctl_eraser(IOCTL_ERASE_SECTOR, flash_cache_addr); */
+        /* _norflash_write_pages(flash_cache_addr, flash_cache_buf, 4096); */
+
+    }
+    norflash_mutex_exit();
+    /* free(flash_cache_buf); */
+    /* flash_cache_buf = NULL; */
+#endif
+ 
+    return 0;//_norflash_close();
+}
+
+
+
+static int norflash_fat_fs_dev_read(struct device *device, void *buf, u32 len, u32 addr)
+{
+
+    int org_len = len;
+#if FLASH_CACHE_ENABLE
+    addr = addr * 512;
+    len = len * 512;
+    norflash_mutex_enter();
+    u32 r_len = 4096 - (addr % 4096);
+    if ((addr >= flash_cache_addr) && (addr < (flash_cache_addr + 4096))) {
+        if (len <= r_len) {
+            memcpy(buf, flash_cache_buf + (addr - flash_cache_addr), len);
+            /* int  ret = len; */
+            norflash_mutex_exit();
+            goto __exit;
+        } else {
+            memcpy(buf, flash_cache_buf + (addr - flash_cache_addr), r_len);
+            addr += r_len;
+            buf += r_len;
+            len -= r_len;
+        }
+
+    }
+    norflash_mutex_exit();
+    norflash_sfc_fs_dev_read(device,buf,len,addr);
+
+#endif
+    norflash_sfc_fs_dev_read(device,buf,len,addr);
+__exit:
+    return org_len;
+}
+
+
+#if FLASH_CACHE_ENABLE
+static void _norflash_cache_sync_timer(struct device *device)
+{
+
+    norflash_mutex_enter();
+    int reg = 0;
+    if (flash_cache_is_dirty) {
+        flash_cache_is_dirty = 0;
+        /* reg = _norflash_sfc_ioctl_eraser(IOCTL_ERASE_SECTOR, flash_cache_addr); */
+        reg = norflash_sfc_fs_dev_ioctl(device,IOCTL_ERASE_SECTOR, flash_cache_addr);
+        if (reg == -EFAULT) {
+            goto __exit;
+        }
+        /* reg = _norflash_write_pages(flash_cache_addr, flash_cache_buf, 4096); */
+        reg = norflash_sfc_fs_dev_write(device, flash_cache_buf,4096,flash_cache_addr);
+    }
+    if (flash_cache_timer) {
+        sys_timeout_del(flash_cache_timer);
+        flash_cache_timer = 0;
+    }
+__exit:
+    norflash_mutex_exit();
+    return;
+
+}
+#endif
+
+
+
+static int norflash_fat_fs_dev_write(struct device *device, void *buf, u32 len, u32 addr)
+{
+    norflash_mutex_enter();
+    int org_len = len;
+#if FLASH_CACHE_ENABLE
+    u8 *w_buf = (u8 *)buf;
+    u32 w_len = len;
+    addr = addr * 512;
+    len = len * 512;
+    int reg; 
+    u32 align_addr = addr / 4096 * 4096;
+    u32 align_len = 4096 - (addr - align_addr);
+    align_len = w_len > align_len ? align_len : w_len;
+    if (align_addr != flash_cache_addr) {
+        if (flash_cache_is_dirty) {
+            flash_cache_is_dirty = 0;
+            reg = norflash_sfc_fs_dev_ioctl(device,IOCTL_ERASE_SECTOR, flash_cache_addr);
+            if (reg == -EFAULT) {
+                line_inf;
+                goto __exit;
+            }
+            /* reg = _norflash_write_pages(flash_cache_addr, flash_cache_buf, 4096); */
+            reg = norflash_sfc_fs_dev_write(device, flash_cache_buf,4096,flash_cache_addr);
+            if (reg != 4096) {
+                line_inf;
+                goto __exit;
+            }
+        }
+        /* fat_sfc_norflash_read(align_addr, flash_cache_buf, 4096, 0); */
+        norflash_sfc_fs_dev_read(device,flash_cache_buf,4096,align_addr);
+        flash_cache_addr = align_addr;
+    }
+    memcpy(flash_cache_buf + (addr - align_addr), w_buf, align_len);
+    if ((addr + align_len) % 4096) {
+        flash_cache_is_dirty = 1;
+        if (flash_cache_timer) {
+            sys_timer_re_run(flash_cache_timer);
+        } else {
+            flash_cache_timer = sys_timeout_add(0, _norflash_cache_sync_timer, FLASH_CACHE_SYNC_T_INTERVAL);
+        }
+    } else {
+        flash_cache_is_dirty = 0;
+        /* reg = norflash_sfc_fs_dev_ioctl(IOCTL_ERASE_SECTOR, align_addr); */
+        reg = norflash_sfc_fs_dev_ioctl(device,IOCTL_ERASE_SECTOR, align_addr);
+        if (reg == -EFAULT ) {
+            line_inf;
+            goto __exit;
+        }
+        /* reg = _norflash_write_pages(align_addr, flash_cache_buf, 4096); */
+        reg = norflash_sfc_fs_dev_write(device, flash_cache_buf,4096,align_addr);
+        if (reg != 4096) {
+            line_inf;
+            goto __exit;
+        }
+    }
+    addr += align_len;
+    w_buf += align_len;
+    w_len -= align_len;
+    while (w_len) {
+        u32 cnt = w_len > 4096 ? 4096 : w_len;
+        /* fat_sfc_norflash_read(addr, flash_cache_buf, 4096, 0); */
+        norflash_sfc_fs_dev_read(device,flash_cache_buf,4096,align_addr);
+        flash_cache_addr = addr;
+        memcpy(flash_cache_buf, w_buf, cnt);
+        if ((addr + cnt) % 4096) {
+            flash_cache_is_dirty = 1;
+            if (flash_cache_timer) {
+                sys_timer_re_run(flash_cache_timer);
+            } else {
+                flash_cache_timer = sys_timeout_add(0, _norflash_cache_sync_timer, FLASH_CACHE_SYNC_T_INTERVAL);
+            }
+        } else {
+            flash_cache_is_dirty = 0;
+            /* reg = norflash_sfc_fs_dev_ioctl(IOCTL_ERASE_SECTOR, addr); */
+            reg = norflash_sfc_fs_dev_ioctl(device,IOCTL_ERASE_SECTOR, addr);
+            if (reg ==  -EFAULT) {
+                line_inf;
+                goto __exit;
+            }
+            /* reg = _norflash_write_pages(addr, flash_cache_buf, 4096); */
+            reg = norflash_sfc_fs_dev_write(device, flash_cache_buf,4096,addr);
+            if (reg != 4096) {
+                line_inf;
+                goto __exit;
+            }
+        }
+        addr += cnt;
+        w_buf += cnt;
+        w_len -= cnt;
+    }
+#else
+    /* reg = _norflash_write_pages(addr, w_buf, w_len); */
+    reg = norflash_sfc_fs_dev_write(device, w_buf,w_len,addr);
+#endif
+
+__exit:
+    norflash_mutex_exit();
+    return org_len;
+}
+
+static bool norflash_fat_fs_dev_online(const struct dev_node *node)
+{
+    return 1;
+}
+
+static int norflash_fat_fs_dev_ioctl(struct device *device, u32 cmd, u32 arg)
+{
+    struct norflash_partition *part = device->private_data;
+
+    switch(cmd){
+        case IOCTL_ERASE_SECTOR:
+            int reg = norflash_sfc_fs_dev_ioctl(device,IOCTL_ERASE_SECTOR, arg*512);
+            return reg;
+            break;
+
+        case IOCTL_FLUSH:
+            norflash_mutex_enter();
+            if (flash_cache_is_dirty) {
+                flash_cache_is_dirty = 0;
+                norflash_sfc_fs_dev_ioctl(device,IOCTL_ERASE_SECTOR, flash_cache_addr);
+                norflash_sfc_fs_dev_write(device, flash_cache_buf,4096,flash_cache_addr);
+            }
+            norflash_mutex_exit();
+            return 0;
+            break;
+
+        case IOCTL_GET_CAPACITY:
+            *(u32 *)arg = part->size / 512;
+
+            /* *(u32 *)arg = part->size; */
+            break;
+
+        case IOCTL_GET_BLOCK_SIZE:
+            *(u32 *)arg = 512;
+            break;
+
+        case IOCTL_CMD_RESUME:
+            break;
+
+        case IOCTL_CMD_SUSPEND:
+            break;
+
+        default:
+            ASSERT(0,"%d",cmd);
+            break;
+    }
+    return 0;
+}
+//按512字节单位读写
+const struct device_operations inside_norflash_fat_fs_dev_ops = {
+    .init   = norflash_fat_fs_dev_init,
+    .online = norflash_fat_fs_dev_online,
+    .open   = norflash_fat_fs_dev_open,
+    .read   = norflash_fat_fs_dev_read,
+    .write  = norflash_fat_fs_dev_write,
+    .ioctl  = norflash_fat_fs_dev_ioctl,
+    .close  = norflash_fat_fs_dev_close,
+};
+
+
+
+
index 9ffe27a..edaaed7 100644 (file)
@@ -54,6 +54,7 @@ struct norflash_sfc_dev_platform_data {
 extern const struct device_operations norflash_sfc_dev_ops;
 extern const struct device_operations norflash_sfc_fs_dev_ops;
 extern const struct device_operations inside_norflash_fs_dev_ops;
+extern const struct device_operations inside_norflash_fat_fs_dev_ops;
 
 #endif
 
index 72405a7..b5c746a 100644 (file)
@@ -311,6 +311,7 @@ void lc_flash_update_ufw_init(char *reserved_area_name)
     if (lc_flash_ufw_update_f_open()) {
         if (update_file_verify(user_remote_base_addr, lc_flash_update_file_read) != 0) {
             //校验失败
+            printf("lc_flash_update_ufw_init:校验失败 user_remote_base_addr:%d\n",user_remote_base_addr);
             goto _ERR_RET;
         }
     } else {
@@ -324,7 +325,7 @@ void lc_flash_update_ufw_init(char *reserved_area_name)
         .p_op_api = &lc_flash_ufw_update_op_api,
         .task_en = 1,
     };
-
+    printf("lc_flash_update_ufw_init:app_active_update_task_init\n");
     app_active_update_task_init(&lc_flash_ufw_update_info);
 
 _ERR_RET:
@@ -334,44 +335,82 @@ _ERR_RET:
     }
 }
 
+#include "device.h"
+void *bk_dev_ptr = NULL;
+//int offset = 0;
 void updata_fd_open(char *reserved_area_name)
 {
-    if (NULL == path) {
-        path = zalloc(sizeof(SDFILE_EXT_RES_ROOT_PATH) + strlen(reserved_area_name));
-        if (NULL == path) {
-            printf("err: alloc lc flash ufw path fail\n");
-            
-        }
-        strcat(path, SDFILE_EXT_RES_ROOT_PATH);
-        strcat(path, reserved_area_name);
+    
+    if (bk_dev_ptr) {
+        
+        dev_close(bk_dev_ptr);
+        bk_dev_ptr=NULL;
     }
-    if (dev_ptr )
-    {
-        fclose((FILE *)dev_ptr);
-        dev_ptr = NULL;
-    }
-    dev_ptr = (void *)fopen(path, "w");
-    if (dev_ptr) {
+    //offset = 0;
+    int ERASE_offset = 0;
+    bk_dev_ptr = dev_open("user_update",NULL);
+    if (bk_dev_ptr) {
         // struct vfs_attr attr;
-        // fget_attrs((FILE *)dev_ptr, &attr);
+        // fget_attrs(dev_ptr, &attr);
         // user_remote_base_addr = sdfile_cpu_addr2flash_addr(attr.sclust);
         // lc_flash_update_info.src_file_addr = user_remote_base_addr;
-        printf("open_updata_fd %s file succ 0x%x, 0x%x", path);
+        printf("open_updata_fd %s file succ", path);
+        while(1)//先全部擦除一遍
+        {
+
+            dev_ioctl(bk_dev_ptr, IOCTL_ERASE_SECTOR, ERASE_offset);
+            printf("ERASE:offset:%d",ERASE_offset);
+            //os_time_dly(1);
+            ERASE_offset += 4*1024;
+            if(ERASE_offset>=0x200000)
+                break;
+        }
         return ;
     } else {
-        printf("open %s file fail", path);
+        printf("updata_fd_open open %s file fail", path);
     }
 }
-int updata_write(char *data,int len)
+char ota_data_tmp[4096];
+int ERASE_offset_tmp = 0;
+//char ota_data_write[4*1024];
+int updata_write(char *data,int offset ,int len)
 {
-    int wlen = fwrite((FILE *)dev_ptr, data, len);
+    if(bk_dev_ptr == NULL)
+        return 0;
+    int wlen  = 0;
+    int rlen = 0;
+    
+    //memset(ota_data_write,1,sizeof(ota_data_write));
+    memset(ota_data_tmp,0,sizeof(ota_data_tmp));
+    //memcpy(ota_data_write,data,len);
+    
+       
+    // if(len <2048)
+    // {
+    //     len = 2048;
+    // }
+    wlen = dev_bulk_write(bk_dev_ptr, data, offset,len);
+    
+    
+    printf("updata_write:wlen:%d,len:%d,offset:%d",wlen,len,offset);
+    rlen = dev_bulk_read(bk_dev_ptr, ota_data_tmp, offset,len);
+    int cmp_t=memcmp(ota_data_tmp,data,len);
+    printf("dev_bulk_read:rlen:%d,cmp_t:%d",rlen,cmp_t);
+    if(cmp_t !=0)
+    {
+        printf("updata_write:写入失败!!!!!!!!!");
+        printf("updata_write:写入失败!!!!!!!!!");
+        printf("updata_write:写入失败!!!!!!!!!");
+        return -1;
+    }
+
     return wlen;
 }
 void updata_fd_close(void)
 {
-    if (dev_ptr )
+    if (bk_dev_ptr )
     {
-        fclose((FILE *)dev_ptr);
-        dev_ptr = NULL;
+        dev_close(bk_dev_ptr);
+        bk_dev_ptr = NULL;
     }
 }
index c6f7283..de73541 100644 (file)
@@ -721,8 +721,8 @@ NORFLASH_SFC_DEV_PLATFORM_DATA_END()
 #define USER_UPDATE_PATH               SDFILE_MOUNT_PATH"/EXT_RESERVED/"USER_UPDATE_FLASH_NAME  //分区
 NORFLASH_SFC_DEV_PLATFORM_DATA_BEGIN(norflash_norfs_inside_update_dev_data)
     .path                 = USER_UPDATE_PATH,
-    .start_addr     = 0x600000,//TCFG_VIRFAT_INSERT_FLASH_BASE + TCFG_VIRFAT_INSERT_FLASH_SIZE,
-    .size           = 0x180000,//CONFIG_EXTERN_USER_VM_FLASH_SIZE,
+    .start_addr     = 0x400000,//TCFG_VIRFAT_INSERT_FLASH_BASE + TCFG_VIRFAT_INSERT_FLASH_SIZE,
+    .size           = 0x200000,//CONFIG_EXTERN_USER_VM_FLASH_SIZE,
 NORFLASH_SFC_DEV_PLATFORM_DATA_END()
 
 #if TCFG_SD0_ENABLE
@@ -915,8 +915,8 @@ REGISTER_DEVICES(device_table) = {
     //res_nor 是物理设备入口
 #if TCFG_NORFLASH_SFC_DEV_ENABLE
     //使用外挂flash  跑ui
-       { "res_nor",   &norflash_sfc_fs_dev_ops, (void *)&norflash_sfc_dev_data},
-       { "update_noenc",   &norflash_sfc_fs_dev_ops, (void *)&norflash_norfs_unenc_dev_data}, // “update_noenc”的设备在初始化时,不会对该区域检查是否与其他区域重叠
+       //{ "res_nor",   &norflash_sfc_fs_dev_ops, (void *)&norflash_sfc_dev_data},
+       //{ "update_noenc",   &norflash_sfc_fs_dev_ops, (void *)&norflash_norfs_unenc_dev_data}, // “update_noenc”的设备在初始化时,不会对该区域检查是否与其他区域重叠
 #endif /*TCFG_NORFLASH_SFC_DEV_ENABLE*/
 
 #if 0//TCFG_VIRFAT_INSERT_FLASH_ENABLE
@@ -966,7 +966,7 @@ REGISTER_DEVICES(device_table) = {
 #if TCFG_NORFLASH_SFC_DEV_ENABLE
 #if TCFG_NOR_VM
     //使用外挂flash
-    {"ui_vm",   &norflash_sfc_fs_dev_ops , (void *)&norflash_norfs_vm_dev_data},
+    //{"ui_vm",   &norflash_sfc_fs_dev_ops , (void *)&norflash_norfs_vm_dev_data},
 #endif
 #endif//TCFG_NORFLASH_SFC_DEV_ENABLE
 
@@ -977,7 +977,10 @@ REGISTER_DEVICES(device_table) = {
 #endif
     
 #endif//TCFG_NORFLASH_SFC_DEV_ENABLE
-    //{"user_update",   &inside_norflash_fs_dev_ops , (void *)&norflash_norfs_inside_update_dev_data},
+    //{"user_update",   &inside_norflash_fat_fs_dev_ops , (void *)&norflash_norfs_inside_update_dev_data},
+    // { "virfat_flash",       &virfat_flash_dev_ops,  (void *)"user_update"},
+    //{ "fat_nor",   &inside_norflash_fs_dev_ops , (void *)&norflash_norfs_inside_fat_nor_dev_data},
+    {"user_update",   &inside_norflash_fs_dev_ops , (void *)&norflash_norfs_inside_update_dev_data},
 };
 
 /************************** LOW POWER config ****************************/
index 5685c09..7475610 100644 (file)
 #define CONFIG_RULE_INSERT_UI_VM_SIZE          0x20000//128k
 
 #define CONFIG_RULE_LC_FLASH_UPDATE_BASE    0x600000 //内置flash升级起始地址
-#define CONFIG_RULE_LC_FLASH_UPDATE_SIZE       0x180000 //ufw升级文件占的空间
+#define CONFIG_RULE_LC_FLASH_UPDATE_SIZE       0x200000 //ufw升级文件占的空间
 
 #else
 #define CONFIG_RULE_INSERT_FLASH_BASE          0x17e000 //1.5m - 8k开始 内置FLASH虚拟文件系统空间基础地址
@@ -454,7 +454,7 @@ DAC硬件上的连接方式,可选的配置:
     注意:
     1、选择 DAC_OUTPUT_MONO_LR_DIFF DAC要选单端输出,选差分N端也会打开导致功耗大。
 */
-#define TCFG_AUDIO_DAC_CONNECT_MODE         DAC_OUTPUT_MONO_L
+#define TCFG_AUDIO_DAC_CONNECT_MODE         DAC_OUTPUT_MONO_LR_DIFF
 
 /*
          DAC模式选择
index fd23ba8..0e8c3f5 100644 (file)
@@ -126,6 +126,8 @@ const struct task_info task_info_table[] = {
     // {"user_ble_protocol",             3,     0,   1024, 256 },
     //{"bk_app_task",             3,     0,   1024*2, 256 },
     {"bk_ALG_task",             3,     1,   1024, 256 },
+    {"bk_uart_task",             3,     1,   2*1024, 256 },
+    
     {0, 0},
 };
 
index 0dda1e2..d9b09c6 100644 (file)
@@ -1683,6 +1683,7 @@ static int esco_dec_data_handler(struct audio_stream_entry *entry,
     //memset(out_frame.data,0,out_frame.data_len);//清掉数据,不然本地喇叭播放
     
     audio_stream_run(&decoder->entry, &out_frame);//播放到本地喇叭,要打开,不然mic数据不对,且会死机。数据不知道穿去哪里
+    gpio_direction_output(TCFG_AUDIO_DAC_PA_PORT, 0); //关闭pa
     if(tmp_buf)
     {
         if (in->data_len == decoder->process_len)
index 4240eeb..2ea4a8b 100644 (file)
@@ -42,16 +42,16 @@ cd %~dp0
 ..\..\md5sum.exe app.bin md5.bin\r
 set /p "themd5=" < "md5.bin"\r
 \r
-..\..\packres.exe -keep-suffix-case JL.sty JL.res JL.str -n res -o JL\r
-..\..\packres.exe -keep-suffix-case sidebar.sty sidebar.res sidebar.str sidebar.tab -n res -o sidebar\r
-..\..\packres.exe -keep-suffix-case watch.sty watch.res watch.str watch.view watch.json -n res -o watch\r
-..\..\packres.exe -keep-suffix-case watch1.sty watch1.res watch1.str watch1.view watch1.json -n res -o watch1\r
-..\..\packres.exe -keep-suffix-case watch2.sty watch2.res watch2.str watch2.view watch2.json -n res -o watch2\r
-..\..\packres.exe -keep-suffix-case watch3.sty watch3.res watch3.str watch3.view watch3.json -n res -o watch3\r
-..\..\packres.exe -keep-suffix-case watch4.sty watch4.res watch4.str watch4.view watch4.json -n res -o watch4\r
-..\..\packres.exe -keep-suffix-case watch5.sty watch5.res watch5.str watch5.view watch5.json -n res -o watch5\r
-..\..\packres.exe -keep-suffix-case F_ASCII.PIX F_GB2312.PIX F_GB2312.TAB ascii.res -n res -o font\r
-\r
+@REM ..\..\packres.exe -keep-suffix-case JL.sty JL.res JL.str -n res -o JL\r
+@REM ..\..\packres.exe -keep-suffix-case sidebar.sty sidebar.res sidebar.str sidebar.tab -n res -o sidebar\r
+@REM ..\..\packres.exe -keep-suffix-case watch.sty watch.res watch.str watch.view watch.json -n res -o watch\r
+@REM ..\..\packres.exe -keep-suffix-case watch1.sty watch1.res watch1.str watch1.view watch1.json -n res -o watch1\r
+@REM ..\..\packres.exe -keep-suffix-case watch2.sty watch2.res watch2.str watch2.view watch2.json -n res -o watch2\r
+@REM ..\..\packres.exe -keep-suffix-case watch3.sty watch3.res watch3.str watch3.view watch3.json -n res -o watch3\r
+@REM ..\..\packres.exe -keep-suffix-case watch4.sty watch4.res watch4.str watch4.view watch4.json -n res -o watch4\r
+@REM ..\..\packres.exe -keep-suffix-case watch5.sty watch5.res watch5.str watch5.view watch5.json -n res -o watch5\r
+@REM ..\..\packres.exe -keep-suffix-case F_ASCII.PIX F_GB2312.PIX F_GB2312.TAB ascii.res -n res -o font\r
+@REM ..\..\packres.exe -keep-suffix-case update_new.ufw -n res -o update_new\r
 ::echo %1\r
 \r
 set CHIPKEY=default.key\r
@@ -60,8 +60,8 @@ set CHIPKEY=default.key
 ::..\..\packres.exe -keep-suffix-case F_ASCII.PIX ascii.res -n res -o font\r
 ::..\..\fat_comm.exe -pad-backup2 -force-align-fat -out new_res.bin -image-size 8 -filelist  JL sidebar watch3 watch4 font  -remove-empty -remove-bpb -mark-bad-after 0x7e0000 -key %CHIPKEY% -address 0\r
 :: 16MBytes\r
-..\..\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 0xfe0000 -key %CHIPKEY% -address 0\r
-\r
+::..\..\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 0xfe0000 -key %CHIPKEY% -address 0\r
+::..\..\fat_comm.exe -pad-backup2 -force-align-fat -out update_new.bin -image-size 16 -filelist  watch4 -remove-empty -remove-bpb -mark-bad-after 0x200000 -key %CHIPKEY% -address 0\r
 IF %ERRORLEVEL% NEQ 0 goto exit_point\r
 \r
 del /Q res.ori\*\r
index 5443754..57246d4 100644 (file)
@@ -51,7 +51,7 @@ set /p "themd5=" < "md5.bin"
 ..\..\packres.exe -keep-suffix-case watch4.sty watch4.res watch4.str watch4.view watch4.json -n res -o watch4\r
 ..\..\packres.exe -keep-suffix-case watch5.sty watch5.res watch5.str watch5.view watch5.json -n res -o watch5\r
 ..\..\packres.exe -keep-suffix-case F_ASCII.PIX F_GB2312.PIX F_GB2312.TAB ascii.res -n res -o font\r
-\r
+..\..\packres.exe -keep-suffix-case update_new.ufw -n res -o update_new\r
 ::echo %1\r
 \r
 set CHIPKEY=default.key\r
@@ -59,8 +59,8 @@ set CHIPKEY=default.key
 :: 8MBytes\r
 :: ..\..\fat_comm.exe -pad-backup2 -force-align-fat -out new_res.bin -image-size 8 -filelist  JL sidebar watch watch1 watch2 watch3 watch4 watch5 font  -remove-empty -remove-bpb -mark-bad-after 0x660000 -address 0\r
 :: 16MBytes\r
-..\..\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\r
-\r
+::..\..\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\r
+..\..\fat_comm.exe -pad-backup2 -force-align-fat -out update_new.bin -image-size 8 -filelist    watch4 -remove-empty -remove-bpb -mark-bad-after 0x200000 -key %CHIPKEY% -address 0\r
 IF %ERRORLEVEL% NEQ 0 goto exit_point\r
 \r
 del /Q res.ori\*\r
@@ -70,7 +70,7 @@ move watch? res.ori\
 move font res.ori\font\r
 \r
 ..\..\packres.exe -n res -o res.bin new_res.bin 0 -normal\r
-::ÍâÖÃflash·ÅÉý¼¶Îļþ£¬Ê¾ÀýΪ·ÅÔÚ0xb00000µØÖ·£¬ÐèÒªÏÈÉú³Énor_up.ufw\r
+::????flash???????????????????0xb00000??????????????nor_up.ufw\r
 ::..\..\packres.exe -n res -o res.bin new_res.bin 0 nor_up.ufw 0xb00000 -normal\r
 \r
 \r
@@ -87,7 +87,7 @@ move font res.ori\font
 ::-reboot 100\r
 \r
 \r
-@rem É¾³ýÁÙʱÎļþ-format all\r
+@rem ?????????-format all\r
 if exist *.mp3 del *.mp3 \r
 if exist *.PIX del *.PIX\r
 if exist *.TAB del *.TAB\r
@@ -107,16 +107,16 @@ del jl_isd.ufw
 ::..\..\zip.exe -r upgrade.zip res.ori update.ufw\r
 ..\..\zip.exe -r upgrade.zip update.ufw\r
 \r
-@REM Éú³ÉÅäÖÃÎļþÉý¼¶Îļþ\r
+@REM ¨¦¨²3¨¦???????t¨¦y?????t\r
 ::ufw_maker.exe -chip AC800X %ADD_KEY% -output config.ufw -res bt_cfg.cfg\r
 \r
 ::IF EXIST jl_693x.bin del jl_693x.bin \r
 \r
 \r
-@rem ³£ÓÃÃüÁî˵Ã÷\r
-@rem -format vm        //²Á³ýVM ÇøÓò\r
-@rem -format cfg       //²Á³ýBT CFG ÇøÓò\r
-@rem -format 0x3f0-2   //±íʾ´ÓµÚ 0x3f0 ¸ö sector ¿ªÊ¼Á¬Ðø²Á³ý 2 ¸ö sector(µÚÒ»¸ö²ÎÊýΪ16½øÖÆ»ò10½øÖƶ¼¿É£¬µÚ¶þ¸ö²ÎÊý±ØÐëÊÇ10½øÖÆ)\r
+@rem 3¡ê¨®??¨¹¨¢??¦Ì?¡Â\r
+@rem -format vm        //2¨¢3yVM ??¨®¨°\r
+@rem -format cfg       //2¨¢3yBT CFG ??¨®¨°\r
+@rem -format 0x3f0-2   //¡À¨ª¨º?¡ä¨®¦Ì¨² 0x3f0 ?? sector ?a¨º?¨¢?D?2¨¢3y 2 ?? sector(¦Ì¨²¨°???2?¨ºy?a16?????¨°10???????¨¦¡ê?¦Ì¨²?t??2?¨ºy¡À?D?¨º?10????)\r
 \r
 :exit_point\r
 \r
diff --git a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/JL b/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/JL
deleted file mode 100644 (file)
index 3d5a84d..0000000
Binary files a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/JL and /dev/null differ
diff --git a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/font b/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/font
deleted file mode 100644 (file)
index 0517805..0000000
Binary files a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/font and /dev/null differ
diff --git a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch b/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch
deleted file mode 100644 (file)
index 83484fb..0000000
Binary files a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch and /dev/null differ
diff --git a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch1 b/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch1
deleted file mode 100644 (file)
index 1b602c4..0000000
Binary files a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch1 and /dev/null differ
diff --git a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch2 b/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch2
deleted file mode 100644 (file)
index 35d5b5e..0000000
Binary files a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch2 and /dev/null differ
diff --git a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch3 b/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch3
deleted file mode 100644 (file)
index 310d37c..0000000
Binary files a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch3 and /dev/null differ
diff --git a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch4 b/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch4
deleted file mode 100644 (file)
index a252f08..0000000
Binary files a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch4 and /dev/null differ
diff --git a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch5 b/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch5
deleted file mode 100644 (file)
index c67c824..0000000
Binary files a/2.code/1.sdk/cpu/br28/tools/download/watch/res.ori/watch5 and /dev/null differ
index d22cc5d..2d33118 100644 (file)
@@ -589,6 +589,24 @@ ISD_CFG
 FILE_LIST = (file = file_authrunFindmy.tkn: type = 0xec);
 #endif
 
+// [RESERVED_EXPAND_CONFIG]
+// UPDATE_FILE = update_new.bin;
+// UPDATE_ADR = 0x500000;
+// UPDATE_LEN = 0x200000;
+// UPDATE_OPT = 1;
+
+
+#if 1
+
+
+ISD_CFG
+[RESERVED_EXPAND_CONFIG]
+UPDATE_FILE = update_new.ufw;
+UPDATE_ADR = 0x400000;
+UPDATE_LEN = 0x200000;
+UPDATE_OPT = 1;
+#endif
+
 ISD_CFG
 [BURNER_CONFIG]
 SIZE = CONFIG_BURNER_INFO_SIZE;