Select one of the symbols to view example projects that use it.
 
Outline
#include "esp_err.h"
#include <stdint.h>
#include <stdbool.h>
#include "esp_private/spi_share_hw_ctrl.h"
#include "sdkconfig.h"
#include "esp_flash.h"
esp_flash_init_default_chip();
esp_flash_app_init();
esp_flash_app_disable_protect(bool);
esp_flash_init_os_functions(esp_flash_t *, int, spi_bus_lock_dev_handle_t);
esp_flash_deinit_os_functions(esp_flash_t *, spi_bus_lock_dev_handle_t *);
esp_flash_init_main_bus_lock();
esp_flash_app_enable_os_functions(esp_flash_t *);
esp_flash_app_disable_os_functions(esp_flash_t *);
esp_flash_set_dangerous_write_protection(esp_flash_t *, const bool);
Files
ESP-IDF
components
app_trace
app_update
bootloader_support
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
include
esp_private
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/spi_flash/include/esp_flash_internal.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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #pragma once #include "esp_err.h" #include <stdint.h> #include <stdbool.h> #include "esp_private/spi_share_hw_ctrl.h" #include "sdkconfig.h" #include "esp_flash.h"6 includes /** Internal API, don't use in the applications */ #ifdef __cplusplus extern "C" { #endif /** @brief Initialise the default SPI flash chip * * Called by OS startup code. You do not need to call this in your own applications. *//* ... */ esp_err_t esp_flash_init_default_chip(void); /** * Enable OS-level SPI flash protections in IDF * * Called by OS startup code. You do not need to call this in your own applications. * * @return ESP_OK if success, otherwise failed. See return value of ``esp_flash_init_os_functions``. *//* ... */ esp_err_t esp_flash_app_init(void); /** * Disable (or enable) OS-level SPI flash protections in IDF * * Called by the IDF internal code (e.g. coredump). You do not need to call this in your own applications. * * @return always ESP_OK. *//* ... */ esp_err_t esp_flash_app_disable_protect(bool disable); /** * Initialize OS-level functions for a specific chip. * * @param chip The chip to init os functions. * @param host_id Which SPI host to use, 1 for SPI1, 2 for SPI2 (HSPI), 3 for SPI3 (VSPI) * @param dev_handle SPI bus lock device handle to acquire during flash operations * * @return * - ESP_OK if success * - ESP_ERR_INVALID_ARG if host_id is invalid *//* ... */ esp_err_t esp_flash_init_os_functions(esp_flash_t *chip, int host_id, spi_bus_lock_dev_handle_t dev_handle); /** * @brief Deinitialize OS-level functions * * @param chip The chip to deinit os functions * @param out_dev_handle The SPI bus lock passed from `esp_flash_init_os_functions`. The caller should deinitialize * the lock. * @return always ESP_OK. *//* ... */ esp_err_t esp_flash_deinit_os_functions(esp_flash_t* chip, spi_bus_lock_dev_handle_t* out_dev_handle); /** * @brief Initialize the bus lock on the SPI1 bus. Should be called if drivers (including esp_flash) * wants to use SPI1 bus. * * @note When using legacy spi flash API, the bus lock will not be available on SPI1 bus. * * @return esp_err_t always ESP_OK. *//* ... */ esp_err_t esp_flash_init_main_bus_lock(void); /** * Initialize OS-level functions for the main flash chip. * * @param chip The chip to init os functions. Only pointer to the default chip is supported now. * * @return always ESP_OK *//* ... */ esp_err_t esp_flash_app_enable_os_functions(esp_flash_t* chip); /** * Disable OS-level functions for the main flash chip during special phases (e.g. coredump) * * @param chip The chip to init os functions. Only "esp_flash_default_chip" is supported now. * * @return always ESP_OK *//* ... */ esp_err_t esp_flash_app_disable_os_functions(esp_flash_t* chip); /** * @brief Set or clear dangerous write protection check on the flash chip. * * This function sets the runtime option to allow or disallow writing to * dangerous areas such as the bootloader and partition table. If * CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set, this function allows * the caller to toggle the protection for specific areas. * * If CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is set, there is no protection * check in the system, and this function does nothing. * * @param chip The flash chip on which to set the write protection. Only * "esp_flash_default_chip" is supported. * @param protect Set to true to enable protection against writing in dangerous * areas (bootloader, partition table). Set to false to disable * the protection. * @return * - ESP_OK: Successful operation. * - ESP_ERR_INVALID_ARG: The chip argument is null. *//* ... */ esp_err_t esp_flash_set_dangerous_write_protection(esp_flash_t *chip, const bool protect); #ifdef __cplusplus }{...} #endif
Details