-->
Page 1 of 2

Using more than 200k of flash, and put rodata in flash

PostPosted: Tue Dec 23, 2014 4:33 am
by joostn
In the linker script section .rodata is mapped into RAM:

Code: Select all.rodata : ALIGN(4)
  {
    _rodata_start = ABSOLUTE(.);
    *(.rodata.*)
    *(.rodata)
    *(.gnu.linkonce.r.*)
...
  } >dram0_0_seg :dram0_0_phdr


This is eating a precious 6k of RAM. In all my ARM linker scripts .rodata goes into .text and thus in Flash. Does anyone know why this is, and can it be changed? I've tried to move it but of course it then fails to boot.

And my second question:
Code: Select all  iram1_0_seg :                          org = 0x40100000, len = 0x8000
  irom0_0_seg :                          org = 0x40240000, len = 0x32000

The linker script only uses 232k of the flash. I think it has 512k, is it possible to use the remaining space for code? I don't use the cloud update feature.

Re: Using more than 200k of flash, and put rodata in flash

PostPosted: Thu Dec 25, 2014 1:23 pm
by Harold L.
joostn wrote:And my second question:
Code: Select all  iram1_0_seg :                          org = 0x40100000, len = 0x8000
  irom0_0_seg :                          org = 0x40240000, len = 0x32000

The linker script only uses 232k of the flash. I think it has 512k, is it possible to use the remaining space for code? I don't use the cloud update feature.


You can change "org" to a lower address, and increase its len to get more space.
e.g.
irom0_0_seg : org = 0x40210000, len = 0x60000

After compiling, you should burn your .irom0.bin to 0x10000 instead of the original 0x40000. That's because 8266 mapped flash chip start from 0x40200000.

That's what I have done successfully in developing NodeLua project: http://nodelua.org

I have no idea with your first question, but very interested about it, dose anyone know ways to do that?

Re: Using more than 200k of flash, and put rodata in flash

PostPosted: Thu Dec 25, 2014 1:48 pm
by jcmvbkbc
joostn wrote:In the linker script section .rodata is mapped into RAM:

Code: Select all.rodata : ALIGN(4)
  {
    _rodata_start = ABSOLUTE(.);
    *(.rodata.*)
    *(.rodata)
    *(.gnu.linkonce.r.*)
...
  } >dram0_0_seg :dram0_0_phdr


This is eating a precious 6k of RAM. In all my ARM linker scripts .rodata goes into .text and thus in Flash. Does anyone know why this is, and can it be changed? I've tried to move it but of course it then fails to boot.

I see at least one reason for that: the bootloader does not enable transparent FLASH mapping in the region 0x40200000, it only loads some code from FLASH and jumps into it. So that code needs to be self-sufficient, at least until the transparent FLASH mapping is enabled.

Re: Using more than 200k of flash, and put rodata in flash

PostPosted: Mon Dec 29, 2014 5:42 am
by joostn
You can change "org" to a lower address, and increase its len to get more space.
e.g.
irom0_0_seg : org = 0x40210000, len = 0x60000


Works like a charm, thanks!