-->
Page 1 of 2

*How to use all the flash for application? I dont want OTA

PostPosted: Thu May 05, 2016 5:51 am
by Ravi S Kashi
Hi All:

Code size of my application is increasing and currently, I am not interested in losing 256K for OTA.
I am using the ESP_IOT_SDK_v1.5.0_15_11_27.

I am using the Eclipse build setting from this link on Windows- http://www.esp8266.com/viewtopic.php?t=820

My Liker file unmodified is :
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 = 0x40240000, len = 0x3C000
}

Code: Select all14:30:06 **** Build of configuration Release for project Vyuha ****
mingw32-make -f C:/Users/Ravi/workspace/Vyuha/Makefile all
CC driver/uart.c
CC user/usergtdp.c
CC user/user_json.c
CC user/user_main.c
CC user/gtdplite.c
CC mqtt/proto.c
CC mqtt/utils.c
CC mqtt/queue.c
CC mqtt/mqtt_msg.c
CC mqtt/ringbuf.c
CC mqtt/mqtt.c
CC modules/wifi.c
CC modules/config.c
AR build/app_app.a
LD build/app.out
c:/espressif/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/5.1.0/../../../../xtensa-lx106-elf/bin/ld.exe: build/app.out section `.text' will not fit in region `iram1_0_seg'
collect2.exe: error: ld returned 1 exit status
C:/Users/Ravi/workspace/Vyuha/Makefile:189: recipe for target 'build/app.out' failed
mingw32-make: *** [build/app.out] Error 1


I pulled out some code and it compiles, with < 700 bytes of iRAM, What needs to be done?
Code: Select all17:49:36 **** Build of configuration Release for project Vyuha ****
mingw32-make -f C:/Users/Ravi/workspace/Vyuha/Makefile all
CC user/user_main.c
CC user/gtdplite.c
CC mqtt/proto.c
CC mqtt/utils.c
CC mqtt/queue.c
CC mqtt/mqtt_msg.c
CC mqtt/ringbuf.c
CC mqtt/mqtt.c
CC modules/wifi.c
CC modules/config.c
AR build/app_app.a
LD build/app.out
------------------------------------------------------------------------------
Section info:

build/app.out:     file format elf32-xtensa-le

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .data         00000838  3ffe8000  3ffe8000  000000e0  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  1 .rodata       000019c4  3ffe8840  3ffe8840  00000920  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .bss          00006638  3ffea208  3ffea208  000022e8  2**4
                  ALLOC
  3 .text         00007d46  40100000  40100000  000022e4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  4 .irom0.text   0003b904  40240000  40240000  0000a030  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
------------------------------------------------------------------------------
   Section|                   Description| Start (hex)|   End (hex)|Used space
------------------------------------------------------------------------------
      data|        Initialized Data (RAM)|    3FFE8000|    3FFE8838|    2104
    rodata|           ReadOnly Data (RAM)|    3FFE8840|    3FFEA204|    6596
       bss|      Uninitialized Data (RAM)|    3FFEA208|    3FFF0840|   26168
      text|          Uncached Code (IRAM)|    40100000|    40107D46|   32070
irom0_text|             Cached Code (SPI)|    40240000|    4027B904|  243972
------------------------------------------------------------------------------
Entry Point : 40100004 call_user_start()
Total Used RAM : 34868
Free RAM : 47052
Free IRam : 698 or 17082 if 48k IRam
------------------------------------------------------------------------------
Generate 0x00000.bin and 0x40000.bin successully in folder firmware.
0x00000.bin-------->0x00000
0x40000.bin-------->0x40000
Done

How to use all the flash for application? I don't want OTA.

Regards,
Ravi

Re: *How to use all the flash for application? I dont want O

PostPosted: Thu May 05, 2016 7:49 am
by martinayotte
It is not the Flash size limit that your code has reached, but IRAM size limit.
Maybe you have too much variables, such html code stored in strings that takes this precious space.

Re: *How to use all the flash for application? I dont want O

PostPosted: Thu May 05, 2016 9:52 am
by Ravi S Kashi
Hi Martinayotte,

Thanks for the reply. Isn't the code in the FLASH copied to IRAM? I removed some C functions not variables to get the code to compile and link.
Code: Select allbuild/app.out section `.text' will not fit in region `iram1_0_seg'

Re: *How to use all the flash for application? I dont want O

PostPosted: Thu May 05, 2016 10:37 am
by martinayotte
I'm not an expert in the caching mechanism, but for functions, you can try to use ICACHE_FLASH_ATTR function attribute to free up some of the IRAM space. And for data, like big strings as I've mentioned, you can set them with ICACHE_RODATA_ATTR attribute, but maybe you will need to have special functions to access them since there will be 32bits alignments. In Arduino framework, those are wrapped as PROGMEM, and there are functions such memcpy_P() to copy them from Flash to RAM manually.