-->
Page 1 of 8

Use all of the 512 kbyte of the 4M flash

PostPosted: Tue Jul 21, 2015 4:53 am
by eriksl
Hello,

Is it possible to use all of the 512 kbyte of the 4M flash? I am not going to do any OTA-updating, so I think it's a pity I can't use this part of the flash. When I flash firmwares beyond the 192 kbyte boundary, the code won't run.

Would it be possible to define an extra segment + section(s) in the linker script that maps to offset 0x40000 (256 k) and put some code there?

Something like this:

Code: Select all MEMORY
 {
   dport0_0_seg :                        org = 0x3FF00000, len = 0x10
   dram0_0_seg :                         org = 0x3FFE8000, len = 0x14000
   iram1_0_seg :                         org = 0x40100000, len = 0x8000
   irom0_0_seg :                         org = 0x40240000, len = 0x3C000
+  irom0_1_seg:                          org = 0x40280000, len = 0x3c000
 }

PHDRS
{
    dport0_0_phdr PT_LOAD;
    dram0_0_phdr PT_LOAD;
    dram0_0_bss_phdr PT_LOAD;
    iram1_0_phdr PT_LOAD;
    irom0_0_phdr PT_LOAD;
+   irom0_1_phdr PT_LOAD;
}


Code: Select all   .irom0.text : ALIGN(4)
   {
     _irom0_text_start = ABSOLUTE(.);
     *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
     _irom0_text_end = ABSOLUTE(.);
   } >irom0_0_seg :irom0_0_phdr
+
+  .irom1.text : ALIGN(4)
+  {
+    _irom1_text_start = ABSOLUTE(.);
+    *(.irom1.text)
+    _irom1_text_end = ABSOLUTE(.);
+  } >irom0_1_seg :irom0_1_phdr


Thanks!

Re: Use all of the 512 kbyte of the 4M flash

PostPosted: Tue Jul 21, 2015 5:21 am
by jcmvbkbc
eriksl wrote:Is it possible to use all of the 512 kbyte of the 4M flash? I am not going to do any OTA-updating, so I think it's a pity I can't use this part of the flash. When I flash firmwares beyond the 192 kbyte boundary, the code won't run.

Why wouldn't it run? You should be able to increase existing sections size, e.g. nodeMCU has this:
Code: Select allMEMORY
{
  dport0_0_seg :                        org = 0x3FF00000, len = 0x10
  dram0_0_seg :                         org = 0x3FFE8000, len = 0x14000
  iram1_0_seg :                         org = 0x40100000, len = 0x8000
  irom0_0_seg :                         org = 0x40210000, len = 0x80000
}

You may have issues at the build time, like unreachable literals or too long calls, but the compiler options -mtext-section-literals and -mlongcalls should help.

eriksl wrote:Would it be possible to define an extra segment + section(s) in the linker script that maps to offset 0x40000 (256 k) and put some code there?

You should be able to do that as well, but then you'd need to mark part of your code to go to these new sections.

Re: Use all of the 512 kbyte of the 4M flash

PostPosted: Tue Jul 21, 2015 7:32 am
by eriksl
Why wouldn't it run? You should be able to increase existing sections size, e.g. nodeMCU has this:
Code: Select allMEMORY
{
  dport0_0_seg :                        org = 0x3FF00000, len = 0x10
  dram0_0_seg :                         org = 0x3FFE8000, len = 0x14000
  iram1_0_seg :                         org = 0x40100000, len = 0x8000
  irom0_0_seg :                         org = 0x40210000, len = 0x80000
}


That sounds promising. I am very curious how they got it working though. If my firmware files together (iram+irom) exceed 236 kb, it stops working altogether, and that's even below the 256 kb (see my other topic about it).

Or maybe it's an esptool.py issue? Can nodemcu be flashed using esptool.py?

BTW this does overwrite the user config area at 0x3c000 and the system config area at 0x7c000!

You should be able to do that as well, but then you'd need to mark part of your code to go to these new sections.

That would be no problem, all my functions are already explicitly section'ed.

Someone first-had experience with this?

I am going to try it step-by-step:

- write a piece of data on, say, 7b000 and read it back, using esptool.py, to check it actually can be done
- try to read the piece of data from the esp8266 itself from my code (the absolute (pointer) address would be 0x40240000 + 0x7b000, right?)

Re: Use all of the 512 kbyte of the 4M flash

PostPosted: Tue Jul 21, 2015 7:41 am
by jcmvbkbc
eriksl wrote:Or maybe it's an esptool.py issue? Can nodemcu be flashed using esptool.py?

I did that successfully.

eriksl wrote:- write a piece of data on, say, 7b000 and read it back, using esptool.py, to check it actually can be done
- try to read the piece of data from the esp8266 itself from my code (the absolute (pointer) address would be 0x40240000 + 0x7b000, right?)

If you write to FLASH at 7b000 with esptool.py that'd be at 0x40200000 + 0x7b000 in physical memory.