Chat freely about anything...

User avatar
By Cool Javelin
#91540 In the olden days, back when computers had only 640 K of ram, there was a trick whereby large programs could overlay part of its code with less used routines to get larger programs than would fit in the RAM.

Is there any way of doing something like that in the ESP8266?

It would require 1 of 2 things I am not sure can exist...
#1, program code would have to run from RAM, (given the limited RAM available this might not be practical) or
#2, a method of changing the program ROM with data from SPIFFS or LittleFS (this would require erasing and programming part of the ROM using some kind of paging.) (Of course, this would exercise the FLASH a lot and may quickly exceed the write cycles of the FLASH.)

I think C++ can handle something like that with the overloading function (I don't know if I am using that term correctly.)

Any ideas?

Thanks, Mark.
User avatar
By eriksl
#91551 The ESP8266 is not really comparable to a PC. One of the most striking differences is that the ESP8266 can execute code directly from FLASH memory. Depending on what model you have, the flash memory can be huge, at least 4 Mbyte but I've heard it can be up to 16 Mbyte. You're never going to get full with your program code.

More restricting is the amount of "normal" RAM, but if you're smart, you can get quite somewhere with the netto ~ 60 Kbytes available. Also there is the small amount of "IRAM" aka ram where code can be stored so it doesn't execute from flash directly. If you keep that to the minimum (i.e. only use it for interrupt handlers), you'll get by too.

Most people don't want to bother though and go for the ESP32 which has double the RAM. The disadvantage of the ESP32, for me, is that it can only be programmed using the IDK, which means absolutely no access to bare metal hardware and little control.
User avatar
By btidey
#91556 Although the flash size can be large (4Mbyte / 16Mbyte) a program is limited to 1MByte due to the hardware cache mechanism on the ESP8266.

I believe it is possible to change the mapping of this 1MByte program space into the flash which in principal would all you to page swap between 1MByte spaces but I don't have any references to examples that achieve this.
User avatar
By eriksl
#91558 Have a look at rboot, it allows for selection of one page of 1 MB for booting (which I am using). I believe, with the proper procedure, you can do that also during runtime. But you will need to take for various things:
- interrupts off
- have all of the SDK code in all page at exactly the same offset
- probably even more