关于ICACHE_FLASH_ATTR的用法

Paulwu
Posts: 8
Joined: Tue Oct 20, 2015 3:32 pm

关于ICACHE_FLASH_ATTR的用法

Postby Paulwu » Thu Oct 22, 2015 9:19 am

看见很多函数前加了void ICACHE_FLASH_ATTR,这句是什么意思?什么情况下需要加上ICACHE_FLASH_ATTR。TKS!

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: 关于ICACHE_FLASH_ATTR的用法

Postby ESP_Faye » Fri Oct 23, 2015 3:50 pm

您好,

请参考帖子:http://bbs.espressif.com/viewtopic.php?f=61&t=366

感谢您对 ESP8266 的关注!

mariuszb
Posts: 12
Joined: Tue Jun 16, 2015 2:51 pm

Re: 关于ICACHE_FLASH_ATTR的用法

Postby mariuszb » Thu Dec 10, 2015 7:03 pm

I would like to understand it well:

1. Functions with ICACHE_FLASH_ATTR are in FLASH and downloaded to IRAM "on execution demand"

2. Functions without ICACHE_FLASH_ATTR are from the beginning in the IRAM

Questions to point 2:
- Are they there permanently ?
- or in the absence of memory erased and then re-loaded like ICACHE_FLASH_ATTR ?
- if they are still in memory and will be a lot of such functions does not run out of cache for ICACHE_FLASH_ATTR function ?

or the only difference is that the functions are loaded into the cache at the beginning and further there is no difference between functions with and without attribute ICACHE_FLASH_ATTR ?

Thanks for ansver :)

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: 关于ICACHE_FLASH_ATTR的用法

Postby ESP_Faye » Fri Dec 11, 2015 3:03 pm

Hi,

Please refer to this topic http://bbs.espressif.com/viewtopic.php?f=7&t=1183&start=10#p5000.

Thanks for your interest in ESP8266 !

jinhucn
Posts: 20
Joined: Wed Dec 23, 2015 12:06 pm

Re: 关于ICACHE_FLASH_ATTR的用法

Postby jinhucn » Fri Dec 25, 2015 3:15 pm

另外两个帖子我都看了,只是说不加ICACHE_FLASH_ATTR的函数在boot时预载到ram。但是没有解释是否永久驻留ram,还是不用的时候会从内存中置换出去。

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: 关于ICACHE_FLASH_ATTR的用法

Postby ESP_Faye » Mon Dec 28, 2015 2:36 pm

您好,

ICACHE_FLASH_ATTR 是 ESP8266_NONOS_SDK 才需要添加的宏,ESP8266_RTOS_SDK 默认使用这个宏,无需特别添加。

如果是一开始就加载到 RAM 的函数,将始终在 RAM 中。在 CACHE 中的函数,才是仅调用时才加载到 CACHE 中。

感谢您对 ESP8266 的关注!

jinhucn
Posts: 20
Joined: Wed Dec 23, 2015 12:06 pm

Re: 关于ICACHE_FLASH_ATTR的用法

Postby jinhucn » Tue Jan 05, 2016 4:39 pm

Espressif_Faye wrote:您好,

ICACHE_FLASH_ATTR 是 ESP8266_NONOS_SDK 才需要添加的宏,ESP8266_RTOS_SDK 默认使用这个宏,无需特别添加。

如果是一开始就加载到 RAM 的函数,将始终在 RAM 中。在 CACHE 中的函数,才是仅调用时才加载到 CACHE 中。

感谢您对 ESP8266 的关注!


加载到CACHE中的函数应该是用完了就会被置换出去的吧,那么user_rf_pre_init和user_init通常只需要运行一次,为什么你们给的例子中没有使用ICACHE_FLASH_ATTR?

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: 关于ICACHE_FLASH_ATTR的用法

Postby ESP_Faye » Tue Jan 05, 2016 5:59 pm

您好,

user_rf_pre_init 和 user_init 可以添加 ICACHE_FLASH_ATTR 宏,如果您有相关需求,自行添加即可。

感谢您对 ESP8266 的关注!

Who is online

Users browsing this forum: No registered users and 1 guest