Select one of the symbols to view example projects that use it.
 
Outline
#include <stdbool.h>
#include <esp_err.h>
#include "esp_flash_partitions.h"
#include "esp_app_format.h"
#include "esp_assert.h"
#define ESP_ERR_IMAGE_BASE
#define ESP_ERR_IMAGE_FLASH_FAIL
#define ESP_ERR_IMAGE_INVALID
#define ESP_IMAGE_HASH_LEN
esp_image_metadata_t
esp_image_load_mode_t
rtc_retain_mem_t
#define ESP_BOOTLOADER_RESERVE_RTC
#define ESP_BOOTLOADER_RESERVE_RTC
esp_image_verify(esp_image_load_mode_t, const esp_partition_pos_t *, esp_image_metadata_t *);
esp_image_get_metadata(const esp_partition_pos_t *, esp_image_metadata_t *);
bootloader_load_image(const esp_partition_pos_t *, esp_image_metadata_t *);
bootloader_load_image_no_verify(const esp_partition_pos_t *, esp_image_metadata_t *);
esp_image_verify_bootloader(uint32_t *);
esp_image_verify_bootloader_data(esp_image_metadata_t *);
esp_image_get_flash_size(esp_image_flash_size_t);
esp_image_flash_mapping_t
Files
ESP-IDF
components
app_trace
app_update
bootloader_support
bootloader_flash
include
private_include
src
bt
cmock
console
cxx
driver
efuse
esp_adc
esp_app_format
esp_bootloader_format
esp_coex
esp_common
esp_driver_ana_cmpr
esp_driver_cam
esp_driver_dac
esp_driver_gpio
esp_driver_gptimer
esp_driver_i2c
esp_driver_i2s
esp_driver_jpeg
esp_driver_ledc
esp_driver_mcpwm
esp_driver_parlio
esp_driver_pcnt
esp_driver_rmt
esp_driver_sdio
esp_driver_sdm
esp_driver_sdmmc
esp_driver_sdspi
esp_driver_spi
esp_driver_tsens
esp_driver_uart
esp_driver_usb_serial_jtag
esp_eth
esp_event
esp_gdbstub
esp_hid
esp_http_client
esp_http_server
esp_https_ota
esp_https_server
esp_hw_support
esp_lcd
esp_local_ctrl
esp_mm
esp_netif
esp_partition
esp_phy
esp_pm
esp_psram
esp_ringbuf
esp_rom
esp_security
esp_system
esp_timer
esp_vfs_console
esp_wifi
esp-tls
espcoredump
hal
heap
http_parser
ieee802154
log
mqtt
newlib
nvs_flash
nvs_sec_provider
openthread
perfmon
protobuf-c
protocomm
pthread
rt
sdmmc
soc
spi_flash
spiffs
tcp_transport
ulp
unity
vfs
wear_levelling
wifi_provisioning
wpa_supplicant
xtensa
examples
lwIP
FreeRTOS
cJSON
mbedTLS
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/bootloader_support/include/esp_image_format.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #pragma once #include <stdbool.h> #include <esp_err.h> #include "esp_flash_partitions.h" #include "esp_app_format.h" #include "esp_assert.h"5 includes #ifdef __cplusplus extern "C" { #endif #define ESP_ERR_IMAGE_BASE 0x2000 #define ESP_ERR_IMAGE_FLASH_FAIL (ESP_ERR_IMAGE_BASE + 1) #define ESP_ERR_IMAGE_INVALID (ESP_ERR_IMAGE_BASE + 2) /* Support for app/bootloader image parsing Can be compiled as part of app or bootloader code. *//* ... */ #define ESP_IMAGE_HASH_LEN 32 /* Length of the appended SHA-256 digest */ /* Structure to hold on-flash image metadata */ typedef struct { uint32_t start_addr; /* Start address of image */ esp_image_header_t image; /* Header for entire image */ esp_image_segment_header_t segments[ESP_IMAGE_MAX_SEGMENTS]; /* Per-segment header data */ uint32_t segment_data[ESP_IMAGE_MAX_SEGMENTS]; /* Data offsets for each segment */ uint32_t image_len; /* Length of image on flash, in bytes */ uint8_t image_digest[32]; /* appended SHA-256 digest */ uint32_t secure_version; /* secure version for anti-rollback, it is covered by sha256 (set if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK=y) */ uint32_t mmu_page_size; /* Flash MMU page size per binary header */ }{ ... } esp_image_metadata_t; typedef enum { ESP_IMAGE_VERIFY, /* Verify image contents, not load to memory, load metadata. Print errors. */ ESP_IMAGE_VERIFY_SILENT, /* Verify image contents, not load to memory, load metadata. Don't print errors. */ #ifdef BOOTLOADER_BUILD ESP_IMAGE_LOAD, /* Verify image contents, load to memory, load metadata. Print errors. */ ESP_IMAGE_LOAD_NO_VALIDATE, /* Not verify image contents, load to memory, load metadata. Print errors. *//* ... */ #endif }{ ... } esp_image_load_mode_t; typedef struct { esp_partition_pos_t partition; /*!< Partition of application which worked before goes to the deep sleep. */ uint16_t reboot_counter; /*!< Reboot counter. Reset only when power is off. */ union { struct { uint8_t factory_reset_state : 1; /* True when Factory reset has occurred */ uint8_t reserve : 7; /* Reserve */ }{ ... }; uint8_t val; }{ ... } flags; uint8_t reserve; /*!< Reserve */ #ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC uint8_t custom[CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE]; /*!< Reserve for custom propose */ #endif uint32_t crc; /*!< Check sum crc32 */ }{ ... } rtc_retain_mem_t; ESP_STATIC_ASSERT(offsetof(rtc_retain_mem_t, crc) == sizeof(rtc_retain_mem_t) - sizeof(uint32_t), "CRC field must be the last field of rtc_retain_mem_t structure"); #ifdef CONFIG_BOOTLOADER_RESERVE_RTC_MEM #ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC ESP_STATIC_ASSERT(CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE % 4 == 0, "CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE must be a multiple of 4 bytes"); /* The custom field must be the penultimate field */ ESP_STATIC_ASSERT(offsetof(rtc_retain_mem_t, custom) == sizeof(rtc_retain_mem_t) - sizeof(uint32_t) - CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE, "custom field in rtc_retain_mem_t structure must be the field before the CRC one");/* ... */ #endif ESP_STATIC_ASSERT(CONFIG_BOOTLOADER_RESERVE_RTC_SIZE % 4 == 0, "CONFIG_BOOTLOADER_RESERVE_RTC_SIZE must be a multiple of 4 bytes"); #ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC #define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE) #else #define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE) #endif ESP_STATIC_ASSERT(sizeof(rtc_retain_mem_t) <= ESP_BOOTLOADER_RESERVE_RTC, "Reserved RTC area must exceed size of rtc_retain_mem_t");/* ... */ #endif // CONFIG_BOOTLOADER_RESERVE_RTC_MEM /** * @brief Verify an app image. * * If encryption is enabled, data will be transparently decrypted. * * @param mode Mode of operation (verify, silent verify, or load). * @param part Partition to load the app from. * @param[inout] data Pointer to the image metadata structure which is be filled in by this function. * 'start_addr' member should be set (to the start address of the image.) * Other fields will all be initialised by this function. * * Image validation checks: * - Magic byte. * - Partition smaller than 16MB. * - All segments & image fit in partition. * - 8 bit image checksum is valid. * - SHA-256 of image is valid (if image has this appended). * - (Signature) if signature verification is enabled. * * @return * - ESP_OK if verify or load was successful * - ESP_ERR_IMAGE_FLASH_FAIL if a SPI flash error occurs * - ESP_ERR_IMAGE_INVALID if the image appears invalid. * - ESP_ERR_INVALID_ARG if the partition or data pointers are invalid. *//* ... */ esp_err_t esp_image_verify(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data); /** * @brief Get metadata of app * * If encryption is enabled, data will be transparently decrypted. * * @param part Partition to load the app from. * @param[out] metadata Pointer to the image metadata structure which is be filled in by this function. * Fields will all be initialised by this function. * * @return * - ESP_OK if filling of metadata was successful *//* ... */ esp_err_t esp_image_get_metadata(const esp_partition_pos_t *part, esp_image_metadata_t *metadata); /** * @brief Verify and load an app image (available only in space of bootloader). * * If encryption is enabled, data will be transparently decrypted. * * @param part Partition to load the app from. * @param[inout] data Pointer to the image metadata structure which is be filled in by this function. * 'start_addr' member should be set (to the start address of the image.) * Other fields will all be initialised by this function. * * Image validation checks: * - Magic byte. * - Partition smaller than 16MB. * - All segments & image fit in partition. * - 8 bit image checksum is valid. * - SHA-256 of image is valid (if image has this appended). * - (Signature) if signature verification is enabled. * * @return * - ESP_OK if verify or load was successful * - ESP_ERR_IMAGE_FLASH_FAIL if a SPI flash error occurs * - ESP_ERR_IMAGE_INVALID if the image appears invalid. * - ESP_ERR_INVALID_ARG if the partition or data pointers are invalid. *//* ... */ esp_err_t bootloader_load_image(const esp_partition_pos_t *part, esp_image_metadata_t *data); /** * @brief Load an app image without verification (available only in space of bootloader). * * If encryption is enabled, data will be transparently decrypted. * * @param part Partition to load the app from. * @param[inout] data Pointer to the image metadata structure which is be filled in by this function. * 'start_addr' member should be set (to the start address of the image.) * Other fields will all be initialised by this function. * * @return * - ESP_OK if verify or load was successful * - ESP_ERR_IMAGE_FLASH_FAIL if a SPI flash error occurs * - ESP_ERR_IMAGE_INVALID if the image appears invalid. * - ESP_ERR_INVALID_ARG if the partition or data pointers are invalid. *//* ... */ esp_err_t bootloader_load_image_no_verify(const esp_partition_pos_t *part, esp_image_metadata_t *data); /** * @brief Verify the bootloader image. * * @param[out] If result is ESP_OK and this pointer is non-NULL, it * will be set to the length of the bootloader image. * * @return As per esp_image_load_metadata(). *//* ... */ esp_err_t esp_image_verify_bootloader(uint32_t *length); /** * @brief Verify the bootloader image. * * @param[out] Metadata for the image. Only valid if result is ESP_OK. * * @return As per esp_image_load_metadata(). *//* ... */ esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data); /** * @brief Get the flash size of the image * * @param app_flash_size The value configured in the image header * @return Actual size, in bytes. *//* ... */ int esp_image_get_flash_size(esp_image_flash_size_t app_flash_size); typedef struct { uint32_t drom_addr; uint32_t drom_load_addr; uint32_t drom_size; uint32_t irom_addr; uint32_t irom_load_addr; uint32_t irom_size; }{ ... } esp_image_flash_mapping_t; #ifdef __cplusplus }{...} #endif
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.