究竟有多少esp8266 flash可以映射?

How much of esp8266 flash can actually be mapped?

我正在尝试 link 一个包含 200Kbyte 常量数据的程序。

我使用 __attribute__((section(".irom.text"))) 属性试图将其放入 FLASH,因为我相信 ESP8266 有 4MB 可用闪存。

唉,linker报错了:

bin/firmware.elf section `.irom0.text' will not fit in region `irom0_0_seg'

使用的linker脚本是我从platform IO得到的,即:

MEMORY
{
  dport0_0_seg :                        org = 0x3FF00000, len = 0x10
  dram0_0_seg :                         org = 0x3FFE8000, len = 0x18000
  iram1_0_seg :                         org = 0x40100000, len = 0x8000
  irom0_0_seg :                         org = 0x40220000, len = 0x5C000
}

INCLUDE "../ld/eagle.app.v6.common.ld"

实际上 irom 部分的长度是 0x5C000 (376 KB) 对于我的代码、常量数组和 SDK 来说可能不够。

那么承诺的 4Mbytes 在哪里?是否可以映射更多的FLASH?

我想我已经弄明白了。

看来4Mbyte模块的系统参数应该位于0x3fb000

因此可以将 irom 段大小增加到 0x3fb000 - 0x20000 = 0x3DB000 字节。

这是一个例子,我在 irom 结束后添加了 0x1000 个备用字节(以防万一我遗漏了一些我不理解的内容):

irom0_0_seg : org = 0x40220000, len = 0x3DA000 /* 4MB FLASH: irom begin untill system params start is 0x3DB000  */

还需要告诉 esp 工具将每个部分放在闪存中的正确位置(注意 esp_init_data_default.bin 所在的位置):

esptool -cd nodemcu -cb 115200 -cp "/dev/ttyUSB0" -ca 0x00000 -cf path/to/eagle.flash.bin -ca 0x20000 -cf path/to/eagle.irom0text.bin -ca 0x3fc000 -cf path/to/framework-esp8266-rtos-sdk/bin/esp_init_data_default.bin -ca 0x3fe000 -cf path/to/framework-esp8266-rtos-sdk/bin/blank.bin