add ota algorithm for device
1. effective "Differential Upgrade" patch algorithm with high compression rate 2. effective recovery algorithm support recovery firmware in blocks which has low memory consumption and wear-leveling strategies, especially suitable for embeded devices with low RAM. 3. add sample ota bootloader project, see: board\TencentOS_tiny_EVB_MX_Plus\KEIL\ota\ota_bootloader_recovery 4. add sample application project for download firmware through http, see: board\TencentOS_tiny_EVB_MX_Plus\KEIL\ota\ota_application_download_through_http 5. add sample application project for download firmware through qcloud explorer console, see: board\TencentOS_tiny_EVB_MX_Plus\KEIL\ota\ota_application_download_through_qcloud_iot_explorer 6. an OTA markdown document is pending
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#include "esp8266.h"
|
||||
#include "mcu_init.h"
|
||||
#include "sal_module_wrapper.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
#include "tos_ota_download.h"
|
||||
|
||||
extern ota_flash_drv_t stm32l4_norflash_onchip_drv_ota;
|
||||
extern ota_flash_prop_t stm32l4_norflash_onchip_prop_ota;
|
||||
|
||||
k_sem_t sem;
|
||||
|
||||
#define TASK1_STK_SIZE 512
|
||||
void user_task(void *arg);
|
||||
osThreadDef(user_task, osPriorityNormal, 1, TASK1_STK_SIZE);
|
||||
|
||||
#define TASK2_STK_SIZE 1024
|
||||
void ota_download_task(void *arg);
|
||||
osThreadDef(ota_download_task, osPriorityNormal, 1, TASK2_STK_SIZE);
|
||||
|
||||
void user_task(void *arg)
|
||||
{
|
||||
int iter = 0;
|
||||
|
||||
while (K_TRUE) {
|
||||
tos_task_delay(1000);
|
||||
|
||||
printf("do sth(v1.1)...\n");
|
||||
|
||||
if (++iter == 2) {
|
||||
printf("trigger ota download\n");
|
||||
tos_sem_post(&sem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ota_download_task(void *arg)
|
||||
{
|
||||
tos_sem_pend(&sem, TOS_TIME_FOREVER);
|
||||
|
||||
esp8266_sal_init(HAL_UART_PORT_0);
|
||||
esp8266_join_ap("SheldonDai", "srnr6x9xbhmb0");
|
||||
|
||||
uint32_t partition_addr = 0x08024800;
|
||||
|
||||
if (tos_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");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tos_ota_download_http("http://39.108.190.129:8000/patch.bin")) {
|
||||
printf("download successfully!\n");
|
||||
} else {
|
||||
printf("download failed!\n");
|
||||
}
|
||||
}
|
||||
|
||||
void application_entry(void *arg)
|
||||
{
|
||||
tos_sem_create(&sem, 0);
|
||||
|
||||
osThreadCreate(osThread(user_task), NULL); // Create task1
|
||||
osThreadCreate(osThread(ota_download_task), NULL); // Create task2
|
||||
}
|
||||
|
Reference in New Issue
Block a user