ESP32_RTOS_SDK V1.1.0

- Main Page
- Modules
- Data Structures
- Files

- File List

upgrade.h
1 /*
2 * ESPRSSIF MIT License
3 *
4 * Copyright (c) 2015 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5 *
6 * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP32 only, in which case,
7 * it is free of charge, to any person obtaining a copy of this software and associated
8 * documentation files (the "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11 * to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or
14 * substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25 #ifndef __UPGRADE_H__
26 #define __UPGRADE_H__
27
28 #include "lwip/sockets.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
50 #define SPI_FLASH_SEC_SIZE 4096
51
59 typedef void (*upgrade_states_check_callback)(void * arg);
60
61 enum ota_error_id {
62 UPGRADE_OK,
63 UPGRADE_FLAG_ERROR = 10000,
64 NO_STATION_IP_ERROR = 10001,
65 UPGRADE_MEM_ERROR = 10002,
66 CREATE_SOCKET_ERROR = 10003,
67 SEND_QUEUE_ERROR = 10004,
68 SERVER_CONNECT_ERROR = 10005,
69 SEND_URL_ERROR = 10006,
70 HTTP_HEAD_ERROR = 10007,
71 DOWNLOAD_TIMEOUT_ERROR = 10008,
72 GET_BIN_LENGTH_ERROR = 10009,
73 ERASE_FLASH_ERROR = 10010,
74 RECV_DATA_ERROR = 10011,
75 BIN_MAGIC_ERROR = 10012,
76 USER_ID_CONFLICT_ERROR = 10013,
77 FLASH_ID_CONFLICT_ERROR = 10014,
78 CRC_CHECK_FAILED_ERROR = 10015,
79 };
80
81 enum {
82 NO_READY = 1,
83 TENTATIVE,
84 READY
85 };
86
87 struct remote_bin_info {
88 uint32 b_sumlen;
89 uint32 b_irom1len;
90 uint8 flash_id_num;
91 };
92
93 struct server_info {
94 struct sockaddr_in sockaddrin;
95 char *http_req;
96 };
97
98 struct upgrade_info {
99 struct server_info s_if;
101 bool upgrade_flag;
103 uint32 check_times;
104 upgrade_states_check_callback check_cb;
105 };
106
117 bool system_upgrade_start(struct upgrade_info *server);
118
129 bool system_upgrade_init(uint8 b_id, uint8 start_flash_id);
130
140 void system_upgrade_deinit(void);
141
149 enum ota_error_id system_upgrade_get_error_id(void);
150
159 uint8 upgrade_get_process_rate(void);
160
171 bool upgrade_get_remote_bin_info(struct server_info *s_if,struct remote_bin_info *rb_if);
172
181 #ifdef __cplusplus
182 }
183 #endif
184
185 #endif
ERASE_FLASH_ERROR
Definition: upgrade.h:73
upgrade_info::s_if
struct server_info s_if
Definition: upgrade.h:99
HTTP_HEAD_ERROR
Definition: upgrade.h:70
GET_BIN_LENGTH_ERROR
Definition: upgrade.h:72
SERVER_CONNECT_ERROR
Definition: upgrade.h:68
SEND_URL_ERROR
Definition: upgrade.h:69
upgrade_get_remote_bin_info
bool upgrade_get_remote_bin_info(struct server_info *s_if, struct remote_bin_info *rb_if)
get bin's sum length and lenth of irom1 part in remote server
UPGRADE_OK
Definition: upgrade.h:62
BIN_MAGIC_ERROR
Definition: upgrade.h:75
RECV_DATA_ERROR
Definition: upgrade.h:74
system_upgrade_deinit
void system_upgrade_deinit(void)
deinit upgrade progress
UPGRADE_MEM_ERROR
Definition: upgrade.h:65
upgrade_info::check_cb
upgrade_states_check_callback check_cb
Definition: upgrade.h:104
ota_error_id
ota_error_id
Definition: upgrade.h:61
upgrade_info::check_times
uint32 check_times
Definition: upgrade.h:103
system_upgrade_get_error_id
enum ota_error_id system_upgrade_get_error_id(void)
get error id of upgrade progress
server_info
Definition: upgrade.h:93
remote_bin_info::b_irom1len
uint32 b_irom1len
Definition: upgrade.h:89
READY
Definition: upgrade.h:84
server_info::http_req
char * http_req
Definition: upgrade.h:95
DOWNLOAD_TIMEOUT_ERROR
Definition: upgrade.h:71
USER_ID_CONFLICT_ERROR
Definition: upgrade.h:76
UPGRADE_FLAG_ERROR
Definition: upgrade.h:63
CRC_CHECK_FAILED_ERROR
Definition: upgrade.h:78
server_info::sockaddrin
struct sockaddr_in sockaddrin
Definition: upgrade.h:94
upgrade_info
Definition: upgrade.h:98
remote_bin_info::b_sumlen
uint32 b_sumlen
Definition: upgrade.h:88
TENTATIVE
Definition: upgrade.h:83
SEND_QUEUE_ERROR
Definition: upgrade.h:67
remote_bin_info::flash_id_num
uint8 flash_id_num
Definition: upgrade.h:90
NO_READY
Definition: upgrade.h:82
FLASH_ID_CONFLICT_ERROR
Definition: upgrade.h:77
NO_STATION_IP_ERROR
Definition: upgrade.h:64
upgrade_get_process_rate
uint8 upgrade_get_process_rate(void)
get download rate process
remote_bin_info
Definition: upgrade.h:87
system_upgrade_init
bool system_upgrade_init(uint8 b_id, uint8 start_flash_id)
init upgrade progress
upgrade_states_check_callback
void(* upgrade_states_check_callback)(void *arg)
upgrade check call function type
Definition: upgrade.h:59
upgrade_info::upgrade_flag
bool upgrade_flag
Definition: upgrade.h:101
system_upgrade_start
bool system_upgrade_start(struct upgrade_info *server)
start upgrade progress
CREATE_SOCKET_ERROR
Definition: upgrade.h:66