diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig index 0f73b9a99..fe069bec6 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig @@ -22,6 +22,7 @@ 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 @@ -193,14 +194,15 @@ CONFIG_TOOL_USING_OTA=y 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=0x0801c000 -CONFIG_BAKUP_FLAH_ADDRESS=0x0801c000 -CONFIG_DOWN_FLAH_ADDRESS=0x0801c000 +CONFIG_XIUOS_FLAH_ADDRESS=0x08030000 +CONFIG_BAKUP_FLAH_ADDRESS=0x08030000 +CONFIG_DOWN_FLAH_ADDRESS=0x08030000 CONFIG_FLAG_FLAH_ADDRESS=0x08077000 CONFIG_APP_FLASH_SIZE=0x00100000 CONFIG_OTA_RX_TIMEOUT=600 @@ -219,7 +221,7 @@ CONFIG_ADD_XIZI_FEATURES=y # 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_FRAMEWORK_DEBUG=y # CONFIG_CONNECTION_INDUSTRIAL_NETWORK is not set # CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS is not set # CONFIG_CONNECTION_INDUSTRIAL_WLAN is not set diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig_app b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig_app index 0f73b9a99..cf461813a 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig_app +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig_app @@ -22,6 +22,7 @@ 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 @@ -198,9 +199,9 @@ CONFIG_OTA_BY_PLATFORM=y # Flash area address and size configuration. # CONFIG_CHIP_FLAH_BASE=0x08000000 -CONFIG_XIUOS_FLAH_ADDRESS=0x0801c000 -CONFIG_BAKUP_FLAH_ADDRESS=0x0801c000 -CONFIG_DOWN_FLAH_ADDRESS=0x0801c000 +CONFIG_XIUOS_FLAH_ADDRESS=0x08030000 +CONFIG_BAKUP_FLAH_ADDRESS=0x08030000 +CONFIG_DOWN_FLAH_ADDRESS=0x08030000 CONFIG_FLAG_FLAH_ADDRESS=0x08077000 CONFIG_APP_FLASH_SIZE=0x00100000 CONFIG_OTA_RX_TIMEOUT=600 diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig_boot b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig_boot index da2c92c42..1257f41b5 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig_boot +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/.defconfig_boot @@ -169,16 +169,17 @@ CONFIG_FS_VFS_DEVFS=y CONFIG_TOOL_USING_OTA=y CONFIG_MCUBOOT_BOOTLOADER=y # CONFIG_MCUBOOT_APPLICATION is not set -# CONFIG_OTA_BY_PLATFORM 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=0x0801c000 -CONFIG_BAKUP_FLAH_ADDRESS=0x0801c000 -CONFIG_DOWN_FLAH_ADDRESS=0x0801c000 +CONFIG_XIUOS_FLAH_ADDRESS=0x08030000 +CONFIG_BAKUP_FLAH_ADDRESS=0x08030000 +CONFIG_DOWN_FLAH_ADDRESS=0x08030000 CONFIG_FLAG_FLAH_ADDRESS=0x08077000 CONFIG_APP_FLASH_SIZE=0x00100000 CONFIG_OTA_RX_TIMEOUT=600 diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/board.c b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/board.c index 4607c0f9d..76bf4c672 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/board.c +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/board.c @@ -72,12 +72,14 @@ void readRomConfiguration(void) { extern pmodule_cfg CFG; // 指向配置信息的指针 /* 从EEPROM中读取网络配置信息 */ - KPrintf("%s PAGE_WRITE_START_ADDR=%08x\n", __func__, PAGE_WRITE_START_ADDR); + KPrintf("%s PAGE_READ_START_ADDR=%08x\n", __func__, PAGE_WRITE_START_ADDR); CFG_READ(PAGE_WRITE_START_ADDR, Configbuf, MODULE_CFG_LEN); /* 如果存储在EEPROM中的网络配置信息无效,或者WCHNET还没有被主机配置过,通过默认配置信息初始化WCHNET */ if ((CFG->cfgFlag[0] != checkcode1) || (CFG->cfgFlag[1] != checkcode2)) { + KPrintf("%s PAGE_ERASE_START_ADDR=%08x\n", __func__, PAGE_WRITE_START_ADDR); CFG_ERASE(PAGE_WRITE_START_ADDR, FLASH_PAGE_SIZE); + KPrintf("%s PAGE_WRITE_START_ADDR=%08x\n", __func__, PAGE_WRITE_START_ADDR); CFG_WRITE(PAGE_WRITE_START_ADDR, (u8 *)&defaultConfiguration, MODULE_CFG_LEN); KPrintf("%s NVIC_SystemReset\n\n", __func__); NVIC_SystemReset(); // 复位ch32v208 diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/link_application.ld b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/link_application.ld index 8071e4897..1360a8058 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/link_application.ld +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/link_application.ld @@ -27,7 +27,7 @@ MEMORY FLASH-160K + RAM-32K */ /*FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 448K*/ - FLASH (rx) : ORIGIN = 0x00010000, LENGTH = 412K + FLASH (rx) : ORIGIN = 0x00030000, LENGTH = 284K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K } diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/link_bootloader.ld b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/link_bootloader.ld index 9758c9ff8..05872500f 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/link_bootloader.ld +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/link_bootloader.ld @@ -26,7 +26,8 @@ MEMORY FLASH-144K + RAM-48K FLASH-160K + RAM-32K */ - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K + /*FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K*/ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 192K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K } diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/common/ymodem.c b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/common/ymodem.c index fed17995b..a5faacc06 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/common/ymodem.c +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/common/ymodem.c @@ -21,6 +21,7 @@ #include "ymodem.h" #include "string.h" #include "flash_for_ota.h" +#include "boot_for_ota.h" uint8_t tab_1024[1024] ={0}; uint8_t FileName[FILE_NAME_LENGTH]; @@ -49,6 +50,6 @@ int32_t Ymodem_Receive(uint8_t *buf, const uint32_t addr) *******************************************************************************/ int32_t SerialDownload(const uint32_t addr) { - int32_t Size = 0; + int32_t Size = IMAGE_IAP_SIZE; return Size; } diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/include/boot_for_ota.h b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/include/boot_for_ota.h index 83724a265..aa4af07f7 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/include/boot_for_ota.h +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/include/boot_for_ota.h @@ -22,7 +22,7 @@ #define __BOOT_FOR_OTA_H__ #define IMAGE_IAP_START_ADD 0x08000000 -#define IMAGE_IAP_SIZE (64 * 1024) +#define IMAGE_IAP_SIZE (192 * 1024) #define IMAGE_A_START_ADD (IMAGE_IAP_START_ADD + IMAGE_IAP_SIZE) void mcuboot_bord_init(void); diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ota/boot_for_ota.c b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ota/boot_for_ota.c index 68d229a6e..303be7c37 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ota/boot_for_ota.c +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ota/boot_for_ota.c @@ -102,27 +102,14 @@ void mcuboot_bord_init(void) void mcuboot_reset(void) { - /* - __set_FAULTMASK(1); - NVIC_SystemReset();*/ + KPrintf("%s NVIC_SystemReset\n\n", __func__); + NVIC_SystemReset(); } void mcuboot_jump(void) { - KPrintf("boot jumpApp\n\n"); + KPrintf("%s jumpApp\n\n", __func__); jumpApp(); - /* - uint32_t addr = XIUOS_FLAH_ADDRESS; - - SCB->VTOR = addr; - asm volatile("LDR R0, %0" : : "m"(addr)); - asm volatile("LDR R0, [R0]"); - asm volatile("MOV SP, R0"); - - addr += 4; - asm volatile("LDR R0, %0" : : "m"(addr)); - asm volatile("LDR R0, [R0]"); - asm volatile("BX R0");*/ } void mcuboot_delay(uint32_t ms) diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ota/flash_for_ota.c b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ota/flash_for_ota.c index 25d69c17a..506108feb 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ota/flash_for_ota.c +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/ota/flash_for_ota.c @@ -75,11 +75,12 @@ void FLASH_DeInit(void) imageSize:要擦除的字节数 * 返 回 值: 如果函数执行成功,状态值为 kStatus_Success,否则状态值为其他错误码 *******************************************************************************/ +#ifdef MCUBOOT_BOOTLOADER 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); - + KPrintf("Flash_Erase start_addr=%08x imageSize=0x%x\n", start_addr, imageSize); FLASH_Unlock_Fast(); for(page_count = 0; page_count < pageNum; page_count++) @@ -91,7 +92,25 @@ status_t Flash_Erase(uint32_t start_addr, uint32_t imageSize) return (status_t)kStatus_Success; } +#else +status_t Flash_Erase(uint32_t start_addr, uint32_t imageSize) +{ +/* + uint32_t page_count; + uint32_t pageNum = (imageSize%FLASH_BLOCK_SIZE != 0)? (imageSize/FLASH_BLOCK_SIZE + 1):(imageSize/FLASH_BLOCK_SIZE); + KPrintf("Flash_Erase start_addr=%08x pageNum=0x%x\n", start_addr, imageSize); + FLASH_Unlock(); + for(page_count = 0; page_count < pageNum; page_count++) + { + FLASH_ErasePage(start_addr + (page_count * FLASH_BLOCK_SIZE)); + } + FLASH_Lock(); + KPrintf("Flash_Erase start_addr=%08x success\n", start_addr); +*/ + return (status_t)kStatus_Success; +} +#endif /******************************************************************************* * 函 数 名: Flash_Write * 功能描述: 写入W25QXX在指定地址开始写入指定长度的数据 @@ -101,12 +120,13 @@ status_t Flash_Erase(uint32_t start_addr, uint32_t imageSize) * 返 回 值: 如果函数执行成功,状态值为 kStatus_Success,否则状态值为其他错误码 * 注 释: 该函数带擦除操作 *******************************************************************************/ +#ifdef MCUBOOT_BOOTLOADER 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); - KPrintf("Flash_Write start_addr=%08x pBuffer=%p imageSize=0x%x\n", WriteAddr, pBuffer, NumByteToWrite); + KPrintf("Flash_Write start_addr=%08x pBuffer=%p NumByteToWrite=0x%x\n", WriteAddr, pBuffer, NumByteToWrite); FLASH_Unlock_Fast(); for(page_count = 0; page_count < pageNum; page_count++) { @@ -116,9 +136,24 @@ status_t Flash_Write(uint32_t WriteAddr, uint8_t *pBuffer, uint32_t NumByteToWri KPrintf("Flash_Write start_addr=%08x success\n", WriteAddr); return (status_t)kStatus_Success; - } +#else +status_t Flash_Write(uint32_t WriteAddr, uint8_t *pBuffer, uint32_t NumByteToWrite) +{ + uint32_t addr; + uint32_t *p_buff = (uint32_t *)pBuffer; + KPrintf("Flash_Write start_addr=%08x pBuffer=%p NumByteToWrite=0x%x\n", WriteAddr, pBuffer, NumByteToWrite); + FLASH_Unlock(); + for (addr = WriteAddr; addr < WriteAddr + NumByteToWrite; addr += 4, p_buff++) { + FLASH_ProgramWord(addr, *p_buff); + } + FLASH_Lock(); + KPrintf("Flash_Write start_addr=%08x success\n", WriteAddr); + + return (status_t)kStatus_Success; +} +#endif /******************************************************************************* * 函 数 名: Flash_Read * 功能描述: 读Flash内容 diff --git a/Ubiquitous/XiZi_IIoT/kernel/thread/init.c b/Ubiquitous/XiZi_IIoT/kernel/thread/init.c index 262424430..33769addc 100644 --- a/Ubiquitous/XiZi_IIoT/kernel/thread/init.c +++ b/Ubiquitous/XiZi_IIoT/kernel/thread/init.c @@ -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; } diff --git a/Ubiquitous/XiZi_IIoT/tool/bootloader/Kconfig b/Ubiquitous/XiZi_IIoT/tool/bootloader/Kconfig index 98ab6c804..45fe943b6 100644 --- a/Ubiquitous/XiZi_IIoT/tool/bootloader/Kconfig +++ b/Ubiquitous/XiZi_IIoT/tool/bootloader/Kconfig @@ -16,7 +16,7 @@ menu "OTA function" bool "Config as application." endchoice - if MCUBOOT_APPLICATION + #if MCUBOOT_APPLICATION choice prompt "The way of OTA firmware upgrade." default OTA_BY_PLATFORM @@ -29,9 +29,11 @@ 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 + #endif menu "Flash area address and size configuration." config CHIP_FLAH_BASE