1.mcu升级功能
This commit is contained in:
parent
d377144dc9
commit
40a52dc31c
|
@ -326,10 +326,12 @@ UINT8 sf_cardv_check_power_on_mode(void)
|
|||
char *pStrSrc = NULL;
|
||||
char *pStrOtsOk = "Mode=";
|
||||
char *pStrUpFw = "UpFw=";
|
||||
char *pStrUpMcu = "mcu=";
|
||||
|
||||
char *temp = NULL;
|
||||
UINT8 startup = 0;
|
||||
UINT8 UpFw = 0;
|
||||
UINT8 Upmcu = 0;
|
||||
|
||||
system("cat /proc/cmdline > /tmp/Mode.txt");
|
||||
fp = fopen("/tmp/Mode.txt","r");
|
||||
|
@ -358,8 +360,13 @@ UINT8 sf_cardv_check_power_on_mode(void)
|
|||
//printf("%s: UpFw=%d\r\n", __func__,UpFw);
|
||||
sf_set_fw_update(UpFw);
|
||||
}
|
||||
printf("%s: PowerOnModeStr=%d UpFw=%d\r\n", __func__,startup,UpFw);
|
||||
|
||||
temp = strstr(pStrSrc, pStrUpMcu);
|
||||
if ( temp != NULL) {
|
||||
temp += strlen("mcu=");
|
||||
sscanf(temp, "%hhd", &Upmcu);
|
||||
sf_set_mcu_update_flag(Upmcu);
|
||||
}
|
||||
SLOGI("StartMode=%d,UpFw=%d Upmcu=%d\r\n", startup, UpFw, Upmcu);
|
||||
free(pStrSrc);
|
||||
}
|
||||
|
||||
|
|
|
@ -317,6 +317,7 @@ SRC = \
|
|||
./code/source/systemMng/sf_commu_mcu_reg.c \
|
||||
./code/source/systemMng/sf_commu_mcu.c \
|
||||
./code/source/systemMng/sys_usrmem.c \
|
||||
./code/source/systemMng/sf_mcu_upgrade.c \
|
||||
./code/source/devMng/sf_dev_other.c \
|
||||
./code/source/devMng/sf_dev_usb.c \
|
||||
./code/source/devMng/sf_keymng.c \
|
||||
|
@ -337,7 +338,7 @@ SRC = \
|
|||
./code/source/sf_blue/src/sf_blue_hal.c \
|
||||
./code/source/sf_blue/src/util.c \
|
||||
./code/source/sf_blue/src/watch.c \
|
||||
|
||||
|
||||
# ./code/source/wifi/sf_data_transfer.c \
|
||||
# ./code/source/wifi/sf_svr_send.c \
|
||||
# ./code/source/wifi/sf_wifi_svr.c
|
||||
|
|
|
@ -81,7 +81,8 @@ void sf_set_module_update(UINT8 flag);
|
|||
UINT8 sf_get_fw_update(void);
|
||||
void sf_set_fw_update(UINT8 flag);
|
||||
UINT8 sf_app_get_night_led_flag(void);
|
||||
|
||||
void sf_set_mcu_update_flag(UINT8 flag);
|
||||
UINT8 sf_get_mcu_update_flag(void);
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
67
code/application/source/sf_app/code/include/sf_mcu_upgrade.h
Executable file
67
code/application/source/sf_app/code/include/sf_mcu_upgrade.h
Executable file
|
@ -0,0 +1,67 @@
|
|||
#ifndef __FIRMWARE_UPGRADE_H
|
||||
|
||||
#define __FIRMWARE_UPGRADE_H
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015-2020 by WuYuan Technology, Inc.
|
||||
*
|
||||
* This software is copyrighted by and is the property of SiFar
|
||||
* Technology, Inc.. All rights are reserved by SiFar Technology, Inc..
|
||||
* This software may only be used in accordance with the corresponding
|
||||
* license agreement. Any unauthorized use, duplication, distribution,
|
||||
* or disclosure of this software is expressly forbidden.
|
||||
*
|
||||
* This Copyright notice MUST not be removed or modified without prior
|
||||
* written consent of SiFar Technology, Inc..
|
||||
*
|
||||
* WuYuan Technology, Inc. reserves the right to modify this software without notice.
|
||||
*
|
||||
* Author: ljy
|
||||
* Ver: 1.0.0 2022.06.15
|
||||
* Description: creat
|
||||
**************************************************************************/
|
||||
#include "sf_type.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct{
|
||||
UINT8* fw_content;
|
||||
UINT32 fw_total_size;
|
||||
UINT32 fw_remain_size;
|
||||
UINT32 fw_complete_size;
|
||||
UINT16 fw_crc;
|
||||
}FW_PKT_t;
|
||||
|
||||
typedef enum{
|
||||
FWUPGRADE_INIT_STATE,
|
||||
FWUPGRADE_ENTER_UPGRADE_STATE,
|
||||
FWUPGRADE_WAIT_TO_RESTART_STATE,
|
||||
FWUPGRADE_COMFIRM_UPGRADE_STATE,
|
||||
FWUPGRADE_TRANSFER_PACKET_STATE,
|
||||
FWUPGRADE_TRANSFER_FINISH_STATE,
|
||||
FWUPGRADE_ERROR_OCCUR_STATE,
|
||||
}FW_UPGRADE_STATE_e;
|
||||
|
||||
extern unsigned char mcu_upgrade_buf[32];
|
||||
extern unsigned char mcu_upgrade_buf_len;
|
||||
|
||||
void Fw_UpgradeThreadStart(void);
|
||||
void Fw_UpgradeThreadStop(void);
|
||||
SINT8 Fw_UpgradeBinExist(char * file);
|
||||
SINT8 Fw_GetFirmwareSize(char * file, UINT32 * file_size);
|
||||
SINT8 Fw_GetFirmwareContent(char * file, UINT8 * file_content, UINT32 file_size);
|
||||
SINT8 Fw_Read(UINT8* cmd, void * data, UINT32* size);
|
||||
SINT8 Fw_Send(UINT8 cmd, void* data, UINT32 size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -466,6 +466,8 @@ typedef enum sf_MCU_MESSAGE_TYPE_E
|
|||
SF_MCU_CMD_MCU_VER = 0x1E00,
|
||||
SF_MCU_CMD_MCU_RTC = 0x1F00,
|
||||
SF_MCU_CMD_SET_MCU = 0x1F01,
|
||||
SF_MCU_CMD_UPDATA = 0x1F02,
|
||||
|
||||
}SF_MCU_MESSAGE_TYPE_E;
|
||||
|
||||
typedef enum sf_PARA_MESSAGE_TYPE_E
|
||||
|
|
|
@ -65,6 +65,7 @@ SINT32 app_auto_poweroff_start(void);
|
|||
UINT8 sf_check_power_on_mode(void);
|
||||
void sf_power_off_msg_to_cardv(void);
|
||||
SINT32 sf_app_mcu_para_power_no_start(void);
|
||||
SINT32 sf_app_mcu_updata_start(void);
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -112,6 +112,8 @@ int main(int argc, char *argv[])
|
|||
SINT32 isUsb = 0;
|
||||
SINT32 isCard = 0;
|
||||
SINT32 isUpdate = 0;
|
||||
UINT8 isMcuUpdate = 0;
|
||||
|
||||
//SF_MESSAGE_BUF_S stMessageBuf = {0};
|
||||
//BOOL autosend = FALSE;
|
||||
SF_MUTEX_INIT_LOCK(Param_mutexLock);
|
||||
|
@ -130,7 +132,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
//sf_set_fw_update(isUpdate);
|
||||
isUpdate = sf_get_fw_update();
|
||||
SLOGI("isUsb = %d isCard = %d isUpdate:%d\n", isUsb,isCard,isUpdate);
|
||||
isMcuUpdate = sf_get_mcu_update_flag();
|
||||
SLOGI("isUsb = %d isCard = %d isUpdate:%d isMcuUpdate:%d\n", isUsb,isCard,isUpdate ,isMcuUpdate);
|
||||
|
||||
if(!isUsb)
|
||||
{
|
||||
|
@ -166,7 +169,7 @@ int main(int argc, char *argv[])
|
|||
sf_set_bt_en(1);
|
||||
}
|
||||
}
|
||||
if((0 == isUpdate) && (puiPara->GprsSwitch))
|
||||
if((0 == isMcuUpdate) && (0 == isUpdate) && (puiPara->GprsSwitch))
|
||||
{
|
||||
sf_4G_usb_init();
|
||||
app_RegisterNet_start();
|
||||
|
|
|
@ -64,6 +64,7 @@ SINT8 bmoduleupdate = 0;
|
|||
static UINT8 ModuleUpdating = 0;
|
||||
static UINT8 FwUpdate = 0;
|
||||
static UINT8 IsNightLedOn = 0;
|
||||
static UINT8 McuUpdateFlag = 0;
|
||||
|
||||
static SF_THREAD_CFG_S sf_msgQueueThread =
|
||||
{
|
||||
|
@ -71,6 +72,15 @@ static SF_THREAD_CFG_S sf_msgQueueThread =
|
|||
.TskId = -1,
|
||||
};
|
||||
|
||||
UINT8 sf_get_mcu_update_flag(void)
|
||||
{
|
||||
return McuUpdateFlag;
|
||||
}
|
||||
|
||||
void sf_set_mcu_update_flag(UINT8 flag)
|
||||
{
|
||||
McuUpdateFlag = flag;
|
||||
}
|
||||
|
||||
UINT8 sf_get_module_update(void)
|
||||
{
|
||||
|
@ -626,7 +636,13 @@ static SINT32 sf_app_process_cmd_SD(SF_MESSAGE_BUF_S *pMessageBuf)
|
|||
|
||||
sf_statistics_param_load(sf_statistics_param_get());
|
||||
MLOGI("card-%d mount OK\r\n", pMessageBuf->arg2 + 1);
|
||||
sf_set_key_fw_update(sf_get_fw_update());
|
||||
|
||||
sf_set_key_fw_update(sf_get_fw_update());//up fw
|
||||
|
||||
if(sf_get_mcu_update_flag())//up mcu
|
||||
{
|
||||
sf_app_mcu_updata_start();
|
||||
}
|
||||
break;
|
||||
case FST_STA_DISK_UNFORMAT:
|
||||
//sf_set_card(1);
|
||||
|
@ -784,6 +800,9 @@ static SINT32 sf_app_proccess_cmd_mcu(SF_MESSAGE_BUF_S *pMessageBuf)
|
|||
case SF_MCU_CMD_SET_MCU:
|
||||
sf_mcu_reg_set(pMessageBuf->arg2, pMessageBuf->arg3);
|
||||
break;
|
||||
case SF_MCU_CMD_UPDATA:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "sf_file.h"
|
||||
#include "sf_hal_ttyusb.h"
|
||||
#include "sf_commu_mcu.h"
|
||||
#include "sf_mcu_upgrade.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
|
@ -135,6 +136,12 @@ SF_THREAD_S McuPowerOnTskCfg =
|
|||
.TskId = -1,
|
||||
};
|
||||
|
||||
SF_THREAD_S McuUpDataTskCfg =
|
||||
{
|
||||
.IsRun = 0,
|
||||
.TskId = -1,
|
||||
};
|
||||
|
||||
SINT8 debugFlag = 0;
|
||||
|
||||
UINT8 McuInitFlag = 0;
|
||||
|
@ -1388,10 +1395,12 @@ UINT8 sf_check_power_on_mode(void)
|
|||
char *pStrSrc = NULL;
|
||||
char *pStrOtsOk = "Mode=";
|
||||
char *pStrUpFw = "UpFw=";
|
||||
char *pStrUpMcu = "mcu=";
|
||||
|
||||
char *temp = NULL;
|
||||
UINT8 startup = 0;
|
||||
UINT8 UpFw = 0;
|
||||
UINT8 Upmcu = 0;
|
||||
|
||||
system("cat /proc/cmdline > /tmp/Mode.txt");
|
||||
fp = fopen("/tmp/Mode.txt","r");
|
||||
|
@ -1419,7 +1428,13 @@ UINT8 sf_check_power_on_mode(void)
|
|||
//printf("%s: UpFw=%d\r\n", __func__,UpFw);
|
||||
sf_set_fw_update(UpFw);
|
||||
}
|
||||
SLOGI("StartMode=%d,UpFw=%d\r\n",startup,UpFw);
|
||||
temp = strstr(pStrSrc, pStrUpMcu);
|
||||
if ( temp != NULL) {
|
||||
temp += strlen("mcu=");
|
||||
sscanf(temp, "%hhd", &Upmcu);
|
||||
sf_set_mcu_update_flag(Upmcu);
|
||||
}
|
||||
SLOGI("StartMode=%d,UpFw=%d Upmcu=%d\r\n", startup, UpFw, Upmcu);
|
||||
|
||||
free(pStrSrc);
|
||||
}
|
||||
|
@ -1563,4 +1578,51 @@ SINT32 sf_app_mcu_para_power_no_start(void)
|
|||
}
|
||||
return SF_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
void* sf_app_mcu_updata_thread(void *arg)
|
||||
{
|
||||
|
||||
SLOGI("thread run\n");
|
||||
McuUpDataTskCfg.IsRun = 1;
|
||||
MLOGI("MCU_UPGRADE\n");
|
||||
UINT32 McuFsize = 0;
|
||||
SINT8 ret = 0;
|
||||
ret = Fw_GetFirmwareSize((char*)"/mnt/sd/Mupgrade.bin", &McuFsize);
|
||||
if((sf_in_card_exist() == SF_TRUE) && (access("/mnt/sd/Mupgrade.bin", F_OK) == 0)
|
||||
&& (ret == 0) && (McuFsize > 1024) && (sf_is_enough_power_to_update() == SF_TRUE))
|
||||
{
|
||||
sf_set_mcu_update_flag(SF_TRUE);
|
||||
Fw_UpgradeThreadStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
// sf_set_mcu_update_flag(SF_TRUE);
|
||||
// sleep(5);
|
||||
// sf_led_set(SF_LED_ALL, SF_LED_STATE_OFF);
|
||||
|
||||
MLOGI(" sf_power_off_msg_to_cardv\n");
|
||||
sf_power_off_msg_to_cardv();
|
||||
}
|
||||
McuUpDataTskCfg.IsRun = 0;
|
||||
SLOGI("thread end\n");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
SINT32 sf_app_mcu_updata_start(void)
|
||||
{
|
||||
SINT32 ret = SF_FAILURE;
|
||||
if(McuUpDataTskCfg.IsRun)
|
||||
{
|
||||
SLOGE("thread has already run !!!\n");
|
||||
return SF_FAILURE;
|
||||
}
|
||||
ret = pthread_create(&McuUpDataTskCfg.TskId, NULL, sf_app_mcu_updata_thread, NULL);
|
||||
if(ret != SF_SUCCESS)
|
||||
{
|
||||
MLOGD("thread creat fail!\n");
|
||||
return ret;
|
||||
}
|
||||
return SF_SUCCESS;
|
||||
|
||||
}
|
|
@ -656,7 +656,15 @@ unsigned char sf_mcu_reg_set(MCUParam_t attrId, unsigned char val)
|
|||
mcuData[i++] = 0;
|
||||
|
||||
mcuReg[i] = SYS_STATUS;
|
||||
mcuData[i++] = isUsb << 2 | isCardFull << 1 | isCard << 0;
|
||||
if((sf_get_module_update() == SF_TRUE)
|
||||
|| (sf_get_mcu_update_flag() == SF_TRUE))
|
||||
{
|
||||
mcuData[i++] = isUsb << 2 | isCardFull << 1 | isCard << 0 | 0x20;
|
||||
}
|
||||
else
|
||||
{
|
||||
mcuData[i++] = isUsb << 2 | isCardFull << 1 | isCard << 0;
|
||||
}
|
||||
|
||||
mcuReg[i] = POWEROFF_TYPE;
|
||||
temp = 0;
|
||||
|
@ -1208,7 +1216,7 @@ UINT8 sf_get_module_sleep_flag(void)
|
|||
int sf_app_while_flag(void)
|
||||
{
|
||||
if((!sf_usb_IsInsert()) && (sf_get_power_off_flag() != 1)
|
||||
&& (sf_get_module_update() != 1) && (sf_get_fw_update() == 0))
|
||||
&& (sf_get_module_update() != 1) && (sf_get_fw_update() == 0) && (sf_get_mcu_update_flag() == 0))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
534
code/application/source/sf_app/code/source/systemMng/sf_mcu_upgrade.c
Executable file
534
code/application/source/sf_app/code/source/systemMng/sf_mcu_upgrade.c
Executable file
|
@ -0,0 +1,534 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright (c) 2015-2020 by WuYuan Technology, Inc.
|
||||
*
|
||||
* This software is copyrighted by and is the property of SiFar
|
||||
* Technology, Inc.. All rights are reserved by SiFar Technology, Inc..
|
||||
* This software may only be used in accordance with the corresponding
|
||||
* license agreement. Any unauthorized use, duplication, distribution,
|
||||
* or disclosure of this software is expressly forbidden.
|
||||
*
|
||||
* This Copyright notice MUST not be removed or modified without prior
|
||||
* written consent of SiFar Technology, Inc..
|
||||
*
|
||||
* WuYuan Technology, Inc. reserves the right to modify this software without notice.
|
||||
*
|
||||
* Author: ljy
|
||||
* Ver: 1.0.0 2022.06.15
|
||||
* Description: creat
|
||||
**************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "sf_common.h"
|
||||
#include "sf_mcu_upgrade.h"
|
||||
#include "sf_param_common.h"
|
||||
#include "sf_ledmng.h"
|
||||
#include "sf_message_queue.h"
|
||||
#include "sf_keymng.h"
|
||||
#include "sf_param_enum.h"
|
||||
#include "sf_type.h"
|
||||
#include "sf_system.h"
|
||||
#include "sf_fileMng.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int gsfd;
|
||||
|
||||
#define UPGRADE_FIRMWARE_NANE (char*)"/mnt/sd/Mupgrade.bin"
|
||||
#define UART_PATH "dev/ttyS2"
|
||||
|
||||
//unsigned char mcu_upgrade_buf[32] = {0};
|
||||
//unsigned char mcu_upgrade_buf_len = 0;
|
||||
|
||||
static FW_PKT_t fw_packet;
|
||||
static SINT8 FwUpgradeExit = 1;
|
||||
static FW_UPGRADE_STATE_e FwUpgradeState = FWUPGRADE_INIT_STATE;
|
||||
static pthread_t FwUpgradeThread = 0;
|
||||
|
||||
extern int pthread_setname_np(pthread_t thread, const char *name);
|
||||
|
||||
static SINT8 depack(UINT8* src, UINT32 srcl, UINT8* cmd, UINT8* dst, UINT32* dstl);
|
||||
static UINT32 pack(UINT8 cmd, UINT8 * src, UINT32 size, UINT8* dst);
|
||||
static void * FwUpgradeTask(void * argv);
|
||||
|
||||
|
||||
static const unsigned short Crc16Table[256] =
|
||||
{
|
||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
||||
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
||||
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
|
||||
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
|
||||
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
|
||||
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
|
||||
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
|
||||
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
|
||||
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
|
||||
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
|
||||
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
|
||||
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
|
||||
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
|
||||
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
|
||||
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
|
||||
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
|
||||
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
|
||||
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
|
||||
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
|
||||
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
|
||||
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
|
||||
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
|
||||
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
|
||||
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
|
||||
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
|
||||
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
|
||||
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
|
||||
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
|
||||
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
|
||||
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
|
||||
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
||||
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||
};
|
||||
|
||||
static unsigned short sf_crc16_check(unsigned char * dataIn, int length)
|
||||
{
|
||||
unsigned short result = 0;
|
||||
unsigned short tableNo = 0;
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
tableNo = ((result & 0xff) ^ (dataIn[i] &0xff));
|
||||
result = ((result >> 8) & 0xff) ^Crc16Table[tableNo];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Fw_UpgradeThreadStart(void)
|
||||
{
|
||||
|
||||
int ret = -1;
|
||||
FwUpgradeExit = 0;
|
||||
ret = pthread_create(&FwUpgradeThread, NULL, FwUpgradeTask, NULL);
|
||||
if(ret == 0)
|
||||
{
|
||||
pthread_setname_np(FwUpgradeThread, "fw_upgrade_task");
|
||||
printf("%s pthread start\r\n", __FUNCTION__);
|
||||
}
|
||||
else
|
||||
{
|
||||
FwUpgradeExit = 1;
|
||||
printf("%s pthread create failed\r\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
void Fw_UpgradeThreadStop(void)
|
||||
{
|
||||
FwUpgradeExit = 1;
|
||||
pthread_join(FwUpgradeThread, NULL);
|
||||
}
|
||||
|
||||
SINT8 Fw_UpgradeBinExist(char * file)
|
||||
{
|
||||
|
||||
if(sf_file_IsExsit((CHAR *)file) != SF_TRUE)
|
||||
{
|
||||
printf("%s, fw file bin not exist\r\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s, fw file bin exist\r\n", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SINT8 Fw_GetFirmwareSize(char * file, UINT32 * file_size)
|
||||
{
|
||||
struct stat statBuf;
|
||||
SINT32 fileFd = 0;
|
||||
fileFd = open((char *)file, O_RDONLY);
|
||||
SINT8 ret = -1;
|
||||
if(fileFd)
|
||||
{
|
||||
fstat(fileFd, &statBuf);
|
||||
*file_size = statBuf.st_size;
|
||||
ret = 0;
|
||||
printf("%s, fw file bin size %d\r\n", __FUNCTION__, *file_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s, fw open file bin failed\r\n", __FUNCTION__);
|
||||
ret = -1;
|
||||
}
|
||||
close(fileFd);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
SINT8 Fw_GetFirmwareContent(char * file, UINT8 * file_content, UINT32 file_size)
|
||||
{
|
||||
SINT32 fileFd = 0;
|
||||
SINT8 ret = -1;
|
||||
UINT32 len = 0;
|
||||
fileFd = open((char *)file, O_RDONLY);
|
||||
|
||||
if(fileFd)
|
||||
{
|
||||
while(len < file_size)
|
||||
{
|
||||
ret = read(fileFd, file_content + len, 32);
|
||||
if(ret < 0)
|
||||
{
|
||||
ret = -1;
|
||||
printf("fw read file bin failed\r\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
len += ret;
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("fw open file bin failed\r\n");
|
||||
ret = -1;
|
||||
}
|
||||
close(fileFd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
SINT8 Fw_Read(UINT8* cmd, void * data, UINT32* size)
|
||||
{
|
||||
SINT8 ret = -1;
|
||||
//SINT8 fd = -1;
|
||||
//UINT8 recvBuf[32] = {0};
|
||||
//UINT32 len = 32;
|
||||
UINT8 trytimes = 0;
|
||||
//fd = open(UART_PATH, O_RDWR);
|
||||
if (gsfd < 0)
|
||||
{
|
||||
printf("Open %s error!\n", UART_PATH);
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
//len = read(fd, recvBuf, len);
|
||||
while(mcu_upgrade_buf_len == 0 && trytimes < 100)
|
||||
{
|
||||
trytimes++;
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
//ret = depack(recvBuf, len, cmd, data, size);
|
||||
ret = depack(mcu_upgrade_buf, mcu_upgrade_buf_len, cmd, (UINT8*)data, size);
|
||||
mcu_upgrade_buf_len = 0;
|
||||
//close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static SINT8 depack(UINT8* src, UINT32 srcl, UINT8* cmd, UINT8* dst, UINT32* dstl)
|
||||
{
|
||||
UINT16 crc1 = 0;
|
||||
UINT16 crc2 = 0;
|
||||
SINT8 ret = -1;
|
||||
crc1 = ((src[srcl - 4] << 8) & 0xff00) | src[srcl - 3];
|
||||
crc2 = sf_crc16_check(&src[2], srcl - 6);
|
||||
if(crc1 != crc2)
|
||||
{
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
*cmd = src[2];
|
||||
|
||||
if(dst != NULL)
|
||||
{
|
||||
memcpy(dst, &src[2], srcl - 6);
|
||||
}
|
||||
|
||||
if(dstl != NULL)
|
||||
{
|
||||
*dstl = srcl - 6;
|
||||
}
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
SINT8 Fw_Send(UINT8 cmd, void* data, UINT32 size)
|
||||
{
|
||||
SINT8 ret = -1;
|
||||
//SINT8 fd = -1;
|
||||
UINT8 sndBuf[300] = {0};
|
||||
UINT32 len = 0;
|
||||
//fd = open(UART_PATH, O_RDWR);
|
||||
if (gsfd < 0)
|
||||
{
|
||||
printf("Open %s error!\n",UART_PATH);
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
len = pack(cmd, (UINT8*)data, size, sndBuf);
|
||||
ret = write(gsfd, sndBuf, len);
|
||||
|
||||
//close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static UINT32 pack(UINT8 cmd, UINT8 * src, UINT32 size, UINT8* dst)
|
||||
{
|
||||
UINT32 crc_start = 0;
|
||||
UINT32 crc_end = 0;
|
||||
UINT16 crc = 0;
|
||||
UINT32 idx = 0;
|
||||
|
||||
dst[idx] = 0x55;
|
||||
idx++;
|
||||
dst[idx] = 0xAA;
|
||||
idx++;
|
||||
crc_start = idx;
|
||||
dst[idx] = cmd;
|
||||
idx++;
|
||||
if(size > 0)
|
||||
{
|
||||
memcpy(&dst[idx], src, size);
|
||||
idx += size;
|
||||
}
|
||||
|
||||
crc_end = idx;
|
||||
crc = sf_crc16_check(&dst[crc_start], crc_end - crc_start);
|
||||
dst[idx] = (crc & 0xff00) >> 8;
|
||||
idx++;
|
||||
dst[idx] = crc & 0x00ff;
|
||||
idx++;
|
||||
|
||||
dst[idx] = 0xff;
|
||||
idx++;
|
||||
dst[idx] = 0xee;
|
||||
idx++;
|
||||
return idx;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void * FwUpgradeTask(void * argv)
|
||||
{
|
||||
SINT8 ret = -1;
|
||||
UINT8 recvBuf[32] = {0};
|
||||
UINT32 recvl = 0;
|
||||
UINT8 cmd = 0x00;
|
||||
UINT8 data[300] = {0};
|
||||
UINT16 len = 0;
|
||||
UINT16 pkt_id = 0;
|
||||
UINT16 ack_id = 0;
|
||||
SINT8 param[1] = {0};
|
||||
param[0] = 0;
|
||||
|
||||
while(FwUpgradeExit == 0)
|
||||
{
|
||||
switch (FwUpgradeState)
|
||||
{
|
||||
case FWUPGRADE_INIT_STATE:
|
||||
//sf_sys_status_led_set(SF_LED_SYS_STATE_UPGRADE_START);
|
||||
printf("FWUPGRADE_INIT_STATE\r\n");
|
||||
fw_packet.fw_content = NULL;
|
||||
fw_packet.fw_total_size = 0;
|
||||
fw_packet.fw_remain_size = 0;
|
||||
fw_packet.fw_complete_size = 0;
|
||||
ret = Fw_GetFirmwareSize(UPGRADE_FIRMWARE_NANE, &fw_packet.fw_total_size);
|
||||
|
||||
if(ret < 0)
|
||||
{
|
||||
printf("Fw_GetFirmwareSize failed\r\n");
|
||||
FwUpgradeState = FWUPGRADE_ERROR_OCCUR_STATE;
|
||||
break;
|
||||
}
|
||||
|
||||
fw_packet.fw_remain_size = fw_packet.fw_total_size;
|
||||
fw_packet.fw_content = (UINT8*)malloc(fw_packet.fw_total_size);
|
||||
if(fw_packet.fw_content == NULL)
|
||||
{
|
||||
printf("malloc file content buffer failed\r\n");
|
||||
FwUpgradeState = FWUPGRADE_ERROR_OCCUR_STATE;
|
||||
break;
|
||||
}
|
||||
ret = Fw_GetFirmwareContent(UPGRADE_FIRMWARE_NANE, fw_packet.fw_content, fw_packet.fw_total_size);
|
||||
fw_packet.fw_crc = sf_crc16_check(fw_packet.fw_content, fw_packet.fw_total_size);
|
||||
|
||||
if(sf_poweron_type_get() != 0x0f) /*at upgrade start mode already*/
|
||||
{
|
||||
FwUpgradeState = FWUPGRADE_ENTER_UPGRADE_STATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
FwUpgradeState = FWUPGRADE_COMFIRM_UPGRADE_STATE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FWUPGRADE_ENTER_UPGRADE_STATE:
|
||||
printf("FWUPGRADE_ENTER_UPGRADE_STATE\r\n");
|
||||
data[0] = 1;
|
||||
ret = Fw_Send(0xec, data, 1);
|
||||
|
||||
ret = Fw_Read(&cmd, recvBuf, &recvl);
|
||||
if(recvBuf[1] == 1)
|
||||
{
|
||||
for(unsigned int i = 0; i < recvl; i++)
|
||||
{
|
||||
printf("recvBuf[%d]=0x%x\r\n", i, recvBuf[i]);
|
||||
}
|
||||
FwUpgradeState = FWUPGRADE_WAIT_TO_RESTART_STATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
FwUpgradeState = FWUPGRADE_ERROR_OCCUR_STATE;
|
||||
}
|
||||
break;
|
||||
|
||||
case FWUPGRADE_WAIT_TO_RESTART_STATE:
|
||||
printf("FWUPGRADE_WAIT_TO_RESTART_STATE\r\n");
|
||||
/*if mcu does not power down the main control within 3 seconds,
|
||||
all indicator lights will flash red for 5 seconds,
|
||||
and the MCU will power down and restart itself.*/
|
||||
sleep(3);
|
||||
//sf_sys_status_led_set(SF_LED_SYS_STATE_UPGRADE_FAIL);
|
||||
//sleep(5);
|
||||
printf("SF_KEY_PIN_AOTU_MODE_POWOFF\r\n");
|
||||
sf_power_off_msg_to_cardv();
|
||||
break;
|
||||
|
||||
case FWUPGRADE_COMFIRM_UPGRADE_STATE:
|
||||
printf("FWUPGRADE_COMFIRM_UPGRADE_STATE\r\n");
|
||||
data[0] = 0;
|
||||
data[1] = (fw_packet.fw_total_size & 0xff000000) >> 24;
|
||||
data[2] = (fw_packet.fw_total_size & 0x00ff0000) >> 16;
|
||||
data[3] = (fw_packet.fw_total_size & 0x0000ff00) >> 8;
|
||||
data[4] = (fw_packet.fw_total_size & 0x000000ff);
|
||||
data[5] = (fw_packet.fw_crc & 0xff00) >> 8;
|
||||
data[6] = (fw_packet.fw_crc & 0x00ff);
|
||||
|
||||
ret = Fw_Send(0xef, data, 7);
|
||||
|
||||
ret = Fw_Read(&cmd, recvBuf, &recvl);
|
||||
for(unsigned int i = 0; i < recvl; i++)
|
||||
printf("recv 0x%x\r\n", recvBuf[i]);
|
||||
if(cmd == 0xef && recvBuf[1] == 0)
|
||||
{
|
||||
FwUpgradeState = FWUPGRADE_TRANSFER_PACKET_STATE;/*mcu allow to upgrade*/
|
||||
}
|
||||
else
|
||||
{
|
||||
FwUpgradeState = FWUPGRADE_ERROR_OCCUR_STATE;
|
||||
}
|
||||
break;
|
||||
|
||||
case FWUPGRADE_TRANSFER_PACKET_STATE:
|
||||
printf("FWUPGRADE_TRANSFER_PACKET_STATE\r\n");
|
||||
if(fw_packet.fw_remain_size >= 256)
|
||||
{
|
||||
len = 256;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = fw_packet.fw_remain_size;
|
||||
}
|
||||
|
||||
data[0] = (pkt_id & 0xff00) >> 8;
|
||||
data[1] = pkt_id & 0x00ff;
|
||||
data[2] = (len & 0xff00) >> 8;
|
||||
data[3] = len & 0x00ff;
|
||||
memcpy(&data[4], fw_packet.fw_content + fw_packet.fw_complete_size, len);
|
||||
|
||||
ret = Fw_Send(0xee, &data, len + 4);
|
||||
ret = Fw_Read(&cmd, recvBuf, &recvl);
|
||||
|
||||
ack_id = ((UINT16)recvBuf[1]) << 8 | recvBuf[2];
|
||||
printf("cmd %x, ack_id %d, pkt_id %d, recv3 %x\r\n",
|
||||
cmd, ack_id, pkt_id, recvBuf[3]);
|
||||
if(cmd == 0xee && ack_id == pkt_id && recvBuf[3] == 0)
|
||||
{
|
||||
fw_packet.fw_remain_size -= len;
|
||||
fw_packet.fw_complete_size += len;
|
||||
pkt_id++;
|
||||
if(fw_packet.fw_total_size == fw_packet.fw_complete_size)
|
||||
{
|
||||
ret = Fw_Read(&cmd, recvBuf, &recvl);
|
||||
if(recvBuf[1] == 0)
|
||||
{
|
||||
FwUpgradeState = FWUPGRADE_TRANSFER_FINISH_STATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
FwUpgradeState = FWUPGRADE_TRANSFER_PACKET_STATE;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
FwUpgradeState = FWUPGRADE_TRANSFER_PACKET_STATE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FwUpgradeState = FWUPGRADE_ERROR_OCCUR_STATE;
|
||||
}
|
||||
break;
|
||||
|
||||
case FWUPGRADE_TRANSFER_FINISH_STATE:
|
||||
printf("FWUPGRADE_TRANSFER_FINISH_STATE\r\n");
|
||||
//sf_sys_status_led_set(SF_LED_SYS_STATE_UPGRADE_SUCCESS);
|
||||
free(fw_packet.fw_content);
|
||||
/*exit upgrade thread*/
|
||||
FwUpgradeExit = 1;
|
||||
break;
|
||||
|
||||
case FWUPGRADE_ERROR_OCCUR_STATE:
|
||||
printf("FWUPGRADE_ERROR_OCCUR_STATE\r\n");
|
||||
if(fw_packet.fw_content != NULL)
|
||||
{
|
||||
free(fw_packet.fw_content);
|
||||
}
|
||||
data[0] = 0;
|
||||
ret = Fw_Send(0xec, data, 1); /*notify mcu to exit upgrade mode*/
|
||||
Fw_Read(&cmd, recvBuf, &recvl);
|
||||
|
||||
sf_power_off_msg_to_cardv();
|
||||
|
||||
/*exit upgrade thread*/
|
||||
FwUpgradeExit = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(200000);
|
||||
}
|
||||
printf("ret is %d\r\n", ret);
|
||||
pthread_exit(NULL);
|
||||
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -40,6 +40,8 @@ void sf_set_pir_statu_flag(BOOL flag);
|
|||
void sf_set_auto_off_time(UINT16 time);
|
||||
void sf_set_keep_alive_time(unsigned int time_s);
|
||||
UINT16 sf_get_auto_off_time(void);
|
||||
void sf_set_mcu_update_flag(UINT8 flag);
|
||||
UINT8 sf_get_mcu_update_flag(void);
|
||||
UINT8 sf_get_fw_update(void);
|
||||
void sf_set_fw_update(UINT8 flag);
|
||||
UINT8 sf_get_module_update(void);
|
||||
|
|
|
@ -97,6 +97,7 @@ static int shared_condition = 1;
|
|||
static SINT32 WifiSocket = 0;
|
||||
static UINT8 UiparaFlag = 0;
|
||||
static SF_BLE_STATUS_E BleStatus = SF_BLE_OK;
|
||||
static UINT8 McuUpdateFlag = 0;
|
||||
|
||||
static SF_THREAD_S UpgradeTskParam =
|
||||
{
|
||||
|
@ -310,7 +311,7 @@ void sf_mode_detect(void)
|
|||
//countDownOffFlg = 0;
|
||||
}
|
||||
|
||||
if(puiPara->AutoOffSwitch == 0 || SF_BLE_CON == sf_get_ble_status() || (0x04 == NetWorkFlag/*SF_4G_SENDING*/) || (0x05 == NetWorkFlag/*SF_4G_SEARCHING*/) || (sf_get_fw_update()) || (sf_get_module_update())/*|| (appActiveStateGet() == APP_STATE_CUSTOMER_TRANSFER)*/)
|
||||
if(puiPara->AutoOffSwitch == 0 || SF_BLE_CON == sf_get_ble_status() || (0x04 == NetWorkFlag/*SF_4G_SENDING*/) || (0x05 == NetWorkFlag/*SF_4G_SEARCHING*/) || (sf_get_fw_update()) || (sf_get_module_update()) || (sf_get_mcu_update_flag())/*|| (appActiveStateGet() == APP_STATE_CUSTOMER_TRANSFER)*/)
|
||||
{
|
||||
AutoOfftime=0;
|
||||
}
|
||||
|
@ -347,6 +348,17 @@ void sf_mode_detect(void)
|
|||
}
|
||||
//printf("[%s:%d] e\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
UINT8 sf_get_mcu_update_flag(void)
|
||||
{
|
||||
return McuUpdateFlag;
|
||||
}
|
||||
|
||||
void sf_set_mcu_update_flag(UINT8 flag)
|
||||
{
|
||||
McuUpdateFlag = flag;
|
||||
}
|
||||
|
||||
UINT8 sf_get_module_update(void)
|
||||
{
|
||||
return ModuleUpdating;
|
||||
|
@ -1775,7 +1787,7 @@ static SINT32 sf_cardv_proccess_cmd_wifi(SF_MESSAGE_BUF_S *pMessageBuf)
|
|||
switch(pMessageBuf->arg1)
|
||||
{
|
||||
case SF_WIFI_CMD_START:
|
||||
if((0 == sf_get_fw_update()) && (sf_get_mode_flag()))
|
||||
if((0 == sf_get_mcu_update_flag()) && (0 == sf_get_fw_update()) && (sf_get_mode_flag()))
|
||||
sf_cardv_wifi_start();
|
||||
break;
|
||||
|
||||
|
@ -2675,7 +2687,7 @@ UINT32 sf_cardv_wifi_start(void)
|
|||
SINT32 ret = 1;
|
||||
UIMenuStoreInfo *puiPara = sf_ui_para_get();
|
||||
|
||||
if((0 == sf_get_fw_update()) && (sf_get_mode_flag()) && (puiPara->WifiSwitch))
|
||||
if((0 == sf_get_mcu_update_flag()) && (0 == sf_get_fw_update()) && (sf_get_mode_flag()) && (puiPara->WifiSwitch))
|
||||
{
|
||||
if(WifiTskCfg.IsRun)
|
||||
{
|
||||
|
|
|
@ -2017,7 +2017,7 @@ void sf_calculate_daily_report(UINT8*dailyHour, UINT8*dailyMin)
|
|||
int sf_while_flag(void)
|
||||
{
|
||||
if((!sf_is_usb_flag()) && (POWEROFF != 1)
|
||||
&& (ModuleUpdating != 1) && (sf_get_fw_update() == 0))
|
||||
&& (ModuleUpdating != 1) && (0 == sf_get_mcu_update_flag()) && (sf_get_fw_update() == 0))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -185,6 +185,7 @@ UINT32 DrvGPIO_GetPhotoMovieModeFromMonitor(void)
|
|||
case PWR_ON_GPRS_INIT://A
|
||||
case PWR_ON_TIME_SYNC://B
|
||||
case PWR_ON_TIME_SEND:
|
||||
case PWR_ON_MCU_UPDATA:
|
||||
#endif
|
||||
Save_MenuInfo();
|
||||
g_uiBootMode = DX_HUNTING_MODE_OTHER;
|
||||
|
|
|
@ -240,8 +240,8 @@ extern BOOL GPIOMap_DetAudio(void);
|
|||
#define PAD_KEY_RIGHT PAD_PIN_CGPIO4
|
||||
#define GPIO_KEY_PLAYBACK C_GPIO_17 // Key Playback (kmp)
|
||||
#define PAD_KEY_PLAYBACK PAD_PIN_CGPIO17
|
||||
#define GPIO_KEY_DOWN C_GPIO_20 // Key Down (kd)
|
||||
#define PAD_KEY_DOWN PAD_PIN_CGPIO20
|
||||
#define GPIO_KEY_DOWN C_GPIO_6 // Key Down (kd)
|
||||
#define PAD_KEY_DOWN PAD_PIN_CGPIO6
|
||||
#define GPIO_KEY_MODE D_GPIO_4 // Key Mode (kmd)
|
||||
#define PAD_KEY_MODE PAD_PIN_DGPIO4
|
||||
#define GPIO_KEY_MENU C_GPIO_21 // Key Menu (km)
|
||||
|
|
|
@ -846,7 +846,7 @@ static int make_bootargs(LINUXTMP_PARTITION *p_linuxtmp, unsigned int bootts_beg
|
|||
//static char bootargs[] = "root=/dev/ram0 rootfstype=ramfs rdinit=/linuxrc bootts=568047,1720128 resume_addr=0x00007e88 user_debug=0xff";
|
||||
#if HUNTING_CAMERA_MCU == ENABLE
|
||||
char PowerOnModeStr[32] = {'\0'};
|
||||
snprintf(PowerOnModeStr, sizeof(PowerOnModeStr), "Mode=%d UpFw=%d",sf_get_power_on_mode(), sf_in_update());
|
||||
snprintf(PowerOnModeStr, sizeof(PowerOnModeStr), "Mode=%d UpFw=%d mcu=%d",sf_get_power_on_mode(), sf_in_update() , sf_in_mcu_update());
|
||||
linuxboot_set_extra_bootarg(PowerOnModeStr);
|
||||
#endif
|
||||
p_linuxtmp->bootargs_addr = p_linuxtmp->tmp_curr;
|
||||
|
|
|
@ -1730,6 +1730,7 @@ void sf_power_on_para_check_init(void)
|
|||
puiPara->FristSendDailyAndGps = 1;
|
||||
puiPara->GpsSendFlag = 0;
|
||||
memset(puiPara->SimIccid,'\0',sizeof(puiPara->SimIccid));
|
||||
//sf_dailyReport_refresh();
|
||||
}
|
||||
else if(PowerOnMode == PWR_ON_TIME_SYNC)
|
||||
{
|
||||
|
@ -1780,4 +1781,7 @@ void sf_power_on_para_check_init(void)
|
|||
Save_MenuInfo();
|
||||
}*/
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#define PWR_ON_GPRS_INIT 0x0A
|
||||
#define PWR_ON_TIME_SYNC 0x0B
|
||||
#define PWR_ON_TIME_SEND 0x0C
|
||||
#define PWR_ON_MCU_UPDATA 0x0F
|
||||
|
||||
/*REG FUNCTION_SWTICH*/
|
||||
#define PIR_OFF 0x00
|
||||
|
@ -527,6 +528,8 @@ UINT8 sf_convert_power_on_mode(void);
|
|||
void sf_hw_info_save(char *name,FST_FILE fd);
|
||||
void sf_set_iso_exp_lv(UINT32 adj, UINT32 iso, UINT32 exp, UINT32 lv);
|
||||
UINT32 sf_in_update(void);
|
||||
UINT32 sf_in_mcu_update(void);
|
||||
int sf_base64_decode(const char * base64, char * bindata);
|
||||
void sf_dailyReport_refresh(void);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -391,12 +391,12 @@ UINT8 sf_mcu_power_on_para_get(MCUParam_t attrId)
|
|||
}
|
||||
else */
|
||||
#endif
|
||||
{
|
||||
if(startMode > PWR_ON_TIME_SEND) //if start mode err, USB IN default power on SETUP
|
||||
{
|
||||
startMode = PWR_ON_SETUP;
|
||||
}
|
||||
}
|
||||
// {
|
||||
// if(startMode > PWR_ON_MCU_UPDATA) //if start mode err, USB IN default power on SETUP
|
||||
// {
|
||||
// startMode = PWR_ON_SETUP;
|
||||
// }
|
||||
// }
|
||||
printf(" start mode = %d \n", startMode);
|
||||
return startMode;
|
||||
}
|
||||
|
@ -765,11 +765,22 @@ UINT32 sf_gpio_get_status(UINT32 ipin)
|
|||
}
|
||||
UINT32 sf_in_update(void)
|
||||
{
|
||||
if(sf_gpio_get_status(GPIO_KEY_TEST)){
|
||||
if((sf_gpio_get_status(GPIO_KEY_TEST)) && (PWR_ON_SETUP == sf_get_power_on_mode()))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
UINT32 sf_in_mcu_update(void)
|
||||
{
|
||||
if((sf_gpio_get_status(GPIO_KEY_DOWN)) && (PWR_ON_SETUP == sf_get_power_on_mode())){
|
||||
return 1;
|
||||
}
|
||||
if(PWR_ON_MCU_UPDATA == sf_get_power_on_mode()){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*************************************************
|
||||
Function: sf_mcu_dataready_get
|
||||
Description:
|
||||
|
@ -2506,6 +2517,90 @@ void sf_hw_info_save(char *name,FST_FILE fd)
|
|||
|
||||
#endif
|
||||
|
||||
/*************************************************
|
||||
Function: sf_dailyReport_refresh
|
||||
Description: refresh dailyreport
|
||||
Input: N/A
|
||||
Output: N/A
|
||||
Return: N/A
|
||||
Others: N/A
|
||||
*************************************************/
|
||||
void sf_dailyReport_refresh(void)
|
||||
{
|
||||
|
||||
UIMenuStoreInfo *puiPara = sf_ui_para_get();
|
||||
UINT32 preTimeValue = 0;
|
||||
UINT32 dr1TimeValue = 0;
|
||||
UINT32 dr2TimeValue = 0;
|
||||
SF_PARA_TIME_S preRtcTime = { 0 };
|
||||
//sf_sys_rtc_time_get(&preRtcTime);
|
||||
struct tm ctv = {0};
|
||||
ctv = hwclock_get_time(TIME_ID_CURRENT);
|
||||
printf("%s:%d tm: %d : %d : %d : %d : %d : %d\n", __FUNCTION__, __LINE__,ctv.tm_year, ctv.tm_mon,ctv.tm_mday,ctv.tm_hour,ctv.tm_min,ctv.tm_sec);
|
||||
preRtcTime.Year = ctv.tm_year;
|
||||
preRtcTime.Mon = ctv.tm_mon;
|
||||
preRtcTime.Day = ctv.tm_mday;
|
||||
preRtcTime.Hour = ctv.tm_hour;
|
||||
preRtcTime.Min = ctv.tm_min;
|
||||
preRtcTime.Sec = ctv.tm_sec;
|
||||
|
||||
preTimeValue = preRtcTime.Hour * 60 + preRtcTime.Min;
|
||||
dr1TimeValue = puiPara->DailyReportTime.Hour * 60 + puiPara->DailyReportTime.Min;
|
||||
dr2TimeValue = dr1TimeValue + (12 * 60);
|
||||
|
||||
if(puiPara->ReDailyReport == 0)
|
||||
{
|
||||
//twice a day
|
||||
if(((preTimeValue < dr1TimeValue) && (preTimeValue < dr2TimeValue)) || ((preTimeValue >= dr1TimeValue) && (preTimeValue >= dr2TimeValue)))
|
||||
{
|
||||
puiPara->DailyReportTime2.Hour = puiPara->DailyReportTime.Hour;
|
||||
puiPara->DailyReportTime2.Min = puiPara->DailyReportTime.Min;
|
||||
}
|
||||
else
|
||||
{
|
||||
puiPara->DailyReportTime2.Hour = (puiPara->DailyReportTime.Hour + 12) % 24;
|
||||
puiPara->DailyReportTime2.Min = puiPara->DailyReportTime.Min;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((preTimeValue >= dr1TimeValue) && (preTimeValue < dr1TimeValue + 60))
|
||||
{
|
||||
puiPara->DailyReportTime2.Hour = (puiPara->DailyReportTime.Hour + 1) % 24;
|
||||
puiPara->DailyReportTime2.Min = puiPara->DailyReportTime.Min;
|
||||
}
|
||||
else if((preTimeValue >= dr1TimeValue + 60) && (preTimeValue < dr2TimeValue))
|
||||
{
|
||||
puiPara->DailyReportTime2.Hour = (puiPara->DailyReportTime.Hour + 12) % 24;
|
||||
puiPara->DailyReportTime2.Min = puiPara->DailyReportTime.Min;
|
||||
}
|
||||
else if((preTimeValue >= dr2TimeValue) && (preTimeValue < dr2TimeValue + 60))
|
||||
{
|
||||
puiPara->DailyReportTime2.Hour = (puiPara->DailyReportTime.Hour + 12 + 1) % 24;
|
||||
puiPara->DailyReportTime2.Min = puiPara->DailyReportTime.Min;
|
||||
}
|
||||
else
|
||||
{
|
||||
puiPara->DailyReportTime2.Hour = puiPara->DailyReportTime.Hour;
|
||||
puiPara->DailyReportTime2.Min = puiPara->DailyReportTime.Min;
|
||||
}
|
||||
}
|
||||
|
||||
if(puiPara->DailyReportTestSwitch)
|
||||
{
|
||||
if(puiPara->ReDailyReport)
|
||||
{
|
||||
puiPara->DailyReportTime2.Hour = (preRtcTime.Hour + (preRtcTime.Min + 15) / 60) % 24;
|
||||
puiPara->DailyReportTime2.Min = (preRtcTime.Min + 15) % 60;
|
||||
}
|
||||
else
|
||||
{
|
||||
puiPara->DailyReportTime2.Hour = (preRtcTime.Hour + (preRtcTime.Min + 5) / 60) % 24;
|
||||
puiPara->DailyReportTime2.Min = (preRtcTime.Min + 5) % 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined __FREERTOS
|
||||
|
||||
int sf_mod_init(void)
|
||||
|
|
Loading…
Reference in New Issue
Block a user