feat(ota): Add ota support
This commit is contained in:
parent
05b11494ad
commit
3e3e3b6e68
51
README.md
51
README.md
|
@ -177,8 +177,9 @@ Here, we use MDK for testing:
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
|
## Document
|
||||||
|
|
||||||
## Speed Strategy
|
### Speed Strategy
|
||||||
|
|
||||||
The maximum rate of esp8266 pure IO is about 2MHz.
|
The maximum rate of esp8266 pure IO is about 2MHz.
|
||||||
When you select max clock, we will take the following actions:
|
When you select max clock, we will take the following actions:
|
||||||
|
@ -190,7 +191,7 @@ When you select max clock, we will take the following actions:
|
||||||
> Note that the most significant speed constraint of this project is still the TCP connection speed.
|
> Note that the most significant speed constraint of this project is still the TCP connection speed.
|
||||||
|
|
||||||
|
|
||||||
## For OpenOCD user
|
### For OpenOCD user
|
||||||
|
|
||||||
This project was originally designed to run on Keil, but now you can also perform firmware flash on OpenOCD.
|
This project was originally designed to run on Keil, but now you can also perform firmware flash on OpenOCD.
|
||||||
|
|
||||||
|
@ -207,6 +208,52 @@ Note that if you want to use a 40MHz SPI acceleration, you need to specify the s
|
||||||
> Keil's timing handling is somewhat different from OpenOCD's. For example, OpenOCD lacks the SWD line reset sequence before reading the `IDCODE` registers.
|
> Keil's timing handling is somewhat different from OpenOCD's. For example, OpenOCD lacks the SWD line reset sequence before reading the `IDCODE` registers.
|
||||||
|
|
||||||
|
|
||||||
|
### System OTA
|
||||||
|
|
||||||
|
When this project is updated, you can update the firmware over the air.
|
||||||
|
|
||||||
|
Visit the following website for OTA operations: [online OTA](http://corsacota.surge.sh/?address=dap.local:3241)
|
||||||
|
|
||||||
|
|
||||||
|
For most ESP8266 devices, you don't need to care about flash size. However, improper setting of the flash size may cause the OTA to fail. In this case, you can change the flash size with `idf.py menuconfig`, or you can modify `sdkconfig`:
|
||||||
|
|
||||||
|
```
|
||||||
|
# Choose a flash size.
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
|
||||||
|
|
||||||
|
# Then set a flash size
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE="2MB"
|
||||||
|
```
|
||||||
|
|
||||||
|
If flash size is 2MB, the sdkconfig file might look like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE="2MB"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
For devices with 1MB flash size such as ESP8285, the following changes must be made:
|
||||||
|
|
||||||
|
```
|
||||||
|
CONFIG_PARTITION_TABLE_FILENAME="partitions_two_ota.1MB.csv"
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE_1MB=y
|
||||||
|
CONFIG_ESPTOOLPY_FLASHSIZE="1MB"
|
||||||
|
CONFIG_ESP8266_BOOT_COPY_APP=y
|
||||||
|
```
|
||||||
|
|
||||||
|
The flash size of the board can be checked with the esptool.py tool:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
esptool.py -p (PORT) flash_id
|
||||||
|
```
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
## Develop
|
## Develop
|
||||||
|
|
||||||
0. Check other branches to know the latest development progress.
|
0. Check other branches to know the latest development progress.
|
||||||
|
|
18
main/main.c
18
main/main.c
|
@ -17,6 +17,8 @@
|
||||||
#include "main/timer.h"
|
#include "main/timer.h"
|
||||||
#include "main/wifi_configuration.h"
|
#include "main/wifi_configuration.h"
|
||||||
|
|
||||||
|
#include "components/corsacOTA/src/corsacOTA.h"
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/event_groups.h"
|
#include "freertos/event_groups.h"
|
||||||
|
@ -207,6 +209,22 @@ void app_main()
|
||||||
#if (USE_MDNS == 1)
|
#if (USE_MDNS == 1)
|
||||||
mdns_setup();
|
mdns_setup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (USE_OTA == 1)
|
||||||
|
co_handle_t handle;
|
||||||
|
co_config_t config = {
|
||||||
|
.thread_name = "corsacOTA",
|
||||||
|
.stack_size = 3192,
|
||||||
|
.thread_prio = 8,
|
||||||
|
.listen_port = 3241,
|
||||||
|
.max_listen_num = 2,
|
||||||
|
.wait_timeout_sec = 60,
|
||||||
|
.wait_timeout_usec = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
corsacOTA_init(&handle, &config);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Specify the usbip server task
|
// Specify the usbip server task
|
||||||
#if (USE_KCP == 1)
|
#if (USE_KCP == 1)
|
||||||
xTaskCreate(kcp_server_task, "kcp_server", 4096, NULL, 7, NULL);
|
xTaskCreate(kcp_server_task, "kcp_server", 4096, NULL, 7, NULL);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
// Use the address "dap.local" to access the device
|
// Use the address "dap.local" to access the device
|
||||||
#define MDNS_HOSTNAME "dap"
|
#define MDNS_HOSTNAME "dap"
|
||||||
#define MDNS_INSTANCE "DAP mDNS"
|
#define MDNS_INSTANCE "DAP mDNS"
|
||||||
|
//
|
||||||
|
|
||||||
#define USE_STATIC_IP 1
|
#define USE_STATIC_IP 1
|
||||||
// If you don't want to specify the ip configuration, then ignore the following items.
|
// If you don't want to specify the ip configuration, then ignore the following items.
|
||||||
|
@ -26,9 +27,12 @@
|
||||||
#define DAP_IP_NETMASK 255, 255, 255, 0
|
#define DAP_IP_NETMASK 255, 255, 255, 0
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#define USE_OTA 1
|
||||||
|
|
||||||
|
|
||||||
#define USE_UART_BRIDGE 0
|
#define USE_UART_BRIDGE 0
|
||||||
#define UART_BRIDGE_PORT 1234
|
#define UART_BRIDGE_PORT 1234
|
||||||
|
//
|
||||||
|
|
||||||
#define USE_TCP_NETCONN 0
|
#define USE_TCP_NETCONN 0
|
||||||
|
|
||||||
|
|
|
@ -66,12 +66,12 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD_74880B=y
|
||||||
# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set
|
# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set
|
||||||
CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=74880
|
CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=74880
|
||||||
CONFIG_ESPTOOLPY_MONITOR_BAUD=74880
|
CONFIG_ESPTOOLPY_MONITOR_BAUD=74880
|
||||||
CONFIG_PARTITION_TABLE_SINGLE_APP=y
|
# CONFIG_PARTITION_TABLE_SINGLE_APP is not set
|
||||||
# CONFIG_PARTITION_TABLE_TWO_OTA is not set
|
CONFIG_PARTITION_TABLE_TWO_OTA=y
|
||||||
# CONFIG_PARTITION_TABLE_CUSTOM is not set
|
# CONFIG_PARTITION_TABLE_CUSTOM is not set
|
||||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||||
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||||
CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv"
|
CONFIG_PARTITION_TABLE_FILENAME="partitions_two_ota.csv"
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set
|
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set
|
||||||
CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y
|
CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y
|
||||||
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE is not set
|
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE is not set
|
||||||
|
|
Loading…
Reference in New Issue