diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/MDK-ARM/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/MDK-ARM/TencentOS_tiny.uvoptx
index 085943b7..649f287d 100644
--- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/MDK-ARM/TencentOS_tiny.uvoptx
+++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/MDK-ARM/TencentOS_tiny.uvoptx
@@ -145,7 +145,7 @@
0
ST-LINKIII-KEIL_SWO
- -U303030303030303030303031 -O10446 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL040000 -FP0($$Device:STM32L431RCTx$CMSIS\Flash\STM32L4xx_256.FLM)
+ -U51FF68064965575333151687 -O10446 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL07800 -FP0($$Device:STM32L431RCTx$CMSIS\Flash\STM32L4xx_256.FLM)
@@ -245,6 +245,38 @@
+
+ 6
+ 0
+ 65
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ ..\Src\main.c
+
+
+
+
+ 7
+ 0
+ 120
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ ..\..\..\..\..\..\components\ota\common\partition\ota_partition.c
+
+
+
@@ -310,7 +342,7 @@
1
- 1
+ 0
0
2
10000000
@@ -340,7 +372,7 @@
Application/User
- 0
+ 1
0
0
0
@@ -700,7 +732,7 @@
Hardware
- 0
+ 1
0
0
0
@@ -1196,7 +1228,7 @@
ota_common
- 0
+ 1
0
0
0
diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/MDK-ARM/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/MDK-ARM/TencentOS_tiny.uvprojx
index c4a3aaec..e87b353d 100644
--- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/MDK-ARM/TencentOS_tiny.uvprojx
+++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/MDK-ARM/TencentOS_tiny.uvprojx
@@ -10,14 +10,14 @@
TencentOS_tiny
0x4
ARM-ADS
- 5060750::V5.06 update 6 (build 750)::ARMCC
+ 5060750::V5.06 update 6 (build 750)::.\ARMCC
0
STM32L431RCTx
STMicroelectronics
- Keil.STM32L4xx_DFP.2.0.0
- http://www.keil.com/pack
+ Keil.STM32L4xx_DFP.2.4.0
+ https://www.keil.com/pack/
IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4")
@@ -185,6 +185,7 @@
0
2
0
+ 0
0
0
8
@@ -275,7 +276,7 @@
1
0x8000000
- 0x40000
+ 0x7800
1
@@ -351,7 +352,7 @@
0
0
0
- 0
+ 4
@@ -1034,4 +1035,19 @@
+
+
+
+ <Project Info>
+
+
+
+
+
+ 0
+ 1
+
+
+
+
diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/Src/main.c b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/Src/main.c
index 0e952e44..645f6e67 100644
--- a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/Src/main.c
+++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/ota/ota_bootloader_recovery/Src/main.c
@@ -38,6 +38,8 @@ extern ota_flash_prop_t stm32l4_norflash_onchip_prop_ota;
int main(void)
{
+ ota_err_t ret;
+
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
@@ -46,10 +48,10 @@ int main(void)
MX_USART2_UART_Init();
- uint32_t partition_addr = 0x08024800;
+ uint32_t partition_addr = 0x0803f800;
- if (ota_env_init(OTA_UPDATE_IN_POSITION, partition_addr, &stm32l4_norflash_onchip_drv_ota, &stm32l4_norflash_onchip_prop_ota) < 0) {
- printf("env init failed!\n");
+ if ((ret = ota_env_init(OTA_UPDATE_IN_POSITION, partition_addr, &stm32l4_norflash_onchip_drv_ota, &stm32l4_norflash_onchip_prop_ota)) != OTA_ERR_NONE) {
+ printf("env init failed!OTA errcode = %d\n", ret);
return -1;
}
diff --git a/components/ota/common/env/ota_env.c b/components/ota/common/env/ota_env.c
index 4fcfaaaa..666e6617 100644
--- a/components/ota/common/env/ota_env.c
+++ b/components/ota/common/env/ota_env.c
@@ -19,23 +19,25 @@
#include "ota_env.h"
#include "ota_partition.h"
-int ota_env_init(ota_updt_type_t updt_type, uint32_t partition_addr, ota_flash_drv_t *flash_drv, ota_flash_prop_t *flash_prop)
+ota_err_t ota_env_init(ota_updt_type_t updt_type, uint32_t partition_addr, ota_flash_drv_t *flash_drv, ota_flash_prop_t *flash_prop)
{
+ ota_err_t ret;
+
if (ota_flash_init(flash_drv, flash_prop) < 0) {
- return -1;
+ return OTA_ERR_FLASH_INIT_FAIL;
}
- if (ota_partition_load(updt_type, partition_addr) < 0) {
- return -1;
+ if ((ret = ota_partition_load(updt_type, partition_addr)) != OTA_ERR_NONE) {
+ return ret;
}
if (tos_kv_init(ota_partition_start(OTA_PARTITION_KV),
ota_partition_end(OTA_PARTITION_KV),
(kv_flash_drv_t *)flash_drv,
(kv_flash_prop_t *)flash_prop) != KV_ERR_NONE) {
- return -1;
+ return OTA_ERR_KV_FAIL;
}
- return 0;
+ return OTA_ERR_NONE;
}
diff --git a/components/ota/common/env/ota_env.h b/components/ota/common/env/ota_env.h
index 833e0eb8..0b03660c 100644
--- a/components/ota/common/env/ota_env.h
+++ b/components/ota/common/env/ota_env.h
@@ -21,8 +21,9 @@
#include "stdint.h"
#include "ota_flash.h"
#include "ota_partition.h"
+#include "ota_err.h"
-int ota_env_init(ota_updt_type_t updt_type, uint32_t partition_addr, ota_flash_drv_t *flash_drv, ota_flash_prop_t *flash_prop);
+ota_err_t ota_env_init(ota_updt_type_t updt_type, uint32_t partition_addr, ota_flash_drv_t *flash_drv, ota_flash_prop_t *flash_prop);
#endif /* _OTA_ENV_H_ */
diff --git a/components/ota/common/partition/ota_partition.c b/components/ota/common/partition/ota_partition.c
index 4fdfec1b..61a4def5 100644
--- a/components/ota/common/partition/ota_partition.c
+++ b/components/ota/common/partition/ota_partition.c
@@ -26,30 +26,31 @@ static int partitions_verify(ota_pt_t *pts, int n)
for (i = 0; i < n; ++i) {
if (pts[i].start >= pts[i].end) {
- return -1;
+ return OTA_ERR_PARTITION_ADDR_FAIL;
}
if (!ota_flash_size_is_aligned(pts[i].end - pts[i].start)) {
- return -1;
+ return OTA_ERR_PARTITION_NOT_ALIGN;
}
}
return 0;
}
-int ota_partition_load(ota_updt_type_t updt_type, uint32_t partition_addr)
+ota_err_t ota_partition_load(ota_updt_type_t updt_type, uint32_t partition_addr)
{
uint8_t crc = 0;
ota_pt_hdr_t hdr;
+ ota_err_t ret;
memset(&ctrl, 0, sizeof(ota_pt_ctrl_t));
if (ota_flash_read(partition_addr, &hdr, sizeof(ota_pt_hdr_t)) != 0) {
- return -1;
+ return OTA_ERR_PARTITION_READ_FAIL;
}
if (hdr.magic != OTA_PARTITION_MAGIC) {
- return -1;
+ return OTA_ERR_PARTITION_MAGIC_NOT_SAME;
}
ctrl.updt_type = updt_type;
@@ -59,33 +60,33 @@ int ota_partition_load(ota_updt_type_t updt_type, uint32_t partition_addr)
if (updt_type == OTA_UPDATE_IN_POSITION) {
if (ota_flash_read(partition_addr + sizeof(ota_pt_hdr_t), &IP_PTS, sizeof(ota_ip_pts_t)) != 0) {
- return -1;
+ return OTA_ERR_PARTITION_READ_FAIL;
}
- if (partitions_verify(IP_PTS_ARRAY, sizeof(IP_PTS) / sizeof(ota_pt_t)) != 0) {
- return -1;
+ if ((ret = partitions_verify(IP_PTS_ARRAY, sizeof(IP_PTS) / sizeof(ota_pt_t))) != OTA_ERR_NONE) {
+ return ret;
}
crc = partitions_crc(crc, IP_PTS_ARRAY, sizeof(IP_PTS) / sizeof(ota_pt_t));
} else if (updt_type == OTA_UPDATE_PING_PONG) {
if (ota_flash_read(partition_addr + sizeof(ota_pt_hdr_t), &PP_PTS, sizeof(ota_pp_pts_t)) != 0) {
- return -1;
+ return OTA_ERR_PARTITION_READ_FAIL;
}
if (partitions_verify(PP_PTS_ARRAY, sizeof(PP_PTS) / sizeof(ota_pt_t)) != 0) {
- return -1;
+ return ret;
}
crc = partitions_crc(crc, PP_PTS_ARRAY, sizeof(PP_PTS) / sizeof(ota_pt_t));
} else {
- return -1;
+ return OTA_ERR_UPDT_TYPE_UNKOWN;
}
if (crc != hdr.crc) {
- return -1;
+ return OTA_ERR_PARTITION_CRC_FAIL;
}
- return 0;
+ return OTA_ERR_NONE;
}
uint32_t ota_partition_start(ota_pt_type_t pt_type)
diff --git a/components/ota/common/partition/ota_partition.h b/components/ota/common/partition/ota_partition.h
index d5aebb63..b72b72b2 100644
--- a/components/ota/common/partition/ota_partition.h
+++ b/components/ota/common/partition/ota_partition.h
@@ -20,6 +20,7 @@
#include "crc8.h"
#include "ota_image.h"
+#include "ota_err.h"
#define OTA_PARTITION_INVALID (uint32_t)-1
@@ -128,7 +129,7 @@ typedef struct ota_partition_control_st {
ota_pts_t pts;
} ota_pt_ctrl_t;
-int ota_partition_load(ota_updt_type_t updt_type, uint32_t partition_addr);
+ota_err_t ota_partition_load(ota_updt_type_t updt_type, uint32_t partition_addr);
uint32_t ota_partition_start(ota_pt_type_t pt_type);
diff --git a/components/ota/recovery/include/ota_err.h b/components/ota/recovery/include/ota_err.h
new file mode 100644
index 00000000..572ddabe
--- /dev/null
+++ b/components/ota/recovery/include/ota_err.h
@@ -0,0 +1,38 @@
+/*----------------------------------------------------------------------------
+ * Tencent is pleased to support the open source community by making TencentOS
+ * available.
+ *
+ * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
+ * If you have downloaded a copy of the TencentOS binary from Tencent, please
+ * note that the TencentOS binary is licensed under the BSD 3-Clause License.
+ *
+ * If you have downloaded a copy of the TencentOS source code from Tencent,
+ * please note that TencentOS source code is licensed under the BSD 3-Clause
+ * License, except for the third-party components listed below which are
+ * subject to different license terms. Your integration of TencentOS into your
+ * own projects may require compliance with the BSD 3-Clause License, as well
+ * as the other licenses applicable to the third-party components included
+ * within TencentOS.
+ *---------------------------------------------------------------------------*/
+
+#ifndef _OTA_ERR_H_
+#define _OTA_ERR_H_
+
+typedef enum ota_err_en {
+ OTA_ERR_NONE = 0u,
+
+ OTA_ERR_FLASH_INIT_FAIL = 1u,
+
+ OTA_ERR_PARTITION_READ_FAIL = 2u,
+ OTA_ERR_PARTITION_MAGIC_NOT_SAME,
+ OTA_ERR_PARTITION_ADDR_FAIL,
+ OTA_ERR_PARTITION_NOT_ALIGN,
+ OTA_ERR_PARTITION_CRC_FAIL,
+
+ OTA_ERR_UPDT_TYPE_UNKOWN,
+
+ OTA_ERR_KV_FAIL
+} ota_err_t;
+
+#endif /* _OTA_ERR_H_ */
+