Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By davydnorris
#57494 Found some interesting stuff just now while I was trying to work out an issue with my Makefile.

I stole the body of my Makefile from the one in CHERT's devkit, and I've been using it to flash my examples and couldn't work out why my chip was reporting 32Mbit(512KB+512KB) on startup, when I was using flash mode 6, which should be 32Mbit(1024KB+1024KB).

It turns out there's a bug in CHERT's script - this is what is in his Makefile:
Code: Select all         
ifeq ($(SPI_SIZE_MAP), 6)
    size_map = 6
    flash = 4096
    flashimageoptions += -fs 32m
    ifeq ($(app), 2)
        addr = 0x101000
    endif
...


Setting -fs 32m is actually flash mode 4, and is 32Mbit(512KB+512KB). The correct line is actually:
Code: Select all    flashimageoptions += -fs 32m-c1


But what is more interesting is that in researching this bug, I found several more flash modes, including 32m-c2, 64m and 128m. The last two are pretty obvious, but it was 32m-c2 that caught my eye. It appears this mode is Flash Mode 7, and is 32Mbit(2048KB+2048KB) - and apart from that there doesn't seem to be anything else written about it anywhere.

I assume it gives us approx. 2048KB user space for code, which would be very useful for larger programs, but wouldn't you have to change the ld files as well? The user_rf_cal_sector_set() routine that comes with esp-open-sdk would cope with this fine but the ones written into user_main.c in some of the examples wouldn't

Has anybody used this mode? Experiences?
User avatar
By piersfinlayson
#57501 Am not familiar with this devkit. However, I have done a bunch of work with rboot and some investigation of using 16MB flash. I don't think you're going to be able to get access to > 1MB of space for user code for the ESP8266, as it can only map 1x1MB window (on a 1MB boundary) to 0x40200000 (which is where your app code lives and is executed from) at once.

It is possible to change which 1MB segment is mapped to 0x40200000 dynamically, but it feels like remapping this within a single application would be very complex - and would some serious linker schenanigans to assign different symbols same or overlapping addresses.

What would be more plausible would be to have different, self-contained, applications, each of which is under 1MB (so within the 1MB window), with the applications jumping between each other.

This is how rboot (with big flash) support works.

If someone has an app > 1MB working I'd be very interested to hear more (although I don't see the practical need).
User avatar
By davydnorris
#57519
piersfinlayson wrote:Am not familiar with this devkit. However, I have done a bunch of work with rboot and some investigation of using 16MB flash. I don't think you're going to be able to get access to > 1MB of space for user code for the ESP8266, as it can only map 1x1MB window (on a 1MB boundary) to 0x40200000 (which is where your app code lives and is executed from) at once.

It is possible to change which 1MB segment is mapped to 0x40200000 dynamically, but it feels like remapping this within a single application would be very complex - and would some serious linker schenanigans to assign different symbols same or overlapping addresses.

What would be more plausible would be to have different, self-contained, applications, each of which is under 1MB (so within the 1MB window), with the applications jumping between each other.

This is how rboot (with big flash) support works.

If someone has an app > 1MB working I'd be very interested to hear more (although I don't see the practical need).


Fantastic info - thanks very much!! And thanks also for the head's up on rboot as well - will have to have a look at that.

The multiple app concept may actually be exactly what I need - I am in the middle of an IoT project that has one unit that initially starts in setup mode, and then can be configured as a standalone sensor with direct Wifi, a sensor in a mesh, or a mesh gateway. This idea may let me build the different pieces as separate 256 or 512KB flashes and then combine them into a single with switching at boot time
User avatar
By piersfinlayson
#57535
davydnorris wrote:The multiple app concept may actually be exactly what I need - I am in the middle of an IoT project that has one unit that initially starts in setup mode, and then can be configured as a standalone sensor with direct Wifi, a sensor in a mesh, or a mesh gateway. This idea may let me build the different pieces as separate 256 or 512KB flashes and then combine them into a single with switching at boot time


You could definitely do this with rboot - there's basically no limit to the number of application images you can have, so long as each one is <1MB, and they are aligned so as not to cross a 1MB boundary. I've successfully booted an app image off the 16th MB of a 16MB flash chip (although booting from above 4MB introduces some extra challenges!).

The approach I've taken with rboot is here:

http://www.packom.net/esp8266/rboot/boo ... p8266.html

Richard Burton's blog (he's the original author of rboot) has lots of very useful info about rboot:

http://richard.burtons.org/tag/rboot/