mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-14 14:06:54 +00:00
bootloader: Check all partitions fit inside configured flash size
This commit is contained in:
@@ -13,12 +13,14 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include "esp_flash_partitions.h"
|
#include "esp_flash_partitions.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
#include "rom/spi_flash.h"
|
||||||
|
|
||||||
static const char *TAG = "flash_parts";
|
static const char *TAG = "flash_parts";
|
||||||
|
|
||||||
esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
|
esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
|
||||||
{
|
{
|
||||||
int num_parts;
|
int num_parts;
|
||||||
|
uint32_t chip_size = g_rom_flashchip.chip_size;
|
||||||
*num_partitions = 0;
|
*num_partitions = 0;
|
||||||
|
|
||||||
for(num_parts = 0; num_parts < ESP_PARTITION_TABLE_MAX_ENTRIES; num_parts++) {
|
for(num_parts = 0; num_parts < ESP_PARTITION_TABLE_MAX_ENTRIES; num_parts++) {
|
||||||
@@ -39,6 +41,15 @@ esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition
|
|||||||
}
|
}
|
||||||
return ESP_ERR_INVALID_STATE;
|
return ESP_ERR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const esp_partition_pos_t *pos = &part->pos;
|
||||||
|
if (pos->offset > chip_size || pos->offset + pos->size > chip_size) {
|
||||||
|
if (log_errors) {
|
||||||
|
ESP_LOGE(TAG, "partition %d invalid - offset 0x%x size 0x%x exceeds flash chip size 0x%x",
|
||||||
|
num_parts, pos->offset, pos->size, chip_size);
|
||||||
|
}
|
||||||
|
return ESP_ERR_INVALID_SIZE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_errors) {
|
if (log_errors) {
|
||||||
|
Reference in New Issue
Block a user