mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-05 21:31:57 +08:00
fix(ota): Fix OTA copy buffer is not align
Using globle macro "ROM_FLASH_BUF_DECLARE" to declare a block of buffer not "uint8_t".
This commit is contained in:
@ -4,6 +4,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#define ROM_FLASH_BUF_DECLARE(__name, __size) uint8_t __name[__size] __attribute__((aligned(4)))
|
||||||
|
|
||||||
typedef struct esp_spi_flash_chip {
|
typedef struct esp_spi_flash_chip {
|
||||||
uint32_t deviceId;
|
uint32_t deviceId;
|
||||||
uint32_t chip_size; // chip size in byte
|
uint32_t chip_size; // chip size in byte
|
||||||
|
@ -59,12 +59,12 @@ typedef union s_boot_param {
|
|||||||
uint8_t enhance_boot_flag : 1;
|
uint8_t enhance_boot_flag : 1;
|
||||||
} boot_base;
|
} boot_base;
|
||||||
|
|
||||||
uint8_t data[4096];
|
ROM_FLASH_BUF_DECLARE(__data, 32);
|
||||||
} boot_param_t;
|
} boot_param_t;
|
||||||
|
|
||||||
static const char *TAG = "partition_port";
|
static const char *TAG = "partition_port";
|
||||||
static uint32_t s_partition_offset;
|
static uint32_t s_partition_offset;
|
||||||
static uint8_t s_cache_buf[SPI_FLASH_SEC_SIZE];
|
static ROM_FLASH_BUF_DECLARE(s_cache_buf, SPI_FLASH_SEC_SIZE);
|
||||||
static sys_param_t s_sys_param;
|
static sys_param_t s_sys_param;
|
||||||
static boot_param_t s_boot_param;
|
static boot_param_t s_boot_param;
|
||||||
static esp_spi_flash_chip_t s_flash_chip = {
|
static esp_spi_flash_chip_t s_flash_chip = {
|
||||||
@ -96,6 +96,11 @@ static inline int spi_flash_read_data(uint32_t addr, void *buf, size_t n)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (addr & 3 || (uint32_t)buf & 3 || n & 3) {
|
||||||
|
ESP_LOGE(TAG, "flash read parameters is not align, value is %p %x %x", buf, n ,addr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "read buffer %p total %d from 0x%x", buf, n ,addr);
|
ESP_LOGD(TAG, "read buffer %p total %d from 0x%x", buf, n ,addr);
|
||||||
|
|
||||||
ret = SPI_read_data(&s_flash_chip, addr, buf, n);
|
ret = SPI_read_data(&s_flash_chip, addr, buf, n);
|
||||||
@ -107,6 +112,11 @@ static inline int spi_flash_write_data(uint32_t addr, const void *buf, uint32_t
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (addr & 3 || (uint32_t)buf & 3 || n & 3) {
|
||||||
|
ESP_LOGE(TAG, "flash write parameters is not align, value is %p %x %x", buf, n ,addr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "write buffer %p total %d to 0x%x", buf, n ,addr);
|
ESP_LOGD(TAG, "write buffer %p total %d to 0x%x", buf, n ,addr);
|
||||||
|
|
||||||
ret = SPIWrite(addr, (void *)buf, n);
|
ret = SPIWrite(addr, (void *)buf, n);
|
||||||
@ -182,7 +192,7 @@ static inline uint32_t esp_get_updated_partition_table_addr(void)
|
|||||||
static inline int spi_flash_write_data_safe(uint32_t addr, const void *buf, size_t n)
|
static inline int spi_flash_write_data_safe(uint32_t addr, const void *buf, size_t n)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
static uint8_t check_buf[SPI_FLASH_SEC_SIZE];
|
static ROM_FLASH_BUF_DECLARE(check_buf, SPI_FLASH_SEC_SIZE);
|
||||||
|
|
||||||
ret = spi_flash_erase(addr);
|
ret = spi_flash_erase(addr);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
Reference in New Issue
Block a user