Merge branch 'bugfix/do_not_mix_esp_partition_and_spi_flash_apis_v5.0' into 'release/v5.0'

partition: use esp_partition_munmap instead of spi_flash_munmap (v5.0)

See merge request espressif/esp-idf!21024
pull/10970/head
Ivan Grokhotkov 2022-12-02 19:29:49 +08:00
commit 85eff825a9
9 zmienionych plików z 37 dodań i 40 usunięć

Wyświetl plik

@ -49,11 +49,11 @@ static const char *TAG = "ota_test";
static void copy_app_partition(esp_ota_handle_t update_handle, const esp_partition_t *curr_app)
{
const void *partition_bin = NULL;
spi_flash_mmap_handle_t data_map;
esp_partition_mmap_handle_t data_map;
ESP_LOGI(TAG, "start the copy process");
TEST_ESP_OK(esp_partition_mmap(curr_app, 0, curr_app->size, SPI_FLASH_MMAP_DATA, &partition_bin, &data_map));
TEST_ESP_OK(esp_partition_mmap(curr_app, 0, curr_app->size, ESP_PARTITION_MMAP_DATA, &partition_bin, &data_map));
TEST_ESP_OK(esp_ota_write(update_handle, (const void *)partition_bin, curr_app->size));
spi_flash_munmap(data_map);
esp_partition_munmap(data_map);
ESP_LOGI(TAG, "finish the copy process");
}
@ -65,15 +65,15 @@ static void copy_app_partition(esp_ota_handle_t update_handle, const esp_partiti
static void copy_app_partition_with_offset(esp_ota_handle_t update_handle, const esp_partition_t *curr_app)
{
const void *partition_bin = NULL;
spi_flash_mmap_handle_t data_map;
esp_partition_mmap_handle_t data_map;
ESP_LOGI(TAG, "start the copy process");
uint32_t offset = 0, bytes_to_write = curr_app->size;
uint32_t write_bytes;
while (bytes_to_write > 0) {
write_bytes = (bytes_to_write > (4 * 1024)) ? (4 * 1024) : bytes_to_write;
TEST_ESP_OK(esp_partition_mmap(curr_app, offset, write_bytes, SPI_FLASH_MMAP_DATA, &partition_bin, &data_map));
TEST_ESP_OK(esp_partition_mmap(curr_app, offset, write_bytes, ESP_PARTITION_MMAP_DATA, &partition_bin, &data_map));
TEST_ESP_OK(esp_ota_write_with_offset(update_handle, (const void *)partition_bin, write_bytes, offset));
spi_flash_munmap(data_map);
esp_partition_munmap(data_map);
bytes_to_write -= write_bytes;
offset += write_bytes;
}
@ -90,11 +90,11 @@ static void copy_app_partition_with_offset(esp_ota_handle_t update_handle, const
static void copy_partition(const esp_partition_t *dst_partition, const esp_partition_t *src_partition)
{
const void *partition_bin = NULL;
spi_flash_mmap_handle_t data_map;
TEST_ESP_OK(esp_partition_mmap(src_partition, 0, src_partition->size, SPI_FLASH_MMAP_DATA, &partition_bin, &data_map));
esp_partition_mmap_handle_t data_map;
TEST_ESP_OK(esp_partition_mmap(src_partition, 0, src_partition->size, ESP_PARTITION_MMAP_DATA, &partition_bin, &data_map));
TEST_ESP_OK(esp_partition_erase_range(dst_partition, 0, dst_partition->size));
TEST_ESP_OK(esp_partition_write(dst_partition, 0, (const void *)partition_bin, dst_partition->size));
spi_flash_munmap(data_map);
esp_partition_munmap(data_map);
}
#endif

Wyświetl plik

@ -126,14 +126,14 @@ TEST_CASE("Spiram cache flush on write/read", "[spiram]")
char buf[512];
const void *out;
spi_flash_mmap_handle_t handle;
esp_partition_mmap(part, 0, 512, SPI_FLASH_MMAP_DATA, &out, &handle);
esp_partition_mmap_handle_t handle;
esp_partition_mmap(part, 0, 512, ESP_PARTITION_MMAP_DATA, &out, &handle);
for (int i=0; i<CYCLES; i++) {
esp_partition_write(part, 0, buf, 512);
esp_partition_read(part, 0, buf, 512);
vTaskDelay(1);
}
spi_flash_munmap(handle);
esp_partition_munmap(handle);
printf("Checked memory %d and %d times.\n", res[0], res[1]);

Wyświetl plik

@ -53,7 +53,7 @@ esp_err_t esp_partition_read(const esp_partition_t *partition,
return err;
}
memcpy(dst, buf, size);
spi_flash_munmap(handle);
esp_partition_munmap(handle);
return ESP_OK;
#else
return ESP_ERR_NOT_SUPPORTED;

Wyświetl plik

@ -6,7 +6,6 @@
#include <string.h>
#include "esp_attr.h"
#include "esp_partition.h"
#include "spi_flash_mmap.h"
#include "esp_flash_encrypt.h"
#include "sdkconfig.h"
#include "core_dump_checksum.h"
@ -645,7 +644,7 @@ esp_err_t esp_core_dump_write_elf(core_dump_write_config_t *write_cfg)
/* Below are the helper function to parse the core dump ELF stored in flash */
static esp_err_t elf_core_dump_image_mmap(spi_flash_mmap_handle_t* core_data_handle, const void **map_addr)
static esp_err_t elf_core_dump_image_mmap(esp_partition_mmap_handle_t* core_data_handle, const void **map_addr)
{
size_t out_size;
assert (core_data_handle);
@ -677,7 +676,7 @@ static esp_err_t elf_core_dump_image_mmap(spi_flash_mmap_handle_t* core_data_han
return ret;
}
/* map the full core dump parition, including the checksum. */
return esp_partition_mmap(core_part, 0, out_size, SPI_FLASH_MMAP_DATA,
return esp_partition_mmap(core_part, 0, out_size, ESP_PARTITION_MMAP_DATA,
map_addr, core_data_handle);
}
@ -708,7 +707,7 @@ esp_err_t esp_core_dump_get_summary(esp_core_dump_summary_t *summary)
elf_note *note;
const void *map_addr;
size_t consumed_note_sz;
spi_flash_mmap_handle_t core_data_handle;
esp_partition_mmap_handle_t core_data_handle;
if (!summary) {
return ESP_ERR_INVALID_ARG;
@ -766,7 +765,7 @@ esp_err_t esp_core_dump_get_summary(esp_core_dump_summary_t *summary)
}
}
}
spi_flash_munmap(core_data_handle);
esp_partition_munmap(core_data_handle);
return ESP_OK;
}

Wyświetl plik

@ -23,7 +23,7 @@
#include "test_mqtt_client_broker.h"
#include "test_mqtt_connection.h"
#include "esp_mac.h"
#include "spi_flash_mmap.h"
#include "esp_partition.h"
static void test_leak_setup(const char * file, long line)
{
@ -59,10 +59,10 @@ TEST_CASE("mqtt init and deinit", "[mqtt][leaks=0]")
static const char* this_bin_addr(void)
{
spi_flash_mmap_handle_t out_handle;
esp_partition_mmap_handle_t out_handle;
const void *binary_address;
const esp_partition_t* partition = esp_ota_get_running_partition();
esp_partition_mmap(partition, 0, partition->size, SPI_FLASH_MMAP_DATA, &binary_address, &out_handle);
esp_partition_mmap(partition, 0, partition->size, ESP_PARTITION_MMAP_DATA, &binary_address, &out_handle);
return binary_address;
}

Wyświetl plik

@ -17,7 +17,7 @@
#include "test_mqtt5_client_broker.h"
#include "test_mqtt_connection.h"
#include "esp_mac.h"
#include "spi_flash_mmap.h"
#include "esp_partition.h"
static esp_mqtt5_user_property_item_t user_property_arr[3] = {
{"board", "esp32"},
@ -89,10 +89,10 @@ TEST_CASE("mqtt5 init and deinit", "[mqtt5][leaks=0]")
static const char* this_bin_addr(void)
{
spi_flash_mmap_handle_t out_handle;
esp_partition_mmap_handle_t out_handle;
const void *binary_address;
const esp_partition_t* partition = esp_ota_get_running_partition();
esp_partition_mmap(partition, 0, partition->size, SPI_FLASH_MMAP_DATA, &binary_address, &out_handle);
esp_partition_mmap(partition, 0, partition->size, ESP_PARTITION_MMAP_DATA, &binary_address, &out_handle);
return binary_address;
}

Wyświetl plik

@ -434,16 +434,16 @@ TEST_CASE("munmap followed by mmap flushes cache", "[spi_flash][mmap]")
const esp_partition_t *p = get_test_data_partition();
const uint32_t* data;
spi_flash_mmap_handle_t handle;
const uint32_t *data;
esp_partition_mmap_handle_t handle;
TEST_ESP_OK( esp_partition_mmap(p, 0, SPI_FLASH_MMU_PAGE_SIZE,
SPI_FLASH_MMAP_DATA, (const void **) &data, &handle) );
ESP_PARTITION_MMAP_DATA, (const void **) &data, &handle) );
uint32_t buf[16];
memcpy(buf, data, sizeof(buf));
spi_flash_munmap(handle);
esp_partition_munmap(handle);
TEST_ESP_OK( esp_partition_mmap(p, SPI_FLASH_MMU_PAGE_SIZE, SPI_FLASH_MMU_PAGE_SIZE,
SPI_FLASH_MMAP_DATA, (const void **) &data, &handle) );
ESP_PARTITION_MMAP_DATA, (const void **) &data, &handle) );
TEST_ASSERT_NOT_EQUAL(0, memcmp(buf, data, sizeof(buf)));
}
@ -456,10 +456,10 @@ TEST_CASE("no stale data read post mmap and write partition", "[spi_flash][mmap]
const esp_partition_t *p = get_test_data_partition();
const uint32_t* data;
spi_flash_mmap_handle_t handle;
const uint32_t *data;
esp_partition_mmap_handle_t handle;
TEST_ESP_OK(esp_partition_mmap(p, 0, SPI_FLASH_MMU_PAGE_SIZE,
SPI_FLASH_MMAP_DATA, (const void **) &data, &handle) );
ESP_PARTITION_MMAP_DATA, (const void **) &data, &handle) );
memcpy(read_data, data, sizeof(read_data));
TEST_ESP_OK(esp_partition_erase_range(p, 0, SPI_FLASH_MMU_PAGE_SIZE));
/* not using esp_partition_write here, since the partition in not marked as "encrypted"
@ -468,7 +468,7 @@ TEST_CASE("no stale data read post mmap and write partition", "[spi_flash][mmap]
/* This should retrigger actual flash content read */
memcpy(read_data, data, sizeof(read_data));
spi_flash_munmap(handle);
esp_partition_munmap(handle);
TEST_ASSERT_EQUAL(0, memcmp(buf, read_data, sizeof(buf)));
}
#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2)

Wyświetl plik

@ -13,7 +13,6 @@
#include <string.h>
#include "esp_system.h"
#include "esp_partition.h"
#include "spi_flash_mmap.h"
#include "nvs_flash.h"
#include "esp_event.h"
#include "esp_netif.h"
@ -41,10 +40,10 @@ extern const uint8_t mqtt_eclipseprojects_io_pem_end[] asm("_binary_mqtt_eclip
//
static void send_binary(esp_mqtt_client_handle_t client)
{
spi_flash_mmap_handle_t out_handle;
esp_partition_mmap_handle_t out_handle;
const void *binary_address;
const esp_partition_t *partition = esp_ota_get_running_partition();
esp_partition_mmap(partition, 0, partition->size, SPI_FLASH_MMAP_DATA, &binary_address, &out_handle);
esp_partition_mmap(partition, 0, partition->size, ESP_PARTITION_MMAP_DATA, &binary_address, &out_handle);
// sending only the configured portion of the partition (if it's less than the partition size)
int binary_size = MIN(CONFIG_BROKER_BIN_SIZE_TO_SEND, partition->size);
int msg_id = esp_mqtt_client_publish(client, "/topic/binary", binary_address, binary_size, 0, 0);

Wyświetl plik

@ -8,7 +8,6 @@
#include <string.h>
#include <assert.h>
#include "esp_partition.h"
#include "spi_flash_mmap.h"
#include "esp_log.h"
static const char *TAG = "example";
@ -36,10 +35,10 @@ void app_main(void)
ESP_LOGI(TAG, "Written sample data to partition: %s", store_data);
const void *map_ptr;
spi_flash_mmap_handle_t map_handle;
esp_partition_mmap_handle_t map_handle;
// Map the partition to data memory
ESP_ERROR_CHECK(esp_partition_mmap(partition, 0, partition->size, SPI_FLASH_MMAP_DATA, &map_ptr, &map_handle));
ESP_ERROR_CHECK(esp_partition_mmap(partition, 0, partition->size, ESP_PARTITION_MMAP_DATA, &map_ptr, &map_handle));
ESP_LOGI(TAG, "Mapped partition to data memory address %p", map_ptr);
// Read back the written verification data using the mapped memory pointer
@ -51,7 +50,7 @@ void app_main(void)
ESP_LOGI(TAG, "Data matches");
// Unmap mapped memory
spi_flash_munmap(map_handle);
esp_partition_munmap(map_handle);
ESP_LOGI(TAG, "Unmapped partition from data memory");
ESP_LOGI(TAG, "Example end");