These are chat archives for esp8266/Arduino

15th
Nov 2016
Rahul-b62
@Rahul-b62
Nov 15 2016 14:23
Hello Guys, currently I am working on SPIFFS , on ESP12E arduino core 2.3.0. I am able to write data into the file. When I use file.position() function to get current position in file , it always return zero. Though I read byte from file , file position remain zero, how do I get the current position of pointer in file so that I can edit the file again????
micw
@micw
Nov 15 2016 20:21
hi
i build some pwm device for my bathroom ligt (led stripes). it communicates via mqtt and uses builtin pwm on D1-D3. when brightness changes, i do lots of analogWrites to fade. for some reason this leads to lot of flicker.
when no analogWrite occurs, there's no flicker
i workarounded it by adding some delay between writes and set pwm frequency to 200
but i wonder if there's a real solution for this issue
Mehrdad K
@mkeyno
Nov 15 2016 20:50
hi @everslick , I can not perform flashEraseSector (then flashWrite) on the part of flash which is out of SPIFF definition, for example for flash setting ESP-12F 2M(1M SPIFF), the flashEraseSector don't work on the remain flash space , should I create new FS object or use another method to writing for such a space
Clemens Kirchgatterer
@everslick
Nov 15 2016 21:26
flashEraseSector might check start and size that come from the linker script. so you might need another flash layout (with no or a very small) SPIFFS partition. still you have to get rid of the global SPIFFS object that is created when compiling with the Arduino IDE.
i guess you have to go for make to accomplish that.
Mehrdad K
@mkeyno
Nov 15 2016 21:29
I can not get rid of current SPIFFS object, because my original files located at , I thought it is possible to mount two or more different SPIFFS objects
Clemens Kirchgatterer
@everslick
Nov 15 2016 21:43
it is, but this will not change start and size symbols that come from the linker script
the global SPIFFS object will use them as start and size parameters and flashEraseSector will use them too
Mehrdad K
@mkeyno
Nov 15 2016 21:49
ok , got it , so I use such following code to change value of _SPIFFS_start & _SPIFFS_end so I could use mine
MyFS = new FS(fs::FSImplPtr(new SPIFFSImpl(512*SPI_FLASH_SEC_SIZE,1*SPI_FLASH_SEC_SIZE , page, block, 1)));
Clemens Kirchgatterer
@everslick
Nov 15 2016 21:50
but i do not see anything in bool flashEraseSector(uint32_t sector); that would stop it from erasing any sector regardless of SPIFFS or linker provided symbols....
@mkeyno this would give you a SPIFFS of 1! sector, which will not work
why do you insist on creating a second SPIFFS partition in the first place?
Mehrdad K
@mkeyno
Nov 15 2016 21:52
MyFS = new FS(fs::FSImplPtr(new SPIFFSImpl(512*SPI_FLASH_SEC_SIZE,512*SPI_FLASH_SEC_SIZE , page, block, 1)));
I've been trying to copy spiff file to remain flash space
Clemens Kirchgatterer
@everslick
Nov 15 2016 21:53
then you will have a second SPIFFS partition. this works, if you have the right flash layout linker script!!!
you said you have 2MByte of flash. how big is the original SPIFFS partition?
Mehrdad K
@mkeyno
Nov 15 2016 21:55
my flash setting set to 2M(1M SIPFF) and I intend to use 2M remain flash space to copy files from SPIFF
Clemens Kirchgatterer
@everslick
Nov 15 2016 21:56
so in reality you have a 4MByte flash?
Mehrdad K
@mkeyno
Nov 15 2016 21:56
yes ESP-12F
Clemens Kirchgatterer
@everslick
Nov 15 2016 21:57
you maybe spi_flash_erase_sector() will not work beyond 2MB then.
i would rather take a 4MB flash layout with a small SPIFFS at the and and use the space between sketch and SPIFFS
this way you can be sure spi_flash_erase_sector() works
Mehrdad K
@mkeyno
Nov 15 2016 22:00
it didn't work, you know with currents setting I have only 1 MB for SPIFF , so I intend use this space such temporary space so I could upload my files then copy to raw flash
with this method I have more space for raw flash writing , but when I use 4M(3M SPIFF) I cant control my SPIFF space , because as you said before SPIFF use scatter method to located files

little problem
error: expected primary-expression before '(' token

MyFS = new FS(fs::FSImplPtr(new SPIFFSImpl(5124096,1004096 , page, block, 1)));

Clemens Kirchgatterer
@everslick
Nov 15 2016 22:11
still, why do you need MyFS then? it is of no use to you
and why don;t you use eagle.flash.4m1m.ld ????
this will give you:
/* Flash Split for 4M chips */ /* sketch 1019KB */ /* empty 2048KB */ /* spiffs 1004KB */ /* eeprom 20KB */
Martin Ayotte
@martinayotte
Nov 15 2016 22:13
@mkeyno and @everslick , If the second location is used as a Raw Flash space, not as a second SPIFFS, then choose Flash size 2MB, and the above 2MB remaining in the 4MB Flash will not bee seen by any execpt your own code. To accomplish that and avoiding the flash functions to fail because outside region, there a method explain here : http://www.packom.org/esp8266/16mb/flash/eeprom/2016/10/14/esp8266-16mbyte-flash_handling.html. (I've recently try it out for accessing 16MB)
Mehrdad K
@mkeyno
Nov 15 2016 22:14
because I could change pre set global parameters (_SPIFFS_start, _SPIFFS_end) so I could perform flashearase for remain raw space
Mehrdad K
@mkeyno
Nov 15 2016 22:19
thanks @martinayotte but I don't intend to use raw space for another SPIFF directory , I just want ESP.flashEraseSector can erase that space so I could use ESP.flashWrite to copy my files from SPIFF to raw space
Clemens Kirchgatterer
@everslick
Nov 15 2016 22:20
again, last try: setting SPIFFS to another location WILL NOT CHANGE the behaviour of flash reading, writing and erasing functions!!! if they refuse to work for locations they think is outside of flash address space then there is not much you can do about it, besides using the trick explained in the link provided by @martinayotte.
the cleaner solution is to: use the linker layout 4M1M. this will give you 2,5MB free flash between sketch and SPIFFS.
Clemens Kirchgatterer
@everslick
Nov 15 2016 23:25
@me-no-dev if you are still interested in a shell for the ESP, i have pushed what i have on github: https://github.com/everslick/genesys/tree/master/src
start with console (and telnet) and you see what they pull in as dependencies.