forked from xuos/xiuos
1.add an API of finding the first user task in xiuos task manage list; 2.add restart application after ota
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
# OTA README
|
||||
|
||||
xiuos当前的ota功能允许应用bin文件可以通过4G实现远程的bin文件更新(限制:1、bin文件存放在设备SD卡并且应用从SD卡启动;2、暂且支持4G实现;3、暂时只支持aiit终端)。
|
||||
xiuos当前的ota功能允许应用bin文件可以通过4G实现远程的bin文件更新(限制:1、bin文件存放在设备SD卡并且应用从SD卡启动;2、暂且支持4G实现;3、暂时只支持aiit终端;4、只支持xiuos内核)。
|
||||
|
||||
## 文件说明
|
||||
|
||||
| 名称 | 说明 |
|
||||
| -- | -- |
|
||||
| ota.c| 设备OTA代码 |
|
||||
| ota.c| xiuos设备OTA代码 |
|
||||
| ota_server.c | pc服务端的实例代码供参考 |
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <transform.h>
|
||||
#include <adapter.h>
|
||||
|
||||
extern int main(void);
|
||||
|
||||
struct ota_header_t
|
||||
{
|
||||
int16 frame_flag; ///< frame start flag 2 Bytes
|
||||
@@ -47,7 +49,8 @@ struct ota_data
|
||||
struct ota_frame_t frame;
|
||||
};
|
||||
|
||||
pthread_t ota_ktask;
|
||||
pthread_t ota_task;
|
||||
pthread_t restart_main;
|
||||
|
||||
/**
|
||||
* @description: CRC16 check
|
||||
@@ -117,6 +120,26 @@ static int CrcFileCheck(uint32 crc_check, unsigned long total_len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void RestartApplication(void)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
attr.schedparam.sched_priority = 10;
|
||||
attr.stacksize = 2048;
|
||||
|
||||
while(1)
|
||||
{
|
||||
unsigned long pid = PrivUserTaskSearch();
|
||||
if (pid > 0)
|
||||
{
|
||||
PrivTaskDelete(pid, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
PrivTaskCreate(&restart_main, &attr, (void *)main, NULL);
|
||||
}
|
||||
static int OtaDataRecv(struct Adapter* adapter)
|
||||
{
|
||||
struct ota_data recv_msg;
|
||||
@@ -172,6 +195,7 @@ try_again:
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
RestartApplication();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -233,6 +257,6 @@ void ApplicationOtaTaskInit(void)
|
||||
attr.schedparam.sched_priority = 10;
|
||||
attr.stacksize = 2048;
|
||||
|
||||
PrivTaskCreate(&ota_ktask, &attr, OtaKTaskEntry, NULL);
|
||||
PrivTaskCreate(&ota_task, &attr, OtaKTaskEntry, NULL);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user