forked from espressif/esp-idf
spi_flash: remove unnecessary src pointer alignment check in spi_flash_write
ROM SPIWrite routine can work with unaligned sources, so this check is unnecessary. Furthermore, it breaks nvs_set_str and nvs_get_blob when data pointer is unaligned. Also fix stray backslash in COUNTER_STOP macro
This commit is contained in:
@@ -39,7 +39,7 @@ static spi_flash_counters_t s_flash_stats;
|
|||||||
#define COUNTER_STOP(counter) \
|
#define COUNTER_STOP(counter) \
|
||||||
do{ \
|
do{ \
|
||||||
s_flash_stats.counter.count++; \
|
s_flash_stats.counter.count++; \
|
||||||
s_flash_stats.counter.time += (xthal_get_ccount() - ts_begin) / (XT_CLOCK_FREQ / 1000000); \\
|
s_flash_stats.counter.time += (xthal_get_ccount() - ts_begin) / (XT_CLOCK_FREQ / 1000000); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define COUNTER_ADD_BYTES(counter, size) \
|
#define COUNTER_ADD_BYTES(counter, size) \
|
||||||
@@ -126,10 +126,6 @@ esp_err_t IRAM_ATTR spi_flash_erase_range(uint32_t start_addr, uint32_t size)
|
|||||||
|
|
||||||
esp_err_t IRAM_ATTR spi_flash_write(size_t dest_addr, const void *src, size_t size)
|
esp_err_t IRAM_ATTR spi_flash_write(size_t dest_addr, const void *src, size_t size)
|
||||||
{
|
{
|
||||||
// TODO: replace this check with code which deals with unaligned sources
|
|
||||||
if (((ptrdiff_t) src) % 4 != 0) {
|
|
||||||
return ESP_ERR_INVALID_ARG;
|
|
||||||
}
|
|
||||||
// Destination alignment is also checked in ROM code, but we can give
|
// Destination alignment is also checked in ROM code, but we can give
|
||||||
// better error code here
|
// better error code here
|
||||||
// TODO: add handling of unaligned destinations
|
// TODO: add handling of unaligned destinations
|
||||||
|
@@ -74,7 +74,7 @@ esp_err_t spi_flash_erase_range(size_t start_addr, size_t size);
|
|||||||
/**
|
/**
|
||||||
* @brief Write data to Flash.
|
* @brief Write data to Flash.
|
||||||
*
|
*
|
||||||
* @note Both des_addr and src_addr have to be 4-byte aligned.
|
* @note Address in flash, dest, has to be 4-byte aligned.
|
||||||
* This is a temporary limitation which will be removed.
|
* This is a temporary limitation which will be removed.
|
||||||
*
|
*
|
||||||
* @param dest destination address in Flash
|
* @param dest destination address in Flash
|
||||||
@@ -88,7 +88,7 @@ esp_err_t spi_flash_write(size_t dest, const void *src, size_t size);
|
|||||||
/**
|
/**
|
||||||
* @brief Read data from Flash.
|
* @brief Read data from Flash.
|
||||||
*
|
*
|
||||||
* @note Both des_addr and src_addr have to be 4-byte aligned.
|
* @note Both src and dest have to be 4-byte aligned.
|
||||||
* This is a temporary limitation which will be removed.
|
* This is a temporary limitation which will be removed.
|
||||||
*
|
*
|
||||||
* @param src source address of the data in Flash.
|
* @param src source address of the data in Flash.
|
||||||
|
Reference in New Issue
Block a user