mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-07 06:34:34 +02:00
feat(spi_flash): Adds esp_flash_set_dangerous_write_protection
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -95,7 +95,27 @@ esp_err_t esp_flash_app_enable_os_functions(esp_flash_t* chip);
|
|||||||
*/
|
*/
|
||||||
esp_err_t esp_flash_app_disable_os_functions(esp_flash_t* chip);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -350,6 +350,22 @@ esp_err_t esp_flash_app_enable_os_functions(esp_flash_t* chip)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_flash_set_dangerous_write_protection(esp_flash_t *chip, const bool protect)
|
||||||
|
{
|
||||||
|
#if !CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED
|
||||||
|
if (chip == NULL) {
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
if (chip->os_func_data != NULL) {
|
||||||
|
((app_func_arg_t*)chip->os_func_data)->no_protect = !protect;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(void)chip;
|
||||||
|
(void)protect;
|
||||||
|
#endif
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// The goal of this part is to manually insert one valid task execution interval, if the time since
|
// The goal of this part is to manually insert one valid task execution interval, if the time since
|
||||||
// last valid interval exceed the limitation (CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS).
|
// last valid interval exceed the limitation (CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS).
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user