New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create custom SPIFF Size ? #1163

Closed
hallard opened this Issue Dec 6, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@hallard
Contributor

hallard commented Dec 6, 2015

Hi guys

I'm trying to optimize size and the balance to use OTA and SPIFFS on ESP01 1MB Flash chip

Unfortunately my SPIFFS size once compiled/gzipped my framework size is about 132K, just after 128KB limit, next limit is 256KB SPIFFS. Of course I selected this one, but this reduce my global sketch size to approx 768KB/2 (when OTA) so about 384KB (less EEP and SDK Config).
I would like fine adjust SPIFFS used to say 160KB and/or 192KB.
Of course I know what to do this in boards.txt but what about the eagle files ? (linker script ?)
If think I need to create both files eagle.flash.1m160.ld and eagle.flash.1m196.ld but I don't really know what to put in and also if this is the only thing to do ?

Any help or documentation on this would be very helpfull.

Thanks for your help

@Links2004

This comment has been minimized.

Show comment
Hide comment
@Links2004

Links2004 Dec 6, 2015

Collaborator

yes the "ld" files are linker scripts.
you need to increase the code size (len) here:
https://github.com/esp8266/Arduino/blob/master/tools/sdk/ld/eagle.flash.1m512.ld#L11
and move the SPIFFS by the same size you increase the code
https://github.com/esp8266/Arduino/blob/master/tools/sdk/ld/eagle.flash.1m512.ld#L14
the changes need to match the boards.txt

Collaborator

Links2004 commented Dec 6, 2015

yes the "ld" files are linker scripts.
you need to increase the code size (len) here:
https://github.com/esp8266/Arduino/blob/master/tools/sdk/ld/eagle.flash.1m512.ld#L11
and move the SPIFFS by the same size you increase the code
https://github.com/esp8266/Arduino/blob/master/tools/sdk/ld/eagle.flash.1m512.ld#L14
the changes need to match the boards.txt

@hallard

This comment has been minimized.

Show comment
Hide comment
@hallard

hallard Dec 6, 2015

Contributor

@Links2004
Thanks, simple and efficient, I'll give it a try ;-)

By the way is there any alignment I need to respect (1,2,4,8 .. bytes ) ?

last but not least, on 512 script block is set by
PROVIDE ( _SPIFFS_block = 0x2000 );
and on 128 and 256 it's
PROVIDE ( _SPIFFS_block = 0x1000 );
Shouldn't I use 0x1000 for any size between 128K and 256K ?

Contributor

hallard commented Dec 6, 2015

@Links2004
Thanks, simple and efficient, I'll give it a try ;-)

By the way is there any alignment I need to respect (1,2,4,8 .. bytes ) ?

last but not least, on 512 script block is set by
PROVIDE ( _SPIFFS_block = 0x2000 );
and on 128 and 256 it's
PROVIDE ( _SPIFFS_block = 0x1000 );
Shouldn't I use 0x1000 for any size between 128K and 256K ?

@hallard

This comment has been minimized.

Show comment
Hide comment
@hallard

hallard Dec 6, 2015

Contributor

Ok, just tried one 160KB SPIFFS and one 144KB SPIFFS

here are my files

modified boards.txt (just the interesting part)

wifinfo.menu.ESPModule.ESP07160=ESP07 (1M/160K SPIFFS)
wifinfo.menu.ESPModule.ESP07160.build.flash_size=1M
wifinfo.menu.ESPModule.ESP07160.build.flash_ld=eagle.flash.1m160.ld
wifinfo.menu.ESPModule.ESP07160.build.spiffs_start=0xD3000
wifinfo.menu.ESPModule.ESP07160.build.spiffs_end=0xFB000
wifinfo.menu.ESPModule.ESP07160.build.spiffs_blocksize=4096
wifinfo.menu.ESPModule.ESP07160.upload.maximum_size=860144

wifinfo.menu.ESPModule.ESP07144=ESP07 (1M/144K SPIFFS)
wifinfo.menu.ESPModule.ESP07144.build.flash_size=1M
wifinfo.menu.ESPModule.ESP07144.build.flash_ld=eagle.flash.1m144.ld
wifinfo.menu.ESPModule.ESP07144.build.spiffs_start=0xD7000
wifinfo.menu.ESPModule.ESP07144.build.spiffs_end=0xFB000
wifinfo.menu.ESPModule.ESP07144.build.spiffs_blocksize=4096
wifinfo.menu.ESPModule.ESP07144.upload.maximum_size=876528

and the 2 linker scripts

  • eagle.flash.1m160.ld
/* Flash Split for 1M chips */
/* sketch 839KB */
/* spiffs 160KB */
/* eeprom 20KB */

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 = 0x40201010, len = 0xd1ff0
}
PROVIDE ( _SPIFFS_start = 0x402D3000 );
PROVIDE ( _SPIFFS_end = 0x402FB000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x1000 );
INCLUDE "../ld/eagle.app.v6.common.ld"
  • eagle.flash.1m144.ld
/* Flash Split for 1M chips */
/* sketch 855KB */
/* spiffs 144KB */
/* eeprom 20KB */

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 = 0x40201010, len = 0xd5ff0
}
PROVIDE ( _SPIFFS_start = 0x402D7000 );
PROVIDE ( _SPIFFS_end = 0x402FB000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x1000 );
INCLUDE "../ld/eagle.app.v6.common.ld"
Contributor

hallard commented Dec 6, 2015

Ok, just tried one 160KB SPIFFS and one 144KB SPIFFS

here are my files

modified boards.txt (just the interesting part)

wifinfo.menu.ESPModule.ESP07160=ESP07 (1M/160K SPIFFS)
wifinfo.menu.ESPModule.ESP07160.build.flash_size=1M
wifinfo.menu.ESPModule.ESP07160.build.flash_ld=eagle.flash.1m160.ld
wifinfo.menu.ESPModule.ESP07160.build.spiffs_start=0xD3000
wifinfo.menu.ESPModule.ESP07160.build.spiffs_end=0xFB000
wifinfo.menu.ESPModule.ESP07160.build.spiffs_blocksize=4096
wifinfo.menu.ESPModule.ESP07160.upload.maximum_size=860144

wifinfo.menu.ESPModule.ESP07144=ESP07 (1M/144K SPIFFS)
wifinfo.menu.ESPModule.ESP07144.build.flash_size=1M
wifinfo.menu.ESPModule.ESP07144.build.flash_ld=eagle.flash.1m144.ld
wifinfo.menu.ESPModule.ESP07144.build.spiffs_start=0xD7000
wifinfo.menu.ESPModule.ESP07144.build.spiffs_end=0xFB000
wifinfo.menu.ESPModule.ESP07144.build.spiffs_blocksize=4096
wifinfo.menu.ESPModule.ESP07144.upload.maximum_size=876528

and the 2 linker scripts

  • eagle.flash.1m160.ld
/* Flash Split for 1M chips */
/* sketch 839KB */
/* spiffs 160KB */
/* eeprom 20KB */

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 = 0x40201010, len = 0xd1ff0
}
PROVIDE ( _SPIFFS_start = 0x402D3000 );
PROVIDE ( _SPIFFS_end = 0x402FB000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x1000 );
INCLUDE "../ld/eagle.app.v6.common.ld"
  • eagle.flash.1m144.ld
/* Flash Split for 1M chips */
/* sketch 855KB */
/* spiffs 144KB */
/* eeprom 20KB */

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 = 0x40201010, len = 0xd5ff0
}
PROVIDE ( _SPIFFS_start = 0x402D7000 );
PROVIDE ( _SPIFFS_end = 0x402FB000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x1000 );
INCLUDE "../ld/eagle.app.v6.common.ld"

@hallard hallard referenced this issue Dec 7, 2015

Open

mkspiffs #11

@Links2004

This comment has been minimized.

Show comment
Hide comment
@Links2004

Links2004 Dec 7, 2015

Collaborator

a smaller block size the 0x1000 (4KB) make no sense since the SPI flash block size is 4KB.
yes 0x1000 is ok.
the aliment shut always be to 4KB (internal flash block size) for data areas that are changed by software.
for code (irom0_0_seg the minimum alignment is 4 but 16 is recommended)

you changes looking good.

Collaborator

Links2004 commented Dec 7, 2015

a smaller block size the 0x1000 (4KB) make no sense since the SPI flash block size is 4KB.
yes 0x1000 is ok.
the aliment shut always be to 4KB (internal flash block size) for data areas that are changed by software.
for code (irom0_0_seg the minimum alignment is 4 but 16 is recommended)

you changes looking good.

@hallard

This comment has been minimized.

Show comment
Hide comment
@hallard

hallard Dec 7, 2015

Contributor

@Links2004
Thanks for your help, I need now to check with @igrr my strange SPIFFS size problem ;-)

Contributor

hallard commented Dec 7, 2015

@Links2004
Thanks for your help, I need now to check with @igrr my strange SPIFFS size problem ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment