前提阅读
指令载入方式
一. iram 方式(0x4010…, 需 load)
用户可通过 ld 文件中 iram1_0_seg 指定某个lib/某个段, 或者通过下面方式指定某个函数/某个变量, 将其放在 iram 中。
#define IRAM_ATTR __attribute__((section(".text")))
在编译选项 -ffunction-sections
打开的情况下,函数的默认属性为 *.text
,*.text
属性的函数,将会被放到 .text
.
如下 ld 所示,esp8266 sdk 默认将 iRAM 中 0x40100000 开始的 32KB 空间用作 iram,sdk 启动后, bootloader 将 flash 中代码 load 到 iram 中。
iram1_0_seg : org = 0x40100000, len = 0x8000
二. cache 方式(0x4020…, 无需 load, 也被称为 flash 方式)
用户可通过 ld 文件中 irom0_0_seg 指定某个lib/某个段, 或者通过下面方式指定某个函数/某个变量, 将其放在 flash 中, 通过 cac