[ch32v208] Support ch32v208rbt6 OTA upgrade from songyanguang
it is OK
|
@ -204,9 +204,20 @@ static int Ec801eConnect(struct Adapter *adapter, enum NetRoleType net_role, con
|
|||
|
||||
/*step1: serial write "+++", quit transparent mode*/
|
||||
PrivTaskDelay(1500); //before +++ command, wait at least 1s
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, EC801E_AT_MODE_CMD);
|
||||
PrivTaskDelay(1500); //after +++ command, wait at least 1s
|
||||
|
||||
for(try = 0; try < TRY_TIMES; try++){
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC801E_ATI_CMD, EC801E_OK_REPLY);
|
||||
if (ret == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
PrivTaskDelay(300);
|
||||
|
||||
/*step2: serial write "AT+CPIN?", check SIM status*/
|
||||
for(try = 0; try < TRY_TIMES; try++){
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, EC801E_GET_CPIN_CMD, EC801E_READY_REPLY);
|
||||
|
|
|
@ -232,7 +232,7 @@ int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check)
|
|||
#endif
|
||||
if (!strstr(result, check))
|
||||
{
|
||||
printf("%s %d check[%s] reply[%s] failed.\n", __func__, __LINE__, check, result);
|
||||
printf("%s %d cmd[%s] check[%s] reply[%s] failed.\n", __func__, __LINE__, cmd, check, result);
|
||||
ret = -1;
|
||||
goto __exit;
|
||||
}
|
||||
|
|
|
@ -178,7 +178,8 @@ bool MQTT_Connect(void)
|
|||
MQTT_Send(Platform_mqtt.Pack_buff,Platform_mqtt.Fixed_len + Platform_mqtt.Variable_len + Platform_mqtt.Payload_len);
|
||||
MdelayKTask(50);
|
||||
MQTT_Recv(mqtt_rxbuf, 4);
|
||||
if(mqtt_rxbuf[0] == parket_connetAck[0] && mqtt_rxbuf[1] == parket_connetAck[1]) //连接成功
|
||||
if(mqtt_rxbuf[0] == parket_connetAck[0] && mqtt_rxbuf[1] == parket_connetAck[1]
|
||||
&& mqtt_rxbuf[2] == parket_connetAck[2] && mqtt_rxbuf[3] == parket_connetAck[3]) //连接成功
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
SRC_FILES := boot.S interrupt.c tick.c switch.S prepare_rhwstack.c interrupt_switch.S ble_task_scheduler.S
|
||||
SRC_FILES := boot.S interrupt.c tick.c switch.S prepare_rhwstack.c interrupt_switch.S
|
||||
ifeq ($(CONFIG_BSP_USING_BLE),y)
|
||||
SRC_FILES += ble_task_scheduler.S
|
||||
endif
|
||||
SRC_DIR := Core User Debug
|
||||
# interrupt_switch.S
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
@ -54,10 +54,12 @@ void HardFault_Handler(void)
|
|||
KPrintf("mepc :%08x\r\n", __get_MEPC());
|
||||
KPrintf("mcause:%08x\r\n", __get_MCAUSE());
|
||||
KPrintf("mtval :%08x\r\n", __get_MTVAL());
|
||||
#ifdef TOOL_SHELL
|
||||
extern void ShowTask(void);
|
||||
extern void ShowMemory(void);
|
||||
ShowTask();
|
||||
ShowMemory();
|
||||
#endif
|
||||
while (1)
|
||||
;
|
||||
|
||||
|
|
|
@ -268,7 +268,11 @@ handle_reset:
|
|||
csrw mtvec, t0
|
||||
|
||||
jal SystemInit
|
||||
#ifdef __BOOTLOADER
|
||||
la t0, ota_entry
|
||||
#else
|
||||
la t0, entry
|
||||
#endif
|
||||
csrw mepc, t0
|
||||
mret
|
||||
|
||||
|
|
|
@ -0,0 +1,326 @@
|
|||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# XiZi_IIoT Project Configuration
|
||||
#
|
||||
CONFIG_BOARD_CH32V208RBT6=y
|
||||
CONFIG_ARCH_RISCV=y
|
||||
|
||||
#
|
||||
# ch32v208rbt6 feature
|
||||
#
|
||||
CONFIG_BSP_USING_UART=y
|
||||
CONFIG_BSP_USING_UART1=y
|
||||
CONFIG_SERIAL_BUS_NAME_1="uart1"
|
||||
CONFIG_SERIAL_DRV_NAME_1="uart1_drv"
|
||||
CONFIG_SERIAL_1_DEVICE_NAME_0="uart1_dev1"
|
||||
# CONFIG_BSP_USING_ETH is not set
|
||||
# CONFIG_BSP_USING_ADC is not set
|
||||
# CONFIG_BSP_USING_BLE is not set
|
||||
# CONFIG_BSP_USING_CAN is not set
|
||||
# CONFIG_BSP_USING_RS485 is not set
|
||||
CONFIG_BSP_USING_LTE=y
|
||||
CONFIG_LTE_BUS_NAME="lte"
|
||||
CONFIG_LTE_DRV_NAME="lte_drv"
|
||||
CONFIG_LTE_DEVICE_NAME_1="lte_dev1"
|
||||
# CONFIG_LTE_TEST is not set
|
||||
|
||||
#
|
||||
# Hardware feature
|
||||
#
|
||||
CONFIG_RESOURCES_SERIAL=y
|
||||
CONFIG_SERIAL_USING_DMA=y
|
||||
CONFIG_SERIAL_RB_BUFSZ=2048
|
||||
|
||||
#
|
||||
# Kernel feature
|
||||
#
|
||||
|
||||
#
|
||||
# separate compile(choose none for compile once)
|
||||
#
|
||||
# CONFIG_SEPARATE_COMPILE is not set
|
||||
# CONFIG_COMPILER_APP is not set
|
||||
# CONFIG_APP_STARTUP_FROM_SDCARD is not set
|
||||
CONFIG_APP_STARTUP_FROM_FLASH=y
|
||||
# CONFIG_COMPILER_KERNEL is not set
|
||||
|
||||
#
|
||||
# Memory Management
|
||||
#
|
||||
# CONFIG_KERNEL_MEMBLOCK is not set
|
||||
CONFIG_MEM_ALIGN_SIZE=8
|
||||
# CONFIG_MEM_EXTERN_SRAM is not set
|
||||
CONFIG_MM_PAGE_SIZE=4096
|
||||
|
||||
#
|
||||
# Using small memory allocator
|
||||
#
|
||||
CONFIG_KERNEL_SMALL_MEM_ALLOC=y
|
||||
CONFIG_SMALL_NUMBER_32B=64
|
||||
CONFIG_SMALL_NUMBER_64B=32
|
||||
|
||||
#
|
||||
# Task feature
|
||||
#
|
||||
CONFIG_USER_APPLICATION=y
|
||||
# CONFIG_TASK_ISOLATION is not set
|
||||
# CONFIG_KERNEL_CAPABILITY is not set
|
||||
|
||||
#
|
||||
# Inter-Task communication
|
||||
#
|
||||
CONFIG_KERNEL_SEMAPHORE=y
|
||||
CONFIG_KERNEL_MUTEX=y
|
||||
CONFIG_KERNEL_EVENT=y
|
||||
CONFIG_KERNEL_MESSAGEQUEUE=y
|
||||
CONFIG_KERNEL_SOFTTIMER=y
|
||||
CONFIG_SCHED_POLICY_RR_REMAINSLICE=y
|
||||
# CONFIG_SCHED_POLICY_RR is not set
|
||||
# CONFIG_SCHED_POLICY_FIFO is not set
|
||||
# CONFIG_KTASK_PRIORITY_8 is not set
|
||||
CONFIG_KTASK_PRIORITY_32=y
|
||||
# CONFIG_KTASK_PRIORITY_256 is not set
|
||||
CONFIG_KTASK_PRIORITY_MAX=32
|
||||
CONFIG_TICK_PER_SECOND=100
|
||||
CONFIG_KERNEL_STACK_OVERFLOW_CHECK=y
|
||||
CONFIG_IDLE_KTASK_STACKSIZE=512
|
||||
CONFIG_ZOMBIE_KTASK_STACKSIZE=512
|
||||
|
||||
#
|
||||
# Kernel Console
|
||||
#
|
||||
CONFIG_KERNEL_CONSOLE=y
|
||||
CONFIG_KERNEL_BANNER=y
|
||||
CONFIG_KERNEL_CONSOLEBUF_SIZE=128
|
||||
|
||||
#
|
||||
# Kernel Hook
|
||||
#
|
||||
# CONFIG_KERNEL_HOOK is not set
|
||||
|
||||
#
|
||||
# Command shell
|
||||
#
|
||||
# CONFIG_TOOL_SHELL is not set
|
||||
|
||||
#
|
||||
# Kernel data structure Manage
|
||||
#
|
||||
CONFIG_KERNEL_QUEUEMANAGE=y
|
||||
CONFIG_KERNEL_WORKQUEUE=y
|
||||
CONFIG_WORKQUEUE_KTASK_STACKSIZE=2048
|
||||
CONFIG_WORKQUEUE_KTASK_PRIORITY=23
|
||||
CONFIG_QUEUE_MAX=16
|
||||
CONFIG_KERNEL_WAITQUEUE=y
|
||||
CONFIG_KERNEL_DATAQUEUE=y
|
||||
# CONFIG_KERNEL_CIRCULAR_AREA is not set
|
||||
# CONFIG_KERNEL_AVL_TREE is not set
|
||||
|
||||
#
|
||||
# Kernel components init
|
||||
#
|
||||
CONFIG_KERNEL_COMPONENTS_INIT=y
|
||||
CONFIG_ENV_INIT_KTASK_STACK_SIZE=2048
|
||||
CONFIG_KERNEL_USER_MAIN=y
|
||||
CONFIG_NAME_NUM_MAX=32
|
||||
# CONFIG_KERNEL_DEBUG is not set
|
||||
# CONFIG_ARCH_SMP is not set
|
||||
|
||||
#
|
||||
# hash table config
|
||||
#
|
||||
CONFIG_ID_HTABLE_SIZE=16
|
||||
CONFIG_ID_NUM_MAX=128
|
||||
# CONFIG_KERNEL_TEST is not set
|
||||
|
||||
#
|
||||
# Kernel Lib
|
||||
#
|
||||
CONFIG_LIB=y
|
||||
CONFIG_LIB_POSIX=y
|
||||
CONFIG_LIB_NEWLIB=y
|
||||
# CONFIG_LIB_MUSLLIB is not set
|
||||
# CONFIG_LIB_OTHER is not set
|
||||
|
||||
#
|
||||
# C++ features
|
||||
#
|
||||
# CONFIG_LIB_CPLUSPLUS is not set
|
||||
|
||||
#
|
||||
# File system
|
||||
#
|
||||
CONFIG_FS_VFS=y
|
||||
# CONFIG_VFS_USING_WORKDIR is not set
|
||||
CONFIG_FS_VFS_DEVFS=y
|
||||
# CONFIG_FS_VFS_FATFS is not set
|
||||
# CONFIG_FS_CH376 is not set
|
||||
# CONFIG_FS_LWEXT4 is not set
|
||||
|
||||
#
|
||||
# Tool feature
|
||||
#
|
||||
|
||||
#
|
||||
# OTA function
|
||||
#
|
||||
CONFIG_TOOL_USING_OTA=y
|
||||
CONFIG_MCUBOOT_BOOTLOADER=y
|
||||
# CONFIG_MCUBOOT_APPLICATION is not set
|
||||
CONFIG_OTA_BY_PLATFORM=y
|
||||
# CONFIG_OTA_BY_TCPSERVER is not set
|
||||
# CONFIG_OTA_BY_NONE is not set
|
||||
|
||||
#
|
||||
# Flash area address and size configuration.
|
||||
#
|
||||
CONFIG_CHIP_FLAH_BASE=0x08000000
|
||||
CONFIG_XIUOS_FLAH_ADDRESS=0x08008000
|
||||
CONFIG_BAKUP_FLAH_ADDRESS=0x08008000
|
||||
CONFIG_DOWN_FLAH_ADDRESS=0x08008000
|
||||
CONFIG_FLAG_FLAH_ADDRESS=0x08077000
|
||||
CONFIG_APP_FLASH_SIZE=0x00100000
|
||||
CONFIG_OTA_RX_TIMEOUT=600
|
||||
CONFIG_OTA_FRAME_SIZE=2048
|
||||
|
||||
#
|
||||
# APP_Framework
|
||||
#
|
||||
|
||||
#
|
||||
# Framework
|
||||
#
|
||||
CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y
|
||||
CONFIG_ADD_XIZI_FEATURES=y
|
||||
# CONFIG_ADD_NUTTX_FEATURES is not set
|
||||
# CONFIG_ADD_RTTHREAD_FEATURES is not set
|
||||
# CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set
|
||||
CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y
|
||||
# CONFIG_CONNECTION_FRAMEWORK_DEBUG is not set
|
||||
# CONFIG_CONNECTION_INDUSTRIAL_NETWORK is not set
|
||||
# CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS is not set
|
||||
# CONFIG_CONNECTION_INDUSTRIAL_WLAN is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_LORA is not set
|
||||
CONFIG_CONNECTION_ADAPTER_4G=y
|
||||
CONFIG_ADAPTER_EC801E=y
|
||||
CONFIG_ADAPTER_4G_EC801E="ec801e"
|
||||
# CONFIG_ADAPTER_EC801E_DRIVER_EXTUART is not set
|
||||
CONFIG_ADAPTER_EC801E_DRIVER="/dev/lte_dev1"
|
||||
# CONFIG_ADAPTER_EC200T is not set
|
||||
# CONFIG_ADAPTER_EC200A is not set
|
||||
# CONFIG_ADAPTER_GM800TF is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_NB is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_WIFI is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_ETHERNET is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_BLUETOOTH is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_ZIGBEE is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_5G is not set
|
||||
# CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set
|
||||
# CONFIG_SUPPORT_CONTROL_FRAMEWORK is not set
|
||||
|
||||
#
|
||||
# Security
|
||||
#
|
||||
# CONFIG_CRYPTO is not set
|
||||
# CONFIG_MBEDTLS is not set
|
||||
|
||||
#
|
||||
# Applications
|
||||
#
|
||||
|
||||
#
|
||||
# config stack size and priority of main task
|
||||
#
|
||||
CONFIG_MAIN_KTASK_STACK_SIZE=1024
|
||||
CONFIG_MAIN_KTASK_PRIORITY=16
|
||||
|
||||
#
|
||||
# test app
|
||||
#
|
||||
# CONFIG_USER_TEST is not set
|
||||
|
||||
#
|
||||
# connection app
|
||||
#
|
||||
# CONFIG_APPLICATION_CONNECTION is not set
|
||||
|
||||
#
|
||||
# control app
|
||||
#
|
||||
|
||||
#
|
||||
# knowing app
|
||||
#
|
||||
# CONFIG_APPLICATION_KNOWING is not set
|
||||
|
||||
#
|
||||
# sensor app
|
||||
#
|
||||
# CONFIG_APPLICATION_SENSOR is not set
|
||||
# CONFIG_USING_EMBEDDED_DATABASE_APP is not set
|
||||
# CONFIG_APP_USING_WEBNET is not set
|
||||
# CONFIG_APPLICATION_WEBSERVER is not set
|
||||
|
||||
#
|
||||
# app lib
|
||||
#
|
||||
CONFIG_APP_SELECT_NEWLIB=y
|
||||
# CONFIG_APP_SELECT_OTHER_LIB is not set
|
||||
|
||||
#
|
||||
# lib using cJSON
|
||||
#
|
||||
# CONFIG_LIB_USING_CJSON is not set
|
||||
|
||||
#
|
||||
# lib using queue
|
||||
#
|
||||
# CONFIG_LIB_USING_QUEUE is not set
|
||||
|
||||
#
|
||||
# lib using LVGL
|
||||
#
|
||||
# CONFIG_LIB_LV is not set
|
||||
|
||||
#
|
||||
# lvgl image display parameter settings
|
||||
#
|
||||
CONFIG_LVGL_WIDTH=320
|
||||
CONFIG_LVGL_HEIGHT=320
|
||||
|
||||
#
|
||||
# lib using embedded_database
|
||||
#
|
||||
# CONFIG_USING_EMBEDDED_DATABASE is not set
|
||||
|
||||
#
|
||||
# lib using LoRaWan
|
||||
#
|
||||
# CONFIG_LIB_USING_LORAWAN is not set
|
||||
|
||||
#
|
||||
# lib using MQTT
|
||||
#
|
||||
CONFIG_LIB_USING_MQTT=y
|
||||
CONFIG_XIUOS_PLATFORM=y
|
||||
# CONFIG_ALIBABA_PLATFORM is not set
|
||||
|
||||
#
|
||||
# xiuos platform mqtt connection parameter configuration.
|
||||
#
|
||||
CONFIG_CLIENTID="D001"
|
||||
CONFIG_USERNAME="ch32v208"
|
||||
CONFIG_PASSWORD="xiuosiot"
|
||||
CONFIG_PLATFORM_SERVERIP="47.115.50.232"
|
||||
CONFIG_PLATFORM_SERVERPORT="1883"
|
||||
# CONFIG_USING_DOWNLOAD_JSON is not set
|
||||
|
||||
#
|
||||
# lib using JerryScript
|
||||
#
|
||||
# CONFIG_LIB_USING_JERRYSCRIPT is not set
|
||||
|
||||
#
|
||||
# lib using SQLite
|
||||
#
|
||||
# CONFIG_LIB_USING_SQLITE is not set
|
|
@ -0,0 +1,351 @@
|
|||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# XiZi_IIoT Project Configuration
|
||||
#
|
||||
CONFIG_BOARD_CH32V208RBT6=y
|
||||
CONFIG_ARCH_RISCV=y
|
||||
|
||||
#
|
||||
# ch32v208rbt6 feature
|
||||
#
|
||||
CONFIG_BSP_USING_UART=y
|
||||
CONFIG_BSP_USING_UART1=y
|
||||
CONFIG_SERIAL_BUS_NAME_1="uart1"
|
||||
CONFIG_SERIAL_DRV_NAME_1="uart1_drv"
|
||||
CONFIG_SERIAL_1_DEVICE_NAME_0="uart1_dev1"
|
||||
# CONFIG_BSP_USING_ETH is not set
|
||||
# CONFIG_BSP_USING_ADC is not set
|
||||
# CONFIG_BSP_USING_BLE is not set
|
||||
# CONFIG_BSP_USING_CAN is not set
|
||||
# CONFIG_BSP_USING_RS485 is not set
|
||||
CONFIG_BSP_USING_LTE=y
|
||||
CONFIG_LTE_BUS_NAME="lte"
|
||||
CONFIG_LTE_DRV_NAME="lte_drv"
|
||||
CONFIG_LTE_DEVICE_NAME_1="lte_dev1"
|
||||
# CONFIG_LTE_TEST is not set
|
||||
|
||||
#
|
||||
# Hardware feature
|
||||
#
|
||||
CONFIG_RESOURCES_SERIAL=y
|
||||
CONFIG_SERIAL_USING_DMA=y
|
||||
CONFIG_SERIAL_RB_BUFSZ=2048
|
||||
|
||||
#
|
||||
# Kernel feature
|
||||
#
|
||||
|
||||
#
|
||||
# separate compile(choose none for compile once)
|
||||
#
|
||||
# CONFIG_SEPARATE_COMPILE is not set
|
||||
# CONFIG_COMPILER_APP is not set
|
||||
# CONFIG_APP_STARTUP_FROM_SDCARD is not set
|
||||
CONFIG_APP_STARTUP_FROM_FLASH=y
|
||||
# CONFIG_COMPILER_KERNEL is not set
|
||||
|
||||
#
|
||||
# Memory Management
|
||||
#
|
||||
# CONFIG_KERNEL_MEMBLOCK is not set
|
||||
CONFIG_MEM_ALIGN_SIZE=8
|
||||
# CONFIG_MEM_EXTERN_SRAM is not set
|
||||
CONFIG_MM_PAGE_SIZE=4096
|
||||
|
||||
#
|
||||
# Using small memory allocator
|
||||
#
|
||||
CONFIG_KERNEL_SMALL_MEM_ALLOC=y
|
||||
CONFIG_SMALL_NUMBER_32B=64
|
||||
CONFIG_SMALL_NUMBER_64B=32
|
||||
|
||||
#
|
||||
# Task feature
|
||||
#
|
||||
CONFIG_USER_APPLICATION=y
|
||||
# CONFIG_TASK_ISOLATION is not set
|
||||
# CONFIG_KERNEL_CAPABILITY is not set
|
||||
|
||||
#
|
||||
# Inter-Task communication
|
||||
#
|
||||
CONFIG_KERNEL_SEMAPHORE=y
|
||||
CONFIG_KERNEL_MUTEX=y
|
||||
CONFIG_KERNEL_EVENT=y
|
||||
CONFIG_KERNEL_MESSAGEQUEUE=y
|
||||
CONFIG_KERNEL_SOFTTIMER=y
|
||||
CONFIG_SCHED_POLICY_RR_REMAINSLICE=y
|
||||
# CONFIG_SCHED_POLICY_RR is not set
|
||||
# CONFIG_SCHED_POLICY_FIFO is not set
|
||||
# CONFIG_KTASK_PRIORITY_8 is not set
|
||||
CONFIG_KTASK_PRIORITY_32=y
|
||||
# CONFIG_KTASK_PRIORITY_256 is not set
|
||||
CONFIG_KTASK_PRIORITY_MAX=32
|
||||
CONFIG_TICK_PER_SECOND=100
|
||||
CONFIG_KERNEL_STACK_OVERFLOW_CHECK=y
|
||||
CONFIG_IDLE_KTASK_STACKSIZE=512
|
||||
CONFIG_ZOMBIE_KTASK_STACKSIZE=512
|
||||
|
||||
#
|
||||
# Kernel Console
|
||||
#
|
||||
CONFIG_KERNEL_CONSOLE=y
|
||||
CONFIG_KERNEL_BANNER=y
|
||||
CONFIG_KERNEL_CONSOLEBUF_SIZE=128
|
||||
|
||||
#
|
||||
# Kernel Hook
|
||||
#
|
||||
# CONFIG_KERNEL_HOOK is not set
|
||||
|
||||
#
|
||||
# Command shell
|
||||
#
|
||||
CONFIG_TOOL_SHELL=y
|
||||
CONFIG_SHELL_ENTER_CR=y
|
||||
CONFIG_SHELL_ENTER_LF=y
|
||||
CONFIG_SHELL_ENTER_CR_AND_LF=y
|
||||
# CONFIG_SHELL_ENTER_CRLF is not set
|
||||
|
||||
#
|
||||
# Set shell user control
|
||||
#
|
||||
CONFIG_SHELL_DEFAULT_USER="letter"
|
||||
CONFIG_SHELL_DEFAULT_USER_PASSWORD=""
|
||||
CONFIG_SHELL_LOCK_TIMEOUT=10000
|
||||
|
||||
#
|
||||
# Set shell config param
|
||||
#
|
||||
CONFIG_SHELL_TASK_STACK_SIZE=4096
|
||||
CONFIG_SHELL_TASK_PRIORITY=20
|
||||
CONFIG_SHELL_MAX_NUMBER=5
|
||||
CONFIG_SHELL_PARAMETER_MAX_NUMBER=8
|
||||
CONFIG_SHELL_HISTORY_MAX_NUMBER=5
|
||||
CONFIG_SHELL_PRINT_BUFFER=128
|
||||
CONFIG_SHELL_HELP_SHOW_PERMISSION=y
|
||||
# CONFIG_SHELL_HELP_LIST_USER is not set
|
||||
CONFIG_SHELL_HELP_LIST_VAR=y
|
||||
# CONFIG_SHELL_HELP_LIST_KEY is not set
|
||||
|
||||
#
|
||||
# Kernel data structure Manage
|
||||
#
|
||||
CONFIG_KERNEL_QUEUEMANAGE=y
|
||||
CONFIG_KERNEL_WORKQUEUE=y
|
||||
CONFIG_WORKQUEUE_KTASK_STACKSIZE=2048
|
||||
CONFIG_WORKQUEUE_KTASK_PRIORITY=23
|
||||
CONFIG_QUEUE_MAX=16
|
||||
CONFIG_KERNEL_WAITQUEUE=y
|
||||
CONFIG_KERNEL_DATAQUEUE=y
|
||||
# CONFIG_KERNEL_CIRCULAR_AREA is not set
|
||||
# CONFIG_KERNEL_AVL_TREE is not set
|
||||
|
||||
#
|
||||
# Kernel components init
|
||||
#
|
||||
CONFIG_KERNEL_COMPONENTS_INIT=y
|
||||
CONFIG_ENV_INIT_KTASK_STACK_SIZE=2048
|
||||
CONFIG_KERNEL_USER_MAIN=y
|
||||
CONFIG_NAME_NUM_MAX=32
|
||||
# CONFIG_KERNEL_DEBUG is not set
|
||||
# CONFIG_ARCH_SMP is not set
|
||||
|
||||
#
|
||||
# hash table config
|
||||
#
|
||||
CONFIG_ID_HTABLE_SIZE=16
|
||||
CONFIG_ID_NUM_MAX=128
|
||||
# CONFIG_KERNEL_TEST is not set
|
||||
|
||||
#
|
||||
# Kernel Lib
|
||||
#
|
||||
CONFIG_LIB=y
|
||||
CONFIG_LIB_POSIX=y
|
||||
CONFIG_LIB_NEWLIB=y
|
||||
# CONFIG_LIB_MUSLLIB is not set
|
||||
# CONFIG_LIB_OTHER is not set
|
||||
|
||||
#
|
||||
# C++ features
|
||||
#
|
||||
# CONFIG_LIB_CPLUSPLUS is not set
|
||||
|
||||
#
|
||||
# File system
|
||||
#
|
||||
CONFIG_FS_VFS=y
|
||||
# CONFIG_VFS_USING_WORKDIR is not set
|
||||
CONFIG_FS_VFS_DEVFS=y
|
||||
# CONFIG_FS_VFS_FATFS is not set
|
||||
# CONFIG_FS_CH376 is not set
|
||||
# CONFIG_FS_LWEXT4 is not set
|
||||
|
||||
#
|
||||
# Tool feature
|
||||
#
|
||||
|
||||
#
|
||||
# OTA function
|
||||
#
|
||||
CONFIG_TOOL_USING_OTA=y
|
||||
# CONFIG_MCUBOOT_BOOTLOADER is not set
|
||||
CONFIG_MCUBOOT_APPLICATION=y
|
||||
CONFIG_OTA_BY_PLATFORM=y
|
||||
# CONFIG_OTA_BY_TCPSERVER is not set
|
||||
# CONFIG_OTA_BY_NONE is not set
|
||||
|
||||
#
|
||||
# Flash area address and size configuration.
|
||||
#
|
||||
CONFIG_CHIP_FLAH_BASE=0x08000000
|
||||
CONFIG_XIUOS_FLAH_ADDRESS=0x08008000
|
||||
CONFIG_BAKUP_FLAH_ADDRESS=0x08008000
|
||||
CONFIG_DOWN_FLAH_ADDRESS=0x08008000
|
||||
CONFIG_FLAG_FLAH_ADDRESS=0x08077000
|
||||
CONFIG_APP_FLASH_SIZE=0x00100000
|
||||
CONFIG_OTA_RX_TIMEOUT=600
|
||||
CONFIG_OTA_FRAME_SIZE=2048
|
||||
|
||||
#
|
||||
# APP_Framework
|
||||
#
|
||||
|
||||
#
|
||||
# Framework
|
||||
#
|
||||
CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y
|
||||
CONFIG_ADD_XIZI_FEATURES=y
|
||||
# CONFIG_ADD_NUTTX_FEATURES is not set
|
||||
# CONFIG_ADD_RTTHREAD_FEATURES is not set
|
||||
# CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set
|
||||
CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y
|
||||
# CONFIG_CONNECTION_FRAMEWORK_DEBUG is not set
|
||||
# CONFIG_CONNECTION_INDUSTRIAL_NETWORK is not set
|
||||
# CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS is not set
|
||||
# CONFIG_CONNECTION_INDUSTRIAL_WLAN is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_LORA is not set
|
||||
CONFIG_CONNECTION_ADAPTER_4G=y
|
||||
CONFIG_ADAPTER_EC801E=y
|
||||
CONFIG_ADAPTER_4G_EC801E="ec801e"
|
||||
# CONFIG_ADAPTER_EC801E_DRIVER_EXTUART is not set
|
||||
CONFIG_ADAPTER_EC801E_DRIVER="/dev/lte_dev1"
|
||||
# CONFIG_ADAPTER_EC200T is not set
|
||||
# CONFIG_ADAPTER_EC200A is not set
|
||||
# CONFIG_ADAPTER_GM800TF is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_NB is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_WIFI is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_ETHERNET is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_BLUETOOTH is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_ZIGBEE is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_5G is not set
|
||||
# CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set
|
||||
# CONFIG_SUPPORT_CONTROL_FRAMEWORK is not set
|
||||
|
||||
#
|
||||
# Security
|
||||
#
|
||||
# CONFIG_CRYPTO is not set
|
||||
# CONFIG_MBEDTLS is not set
|
||||
|
||||
#
|
||||
# Applications
|
||||
#
|
||||
|
||||
#
|
||||
# config stack size and priority of main task
|
||||
#
|
||||
CONFIG_MAIN_KTASK_STACK_SIZE=1024
|
||||
CONFIG_MAIN_KTASK_PRIORITY=16
|
||||
|
||||
#
|
||||
# test app
|
||||
#
|
||||
# CONFIG_USER_TEST is not set
|
||||
|
||||
#
|
||||
# connection app
|
||||
#
|
||||
# CONFIG_APPLICATION_CONNECTION is not set
|
||||
|
||||
#
|
||||
# control app
|
||||
#
|
||||
|
||||
#
|
||||
# knowing app
|
||||
#
|
||||
# CONFIG_APPLICATION_KNOWING is not set
|
||||
|
||||
#
|
||||
# sensor app
|
||||
#
|
||||
# CONFIG_APPLICATION_SENSOR is not set
|
||||
# CONFIG_USING_EMBEDDED_DATABASE_APP is not set
|
||||
# CONFIG_APP_USING_WEBNET is not set
|
||||
# CONFIG_APPLICATION_WEBSERVER is not set
|
||||
|
||||
#
|
||||
# app lib
|
||||
#
|
||||
CONFIG_APP_SELECT_NEWLIB=y
|
||||
# CONFIG_APP_SELECT_OTHER_LIB is not set
|
||||
|
||||
#
|
||||
# lib using cJSON
|
||||
#
|
||||
# CONFIG_LIB_USING_CJSON is not set
|
||||
|
||||
#
|
||||
# lib using queue
|
||||
#
|
||||
# CONFIG_LIB_USING_QUEUE is not set
|
||||
|
||||
#
|
||||
# lib using LVGL
|
||||
#
|
||||
# CONFIG_LIB_LV is not set
|
||||
|
||||
#
|
||||
# lvgl image display parameter settings
|
||||
#
|
||||
CONFIG_LVGL_WIDTH=320
|
||||
CONFIG_LVGL_HEIGHT=320
|
||||
|
||||
#
|
||||
# lib using embedded_database
|
||||
#
|
||||
# CONFIG_USING_EMBEDDED_DATABASE is not set
|
||||
|
||||
#
|
||||
# lib using LoRaWan
|
||||
#
|
||||
# CONFIG_LIB_USING_LORAWAN is not set
|
||||
|
||||
#
|
||||
# lib using MQTT
|
||||
#
|
||||
CONFIG_LIB_USING_MQTT=y
|
||||
CONFIG_XIUOS_PLATFORM=y
|
||||
# CONFIG_ALIBABA_PLATFORM is not set
|
||||
|
||||
#
|
||||
# xiuos platform mqtt connection parameter configuration.
|
||||
#
|
||||
CONFIG_CLIENTID="D001"
|
||||
CONFIG_USERNAME="ch32v208"
|
||||
CONFIG_PASSWORD="xiuosiot"
|
||||
CONFIG_PLATFORM_SERVERIP="47.115.50.232"
|
||||
CONFIG_PLATFORM_SERVERPORT="1883"
|
||||
# CONFIG_USING_DOWNLOAD_JSON is not set
|
||||
|
||||
#
|
||||
# lib using JerryScript
|
||||
#
|
||||
# CONFIG_LIB_USING_JERRYSCRIPT is not set
|
||||
|
||||
#
|
||||
# lib using SQLite
|
||||
#
|
||||
# CONFIG_LIB_USING_SQLITE is not set
|
|
@ -0,0 +1,326 @@
|
|||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# XiZi_IIoT Project Configuration
|
||||
#
|
||||
CONFIG_BOARD_CH32V208RBT6=y
|
||||
CONFIG_ARCH_RISCV=y
|
||||
|
||||
#
|
||||
# ch32v208rbt6 feature
|
||||
#
|
||||
CONFIG_BSP_USING_UART=y
|
||||
CONFIG_BSP_USING_UART1=y
|
||||
CONFIG_SERIAL_BUS_NAME_1="uart1"
|
||||
CONFIG_SERIAL_DRV_NAME_1="uart1_drv"
|
||||
CONFIG_SERIAL_1_DEVICE_NAME_0="uart1_dev1"
|
||||
# CONFIG_BSP_USING_ETH is not set
|
||||
# CONFIG_BSP_USING_ADC is not set
|
||||
# CONFIG_BSP_USING_BLE is not set
|
||||
# CONFIG_BSP_USING_CAN is not set
|
||||
# CONFIG_BSP_USING_RS485 is not set
|
||||
CONFIG_BSP_USING_LTE=y
|
||||
CONFIG_LTE_BUS_NAME="lte"
|
||||
CONFIG_LTE_DRV_NAME="lte_drv"
|
||||
CONFIG_LTE_DEVICE_NAME_1="lte_dev1"
|
||||
# CONFIG_LTE_TEST is not set
|
||||
|
||||
#
|
||||
# Hardware feature
|
||||
#
|
||||
CONFIG_RESOURCES_SERIAL=y
|
||||
CONFIG_SERIAL_USING_DMA=y
|
||||
CONFIG_SERIAL_RB_BUFSZ=2048
|
||||
|
||||
#
|
||||
# Kernel feature
|
||||
#
|
||||
|
||||
#
|
||||
# separate compile(choose none for compile once)
|
||||
#
|
||||
# CONFIG_SEPARATE_COMPILE is not set
|
||||
# CONFIG_COMPILER_APP is not set
|
||||
# CONFIG_APP_STARTUP_FROM_SDCARD is not set
|
||||
CONFIG_APP_STARTUP_FROM_FLASH=y
|
||||
# CONFIG_COMPILER_KERNEL is not set
|
||||
|
||||
#
|
||||
# Memory Management
|
||||
#
|
||||
# CONFIG_KERNEL_MEMBLOCK is not set
|
||||
CONFIG_MEM_ALIGN_SIZE=8
|
||||
# CONFIG_MEM_EXTERN_SRAM is not set
|
||||
CONFIG_MM_PAGE_SIZE=4096
|
||||
|
||||
#
|
||||
# Using small memory allocator
|
||||
#
|
||||
CONFIG_KERNEL_SMALL_MEM_ALLOC=y
|
||||
CONFIG_SMALL_NUMBER_32B=64
|
||||
CONFIG_SMALL_NUMBER_64B=32
|
||||
|
||||
#
|
||||
# Task feature
|
||||
#
|
||||
CONFIG_USER_APPLICATION=y
|
||||
# CONFIG_TASK_ISOLATION is not set
|
||||
# CONFIG_KERNEL_CAPABILITY is not set
|
||||
|
||||
#
|
||||
# Inter-Task communication
|
||||
#
|
||||
CONFIG_KERNEL_SEMAPHORE=y
|
||||
CONFIG_KERNEL_MUTEX=y
|
||||
CONFIG_KERNEL_EVENT=y
|
||||
CONFIG_KERNEL_MESSAGEQUEUE=y
|
||||
CONFIG_KERNEL_SOFTTIMER=y
|
||||
CONFIG_SCHED_POLICY_RR_REMAINSLICE=y
|
||||
# CONFIG_SCHED_POLICY_RR is not set
|
||||
# CONFIG_SCHED_POLICY_FIFO is not set
|
||||
# CONFIG_KTASK_PRIORITY_8 is not set
|
||||
CONFIG_KTASK_PRIORITY_32=y
|
||||
# CONFIG_KTASK_PRIORITY_256 is not set
|
||||
CONFIG_KTASK_PRIORITY_MAX=32
|
||||
CONFIG_TICK_PER_SECOND=100
|
||||
CONFIG_KERNEL_STACK_OVERFLOW_CHECK=y
|
||||
CONFIG_IDLE_KTASK_STACKSIZE=512
|
||||
CONFIG_ZOMBIE_KTASK_STACKSIZE=512
|
||||
|
||||
#
|
||||
# Kernel Console
|
||||
#
|
||||
CONFIG_KERNEL_CONSOLE=y
|
||||
CONFIG_KERNEL_BANNER=y
|
||||
CONFIG_KERNEL_CONSOLEBUF_SIZE=128
|
||||
|
||||
#
|
||||
# Kernel Hook
|
||||
#
|
||||
# CONFIG_KERNEL_HOOK is not set
|
||||
|
||||
#
|
||||
# Command shell
|
||||
#
|
||||
# CONFIG_TOOL_SHELL is not set
|
||||
|
||||
#
|
||||
# Kernel data structure Manage
|
||||
#
|
||||
CONFIG_KERNEL_QUEUEMANAGE=y
|
||||
CONFIG_KERNEL_WORKQUEUE=y
|
||||
CONFIG_WORKQUEUE_KTASK_STACKSIZE=2048
|
||||
CONFIG_WORKQUEUE_KTASK_PRIORITY=23
|
||||
CONFIG_QUEUE_MAX=16
|
||||
CONFIG_KERNEL_WAITQUEUE=y
|
||||
CONFIG_KERNEL_DATAQUEUE=y
|
||||
# CONFIG_KERNEL_CIRCULAR_AREA is not set
|
||||
# CONFIG_KERNEL_AVL_TREE is not set
|
||||
|
||||
#
|
||||
# Kernel components init
|
||||
#
|
||||
CONFIG_KERNEL_COMPONENTS_INIT=y
|
||||
CONFIG_ENV_INIT_KTASK_STACK_SIZE=2048
|
||||
CONFIG_KERNEL_USER_MAIN=y
|
||||
CONFIG_NAME_NUM_MAX=32
|
||||
# CONFIG_KERNEL_DEBUG is not set
|
||||
# CONFIG_ARCH_SMP is not set
|
||||
|
||||
#
|
||||
# hash table config
|
||||
#
|
||||
CONFIG_ID_HTABLE_SIZE=16
|
||||
CONFIG_ID_NUM_MAX=128
|
||||
# CONFIG_KERNEL_TEST is not set
|
||||
|
||||
#
|
||||
# Kernel Lib
|
||||
#
|
||||
CONFIG_LIB=y
|
||||
CONFIG_LIB_POSIX=y
|
||||
CONFIG_LIB_NEWLIB=y
|
||||
# CONFIG_LIB_MUSLLIB is not set
|
||||
# CONFIG_LIB_OTHER is not set
|
||||
|
||||
#
|
||||
# C++ features
|
||||
#
|
||||
# CONFIG_LIB_CPLUSPLUS is not set
|
||||
|
||||
#
|
||||
# File system
|
||||
#
|
||||
CONFIG_FS_VFS=y
|
||||
# CONFIG_VFS_USING_WORKDIR is not set
|
||||
CONFIG_FS_VFS_DEVFS=y
|
||||
# CONFIG_FS_VFS_FATFS is not set
|
||||
# CONFIG_FS_CH376 is not set
|
||||
# CONFIG_FS_LWEXT4 is not set
|
||||
|
||||
#
|
||||
# Tool feature
|
||||
#
|
||||
|
||||
#
|
||||
# OTA function
|
||||
#
|
||||
CONFIG_TOOL_USING_OTA=y
|
||||
CONFIG_MCUBOOT_BOOTLOADER=y
|
||||
# CONFIG_MCUBOOT_APPLICATION is not set
|
||||
CONFIG_OTA_BY_PLATFORM=y
|
||||
# CONFIG_OTA_BY_TCPSERVER is not set
|
||||
# CONFIG_OTA_BY_NONE is not set
|
||||
|
||||
#
|
||||
# Flash area address and size configuration.
|
||||
#
|
||||
CONFIG_CHIP_FLAH_BASE=0x08000000
|
||||
CONFIG_XIUOS_FLAH_ADDRESS=0x08008000
|
||||
CONFIG_BAKUP_FLAH_ADDRESS=0x08008000
|
||||
CONFIG_DOWN_FLAH_ADDRESS=0x08008000
|
||||
CONFIG_FLAG_FLAH_ADDRESS=0x08077000
|
||||
CONFIG_APP_FLASH_SIZE=0x00100000
|
||||
CONFIG_OTA_RX_TIMEOUT=600
|
||||
CONFIG_OTA_FRAME_SIZE=2048
|
||||
|
||||
#
|
||||
# APP_Framework
|
||||
#
|
||||
|
||||
#
|
||||
# Framework
|
||||
#
|
||||
CONFIG_TRANSFORM_LAYER_ATTRIUBUTE=y
|
||||
CONFIG_ADD_XIZI_FEATURES=y
|
||||
# CONFIG_ADD_NUTTX_FEATURES is not set
|
||||
# CONFIG_ADD_RTTHREAD_FEATURES is not set
|
||||
# CONFIG_SUPPORT_SENSOR_FRAMEWORK is not set
|
||||
CONFIG_SUPPORT_CONNECTION_FRAMEWORK=y
|
||||
# CONFIG_CONNECTION_FRAMEWORK_DEBUG is not set
|
||||
# CONFIG_CONNECTION_INDUSTRIAL_NETWORK is not set
|
||||
# CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS is not set
|
||||
# CONFIG_CONNECTION_INDUSTRIAL_WLAN is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_LORA is not set
|
||||
CONFIG_CONNECTION_ADAPTER_4G=y
|
||||
CONFIG_ADAPTER_EC801E=y
|
||||
CONFIG_ADAPTER_4G_EC801E="ec801e"
|
||||
# CONFIG_ADAPTER_EC801E_DRIVER_EXTUART is not set
|
||||
CONFIG_ADAPTER_EC801E_DRIVER="/dev/lte_dev1"
|
||||
# CONFIG_ADAPTER_EC200T is not set
|
||||
# CONFIG_ADAPTER_EC200A is not set
|
||||
# CONFIG_ADAPTER_GM800TF is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_NB is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_WIFI is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_ETHERNET is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_BLUETOOTH is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_ZIGBEE is not set
|
||||
# CONFIG_CONNECTION_ADAPTER_5G is not set
|
||||
# CONFIG_SUPPORT_KNOWING_FRAMEWORK is not set
|
||||
# CONFIG_SUPPORT_CONTROL_FRAMEWORK is not set
|
||||
|
||||
#
|
||||
# Security
|
||||
#
|
||||
# CONFIG_CRYPTO is not set
|
||||
# CONFIG_MBEDTLS is not set
|
||||
|
||||
#
|
||||
# Applications
|
||||
#
|
||||
|
||||
#
|
||||
# config stack size and priority of main task
|
||||
#
|
||||
CONFIG_MAIN_KTASK_STACK_SIZE=1024
|
||||
CONFIG_MAIN_KTASK_PRIORITY=16
|
||||
|
||||
#
|
||||
# test app
|
||||
#
|
||||
# CONFIG_USER_TEST is not set
|
||||
|
||||
#
|
||||
# connection app
|
||||
#
|
||||
# CONFIG_APPLICATION_CONNECTION is not set
|
||||
|
||||
#
|
||||
# control app
|
||||
#
|
||||
|
||||
#
|
||||
# knowing app
|
||||
#
|
||||
# CONFIG_APPLICATION_KNOWING is not set
|
||||
|
||||
#
|
||||
# sensor app
|
||||
#
|
||||
# CONFIG_APPLICATION_SENSOR is not set
|
||||
# CONFIG_USING_EMBEDDED_DATABASE_APP is not set
|
||||
# CONFIG_APP_USING_WEBNET is not set
|
||||
# CONFIG_APPLICATION_WEBSERVER is not set
|
||||
|
||||
#
|
||||
# app lib
|
||||
#
|
||||
CONFIG_APP_SELECT_NEWLIB=y
|
||||
# CONFIG_APP_SELECT_OTHER_LIB is not set
|
||||
|
||||
#
|
||||
# lib using cJSON
|
||||
#
|
||||
# CONFIG_LIB_USING_CJSON is not set
|
||||
|
||||
#
|
||||
# lib using queue
|
||||
#
|
||||
# CONFIG_LIB_USING_QUEUE is not set
|
||||
|
||||
#
|
||||
# lib using LVGL
|
||||
#
|
||||
# CONFIG_LIB_LV is not set
|
||||
|
||||
#
|
||||
# lvgl image display parameter settings
|
||||
#
|
||||
CONFIG_LVGL_WIDTH=320
|
||||
CONFIG_LVGL_HEIGHT=320
|
||||
|
||||
#
|
||||
# lib using embedded_database
|
||||
#
|
||||
# CONFIG_USING_EMBEDDED_DATABASE is not set
|
||||
|
||||
#
|
||||
# lib using LoRaWan
|
||||
#
|
||||
# CONFIG_LIB_USING_LORAWAN is not set
|
||||
|
||||
#
|
||||
# lib using MQTT
|
||||
#
|
||||
CONFIG_LIB_USING_MQTT=y
|
||||
CONFIG_XIUOS_PLATFORM=y
|
||||
# CONFIG_ALIBABA_PLATFORM is not set
|
||||
|
||||
#
|
||||
# xiuos platform mqtt connection parameter configuration.
|
||||
#
|
||||
CONFIG_CLIENTID="D001"
|
||||
CONFIG_USERNAME="ch32v208"
|
||||
CONFIG_PASSWORD="xiuosiot"
|
||||
CONFIG_PLATFORM_SERVERIP="47.115.50.232"
|
||||
CONFIG_PLATFORM_SERVERPORT="1883"
|
||||
# CONFIG_USING_DOWNLOAD_JSON is not set
|
||||
|
||||
#
|
||||
# lib using JerryScript
|
||||
#
|
||||
# CONFIG_LIB_USING_JERRYSCRIPT is not set
|
||||
|
||||
#
|
||||
# lib using SQLite
|
||||
#
|
||||
# CONFIG_LIB_USING_SQLITE is not set
|
|
@ -78,6 +78,7 @@ void readRomConfiguration(void) {
|
|||
if ((CFG->cfgFlag[0] != checkcode1) || (CFG->cfgFlag[1] != checkcode2)) {
|
||||
CFG_ERASE(PAGE_WRITE_START_ADDR, FLASH_PAGE_SIZE);
|
||||
CFG_WRITE(PAGE_WRITE_START_ADDR, (u8 *)&defaultConfiguration, MODULE_CFG_LEN);
|
||||
KPrintf("%s NVIC_SystemReset\r\n\r\n", __func__);
|
||||
NVIC_SystemReset(); // 复位ch32v208
|
||||
}
|
||||
|
||||
|
@ -211,7 +212,8 @@ void InitBoardHardware() {
|
|||
#ifdef BSP_USING_UART
|
||||
InitHwUart();
|
||||
InstallConsole("uart1", SERIAL_DRV_NAME_1, SERIAL_1_DEVICE_NAME_0);
|
||||
KPrintf("console init completed.\n");
|
||||
KPrintf("\nconsole init completed.\n");
|
||||
KPrintf("compiled on: %s at %s\n", __DATE__, __TIME__);
|
||||
#endif
|
||||
|
||||
readRomConfiguration(); // 读取配置信息到外部变量CFG中
|
||||
|
@ -245,4 +247,9 @@ void InitBoardHardware() {
|
|||
(x_ubase)MEMORY_END_ADDRESS, SRAM_SIZE, __stack_size);
|
||||
KPrintf("board init done.\n");
|
||||
KPrintf("start kernel...\n");
|
||||
|
||||
#ifdef TOOL_USING_OTA
|
||||
extern void app_clear_jumpflag(void);
|
||||
app_clear_jumpflag(); // set lastjumpflag to JUMP_SUCCESS_FLAG
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -4,7 +4,14 @@ export MARCH := rv32imac_zicsr
|
|||
|
||||
export CFLAGS := -march=$(MARCH) -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -g
|
||||
export AFLAGS := -march=$(MARCH) -mabi=ilp32 -x assembler-with-cpp -ggdb
|
||||
|
||||
ifeq ($(CONFIG_MCUBOOT_BOOTLOADER),y)
|
||||
export LFLAGS := -march=$(MARCH) -mabi=ilp32 -nostartfiles -Wl,--gc-sections,-Map=XiZi-ch32v208vct6.map,-cref,-u,_start -T $(BSP_ROOT)/link_bootloader.ld
|
||||
else ifeq ($(CONFIG_MCUBOOT_APPLICATION),y)
|
||||
export LFLAGS := -march=$(MARCH) -mabi=ilp32 -nostartfiles -Wl,--gc-sections,-Map=XiZi-ch32v208vct6.map,-cref,-u,_start -T $(BSP_ROOT)/link_application.ld
|
||||
else
|
||||
export LFLAGS := -march=$(MARCH) -mabi=ilp32 -nostartfiles -Wl,--gc-sections,-Map=XiZi-ch32v208vct6.map,-cref,-u,_start -T $(BSP_ROOT)/link.ld
|
||||
endif
|
||||
|
||||
# export CFLAGS := -march=$(MARCH) -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -g -std=gnu99
|
||||
# export AFLAGS := -march=$(MARCH) -mabi=ilp32 -x assembler-with-cpp -ggdb
|
||||
|
@ -17,6 +24,9 @@ export CXXFLAGS := -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-
|
|||
export CROSS_COMPILE ?=/opt/riscv64-toolchain/bin/riscv64-unknown-elf-
|
||||
|
||||
export DEFINES := -DHAVE_CCONFIG_H -DHAVE_SIGINFO
|
||||
ifeq ($(CONFIG_MCUBOOT_BOOTLOADER),y)
|
||||
export DEFINES += -D__BOOTLOADER
|
||||
endif
|
||||
|
||||
export LINK_WCH_NET := $(KERNEL_ROOT)/board/ch32v208rbt6/third_party_driver/ethernet/libwchnet.a
|
||||
export LINK_WCH_BLE := $(KERNEL_ROOT)/board/ch32v208rbt6/third_party_driver/ble/lib/libwchble.a
|
||||
|
|
|
@ -0,0 +1,224 @@
|
|||
ENTRY( _start )
|
||||
|
||||
__stack_size = 2048;
|
||||
|
||||
PROVIDE( _stack_size = __stack_size );
|
||||
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* CH32V20x_D6 - CH32V203F6-CH32V203G6-CH32V203K6-CH32V203C6 */
|
||||
/*
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 32K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 10K
|
||||
*/
|
||||
|
||||
/* CH32V20x_D6 - CH32V203K8-CH32V203C8-CH32V203G8-CH32V203F8 */
|
||||
/*
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
|
||||
*/
|
||||
|
||||
/* CH32V20x_D8 - CH32V203RB
|
||||
CH32V20x_D8W - CH32V208x
|
||||
FLASH + RAM supports the following configuration
|
||||
FLASH-128K + RAM-64K
|
||||
FLASH-144K + RAM-48K
|
||||
FLASH-160K + RAM-32K
|
||||
*/
|
||||
FLASH (rx) : ORIGIN = 0x00008000, LENGTH = 288K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||
}
|
||||
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
.init :
|
||||
{
|
||||
_sinit = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
. = ALIGN(4);
|
||||
_einit = .;
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.vector :
|
||||
{
|
||||
*(.vector);
|
||||
. = ALIGN(64);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.highcode :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.highcode);
|
||||
*(.highcode.*);
|
||||
. = ALIGN(4);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
EXCLUDE_FILE (*wchble.a) *(.text .text*)
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.rodata)
|
||||
*(.rodata*)
|
||||
*(.sdata2.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.gnu.linkonce.t.*)
|
||||
. = ALIGN(4);
|
||||
|
||||
/* section information for shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP (*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
PROVIDE(__ctors_start__ = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE(__ctors_end__ = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
__isrtbl_idx_start = .;
|
||||
KEEP(*(.isrtbl.idx))
|
||||
__isrtbl_start = .;
|
||||
KEEP(*(.isrtbl))
|
||||
__isrtbl_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
PROVIDE(g_service_table_start = ABSOLUTE(.));
|
||||
KEEP(*(.g_service_table))
|
||||
PROVIDE(g_service_table_end = ABSOLUTE(.));
|
||||
|
||||
*(.gnu.linkonce.t.*)
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.fini :
|
||||
{
|
||||
KEEP(*(SORT_NONE(.fini)))
|
||||
. = ALIGN(4);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
PROVIDE( _etext = . );
|
||||
PROVIDE( _eitcm = . );
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.ctors :
|
||||
{
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*crtbegin?.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.dtors :
|
||||
{
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*crtbegin?.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.dalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_data_vma = .);
|
||||
} >RAM AT>FLASH
|
||||
|
||||
.dlalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_data_lma = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.gnu.linkonce.r.*)
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
. = ALIGN(8);
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
*(.sdata .sdata.*)
|
||||
*(.sdata2.*)
|
||||
*(.gnu.linkonce.s.*)
|
||||
. = ALIGN(8);
|
||||
*(.srodata.cst16)
|
||||
*(.srodata.cst8)
|
||||
*(.srodata.cst4)
|
||||
*(.srodata.cst2)
|
||||
*(.srodata .srodata.*)
|
||||
. = ALIGN(4);
|
||||
PROVIDE( _edata = .);
|
||||
} >RAM AT>FLASH
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE( _sbss = .);
|
||||
*(.sbss*)
|
||||
*(.gnu.linkonce.sb.*)
|
||||
*(.bss*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON*)
|
||||
. = ALIGN(4);
|
||||
PROVIDE( _ebss = .);
|
||||
} >RAM AT>FLASH
|
||||
|
||||
PROVIDE( _end = _ebss);
|
||||
PROVIDE( end = . );
|
||||
|
||||
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
|
||||
{
|
||||
PROVIDE( _heap_end = . );
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_susrstack = . );
|
||||
. = . + __stack_size;
|
||||
PROVIDE( _eusrstack = .);
|
||||
} >RAM
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,237 @@
|
|||
ENTRY( _start )
|
||||
|
||||
__stack_size = 2048;
|
||||
|
||||
PROVIDE( _stack_size = __stack_size );
|
||||
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* CH32V20x_D6 - CH32V203F6-CH32V203G6-CH32V203K6-CH32V203C6 */
|
||||
/*
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 32K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 10K
|
||||
*/
|
||||
|
||||
/* CH32V20x_D6 - CH32V203K8-CH32V203C8-CH32V203G8-CH32V203F8 */
|
||||
/*
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
|
||||
*/
|
||||
|
||||
/* CH32V20x_D8 - CH32V203RB
|
||||
CH32V20x_D8W - CH32V208x
|
||||
FLASH + RAM supports the following configuration
|
||||
FLASH-128K + RAM-64K
|
||||
FLASH-144K + RAM-48K
|
||||
FLASH-160K + RAM-32K
|
||||
*/
|
||||
FLASH_FAST (rx) : ORIGIN = 0x00000000, LENGTH = 32K
|
||||
FLASH (rx) : ORIGIN = 0x00050000, LENGTH = 156K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||
}
|
||||
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.init :
|
||||
{
|
||||
_sinit = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
. = ALIGN(4);
|
||||
_einit = .;
|
||||
} >FLASH_FAST AT>FLASH_FAST
|
||||
|
||||
.vector :
|
||||
{
|
||||
*(.vector);
|
||||
. = ALIGN(64);
|
||||
} >FLASH_FAST AT>FLASH_FAST
|
||||
|
||||
.highcode :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.highcode);
|
||||
*(.highcode.*);
|
||||
. = ALIGN(4);
|
||||
} >FLASH_FAST AT>FLASH_FAST
|
||||
|
||||
.text.fast :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text.fast)
|
||||
*arch/risc-v/ch32v208rbt6*.o(.text)
|
||||
*board/ch32v208rbt6/third_party_driver/Peripheral/src/ch32v20x_flash.o(.text)
|
||||
*board/ch32v208rbt6/third_party_driver/Peripheral/src/ch32v20x_usart.o(.text)
|
||||
*board/ch32v208rbt6/third_party_driver/lte/connect_lte.o(.text)
|
||||
*kernel/thread*.o(.text)
|
||||
*resources/serial*.o(.text)
|
||||
. = ALIGN(4);
|
||||
} >FLASH_FAST AT>FLASH_FAST
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
EXCLUDE_FILE (*wchble.a) *(.text .text*)
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.rodata)
|
||||
*(.rodata*)
|
||||
*(.sdata2.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.gnu.linkonce.t.*)
|
||||
. = ALIGN(4);
|
||||
|
||||
/* section information for shell */
|
||||
. = ALIGN(4);
|
||||
_shell_command_start = .;
|
||||
KEEP (*(shellCommand))
|
||||
_shell_command_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
PROVIDE(__ctors_start__ = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE(__ctors_end__ = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
__isrtbl_idx_start = .;
|
||||
KEEP(*(.isrtbl.idx))
|
||||
__isrtbl_start = .;
|
||||
KEEP(*(.isrtbl))
|
||||
__isrtbl_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
PROVIDE(g_service_table_start = ABSOLUTE(.));
|
||||
KEEP(*(.g_service_table))
|
||||
PROVIDE(g_service_table_end = ABSOLUTE(.));
|
||||
|
||||
*(.gnu.linkonce.t.*)
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.fini :
|
||||
{
|
||||
KEEP(*(SORT_NONE(.fini)))
|
||||
. = ALIGN(4);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
PROVIDE( _etext = . );
|
||||
PROVIDE( _eitcm = . );
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.ctors :
|
||||
{
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*crtbegin?.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.dtors :
|
||||
{
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*crtbegin?.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.dalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_data_vma = .);
|
||||
} >RAM AT>FLASH
|
||||
|
||||
.dlalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_data_lma = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.gnu.linkonce.r.*)
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
. = ALIGN(8);
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
*(.sdata .sdata.*)
|
||||
*(.sdata2.*)
|
||||
*(.gnu.linkonce.s.*)
|
||||
. = ALIGN(8);
|
||||
*(.srodata.cst16)
|
||||
*(.srodata.cst8)
|
||||
*(.srodata.cst4)
|
||||
*(.srodata.cst2)
|
||||
*(.srodata .srodata.*)
|
||||
. = ALIGN(4);
|
||||
PROVIDE( _edata = .);
|
||||
} >RAM AT>FLASH
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE( _sbss = .);
|
||||
*(.sbss*)
|
||||
*(.gnu.linkonce.sb.*)
|
||||
*(.bss*)
|
||||
*(.gnu.linkonce.b.*)
|
||||
*(COMMON*)
|
||||
. = ALIGN(4);
|
||||
PROVIDE( _ebss = .);
|
||||
} >RAM AT>FLASH
|
||||
|
||||
PROVIDE( _end = _ebss);
|
||||
PROVIDE( end = . );
|
||||
|
||||
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
|
||||
{
|
||||
PROVIDE( _heap_end = . );
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_susrstack = . );
|
||||
. = . + __stack_size;
|
||||
PROVIDE( _eusrstack = .);
|
||||
} >RAM
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -109,5 +109,8 @@ menuconfig BSP_USING_LTE
|
|||
config LTE_DEVICE_NAME_1
|
||||
string "lte bus device 1 name"
|
||||
default "lte_dev1"
|
||||
config LTE_TEST
|
||||
bool "Enable lte test"
|
||||
default n
|
||||
endif
|
||||
|
|
@ -22,4 +22,8 @@ endif
|
|||
ifeq ($(CONFIG_BSP_USING_LTE),y)
|
||||
SRC_DIR += lte
|
||||
endif
|
||||
ifeq ($(CONFIG_TOOL_USING_OTA),y)
|
||||
SRC_DIR += ota
|
||||
SRC_DIR += common
|
||||
endif
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
@ -102,6 +102,7 @@ void CFG_READ(u32 StartAddr, u8 *Buffer, u32 Length) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef BSP_USING_BLE
|
||||
/**
|
||||
* @brief 尝试使用配置通过4G连接到服务器,并且蓝牙响应连接状态报文。
|
||||
* @param requestId 蓝牙请求报文ID
|
||||
|
@ -531,6 +532,7 @@ void startParseBleRequestTask(uint8_t *request) {
|
|||
PrivTaskCreate(&parseBleRequestThread, &parseBleRequestTaskAttr, parseBleRequest, &parseBleRequestTaskArgs);
|
||||
PrivTaskStartup(&parseBleRequestThread);
|
||||
}
|
||||
#endif /* BSP_USING_BLE */
|
||||
|
||||
/**
|
||||
* @brief 命令行显示配置信息
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
ifeq ($(CONFIG_TOOL_USING_OTA),y)
|
||||
SRC_FILES += common.c ymodem.c
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file: common.c
|
||||
* @brief: file common.c
|
||||
* @version: 1.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2023/3/24
|
||||
*/
|
||||
|
||||
#include <xs_base.h>
|
||||
#include "common.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief UartConfig
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void UartConfig(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Print a string on the HyperTerminal
|
||||
* @param s: The string to be printed
|
||||
* @retval None
|
||||
*/
|
||||
void Serial_PutString(uint8_t *s)
|
||||
{
|
||||
KPrintf("%s", s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test to see if a key has been pressed on the HyperTerminal
|
||||
* @param key: The key pressed
|
||||
* @retval 1: Correct
|
||||
* 0: Error
|
||||
*/
|
||||
uint32_t SerialKeyPressed(uint8_t *key)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a key from the HyperTerminal
|
||||
* @param None
|
||||
* @retval The Key Pressed
|
||||
*/
|
||||
uint8_t GetKey(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file: ymodem.c
|
||||
* @brief: file ymodem.c
|
||||
* @version: 1.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2023/3/24
|
||||
*/
|
||||
#include <xs_base.h>
|
||||
#include "ymodem.h"
|
||||
#include "string.h"
|
||||
#include "flash_for_ota.h"
|
||||
#include "boot_for_ota.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: Ymodem_Receive
|
||||
* 功能描述: 使用ymodem协议接收文件
|
||||
* 形 参: buf:数据buffer
|
||||
addr:下载flash起始地址
|
||||
timeout:超时时间
|
||||
* 返 回 值: 文件的大小
|
||||
*******************************************************************************/
|
||||
int32_t Ymodem_Receive(uint8_t *buf, const uint32_t addr)
|
||||
{
|
||||
int32_t size = 0;
|
||||
return size;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: SerialDownload
|
||||
* 功能描述: 通过串口下载文件
|
||||
* 形 参: addr:存储文件的flash起始地址
|
||||
* 返 回 值: 文件的大小
|
||||
*******************************************************************************/
|
||||
int32_t SerialDownload(const uint32_t addr)
|
||||
{
|
||||
int32_t Size = 1; //TODO: 208 does not support serial download
|
||||
return Size;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file boot_for_ota.h
|
||||
* @brief support bootloader function
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023-11-20
|
||||
*/
|
||||
|
||||
#ifndef __BOOT_FOR_OTA_H__
|
||||
#define __BOOT_FOR_OTA_H__
|
||||
|
||||
#define IMAGE_IAP_START_ADD 0x08000000
|
||||
#define IMAGE_IAP_SIZE (32 * 1024)
|
||||
#define IMAGE_A_START_ADD (IMAGE_IAP_START_ADD + IMAGE_IAP_SIZE)
|
||||
|
||||
void mcuboot_bord_init(void);
|
||||
void mcuboot_reset(void);
|
||||
void mcuboot_jump(void);
|
||||
void mcuboot_delay(uint32_t ms);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file: common.h
|
||||
* @brief: file common.h
|
||||
* @version: 1.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2023/3/24
|
||||
*/
|
||||
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum {
|
||||
kStatus_Success = 0,
|
||||
};
|
||||
|
||||
void UartConfig(void);
|
||||
uint32_t SerialKeyPressed(uint8_t *key);
|
||||
uint8_t GetKey(void);
|
||||
void SerialPutChar(uint8_t c);
|
||||
void Serial_PutString(uint8_t *s);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file flash_for_ota.h
|
||||
* @brief support flash function
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023-11-20
|
||||
*/
|
||||
|
||||
#ifndef __FLASH_FOR_OTA_H__
|
||||
#define __FLASH_FOR_OTA_H__
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define FLASH_PAGE_FAST_SIZE 256
|
||||
|
||||
typedef int32_t status_t;
|
||||
|
||||
void FLASH_Init(void);
|
||||
void FLASH_DeInit(void);
|
||||
status_t Flash_Erase(uint32_t start_addr, uint32_t imageSize);
|
||||
status_t Flash_Write(uint32_t WriteAddr, uint8_t *pBuffer, uint32_t NumByteToWrite);
|
||||
status_t Flash_Read(uint32_t addr, uint8_t *buf, uint32_t len);
|
||||
status_t Flash_Copy(uint32_t srcAddr,uint32_t dstAddr, uint32_t imageSize);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file: ymodem.h
|
||||
* @brief: file ymodem.h
|
||||
* @version: 1.0
|
||||
* @author: AIIT XUOS Lab
|
||||
* @date: 2023/3/24
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _YMODEM_H_
|
||||
#define _YMODEM_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int32_t SerialDownload(const uint32_t addr);
|
||||
int32_t Ymodem_Receive(uint8_t *buf, const uint32_t addr);
|
||||
|
||||
#endif
|
|
@ -1,5 +1,7 @@
|
|||
# SRC_FILES := connect_uart.c test_uart.c
|
||||
ifeq ($(CONFIG_LTE_TEST),y)
|
||||
SRC_DIR := test
|
||||
endif
|
||||
SRC_FILES := connect_lte.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
@ -315,12 +315,19 @@ int InitHwLte(void) {
|
|||
USART_Cmd(USART2, ENABLE);
|
||||
|
||||
/* Enable module pin */
|
||||
GPIO_InitStructure_Lte.GPIO_Pin = GPIO_Pin_7;
|
||||
GPIO_InitStructure_Lte.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure_Lte.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure_Lte);
|
||||
GPIO_SetBits(GPIOA, GPIO_Pin_7);
|
||||
Delay_Ms(500); // >= 300ms
|
||||
GPIO_ResetBits(GPIOA, GPIO_Pin_7);
|
||||
GPIO_InitStructure_Lte.GPIO_Pin = GPIO_Pin_6;
|
||||
GPIO_InitStructure_Lte.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure_Lte.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure_Lte);
|
||||
GPIO_SetBits(GPIOA, GPIO_Pin_6);
|
||||
Delay_Ms(2000);
|
||||
Delay_Ms(1000); // >= 500ms
|
||||
GPIO_ResetBits(GPIOA, GPIO_Pin_6);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "ch32v20x_usart.h"
|
||||
#include "connect_uart.h"
|
||||
#include "debug.h"
|
||||
#include "shell.h"
|
||||
#include "string.h"
|
||||
|
||||
#define TRANSPARENT_TRANSMISSION_MODE 0
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
SRC_FILES := flash_for_ota.c boot_for_ota.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,95 @@
|
|||
# 编译
|
||||
生成支持OTA升级的固件,需要分别编译boot和app。其中,boot是升级需要的固件,app是正常系统固件。
|
||||
|
||||
编译boot之前,需要在路径 Ubiquitous/XiZi_IIoT 下,执行:
|
||||
|
||||
cp board/ch32v208rbt6/.defconfig_boot board/ch32v208rbt6/.defconfig
|
||||
|
||||
编译app之前,需要在路径 Ubiquitous/XiZi_IIoT 下,执行:
|
||||
|
||||
cp board/ch32v208rbt6/.defconfig_app board/ch32v208rbt6/.defconfig
|
||||
|
||||
可以执行 make BOARD=ch32v208rbt6 menuconfig,查看config 选项。
|
||||
|
||||
.config - XiZi_IIoT Project Configuration
|
||||
> Tool feature > OTA function > Enable support OTA function > Compile bootloader bin or application bin.
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
.config - XiZi_IIoT Project Configuration
|
||||
> APP_Framework > app lib > lib using MQTT > Enable support MQTT function > xiuos platform mqtt connection parameter configuration.
|
||||
|
||||

|
||||
|
||||
执行 make BOARD=ch32v208rbt6,进行编译。
|
||||
|
||||
编译后,分别生成 XiZi-ch32v208rbt6-boot.bin 和 XiZi-ch32v208rbt6-app.bin,以及 XiZi-ch32v208rbt6-boot.hex 和 XiZi-ch32v208rbt6-app.hex。
|
||||
|
||||
从沁恒官网([产品手册 - 南京沁恒微电子股份有限公司](https://www.wch.cn/downloads/category/27.html))下载工具软件 WCH_AssemblingFileTool.exe,将 XiZi-ch32v208rbt6-boot.hex 和 XiZi-ch32v208rbt6-app.hex 合并成 XiZi-ch32v208rbt6.bin。
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
# 烧录
|
||||
从沁恒官网下载工具软件 WchIspStudio.exe,选择芯片和串口,选择固件。
|
||||
|
||||
设备端,按boot和reset按键,让设备进入烧录模式。点击“解除代码保护”和“下载”,进行烧录。
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
# OTA升级
|
||||
|
||||
烧录成功后,先启动 boot 程序,然后跳转到 app 程序 。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
进入系统后初始化4G模块并开启线程进行mqtt通信,可以看到此时的版本是 001.000.000。
|
||||
|
||||

|
||||
|
||||
然后,需要进入publisher,将要更新的app程序XiZi-ch32v208rbt6-app.bin放到publisher下,修改main.py中的version和文件名。
|
||||
|
||||
然后,电脑上运行 python3 main_early.py (需pip install paho-mqtt安装依赖库)。
|
||||
|
||||

|
||||
|
||||
设备检测到版本信息后,写入OTA状态,然后重启,重启后boot进入下载状态。
|
||||
|
||||

|
||||
|
||||
然后,电脑上运行 python3 main.py。
|
||||
|
||||

|
||||
|
||||
设备检测到版本信息后,开始传输文件。
|
||||
|
||||

|
||||
|
||||
当传输进度为100%后,更新app的bin将烧录至APP区,之后板子会自动重启。
|
||||
|
||||

|
||||
|
||||
重启后依然先进入boot,然后启动app。查看APP日志,以及version打印信息确认升级成功。
|
||||
|
||||
|
||||
|
||||
# 注意事项
|
||||
|
||||
CH32V208的FLASH大小是480KB,其中零等待运行区域大小是128KB。FLASH快速写函数以及系统中断等关键函数需要运行在零等待运行区域。
|
||||
|
||||
程序分布如下:
|
||||
|
||||
|address|Area|Size|
|
||||
|-|-|-|
|
||||
|0x08000000 ~ 0x08008000 | Boot_FAST | 32KB |
|
||||
|0x08008000 ~ 0x08050000 | Application | 288KB |
|
||||
|0x08050000 ~ 0x08077000 | Boot_SLOW | 156KB |
|
||||
|0x08077000 ~ 0x08078000 | OTA_FLAG | 4KB |
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file boot_for_ota.c
|
||||
* @brief support bootloader function
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023-11-20
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <xs_base.h>
|
||||
#include "boot_for_ota.h"
|
||||
#include "flash_for_ota.h"
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#include <ModuleConfig.h>
|
||||
#include <device.h>
|
||||
#include <stdint.h>
|
||||
#include <xizi.h>
|
||||
|
||||
#include "HAL.h"
|
||||
#include "adc.h"
|
||||
#include "ch32v20x.h"
|
||||
#include "connect_ble.h"
|
||||
#include "connect_can.h"
|
||||
#include "connect_ether.h"
|
||||
#include "connect_lte.h"
|
||||
#include "connect_rs485.h"
|
||||
#include "connect_uart.h"
|
||||
#include "core_riscv.h"
|
||||
#include "config.h"
|
||||
#include "xsconfig.h"
|
||||
|
||||
|
||||
#ifdef TOOL_USING_OTA
|
||||
|
||||
#define jumpApp ((void (*)(void))((int *)(IMAGE_A_START_ADD-0x08000000)))
|
||||
|
||||
|
||||
static uint32_t _SysTick_Config(uint32_t ticks) {
|
||||
// SystemCoreClockUpdate();
|
||||
NVIC_SetPriority(SysTicK_IRQn, 0x01);
|
||||
NVIC_SetPriority(Software_IRQn, 0xf0);
|
||||
NVIC_EnableIRQ(SysTicK_IRQn);
|
||||
NVIC_EnableIRQ(Software_IRQn);
|
||||
SysTick->CTLR = 0;
|
||||
SysTick->SR = 0;
|
||||
SysTick->CNT = 0;
|
||||
SysTick->CMP = ticks - 1;
|
||||
SysTick->CTLR = 0xF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mcuboot_bord_init(void)
|
||||
{
|
||||
Delay_Init();
|
||||
USART_Printf_Init(115200);
|
||||
/* System Tick Configuration */
|
||||
extern uint32_t SystemCoreClock;
|
||||
_SysTick_Config(SystemCoreClock / TICK_PER_SECOND);
|
||||
/* initialize memory system */
|
||||
InitBoardMemory(MEMORY_START_ADDRESS, (void *)MEMORY_END_ADDRESS);
|
||||
|
||||
#ifdef BSP_USING_UART
|
||||
InitHwUart();
|
||||
InstallConsole("uart1", SERIAL_DRV_NAME_1, SERIAL_1_DEVICE_NAME_0);
|
||||
KPrintf("\nboot console init completed.\n");
|
||||
KPrintf("boot compiled on: %s at %s\n", __DATE__, __TIME__);
|
||||
#endif
|
||||
|
||||
void readRomConfiguration(void);
|
||||
readRomConfiguration(); // 读取配置信息到外部变量CFG中
|
||||
|
||||
KPrintf("mcuboot board init done.\n");
|
||||
}
|
||||
|
||||
void mcuboot_reset(void)
|
||||
{
|
||||
KPrintf("%s NVIC_SystemReset\n\n", __func__);
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void mcuboot_jump(void)
|
||||
{
|
||||
KPrintf("%s jumpApp\n\n", __func__);
|
||||
jumpApp();
|
||||
}
|
||||
|
||||
void mcuboot_delay(uint32_t ms)
|
||||
{
|
||||
/* ImxrtMsDelay(ms);*/
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file flash_for_ota.c
|
||||
* @brief support flash function
|
||||
* @version 2.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023-11-20
|
||||
*/
|
||||
|
||||
#include <xizi.h>
|
||||
#include <stdio.h>
|
||||
#include "flash_for_ota.h"
|
||||
#include "ch32v20x_flash.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: FLASH_Init
|
||||
* 功能描述: Flash接口初始化,需在进行Flash相关操作前进行调用
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*******************************************************************************/
|
||||
void FLASH_Init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: FLASH_DeInit
|
||||
* 功能描述: Flash接口反初始化,需在完成Flash相关操作后进行调用
|
||||
* 形 参: 无
|
||||
* 返 回 值: 无
|
||||
*******************************************************************************/
|
||||
void FLASH_DeInit(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: Flash_Erase
|
||||
* 功能描述: 以扇区为擦除单位擦除Flash指定长度的空间,最终擦除的字节可能大于imageSize
|
||||
* 形 参: start_addr:擦除区域起始地址
|
||||
imageSize:要擦除的字节数
|
||||
* 返 回 值: 如果函数执行成功,状态值为 kStatus_Success,否则状态值为其他错误码
|
||||
*******************************************************************************/
|
||||
status_t Flash_Erase(uint32_t start_addr, uint32_t imageSize)
|
||||
{
|
||||
uint32_t page_count;
|
||||
uint32_t pageNum = (imageSize%FLASH_PAGE_FAST_SIZE != 0)? (imageSize/FLASH_PAGE_FAST_SIZE + 1):(imageSize/FLASH_PAGE_FAST_SIZE);
|
||||
|
||||
FLASH_Unlock_Fast();
|
||||
for(page_count = 0; page_count < pageNum; page_count++)
|
||||
{
|
||||
FLASH_ErasePage_Fast(start_addr + (page_count * FLASH_PAGE_FAST_SIZE));
|
||||
}
|
||||
FLASH_Lock_Fast();
|
||||
|
||||
return (status_t)kStatus_Success;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: Flash_Write
|
||||
* 功能描述: 写入W25QXX在指定地址开始写入指定长度的数据
|
||||
* 形 参: pBuffer:数据存储区
|
||||
WriteAddr:开始写入的地址
|
||||
NumByteToWrite:要写入的字节数(最大65535)
|
||||
* 返 回 值: 如果函数执行成功,状态值为 kStatus_Success,否则状态值为其他错误码
|
||||
* 注 释: 该函数带擦除操作
|
||||
*******************************************************************************/
|
||||
status_t Flash_Write(uint32_t WriteAddr, uint8_t *pBuffer, uint32_t NumByteToWrite)
|
||||
{
|
||||
uint32_t page_count;
|
||||
uint32_t pageNum = (NumByteToWrite%FLASH_PAGE_FAST_SIZE != 0)? (NumByteToWrite/FLASH_PAGE_FAST_SIZE + 1):(NumByteToWrite/FLASH_PAGE_FAST_SIZE);
|
||||
|
||||
FLASH_Unlock_Fast();
|
||||
for(page_count = 0; page_count < pageNum; page_count++)
|
||||
{
|
||||
FLASH_ProgramPage_Fast(WriteAddr + (page_count * FLASH_PAGE_FAST_SIZE), (uint32_t *)&pBuffer[page_count * FLASH_PAGE_FAST_SIZE]);
|
||||
}
|
||||
FLASH_Lock_Fast();
|
||||
|
||||
return (status_t)kStatus_Success;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: Flash_Read
|
||||
* 功能描述: 读Flash内容
|
||||
* 形 参: addr:读取区域起始地址
|
||||
buf:数据存储区
|
||||
len:要读取的字节数
|
||||
* 返 回 值: 如果函数执行成功,状态值为 kStatus_Success,否则状态值为其他错误码
|
||||
*******************************************************************************/
|
||||
status_t Flash_Read(uint32_t addr, uint8_t *buf, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
*buf++ = *(uint8_t*)addr++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: Flash_Copy
|
||||
* 功能描述: 实现flash数据在分区之间的拷贝
|
||||
* 形 参: srcAddr:源flash的起始地址
|
||||
dstAddr:目标flash的起始地址;
|
||||
imageSize:要拷贝的flash空间大小,单位为字节
|
||||
* 返 回 值: 如果函数执行成功,状态值为 kStatus_Success,否则状态值为其他错误码
|
||||
*******************************************************************************/
|
||||
status_t Flash_Copy(uint32_t srcAddr,uint32_t dstAddr, uint32_t imageSize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: NOR_FLASH_Write
|
||||
* 功能描述: 写入W25QXX在指定地址开始写入指定长度的数据
|
||||
* 形 参: FlashAddress:用于存储当前写入Flash地址的指针,写入过程中会移动
|
||||
Data:要写入数据存储区
|
||||
DataLength:要写入的字节数
|
||||
* 返 回 值: 如果函数执行成功,状态值为 kStatus_Success,否则状态值为其他错误码
|
||||
*******************************************************************************/
|
||||
status_t NOR_FLASH_Write(uint32_t* FlashAddress, uint8_t* Data ,uint16_t DataLength,uint8_t doneFlag)
|
||||
{
|
||||
return 0;
|
||||
}
|
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 22 KiB |
|
@ -0,0 +1,127 @@
|
|||
import paho.mqtt.client as mqtt
|
||||
import json
|
||||
import os
|
||||
import hashlib
|
||||
|
||||
# 配置参数(根据实际情况修改)
|
||||
MQTT_BROKER = "47.115.50.232" # MQTT代理地址
|
||||
MQTT_PORT = 1883 # 端口
|
||||
FILE_PATH = "XiZi-ch32v208rbt6-app.bin" # 要发送的固件文件路径
|
||||
CLIENT_ID = "D001" # 设备客户端ID
|
||||
VERSION = "001.000.002" # 新固件版本号
|
||||
FILE_ID = 1 # 文件标识符
|
||||
|
||||
def calculate_md5(file_path):
|
||||
""" 计算文件的MD5哈希值 """
|
||||
hash_md5 = hashlib.md5()
|
||||
with open(file_path, "rb") as f:
|
||||
for chunk in iter(lambda: f.read(4096), b""):
|
||||
hash_md5.update(chunk)
|
||||
return hash_md5.hexdigest()
|
||||
|
||||
def compact_json(payload: dict) -> str:
|
||||
"""生成无空格/换行的紧凑JSON字符串"""
|
||||
return json.dumps(payload, separators=(',', ':'))
|
||||
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
""" 连接回调函数 """
|
||||
if rc == 0:
|
||||
print("连接成功!")
|
||||
# 订阅文件请求主题
|
||||
client.subscribe("xiuosiot/ota/files")
|
||||
|
||||
# 发送初始更新信息
|
||||
init_payload = {
|
||||
"fileSize": userdata["file_size"],
|
||||
"version": userdata["fw_version"],
|
||||
"fileId": userdata["file_id"],
|
||||
"md5": userdata["file_md5"]
|
||||
}
|
||||
client.publish(
|
||||
topic=f"ota/{CLIENT_ID}/update",
|
||||
payload=compact_json(init_payload),
|
||||
qos=1
|
||||
)
|
||||
print(f"已发送初始化消息到 ota/{CLIENT_ID}/update")
|
||||
|
||||
else:
|
||||
print(f"连接失败,错误码:{rc}")
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
""" 消息到达回调函数 """
|
||||
try:
|
||||
payload = json.loads(msg.payload.decode())
|
||||
print("收到文件请求:", payload)
|
||||
|
||||
# 验证必要字段
|
||||
required_fields = ["clientId", "fileId", "fileOffset", "size"]
|
||||
if not all(field in payload for field in required_fields):
|
||||
print("错误:缺少必要字段")
|
||||
return
|
||||
|
||||
# 验证客户端ID
|
||||
if payload["clientId"] != CLIENT_ID:
|
||||
print(f"忽略非目标客户端请求:{payload['clientId']}")
|
||||
return
|
||||
|
||||
# 提取请求参数
|
||||
offset = payload["fileOffset"]
|
||||
request_size = payload["size"]
|
||||
reply_topic = f"ota/{CLIENT_ID}/files"
|
||||
|
||||
# 读取文件内容
|
||||
try:
|
||||
with open(FILE_PATH, "rb") as f:
|
||||
f.seek(offset)
|
||||
file_data = f.read(request_size)
|
||||
|
||||
if len(file_data) == 0:
|
||||
print("错误:读取到空数据或超出文件范围")
|
||||
return
|
||||
except Exception as e:
|
||||
print(f"文件读取失败:{str(e)}")
|
||||
return
|
||||
|
||||
# 发送文件片段
|
||||
client.publish(reply_topic, file_data, qos=1)
|
||||
print(f"已发送 {len(file_data)} 字节到 {reply_topic}")
|
||||
|
||||
except json.JSONDecodeError:
|
||||
print("错误:无效的JSON格式")
|
||||
except Exception as e:
|
||||
print(f"处理消息时出错:{str(e)}")
|
||||
|
||||
def main():
|
||||
# 验证文件存在性
|
||||
if not os.path.exists(FILE_PATH):
|
||||
print(f"错误:文件 {FILE_PATH} 不存在")
|
||||
exit(1)
|
||||
|
||||
# 计算文件参数
|
||||
file_size = os.path.getsize(FILE_PATH)
|
||||
file_md5 = calculate_md5(FILE_PATH)
|
||||
|
||||
# 创建MQTT客户端
|
||||
client = mqtt.Client(userdata={
|
||||
"file_size": file_size,
|
||||
"fw_version": VERSION,
|
||||
"file_id": FILE_ID,
|
||||
"file_md5": file_md5
|
||||
})
|
||||
|
||||
# 设置回调函数
|
||||
client.on_connect = on_connect
|
||||
client.on_message = on_message
|
||||
|
||||
try:
|
||||
client.username_pw_set("ch32v208", "xiuosiot") # 取消注释并填写凭证
|
||||
client.connect(MQTT_BROKER, MQTT_PORT, 60)
|
||||
client.loop_forever()
|
||||
except KeyboardInterrupt:
|
||||
print("\n程序已终止")
|
||||
except Exception as e:
|
||||
print(f"连接错误:{str(e)}")
|
||||
exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,127 @@
|
|||
import paho.mqtt.client as mqtt
|
||||
import json
|
||||
import os
|
||||
import hashlib
|
||||
|
||||
# 配置参数(根据实际情况修改)
|
||||
MQTT_BROKER = "47.115.50.232" # MQTT代理地址
|
||||
MQTT_PORT = 1883 # 端口
|
||||
FILE_PATH = "XiZi-ch32v208rbt6-app.bin" # 要发送的固件文件路径
|
||||
CLIENT_ID = "D001" # 设备客户端ID
|
||||
VERSION = "001.000.002" # 新固件版本号
|
||||
FILE_ID = 1 # 文件标识符
|
||||
|
||||
def calculate_md5(file_path):
|
||||
""" 计算文件的MD5哈希值 """
|
||||
hash_md5 = hashlib.md5()
|
||||
with open(file_path, "rb") as f:
|
||||
for chunk in iter(lambda: f.read(4096), b""):
|
||||
hash_md5.update(chunk)
|
||||
return hash_md5.hexdigest()
|
||||
|
||||
def compact_json(payload: dict) -> str:
|
||||
"""生成无空格/换行的紧凑JSON字符串"""
|
||||
return json.dumps(payload, separators=(',', ':'))
|
||||
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
""" 连接回调函数 """
|
||||
if rc == 0:
|
||||
print("连接成功!")
|
||||
# 订阅文件请求主题
|
||||
client.subscribe("xiuosiot/ota/files")
|
||||
|
||||
# 发送初始更新信息
|
||||
init_payload = {
|
||||
"fileSize": userdata["file_size"],
|
||||
"version": userdata["fw_version"],
|
||||
"fileId": userdata["file_id"],
|
||||
"md5": userdata["file_md5"]
|
||||
}
|
||||
client.publish(
|
||||
topic=f"ota/{CLIENT_ID}/update",
|
||||
payload=compact_json(init_payload),
|
||||
qos=1
|
||||
)
|
||||
print(f"已发送初始化消息到 ota/{CLIENT_ID}/update")
|
||||
|
||||
else:
|
||||
print(f"连接失败,错误码:{rc}")
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
""" 消息到达回调函数 """
|
||||
try:
|
||||
payload = json.loads(msg.payload.decode())
|
||||
print("收到文件请求:", payload)
|
||||
|
||||
# 验证必要字段
|
||||
required_fields = ["clientId", "fileId", "fileOffset", "size"]
|
||||
if not all(field in payload for field in required_fields):
|
||||
print("错误:缺少必要字段")
|
||||
return
|
||||
|
||||
# 验证客户端ID
|
||||
if payload["clientId"] != CLIENT_ID:
|
||||
print(f"忽略非目标客户端请求:{payload['clientId']}")
|
||||
return
|
||||
|
||||
# 提取请求参数
|
||||
offset = payload["fileOffset"]
|
||||
request_size = payload["size"]
|
||||
reply_topic = f"ota/{CLIENT_ID}/files"
|
||||
|
||||
# 读取文件内容
|
||||
try:
|
||||
with open(FILE_PATH, "rb") as f:
|
||||
f.seek(offset)
|
||||
file_data = f.read(request_size)
|
||||
|
||||
if len(file_data) == 0:
|
||||
print("错误:读取到空数据或超出文件范围")
|
||||
return
|
||||
except Exception as e:
|
||||
print(f"文件读取失败:{str(e)}")
|
||||
return
|
||||
|
||||
# 发送文件片段
|
||||
#client.publish(reply_topic, file_data, qos=1)
|
||||
#print(f"已发送 {len(file_data)} 字节到 {reply_topic}")
|
||||
|
||||
except json.JSONDecodeError:
|
||||
print("错误:无效的JSON格式")
|
||||
except Exception as e:
|
||||
print(f"处理消息时出错:{str(e)}")
|
||||
|
||||
def main():
|
||||
# 验证文件存在性
|
||||
if not os.path.exists(FILE_PATH):
|
||||
print(f"错误:文件 {FILE_PATH} 不存在")
|
||||
exit(1)
|
||||
|
||||
# 计算文件参数
|
||||
file_size = os.path.getsize(FILE_PATH)
|
||||
file_md5 = calculate_md5(FILE_PATH)
|
||||
|
||||
# 创建MQTT客户端
|
||||
client = mqtt.Client(userdata={
|
||||
"file_size": file_size,
|
||||
"fw_version": VERSION,
|
||||
"file_id": FILE_ID,
|
||||
"file_md5": file_md5
|
||||
})
|
||||
|
||||
# 设置回调函数
|
||||
client.on_connect = on_connect
|
||||
client.on_message = on_message
|
||||
|
||||
try:
|
||||
client.username_pw_set("ch32v208", "xiuosiot") # 取消注释并填写凭证
|
||||
client.connect(MQTT_BROKER, MQTT_PORT, 60)
|
||||
client.loop_forever()
|
||||
except KeyboardInterrupt:
|
||||
print("\n程序已终止")
|
||||
except Exception as e:
|
||||
print(f"连接错误:{str(e)}")
|
||||
exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -221,7 +221,7 @@ static int SerialGetChar(struct SerialHardwareDevice *serial_dev) {
|
|||
if (RESET != USART_GetFlagStatus((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base, USART_FLAG_RXNE)) {
|
||||
ch = USART_ReceiveData((USART_TypeDef *)serial_cfg->hw_cfg.serial_register_base) & 0xff;
|
||||
}
|
||||
#ifdef BSP_USING_LTE
|
||||
#ifdef LTE_TEST
|
||||
#define TRANSPARENT_TRANSMISSION_MODE 0 // 数据透传模式
|
||||
#define COMMAND_LINE_MODE 1 // 命令行模式
|
||||
/* lte模式下,实现DBG串口和MAIN串口的数据转发 */
|
||||
|
|
|
@ -660,8 +660,10 @@ void *x_malloc(x_size_t size)
|
|||
KPrintf("dynamic_buddy_end:%d\n", ByteManager.dynamic_buddy_manager.dynamic_buddy_end);
|
||||
KPrintf("dynamic_buddy_start:%d\n", ByteManager.dynamic_buddy_manager.dynamic_buddy_start);
|
||||
KPrintf("active_memory:%d\n", ByteManager.dynamic_buddy_manager.active_memory);
|
||||
#ifdef TOOL_SHELL
|
||||
extern int ShowTask();
|
||||
ShowTask();
|
||||
#endif
|
||||
return NONE;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -256,8 +256,10 @@ KPrintf("%s %d\n", __func__, __LINE__);
|
|||
#endif
|
||||
|
||||
KPrintf("%s %d\n", __func__, __LINE__);
|
||||
#ifdef TOOL_SHELL
|
||||
extern long ShowTask(void);
|
||||
ShowTask();
|
||||
#endif
|
||||
StartupOsAssign();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -444,6 +444,27 @@ static uint32 SerialDevOpen(void *dev)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
serial_dev->haldev.dev_sem = KSemaphoreCreate(0);
|
||||
if (serial_dev->haldev.dev_sem < 0)
|
||||
{
|
||||
KPrintf("SerialDevOpen create sem failed .\n");
|
||||
|
||||
if (serial_dev->serial_fifo.serial_rx->serial_rx_buffer)
|
||||
{
|
||||
x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
}
|
||||
if (serial_dev->serial_fifo.serial_rx)
|
||||
{
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
}
|
||||
if (serial_dev->serial_fifo.serial_tx)
|
||||
{
|
||||
x_free(serial_dev->serial_fifo.serial_tx);
|
||||
}
|
||||
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (NONE == serial_dev->serial_fifo.serial_rx)
|
||||
{
|
||||
if (SIGN_OPER_INT_RX & serial_dev_param->serial_set_mode)
|
||||
|
@ -596,27 +617,6 @@ static uint32 SerialDevOpen(void *dev)
|
|||
#endif
|
||||
}
|
||||
|
||||
serial_dev->haldev.dev_sem = KSemaphoreCreate(0);
|
||||
if (serial_dev->haldev.dev_sem < 0)
|
||||
{
|
||||
KPrintf("SerialDevOpen create sem failed .\n");
|
||||
|
||||
if (serial_dev->serial_fifo.serial_rx->serial_rx_buffer)
|
||||
{
|
||||
x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
}
|
||||
if (serial_dev->serial_fifo.serial_rx)
|
||||
{
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
}
|
||||
if (serial_dev->serial_fifo.serial_tx)
|
||||
{
|
||||
x_free(serial_dev->serial_fifo.serial_tx);
|
||||
}
|
||||
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
return EOK;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#! /bin/env sh
|
||||
export CROSS_COMPILE=/home/syg/data/ch32v208/xpack-riscv-none-elf-gcc-11.3.0-1/bin/riscv-none-elf-
|
||||
make BOARD=ch32v208rbt6 distclean
|
||||
make BOARD=ch32v208rbt6 menuconfig
|
||||
make BOARD=ch32v208rbt6
|
||||
|
|
@ -16,7 +16,6 @@ menu "OTA function"
|
|||
bool "Config as application."
|
||||
endchoice
|
||||
|
||||
if MCUBOOT_APPLICATION
|
||||
choice
|
||||
prompt "The way of OTA firmware upgrade."
|
||||
default OTA_BY_PLATFORM
|
||||
|
@ -29,9 +28,10 @@ menu "OTA function"
|
|||
bool "Through the public network TCP server."
|
||||
select SUPPORT_CONNECTION_FRAMEWORK
|
||||
select CONNECTION_ADAPTER_4G
|
||||
endchoice
|
||||
endif
|
||||
|
||||
config OTA_BY_NONE
|
||||
bool "Not download firmware."
|
||||
endchoice
|
||||
|
||||
menu "Flash area address and size configuration."
|
||||
config CHIP_FLAH_BASE
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <transform.h>
|
||||
#include "shell.h"
|
||||
#include "boot_for_ota.h"
|
||||
#include "ymodem.h"
|
||||
#include "ota.h"
|
||||
|
@ -105,6 +104,7 @@ static const uint32_t crc32tab[] = {
|
|||
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||
};
|
||||
|
||||
__attribute__((aligned(8))) ota_info_t g_ota_info;
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: calculate_crc32
|
||||
|
@ -188,6 +188,19 @@ static status_t UpdateOTAFlag(ota_info_t *ptr)
|
|||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: GetOTAFlagStatus
|
||||
* 功能描述: 获取OTA Flag区域的Status信息
|
||||
* 形 参:
|
||||
* 返 回 值:
|
||||
*******************************************************************************/
|
||||
static uint32_t GetOTAFlagStatus(void)
|
||||
{
|
||||
ota_info_t ota_info;
|
||||
memset(&ota_info, 0, sizeof(ota_info_t));
|
||||
mcuboot.op_flash_read(FLAG_FLAH_ADDRESS, (void*)&ota_info, sizeof(ota_info_t));
|
||||
return ota_info.status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* 函 数 名: InitialVersion
|
||||
|
@ -198,19 +211,19 @@ static status_t UpdateOTAFlag(ota_info_t *ptr)
|
|||
static void InitialVersion(void)
|
||||
{
|
||||
int32_t size;
|
||||
ota_info_t ota_info;
|
||||
ota_info_t *p_ota_info = &g_ota_info;
|
||||
|
||||
memset(&ota_info, 0, sizeof(ota_info_t));
|
||||
memset(p_ota_info, 0, sizeof(ota_info_t));
|
||||
size = mcuboot.download_by_serial(XIUOS_FLAH_ADDRESS);
|
||||
if(size > 0)
|
||||
{
|
||||
ota_info.os.size = size;
|
||||
ota_info.os.crc32 = calculate_crc32(XIUOS_FLAH_ADDRESS, size);
|
||||
p_ota_info->os.size = size;
|
||||
p_ota_info->os.crc32 = calculate_crc32(XIUOS_FLAH_ADDRESS, size);
|
||||
|
||||
strncpy(ota_info.os.version,"001.000.000",sizeof(ota_info.os.version));
|
||||
strncpy(ota_info.os.description, "The initial firmware.", sizeof(ota_info.os.description));
|
||||
strncpy(p_ota_info->os.version,"001.000.000",sizeof(p_ota_info->os.version));
|
||||
strncpy(p_ota_info->os.description, "The initial firmware.", sizeof(p_ota_info->os.description));
|
||||
|
||||
UpdateOTAFlag(&ota_info);
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,6 +450,12 @@ static void Update(void)
|
|||
/*进行新版本的升级*/
|
||||
else
|
||||
{
|
||||
if(XIUOS_FLAH_ADDRESS == DOWN_FLAH_ADDRESS)
|
||||
{
|
||||
mcuboot.flash_deinit();
|
||||
return;
|
||||
}
|
||||
|
||||
if(UpdateNewApplication() == true) /*如果实际发生了flash搬移,操作完成后再重启一次*/
|
||||
{
|
||||
mcuboot.flash_deinit();
|
||||
|
@ -459,21 +478,30 @@ static void Update(void)
|
|||
*******************************************************************************/
|
||||
static void BootLoaderJumpApp(void)
|
||||
{
|
||||
ota_info_t ota_info;
|
||||
ota_info_t *p_ota_info = &g_ota_info;
|
||||
|
||||
mcuboot.flash_init();
|
||||
memset(&ota_info, 0, sizeof(ota_info_t));
|
||||
mcuboot.op_flash_read(FLAG_FLAH_ADDRESS, (void*)&ota_info, sizeof(ota_info_t));
|
||||
memset(p_ota_info, 0, sizeof(ota_info_t));
|
||||
mcuboot.op_flash_read(FLAG_FLAH_ADDRESS, (void*)p_ota_info, sizeof(ota_info_t));
|
||||
|
||||
if(ota_info.lastjumpflag == JUMP_FAILED_FLAG)
|
||||
if(p_ota_info->lastjumpflag == JUMP_FAILED_FLAG)
|
||||
{
|
||||
if(XIUOS_FLAH_ADDRESS == DOWN_FLAH_ADDRESS)
|
||||
{
|
||||
mcuboot.print_string("\r\n------Jump to app partition failed, retry download!------\r\n");
|
||||
p_ota_info->status = OTA_STATUS_BOOT_DOWNLOAD;
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
mcuboot.print_string("\r\n------Jump to app partition failed,start version rollback!------\r\n");
|
||||
BackupVersion();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ota_info.lastjumpflag = JUMP_FAILED_FLAG;
|
||||
UpdateOTAFlag(&ota_info);
|
||||
p_ota_info->lastjumpflag = JUMP_FAILED_FLAG;
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
}
|
||||
mcuboot.flash_deinit();
|
||||
mcuboot.op_jump();
|
||||
|
@ -883,18 +911,21 @@ static void mqttCloudInteraction(void* parameter)
|
|||
int datalen;
|
||||
int ret = 0;
|
||||
int freecnt = 0;
|
||||
ota_info_t ota_info;
|
||||
ota_info_t *p_ota_info = &g_ota_info;
|
||||
uint32_t heart_time = 0;
|
||||
uint32_t flashdestination = DOWN_FLAH_ADDRESS;
|
||||
uint8_t topicdatabuff[2][64];
|
||||
char *ptr1, *ptr2;
|
||||
uint16_t payloadLen;
|
||||
|
||||
KPrintf("%s enter\n", __func__);
|
||||
mcuboot.flash_init();
|
||||
memset(&ota_info, 0, sizeof(ota_info_t));
|
||||
mcuboot.op_flash_read(FLAG_FLAH_ADDRESS, (void*)&ota_info, sizeof(ota_info_t));
|
||||
ota_info.status = OTA_STATUS_DOWNLOADING;
|
||||
UpdateOTAFlag(&ota_info);
|
||||
memset(p_ota_info, 0, sizeof(ota_info_t));
|
||||
mcuboot.op_flash_read(FLAG_FLAH_ADDRESS, (void*)p_ota_info, sizeof(ota_info_t));
|
||||
#ifndef MCUBOOT_BOOTLOADER
|
||||
p_ota_info->status = OTA_STATUS_DOWNLOADING;
|
||||
#endif
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
memset(topicdatabuff,0,sizeof(topicdatabuff));
|
||||
sprintf(topicdatabuff[0],"ota/%s/update",CLIENTID);
|
||||
sprintf(topicdatabuff[1],"ota/%s/files",CLIENTID);
|
||||
|
@ -943,6 +974,7 @@ reconnect:
|
|||
}
|
||||
else if(MqttRxbuf[0] == 0x30)
|
||||
{
|
||||
KPrintf("recv datalen %d \n", datalen);
|
||||
freecnt = 0;
|
||||
payloadLen = MQTT_DealPublishData(MqttRxbuf, datalen);
|
||||
|
||||
|
@ -954,28 +986,45 @@ reconnect:
|
|||
if(sscanf(ptr2,"{\"fileSize\":%d,\"version\":\"%11s\",\"fileId\":%d,\"md5\"",&platform_ota.size,platform_ota.version,&platform_ota.streamId)==3)
|
||||
{
|
||||
KPrintf("OTA firmware information:file size is %d,file id is %d,file version is %s!\r\n",platform_ota.size,platform_ota.streamId,platform_ota.version);
|
||||
KPrintf("------Start the firmware file transfer!------\r\n");
|
||||
KPrintf("---------------------------------------------\r\n");
|
||||
#ifndef MCUBOOT_BOOTLOADER
|
||||
if(XIUOS_FLAH_ADDRESS == DOWN_FLAH_ADDRESS)
|
||||
{
|
||||
if (strcmp(platform_ota.version, p_ota_info->os.version) == 0) {
|
||||
KPrintf("current version is the latest version and does not upgrade\n");
|
||||
MdelayKTask(2000);
|
||||
continue;
|
||||
}
|
||||
KPrintf("mqttCloudInteraction write OTA flag and reboot\n");
|
||||
p_ota_info->status = OTA_STATUS_BOOT_DOWNLOAD;
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
MQTT_Disconnect();
|
||||
mcuboot.flash_deinit();
|
||||
mcuboot.op_reset();
|
||||
}
|
||||
#endif
|
||||
if(platform_ota.size > APP_FLASH_SIZE)
|
||||
{
|
||||
KPrintf("File size is larger than partition size,the partition size is %dk.\n",APP_FLASH_SIZE/1024);
|
||||
ret = -1;
|
||||
ota_info.status = OTA_STATUS_ERROR;
|
||||
memset(ota_info.error_message,0,sizeof(ota_info.error_message));
|
||||
strncpy(ota_info.error_message, "File size is larger than partition size!",sizeof(ota_info.error_message));
|
||||
UpdateOTAFlag(&ota_info);
|
||||
p_ota_info->status = OTA_STATUS_ERROR;
|
||||
memset(p_ota_info->error_message,0,sizeof(p_ota_info->error_message));
|
||||
strncpy(p_ota_info->error_message, "File size is larger than partition size!",sizeof(p_ota_info->error_message));
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
break;
|
||||
}
|
||||
KPrintf("Start erase download partition\n");
|
||||
if(mcuboot.op_flash_erase(DOWN_FLAH_ADDRESS,platform_ota.size) != kStatus_Success)
|
||||
{
|
||||
KPrintf("Failed to erase download partition!\n");
|
||||
ret = -1;
|
||||
ota_info.status = OTA_STATUS_ERROR;
|
||||
memset(ota_info.error_message,0,sizeof(ota_info.error_message));
|
||||
strncpy(ota_info.error_message, "Failed to erase download partition!",sizeof(ota_info.error_message));
|
||||
UpdateOTAFlag(&ota_info);
|
||||
p_ota_info->status = OTA_STATUS_ERROR;
|
||||
memset(p_ota_info->error_message,0,sizeof(p_ota_info->error_message));
|
||||
strncpy(p_ota_info->error_message, "Failed to erase download partition!",sizeof(p_ota_info->error_message));
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
break;
|
||||
}
|
||||
KPrintf("------Start the firmware file transfer!------\r\n");
|
||||
KPrintf("---------------------------------------------\r\n");
|
||||
platform_ota.counter = (platform_ota.size%FRAME_LEN != 0)? (platform_ota.size/FRAME_LEN + 1):(platform_ota.size/FRAME_LEN);
|
||||
platform_ota.num = 1; //下载次数,初始值为1
|
||||
platform_ota.downlen = FRAME_LEN; //记录本次下载量
|
||||
|
@ -985,10 +1034,10 @@ reconnect:
|
|||
{
|
||||
KPrintf("Failed to get ota information!\n");
|
||||
ret = -1;
|
||||
ota_info.status = OTA_STATUS_ERROR;
|
||||
memset(ota_info.error_message,0,sizeof(ota_info.error_message));
|
||||
strncpy(ota_info.error_message, "Failed to get ota information!",sizeof(ota_info.error_message));
|
||||
UpdateOTAFlag(&ota_info);
|
||||
p_ota_info->status = OTA_STATUS_ERROR;
|
||||
memset(p_ota_info->error_message,0,sizeof(p_ota_info->error_message));
|
||||
strncpy(p_ota_info->error_message, "Failed to get ota information!",sizeof(p_ota_info->error_message));
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1002,10 +1051,10 @@ reconnect:
|
|||
{
|
||||
KPrintf("current frame[%d] flash failed.\n",platform_ota.num-1);
|
||||
ret = -1;
|
||||
ota_info.status = OTA_STATUS_ERROR;
|
||||
memset(ota_info.error_message,0,sizeof(ota_info.error_message));
|
||||
sprintf(ota_info.error_message,"current frame[%d] flash failed.",platform_ota.num-1);
|
||||
UpdateOTAFlag(&ota_info);
|
||||
p_ota_info->status = OTA_STATUS_ERROR;
|
||||
memset(p_ota_info->error_message,0,sizeof(p_ota_info->error_message));
|
||||
sprintf(p_ota_info->error_message,"current frame[%d] flash failed.",platform_ota.num-1);
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -1085,21 +1134,26 @@ reconnect:
|
|||
// 新版本固件接收完毕,写入描述信息
|
||||
if(0 == ret)
|
||||
{
|
||||
ota_info.down.size = platform_ota.size;
|
||||
ota_info.down.crc32 = calculate_crc32(DOWN_FLAH_ADDRESS, platform_ota.size);
|
||||
p_ota_info->down.size = platform_ota.size;
|
||||
p_ota_info->down.crc32 = calculate_crc32(DOWN_FLAH_ADDRESS, platform_ota.size);
|
||||
|
||||
memset(ota_info.down.version,0,sizeof(ota_info.down.version));
|
||||
strncpy(ota_info.down.version, platform_ota.version, sizeof(ota_info.down.version));
|
||||
memset(p_ota_info->down.version,0,sizeof(p_ota_info->down.version));
|
||||
strncpy(p_ota_info->down.version, platform_ota.version, sizeof(p_ota_info->down.version));
|
||||
|
||||
memset(ota_info.down.description,0,sizeof(ota_info.down.description));
|
||||
strncpy(ota_info.down.description, "MQTT OTA bin.",sizeof(ota_info.down.description));
|
||||
memset(p_ota_info->down.description,0,sizeof(p_ota_info->down.description));
|
||||
strncpy(p_ota_info->down.description, "MQTT OTA bin.",sizeof(p_ota_info->down.description));
|
||||
|
||||
ota_info.status = OTA_STATUS_READY;
|
||||
if(XIUOS_FLAH_ADDRESS == DOWN_FLAH_ADDRESS)
|
||||
{
|
||||
memcpy(&p_ota_info->os, &p_ota_info->down,sizeof(p_ota_info->os));
|
||||
}
|
||||
|
||||
memset(ota_info.error_message,0,sizeof(ota_info.error_message));
|
||||
strncpy(ota_info.error_message, "No error message!",sizeof(ota_info.error_message));
|
||||
p_ota_info->status = OTA_STATUS_READY;
|
||||
|
||||
UpdateOTAFlag(&ota_info);
|
||||
memset(p_ota_info->error_message,0,sizeof(p_ota_info->error_message));
|
||||
strncpy(p_ota_info->error_message, "No error message!",sizeof(p_ota_info->error_message));
|
||||
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
KPrintf("firmware file transfer successful,start reboot!\n");
|
||||
}
|
||||
else
|
||||
|
@ -1379,13 +1433,13 @@ int OtaTask(void)
|
|||
*******************************************************************************/
|
||||
void app_clear_jumpflag(void)
|
||||
{
|
||||
ota_info_t ota_info;
|
||||
ota_info_t *p_ota_info = &g_ota_info;
|
||||
mcuboot.flash_init();
|
||||
//跳转成功设置lastjumpflag为JUMP_SUCCESS_FLAG
|
||||
memset(&ota_info, 0, sizeof(ota_info_t));
|
||||
mcuboot.op_flash_read(FLAG_FLAH_ADDRESS, (void*)&ota_info, sizeof(ota_info_t));
|
||||
ota_info.lastjumpflag = JUMP_SUCCESS_FLAG;
|
||||
UpdateOTAFlag(&ota_info);
|
||||
memset(p_ota_info, 0, sizeof(ota_info_t));
|
||||
mcuboot.op_flash_read(FLAG_FLAH_ADDRESS, (void*)p_ota_info, sizeof(ota_info_t));
|
||||
p_ota_info->lastjumpflag = JUMP_SUCCESS_FLAG;
|
||||
UpdateOTAFlag(p_ota_info);
|
||||
mcuboot.flash_deinit();
|
||||
}
|
||||
|
||||
|
@ -1402,6 +1456,11 @@ void ota_entry(void)
|
|||
uint32_t ret;
|
||||
uint32_t timeout = 1000;
|
||||
|
||||
if(XIUOS_FLAH_ADDRESS == DOWN_FLAH_ADDRESS) {
|
||||
DISABLE_INTERRUPT();
|
||||
SysInitIsrManager();
|
||||
}
|
||||
|
||||
mcuboot.board_init();
|
||||
|
||||
mcuboot.print_string("Please press 'space' key into menu in 5s !!!\r\n");
|
||||
|
@ -1446,9 +1505,33 @@ void ota_entry(void)
|
|||
}
|
||||
//10s内不按下空格键默然进行升级,升级完成后跳转
|
||||
else
|
||||
{
|
||||
if(XIUOS_FLAH_ADDRESS == DOWN_FLAH_ADDRESS)
|
||||
{
|
||||
if(OTA_STATUS_BOOT_DOWNLOAD == GetOTAFlagStatus())
|
||||
{
|
||||
#ifdef BSP_USING_LTE
|
||||
mcuboot.print_string("ota_entry to InitHwLte\r\n");
|
||||
extern int InitHwLte(void);
|
||||
InitHwLte();
|
||||
#endif
|
||||
app_clear_jumpflag();
|
||||
|
||||
mcuboot.print_string("ota_entry to XiUOSStartup\r\n");
|
||||
extern int XiUOSStartup(void);
|
||||
XiUOSStartup();
|
||||
}
|
||||
else
|
||||
{
|
||||
Update();
|
||||
BootLoaderJumpApp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Update();
|
||||
BootLoaderJumpApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef enum {
|
|||
OTA_STATUS_DOWNLOADED, //固件下载完成
|
||||
OTA_STATUS_UPDATING, //正在进行OTA升级
|
||||
OTA_STATUS_BACKUP, //正在版本回退
|
||||
OTA_STATUS_BOOT_DOWNLOAD,//boot阶段下载固件
|
||||
OTA_STATUS_ERROR, //出现错误,升级失败
|
||||
} ota_status_t;
|
||||
|
||||
|
|