AT+CUSTOTA=total_len,current_packet_len,offset,checksum
OK
MCU 收到 > 之后发送 data,当前数据写入到 FLASH 之后,打印 RECV OK,当接收到 total_len 所有数据之后,如果校验成功会打印 CUSTOTA OK,否则会打印 ERROR
total_len: 整个 bin 的大小
current_packet_len:当前包的大小
offset:当前包在 bin 中的偏移地址
checksum:当前包的 checksum
data:当前包的数据
NOTE:在当前的 demo 的 esp8266 的 app bin 文件烧录在 0x110000 的位置
/* UART Echo Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/uart.h"
#include "esp_spi_flash.h"
#include "string.h"
/**
* This is an example which echos any data it receives on UART1 back to the sender,
* with hardware flow control turned off. It does not use UART driver event queue.
*
* - Port: UART1
* - Receive (Rx) buffer: on
* - Transmit (Tx) buffer: off
* - Flow control: off
* - Event queue: off
* - Pin assignment: see defines below
*/
#define ECHO_TEST_TXD (GPIO_NUM_4)
#define ECHO_TEST_RXD (GPIO_NUM_5)
#define ECHO_TEST_RTS (UART_PIN_NO_CHANGE)
#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)
#define READ_BIN_MIN(A,B) ((A) < (B) ? (A):(B))
#define BUF_SIZE (1024)
#define BUF_SIZE_RECV (128)
#define BUF_SIZE_RECV_DELIMITER (1)
#define BUF_SIZE_RECV_RECV_OK (7)
static void echo_task()
{
/* Configure parameters of an UART driver,
* communication pins and install the driver */
uart_config_t uart_config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};
uart_param_config(UART_NU