Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By projectgus
#18673 Hi coldpenguin,

The default storage location for all functions is the iram section, which is only 32KB.

Functions marked with ICACHE_FLASH_ATTR will go into the irom section, which is stored in the SPI flash (size depends on the module but it's least 512KB usually bigger.)

As a rule, you should mark almost all your functions with ICACHE_FLASH_ATTR. The exceptions are functions called from interrupt handlers where the flash cache may be disabled, and functions that you're really sure get called very often. If unsure, mark with ICACHE_FLASH_ATTR.

There's some more information about the various sections, flash caching, etc. on the wiki: https://github.com/esp8266/esp8266-wiki/wiki/Memory-Map

For examples of how to apply ICACHE_FLASH_ATTR, have a dig around in the sources that come with the SDK.

Angus
User avatar
By jcmvbkbc
#18685
projectgus wrote:The default storage location for all functions is the iram section, which is only 32KB.

Actually there's 64KB, at least OTA boot code uses memory in the upper 32KB, I guess we can use full 64KB if OTA functionality isn't needed.
User avatar
By projectgus
#18687
jcmvbkbc wrote:Actually there's 64KB, at least OTA boot code uses memory in the upper 32KB, I guess we can use full 64KB if OTA functionality isn't needed.


That's very interesting, thanks.

I just tried writing to the upper 32KB of IRAM via openocd, while running the RTOS SDK. The region reads back as all zeroes. Writing to the lower 32KB works as expected.

I wonder if this relates to the flash caching behaviour somehow? You can either have that region mapped to address space, or used as cache?

Just unmapping the flash (clearing bit 17 of 0x60000208) wasn't enough to change anything.