mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 16:48:35 -07:00
<:Nami2:939038794794020874>
This commit is contained in:
33
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/esp_targets.h
vendored
Normal file
33
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/esp_targets.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_loader.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t cmd;
|
||||
uint32_t usr;
|
||||
uint32_t usr1;
|
||||
uint32_t usr2;
|
||||
uint32_t w0;
|
||||
uint32_t mosi_dlen;
|
||||
uint32_t miso_dlen;
|
||||
} target_registers_t;
|
||||
|
||||
esp_loader_error_t loader_detect_chip(target_chip_t *target, const target_registers_t **regs);
|
||||
esp_loader_error_t loader_read_spi_config(target_chip_t target_chip, uint32_t *spi_config);
|
||||
bool encryption_in_begin_flash_cmd(target_chip_t target);
|
||||
28
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/md5_hash.h
vendored
Normal file
28
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/md5_hash.h
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* MD5 hash implementation and interface functions
|
||||
* Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
struct MD5Context {
|
||||
uint32_t buf[4];
|
||||
uint32_t bits[2];
|
||||
uint8_t in[64];
|
||||
};
|
||||
|
||||
void MD5Init(struct MD5Context *context);
|
||||
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len);
|
||||
void MD5Final(unsigned char digest[16], struct MD5Context *context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
230
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/protocol.h
vendored
Normal file
230
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/protocol.h
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
/* Copyright 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_loader.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define STATUS_FAILURE 1
|
||||
#define STATUS_SUCCESS 0
|
||||
|
||||
#define READ_DIRECTION 1
|
||||
#define WRITE_DIRECTION 0
|
||||
|
||||
#define MD5_SIZE 32
|
||||
|
||||
typedef enum __attribute__((packed))
|
||||
{
|
||||
FLASH_BEGIN = 0x02,
|
||||
FLASH_DATA = 0x03,
|
||||
FLASH_END = 0x04,
|
||||
MEM_BEGIN = 0x05,
|
||||
MEM_END = 0x06,
|
||||
MEM_DATA = 0x07,
|
||||
SYNC = 0x08,
|
||||
WRITE_REG = 0x09,
|
||||
READ_REG = 0x0a,
|
||||
|
||||
SPI_SET_PARAMS = 0x0b,
|
||||
SPI_ATTACH = 0x0d,
|
||||
CHANGE_BAUDRATE = 0x0f,
|
||||
FLASH_DEFL_BEGIN = 0x10,
|
||||
FLASH_DEFL_DATA = 0x11,
|
||||
FLASH_DEFL_END = 0x12,
|
||||
SPI_FLASH_MD5 = 0x13,
|
||||
} command_t;
|
||||
|
||||
typedef enum __attribute__((packed))
|
||||
{
|
||||
RESPONSE_OK = 0x00,
|
||||
INVALID_COMMAND = 0x05, // parameters or length field is invalid
|
||||
COMMAND_FAILED = 0x06, // Failed to act on received message
|
||||
INVALID_CRC = 0x07, // Invalid CRC in message
|
||||
FLASH_WRITE_ERR = 0x08, // After writing a block of data to flash, the ROM loader reads the value back and the 8-bit CRC is compared to the data read from flash. If they don't match, this error is returned.
|
||||
FLASH_READ_ERR = 0x09, // SPI read failed
|
||||
READ_LENGTH_ERR = 0x0a, // SPI read request length is too long
|
||||
DEFLATE_ERROR = 0x0b, // ESP32 compressed uploads only
|
||||
} error_code_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t direction;
|
||||
uint8_t command; // One of command_t
|
||||
uint16_t size;
|
||||
uint32_t checksum;
|
||||
} command_common_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t erase_size;
|
||||
uint32_t packet_count;
|
||||
uint32_t packet_size;
|
||||
uint32_t offset;
|
||||
uint32_t encrypted;
|
||||
} flash_begin_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t data_size;
|
||||
uint32_t sequence_number;
|
||||
uint32_t zero_0;
|
||||
uint32_t zero_1;
|
||||
} data_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t stay_in_loader;
|
||||
} flash_end_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t total_size;
|
||||
uint32_t blocks;
|
||||
uint32_t block_size;
|
||||
uint32_t offset;
|
||||
} mem_begin_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t stay_in_loader;
|
||||
uint32_t entry_point_address;
|
||||
} mem_end_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint8_t sync_sequence[36];
|
||||
} sync_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t address;
|
||||
uint32_t value;
|
||||
uint32_t mask;
|
||||
uint32_t delay_us;
|
||||
} write_reg_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t address;
|
||||
} read_reg_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t configuration;
|
||||
uint32_t zero; // ESP32 ROM only
|
||||
} spi_attach_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t new_baudrate;
|
||||
uint32_t old_baudrate;
|
||||
} change_baudrate_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t address;
|
||||
uint32_t size;
|
||||
uint32_t reserved_0;
|
||||
uint32_t reserved_1;
|
||||
} spi_flash_md5_command_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t direction;
|
||||
uint8_t command; // One of command_t
|
||||
uint16_t size;
|
||||
uint32_t value;
|
||||
} common_response_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t failed;
|
||||
uint8_t error;
|
||||
} response_status_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
common_response_t common;
|
||||
response_status_t status;
|
||||
} response_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
common_response_t common;
|
||||
uint8_t md5[MD5_SIZE]; // ROM only
|
||||
response_status_t status;
|
||||
} rom_md5_response_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
command_common_t common;
|
||||
uint32_t id;
|
||||
uint32_t total_size;
|
||||
uint32_t block_size;
|
||||
uint32_t sector_size;
|
||||
uint32_t page_size;
|
||||
uint32_t status_mask;
|
||||
} write_spi_command_t;
|
||||
|
||||
esp_loader_error_t loader_initialize_conn(esp_loader_connect_args_t *connect_args);
|
||||
|
||||
#ifdef SERIAL_FLASHER_INTERFACE_UART
|
||||
esp_loader_error_t loader_flash_begin_cmd(uint32_t offset, uint32_t erase_size, uint32_t block_size, uint32_t blocks_to_write, bool encryption);
|
||||
|
||||
esp_loader_error_t loader_flash_data_cmd(const uint8_t *data, uint32_t size);
|
||||
|
||||
esp_loader_error_t loader_flash_end_cmd(bool stay_in_loader);
|
||||
|
||||
esp_loader_error_t loader_sync_cmd(void);
|
||||
|
||||
esp_loader_error_t loader_spi_attach_cmd(uint32_t config);
|
||||
|
||||
esp_loader_error_t loader_md5_cmd(uint32_t address, uint32_t size, uint8_t *md5_out);
|
||||
|
||||
esp_loader_error_t loader_spi_parameters(uint32_t total_size);
|
||||
#endif /* SERIAL_FLASHER_INTERFACE_UART */
|
||||
|
||||
esp_loader_error_t loader_mem_begin_cmd(uint32_t offset, uint32_t size, uint32_t blocks_to_write, uint32_t block_size);
|
||||
|
||||
esp_loader_error_t loader_mem_data_cmd(const uint8_t *data, uint32_t size);
|
||||
|
||||
esp_loader_error_t loader_mem_end_cmd(uint32_t entrypoint);
|
||||
|
||||
esp_loader_error_t loader_write_reg_cmd(uint32_t address, uint32_t value, uint32_t mask, uint32_t delay_us);
|
||||
|
||||
esp_loader_error_t loader_read_reg_cmd(uint32_t address, uint32_t *reg);
|
||||
|
||||
esp_loader_error_t loader_change_baudrate_cmd(uint32_t baudrate);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
31
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/protocol_prv.h
vendored
Normal file
31
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/protocol_prv.h
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "esp_loader.h"
|
||||
#include "protocol.h"
|
||||
|
||||
void log_loader_internal_error(error_code_t error);
|
||||
|
||||
esp_loader_error_t send_cmd(const void *cmd_data, uint32_t size, uint32_t *reg_value);
|
||||
|
||||
esp_loader_error_t send_cmd_with_data(const void *cmd_data, size_t cmd_size,
|
||||
const void *data, size_t data_size);
|
||||
|
||||
esp_loader_error_t send_cmd_md5(const void *cmd_data, size_t cmd_size, uint8_t md5_out[MD5_SIZE]);
|
||||
28
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/slip.h
vendored
Normal file
28
applications/external/esp_flasher/lib/esp-serial-flasher/private_include/slip.h
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_loader.h"
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
esp_loader_error_t SLIP_receive_data(uint8_t *buff, size_t size);
|
||||
|
||||
esp_loader_error_t SLIP_receive_packet(uint8_t *buff, size_t size);
|
||||
|
||||
esp_loader_error_t SLIP_send(const uint8_t *data, size_t size);
|
||||
|
||||
esp_loader_error_t SLIP_send_delimiter(void);
|
||||
Reference in New Issue
Block a user