11/*
2- * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+ * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -183,7 +183,7 @@ extern rom_spiflash_api_func_t *esp_flash_api_funcs;
183183 call rom_spiflash_api_funcs->end() before returning.
184184*/
185185#if !CONFIG_SPI_FLASH_ROM_IMPL || ESP_ROM_HAS_ENCRYPTED_WRITES_USING_LEGACY_DRV
186- static esp_err_t IRAM_ATTR spiflash_start_default (esp_flash_t * chip )
186+ static esp_err_t spiflash_start_default (esp_flash_t * chip )
187187{
188188 if (chip -> os_func != NULL && chip -> os_func -> start != NULL ) {
189189 esp_err_t err = chip -> os_func -> start (chip -> os_func_data );
@@ -197,7 +197,7 @@ static esp_err_t IRAM_ATTR spiflash_start_default(esp_flash_t *chip)
197197
198198/* Static function to notify OS that SPI flash operation is complete.
199199 */
200- static esp_err_t IRAM_ATTR spiflash_end_default (esp_flash_t * chip , esp_err_t err )
200+ static esp_err_t spiflash_end_default (esp_flash_t * chip , esp_err_t err )
201201{
202202 if (chip -> os_func != NULL
203203 && chip -> os_func -> end != NULL ) {
@@ -210,7 +210,7 @@ static esp_err_t IRAM_ATTR spiflash_end_default(esp_flash_t *chip, esp_err_t err
210210}
211211
212212// check that the 'chip' parameter is properly initialised
213- static IRAM_ATTR esp_err_t check_chip_pointer_default (esp_flash_t * * inout_chip )
213+ static esp_err_t check_chip_pointer_default (esp_flash_t * * inout_chip )
214214{
215215 esp_flash_t * chip = * inout_chip ;
216216 if (chip == NULL ) {
@@ -223,7 +223,7 @@ static IRAM_ATTR esp_err_t check_chip_pointer_default(esp_flash_t **inout_chip)
223223 return ESP_OK ;
224224}
225225
226- static IRAM_ATTR esp_err_t flash_end_flush_cache (esp_flash_t * chip , esp_err_t err , bool bus_acquired , uint32_t address , uint32_t length )
226+ static esp_err_t flash_end_flush_cache (esp_flash_t * chip , esp_err_t err , bool bus_acquired , uint32_t address , uint32_t length )
227227{
228228 if (!bus_acquired ) {
229229 // Try to acquire the bus again to flush the cache before exit.
@@ -247,13 +247,13 @@ static IRAM_ATTR esp_err_t flash_end_flush_cache(esp_flash_t* chip, esp_err_t er
247247
248248static esp_err_t detect_spi_flash_chip (esp_flash_t * chip );
249249
250- bool IRAM_ATTR esp_flash_chip_driver_initialized (const esp_flash_t * chip )
250+ bool esp_flash_chip_driver_initialized (const esp_flash_t * chip )
251251{
252252 if (!chip -> chip_drv ) return false;
253253 return true;
254254}
255255
256- esp_err_t IRAM_ATTR esp_flash_init (esp_flash_t * chip )
256+ esp_err_t esp_flash_init (esp_flash_t * chip )
257257{
258258 // Chip init flow
259259 // 1. Read chip id
@@ -324,7 +324,7 @@ esp_err_t IRAM_ATTR esp_flash_init(esp_flash_t *chip)
324324
325325// Note: This function is only used for internal. Only call this function to initialize the main flash.
326326// (flash chip on SPI1 CS0)
327- esp_err_t IRAM_ATTR esp_flash_init_main (esp_flash_t * chip )
327+ esp_err_t esp_flash_init_main (esp_flash_t * chip )
328328{
329329 // Chip init flow
330330 // 1. Read chip id
@@ -455,7 +455,7 @@ esp_err_t esp_flash_read_id(esp_flash_t* chip, uint32_t* out_id)
455455}
456456#endif //CONFIG_SPI_FLASH_ROM_IMPL
457457
458- static esp_err_t IRAM_ATTR NOINLINE_ATTR read_unique_id (esp_flash_t * chip , uint64_t * out_uid )
458+ static esp_err_t NOINLINE_ATTR read_unique_id (esp_flash_t * chip , uint64_t * out_uid )
459459{
460460 esp_err_t err = rom_spiflash_api_funcs -> start (chip );
461461 if (err != ESP_OK ) {
@@ -490,7 +490,7 @@ esp_err_t esp_flash_read_unique_chip_id(esp_flash_t *chip, uint64_t* out_uid)
490490 return read_unique_id (chip , out_uid );
491491}
492492
493- static esp_err_t IRAM_ATTR detect_spi_flash_chip (esp_flash_t * chip )
493+ static esp_err_t detect_spi_flash_chip (esp_flash_t * chip )
494494{
495495 esp_err_t err ;
496496 uint32_t flash_id = chip -> chip_id ;
@@ -526,7 +526,7 @@ static esp_err_t IRAM_ATTR detect_spi_flash_chip(esp_flash_t *chip)
526526 return ESP_OK ;
527527}
528528
529- esp_err_t IRAM_ATTR esp_flash_get_physical_size (esp_flash_t * chip , uint32_t * flash_size )
529+ esp_err_t esp_flash_get_physical_size (esp_flash_t * chip , uint32_t * flash_size )
530530{
531531 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
532532 if (err != ESP_OK ) {
@@ -556,9 +556,9 @@ esp_err_t IRAM_ATTR esp_flash_get_physical_size(esp_flash_t *chip, uint32_t *fla
556556#ifndef CONFIG_SPI_FLASH_ROM_IMPL
557557
558558/* Return true if regions 'a' and 'b' overlap at all, based on their start offsets and lengths. */
559- inline static bool regions_overlap (uint32_t a_start , uint32_t a_len ,uint32_t b_start , uint32_t b_len );
559+ inline static IRAM_ATTR bool regions_overlap (uint32_t a_start , uint32_t a_len ,uint32_t b_start , uint32_t b_len );
560560
561- esp_err_t IRAM_ATTR esp_flash_get_size (esp_flash_t * chip , uint32_t * out_size )
561+ esp_err_t esp_flash_get_size (esp_flash_t * chip , uint32_t * out_size )
562562{
563563 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
564564 if (err != ESP_OK ) {
@@ -576,7 +576,7 @@ esp_err_t IRAM_ATTR esp_flash_get_size(esp_flash_t *chip, uint32_t *out_size)
576576 return esp_flash_get_physical_size (chip , out_size );
577577}
578578
579- esp_err_t IRAM_ATTR esp_flash_erase_chip (esp_flash_t * chip )
579+ esp_err_t esp_flash_erase_chip (esp_flash_t * chip )
580580{
581581 esp_err_t err = ESP_OK ;
582582 uint32_t size = 0 ;
@@ -589,7 +589,7 @@ esp_err_t IRAM_ATTR esp_flash_erase_chip(esp_flash_t *chip)
589589 return err ;
590590}
591591
592- esp_err_t IRAM_ATTR esp_flash_erase_region (esp_flash_t * chip , uint32_t start , uint32_t len )
592+ esp_err_t esp_flash_erase_region (esp_flash_t * chip , uint32_t start , uint32_t len )
593593{
594594 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
595595 VERIFY_CHIP_OP (erase_sector );
@@ -711,7 +711,7 @@ esp_err_t IRAM_ATTR esp_flash_erase_region(esp_flash_t *chip, uint32_t start, ui
711711 * done after the other arguments are checked.
712712 */
713713extern esp_err_t rom_esp_flash_erase_region (esp_flash_t * chip , uint32_t start , uint32_t len );
714- esp_err_t IRAM_ATTR esp_flash_erase_region (esp_flash_t * chip , uint32_t start , uint32_t len )
714+ esp_err_t esp_flash_erase_region (esp_flash_t * chip , uint32_t start , uint32_t len )
715715{
716716 if (len == 0 ) {
717717 return ESP_OK ;
@@ -722,7 +722,7 @@ esp_err_t IRAM_ATTR esp_flash_erase_region(esp_flash_t *chip, uint32_t start, ui
722722
723723#ifndef CONFIG_SPI_FLASH_ROM_IMPL
724724
725- esp_err_t IRAM_ATTR esp_flash_get_chip_write_protect (esp_flash_t * chip , bool * out_write_protected )
725+ esp_err_t esp_flash_get_chip_write_protect (esp_flash_t * chip , bool * out_write_protected )
726726{
727727 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
728728 VERIFY_CHIP_OP (get_chip_write_protect );
@@ -740,7 +740,7 @@ esp_err_t IRAM_ATTR esp_flash_get_chip_write_protect(esp_flash_t *chip, bool *ou
740740 return rom_spiflash_api_funcs -> end (chip , err );
741741}
742742
743- esp_err_t IRAM_ATTR esp_flash_set_chip_write_protect (esp_flash_t * chip , bool write_protect )
743+ esp_err_t esp_flash_set_chip_write_protect (esp_flash_t * chip , bool write_protect )
744744{
745745 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
746746 VERIFY_CHIP_OP (set_chip_write_protect );
@@ -789,7 +789,7 @@ static esp_err_t find_region(const esp_flash_t *chip, const esp_flash_region_t *
789789 return ESP_ERR_NOT_FOUND ;
790790}
791791
792- esp_err_t IRAM_ATTR esp_flash_get_protected_region (esp_flash_t * chip , const esp_flash_region_t * region , bool * out_protected )
792+ esp_err_t esp_flash_get_protected_region (esp_flash_t * chip , const esp_flash_region_t * region , bool * out_protected )
793793{
794794 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
795795 VERIFY_CHIP_OP (get_protected_regions );
@@ -818,7 +818,7 @@ esp_err_t IRAM_ATTR esp_flash_get_protected_region(esp_flash_t *chip, const esp_
818818 return rom_spiflash_api_funcs -> end (chip , err );
819819}
820820
821- esp_err_t IRAM_ATTR esp_flash_set_protected_region (esp_flash_t * chip , const esp_flash_region_t * region , bool protect )
821+ esp_err_t esp_flash_set_protected_region (esp_flash_t * chip , const esp_flash_region_t * region , bool protect )
822822{
823823 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
824824 VERIFY_CHIP_OP (set_protected_regions );
@@ -848,7 +848,7 @@ esp_err_t IRAM_ATTR esp_flash_set_protected_region(esp_flash_t *chip, const esp_
848848 return rom_spiflash_api_funcs -> end (chip , err );
849849}
850850
851- esp_err_t IRAM_ATTR esp_flash_read (esp_flash_t * chip , void * buffer , uint32_t address , uint32_t length )
851+ esp_err_t esp_flash_read (esp_flash_t * chip , void * buffer , uint32_t address , uint32_t length )
852852{
853853 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
854854 VERIFY_CHIP_OP (read );
@@ -925,7 +925,7 @@ esp_err_t IRAM_ATTR esp_flash_read(esp_flash_t *chip, void *buffer, uint32_t add
925925}
926926
927927#if CONFIG_SPI_FLASH_WARN_SETTING_ZERO_TO_ONE
928- static esp_err_t IRAM_ATTR s_check_setting_zero_to_one (esp_flash_t * chip , uint32_t verify_address , uint32_t remain_verify_len , const uint32_t * to_write_buf , bool is_encrypted )
928+ static esp_err_t s_check_setting_zero_to_one (esp_flash_t * chip , uint32_t verify_address , uint32_t remain_verify_len , const uint32_t * to_write_buf , bool is_encrypted )
929929{
930930 esp_err_t err = ESP_FAIL ;
931931 uint8_t verify_buffer [VERIFY_BUF_LEN ];
@@ -964,7 +964,7 @@ static esp_err_t IRAM_ATTR s_check_setting_zero_to_one(esp_flash_t *chip, uint32
964964#endif //#if CONFIG_SPI_FLASH_WARN_SETTING_ZERO_TO_ONE
965965
966966#if CONFIG_SPI_FLASH_VERIFY_WRITE
967- static esp_err_t IRAM_ATTR s_verify_write (esp_flash_t * chip , uint32_t verify_address , uint32_t remain_verify_len , const uint32_t * expected_buf , bool is_encrypted )
967+ static esp_err_t s_verify_write (esp_flash_t * chip , uint32_t verify_address , uint32_t remain_verify_len , const uint32_t * expected_buf , bool is_encrypted )
968968{
969969 esp_err_t err = ESP_FAIL ;
970970 uint8_t verify_buffer [VERIFY_BUF_LEN ];
@@ -1001,7 +1001,7 @@ static esp_err_t IRAM_ATTR s_verify_write(esp_flash_t *chip, uint32_t verify_add
10011001}
10021002#endif //#if CONFIG_SPI_FLASH_VERIFY_WRITE
10031003
1004- esp_err_t IRAM_ATTR esp_flash_write (esp_flash_t * chip , const void * buffer , uint32_t address , uint32_t length )
1004+ esp_err_t esp_flash_write (esp_flash_t * chip , const void * buffer , uint32_t address , uint32_t length )
10051005{
10061006 esp_err_t ret = ESP_FAIL ;
10071007#if CONFIG_SPI_FLASH_VERIFY_WRITE
@@ -1123,14 +1123,14 @@ esp_err_t IRAM_ATTR esp_flash_write(esp_flash_t *chip, const void *buffer, uint3
11231123 return err ;
11241124}
11251125
1126- inline static IRAM_ATTR bool regions_overlap (uint32_t a_start , uint32_t a_len ,uint32_t b_start , uint32_t b_len )
1126+ inline static bool regions_overlap (uint32_t a_start , uint32_t a_len ,uint32_t b_start , uint32_t b_len )
11271127{
11281128 uint32_t a_end = a_start + a_len ;
11291129 uint32_t b_end = b_start + b_len ;
11301130 return (a_end > b_start && b_end > a_start );
11311131}
11321132
1133- esp_err_t IRAM_ATTR esp_flash_read_encrypted (esp_flash_t * chip , uint32_t address , void * out_buffer , uint32_t length )
1133+ esp_err_t esp_flash_read_encrypted (esp_flash_t * chip , uint32_t address , void * out_buffer , uint32_t length )
11341134{
11351135 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
11361136 if (err != ESP_OK ) return err ;
@@ -1163,7 +1163,7 @@ esp_err_t IRAM_ATTR esp_flash_read_encrypted(esp_flash_t *chip, uint32_t address
11631163}
11641164
11651165// test only, non-public
1166- IRAM_ATTR esp_err_t esp_flash_get_io_mode (esp_flash_t * chip , bool * qe )
1166+ esp_err_t esp_flash_get_io_mode (esp_flash_t * chip , bool * qe )
11671167{
11681168 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
11691169 VERIFY_CHIP_OP (get_io_mode );
@@ -1181,7 +1181,7 @@ IRAM_ATTR esp_err_t esp_flash_get_io_mode(esp_flash_t* chip, bool* qe)
11811181 return err ;
11821182}
11831183
1184- IRAM_ATTR esp_err_t esp_flash_set_io_mode (esp_flash_t * chip , bool qe )
1184+ esp_err_t esp_flash_set_io_mode (esp_flash_t * chip , bool qe )
11851185{
11861186 esp_err_t err = rom_spiflash_api_funcs -> chip_check (& chip );
11871187 VERIFY_CHIP_OP (set_io_mode );
@@ -1214,7 +1214,7 @@ FORCE_INLINE_ATTR esp_err_t s_encryption_write_unlock(esp_flash_t *chip) {
12141214 return err ;
12151215}
12161216
1217- esp_err_t IRAM_ATTR esp_flash_write_encrypted (esp_flash_t * chip , uint32_t address , const void * buffer , uint32_t length )
1217+ esp_err_t esp_flash_write_encrypted (esp_flash_t * chip , uint32_t address , const void * buffer , uint32_t length )
12181218{
12191219 esp_err_t ret = ESP_FAIL ;
12201220#if CONFIG_SPI_FLASH_VERIFY_WRITE
0 commit comments