1. Summary
This article introduces the migration and implementation of a customer private OTA service process on ING918xx. Please refer to the Link for INGCHIPS OTA Service reference FOTA quick demo.
2. ING918xx OTA method
1. Download the new program (Application 2 in the following figure) to the free space of Flash.
2. Provide the starting address of the new program.
3. Restart, and the BootLoader will automatically move and complete the update.
3. Implementation
Create ota_private_service.c
3.1 Prepare the status structure
// 包含必须的头文件 #include <stdio.h> #include <stdint.h> #include <string.h> #include "ingsoc.h" #include "platform_api.h" #include "rom_tools.h" #include "eflash.h" #include "ota_service.h" |
// 创建状态记录信息结构体
#define PAGE_SIZE (8192)//static size for one flash page
typedef enum
{
OTA_SERVICE_DISABLED = 0,
OTA_SERVICE_START = (1 << 0),
OTA_SERVICE_END = (1 << 1)
} ota_service_flag_e;
typedef struct
{
ota_ver_t ota_ver;//place to save app version
ota_service_flag_e ota_service_flag;//start/end
// static data from controller
uint32_t ota_load_addr;//load address of new app
uint32_t ota_flash_base_addr;//flash address to save ota data
uint32_t ota_file_size;//total size of new app bin
// dynamic variables to hold downloading progess
uint32_t ota_curr_page_addr;
uint32_t ota_curr_page_size;
uint8_t page_buffer[PAGE_SIZE];
uint32_t ota_total_size;//size that has been program to flash
} ota_service_data_s;
ota_service_data_s ota_service_data =
{
.ota_service_flag = OTA_SERVICE_DISABLED,
.ota_ver = { .app = {.major = 0, .minor = 0, .patch = 0} },
.ota_curr_page_addr = 0,
.ota_total_size = 0
};
|
3.2 Create the initialization interface
Three information needed before download:
1.load addr:start address of new program
2.flash addr:base address for new program before restart
3.file size: size of the new program
|
Return is 0 when initialization failed.
3.3 Create data interface
Prepare the data interface for OTA:
|
|
|
3.4 Create restart interface
|
4. Details
The call process is as the following:
1.find the API in profile.c, and specify the handle(eg. HANDLE_OF_OTA_DATA)for OTA.
|
2.Host device start OTA cmd,and send the information (load_addr, flash_addr, file_size)
|
3.Host device send the data cmd to start OTA
|
4.Host device send reboot cmd to finish the OTA
|
5. Potential Issues
1.The download program does not add application layer check, which can be implemented by designer, such as CRC.
2.There is no data check function (read the downloaded program to the main device for comparative check). The read part can be implemented with memcpy and can be added according to the request.