So I decided to bite the bullet and develop my framework directly onto the ESP. However, I didn't want to develop it on Linux, which seems to be the standard fare out there. I develop my Arduino/Atmel code using Eclipse on my Windows PC and I like the environment. I found a site out there that documents how to do ESP development via Eclipse.
If that's how you want to roll, here's the link.
Using a USB FTDI Serial cable (at 3.3v Tx & Rx lines) and a little breadboard with a 3.3v regulator (the signals from the cable are 3.3v, but annoyingly the power is 5v), and reset and program switch, I'm able to deliver my code right to the ESP chip.
So I rewrote the Framework to work directly off the ESP. And it works great. I had some challenges. The documentation regarding the ESP is scant and not well organized. I mean you can find the manuals for the API, but it doesn't document the ports, how to set them up, or anything about how memory is organized.
Here's what I learned/figured out:
- There seems to be a lot of RAM (compared to the Arduino), I'd say probably 128K (for variables, stack, etc.)
- There is special section of RAM called IRAM and this is where the program instructions are executed. 32K there (I know because I blew through it quick until I learned the trick).
- There is 512K Flash which lives in SPI ROM. Half of it is used for the kernel and the other for your program.
- IRAM is important because the SPI FLASH is not directly addressable by the processor (i.e. address bus). So any code that needs to be run is placed in IRAM and executed. So how does one run 512K of code in 32K? You don't. Whenever the processor needs to make a call to a function, it checks if it is in the IRAM cache and if not, loads it in from the SPI Flash and then executes it. If it needs room for the function, it tosses an unused piece of code. I suppose the kernel manages all this using interrupts. But the take from this is some code, like functions called from interrupts must be in IRAM all the time, but most doesn't. So if you want to conserve IRAM, you decorate all your functions (not being called by an interrupt) with ICACHE_FLASH_ATTR. If you don't, then the function will get loaded at boot and never bounced and you can burn up IRAM quickly.
I am still working on the code, but I am maintaining it on GitHub here. The GitHub will only have code that somewhat works. As I add stuff, I'll commit it and post a log.