Robo's esp'ecial ESP8266 fork
Re: Robo's esp'ecial ESP8266 fork
I am blocked again. I have written a simple TCP web server
https://github.com/mianos/micropython/b ... pts/srv.py
and it leaks ram on each connection.
I'll be trying to debug the issue. (I suspect it is a case of the esp socket data or objects being orphaned or tied to the callback and the gc does not think is free).
I'm open to suggestions or any help as to how to fix it.
Every time I start to look at the gc I don't get far. It's starting to be the only area I don't totally grok.
Maybe write a simple module that reflects the strategy in the socket code with the single static instance and isolate it a bit.
https://github.com/mianos/micropython/b ... pts/srv.py
and it leaks ram on each connection.
I'll be trying to debug the issue. (I suspect it is a case of the esp socket data or objects being orphaned or tied to the callback and the gc does not think is free).
I'm open to suggestions or any help as to how to fix it.
Every time I start to look at the gc I don't get far. It's starting to be the only area I don't totally grok.
Maybe write a simple module that reflects the strategy in the socket code with the single static instance and isolate it a bit.
Re: Robo's esp'ecial ESP8266 fork
I think there are some issues with how the GC works on the esp8266 port, since it seems to use much more memory than it should. We will get to fixing it soon!
Re: Robo's esp'ecial ESP8266 fork
I'll try to get into it myself in the meantime. The rest of the system is top notch. I've had some sensors running for months now and no trouble at all. This is the last problem I have.
Re: Robo's esp'ecial ESP8266 fork
Congrats on this! What is it like to call C code from micropython? Seems like you've done that a lot, and being new to this I want to look up How C code is called ( to see how much work it will be to pull in parts of contiki radio networking).To achieve 100% reliability I have integrated the ESP wifi events callbacks.
Now, I can connect to to an access point and be informed when the board receives a DHCP address.
Once I receive this I can proceed to get temperatures etc., and send them to the server.
Does micropython using 32kb of RAM leave half available when running in the ESP's 64kb of RAM?
John Griessen blog.kitmatic.com
Re: Robo's esp'ecial ESP8266 fork
It's trivial. Micropython is built for this. You just put the calls into a table and use some macros that set up the binding and the end of the function. Pretty much every file (mod_esp*) in my project calls C.jgriessen wrote: What is it like to call C code from micropython? Seems like you've done that a lot, and being new to this I want to look up How C code is called ( to see how much work it will be to pull in parts of contiki radio networking).
It's easy the other way too. I am currently implementing a C web server that calls python on GET/POST. You just do this "import esp; aa = esp.ws(callback=lambda aa: print(aa.body())); aa.listen()"
The simplest example of calling and and then python back is probably in esp8266/os_timer.c
There is way less ram free but you can store a lot more stuff in ROM. In the case of code (.text), you can store it in ROM, if you are not calling it in real interrupt handlers, and the CPU will move the it into ram for you. I store all python modules in the ROM but I have to do some byte fidlling before passing it to the interpreter as you can only read from ROM on 4 byte boundaries.Does micropython using 32kb of RAM leave half available when running in the ESP's 64kb of RAM?
The lack of RAM is a constant challenge but with some care and thoughtfully placed garbage collections I can run continuous code without any leaking. I have an app polling one of my ESPs right now, doing 10 per second and it's been running all night.
If you don't make any mistakes with pointers you can achieve the same stability as much larger boards with simpler problems that need less ram.
Re: Robo's esp'ecial ESP8266 fork
Did you get one of the beta ESP32's?The lack of RAM is a constant challenge
If you are developing a product, I'd like to talk about ideas to better promote my stalled kickstarter for outdoor chip radio sensor molded plastic enclosures.
https://www.kickstarter.com/projects/16 ... tdoor-radi
John Griessen blog.kitmatic.com
Re: Robo's esp'ecial ESP8266 fork
No I didn't get the new ESP. I do have a pyboard. I also have a CC3300 dev kit and quite a few other dev kits about.jgriessen wrote:Did you get one of the beta ESP32's?The lack of RAM is a constant challenge
If you are developing a product, I'd like to talk about ideas to better promote my stalled kickstarter for outdoor chip radio sensor molded plastic enclosures.
https://www.kickstarter.com/projects/16 ... tdoor-radi
I rather like the challenge of the ESP8266. It is quite constrained. I think the ridiculously low price point makes it a very different product. I am just finishing up a micro embedded web server (and client that uses mostly the same code) that integrates into micropython in a pythonic way. This makes sensors trivial to manage in either direction.
Code: Select all
import esp
import ujson
def cb(aws):
print(aws.headers())
print(aws.uri())
print(aws.method())
js = ujson.loads(aws.body())
return '{"status": %d}' % counter
# web server, calls cb with the incoming web request
aa = esp.ws(callback=cb, local_port=80)
aa.listen()
# web client, calls cb with result from the remote reply
bb = esp.ws(callback=cb, remote=('131.84.1.118', 8000))
bb.async_send('/status')
Re: Robo's esp'ecial ESP8266 fork
Everything working on my web server and client abstraction and boom, now I have written much more python I'm out of RAM for compilation of the python (even reading the python source code from the external ROM with my frozen from irom module).
I'm going to have to have a try of the pre-compiled python pull.
Does anyone know of an example of a C property example? For example, if I wanted to use request.headers and not request.headers() to make it more like django from a C function that provides the tuple.
I'm going to have to have a try of the pre-compiled python pull.
Does anyone know of an example of a C property example? For example, if I wanted to use request.headers and not request.headers() to make it more like django from a C function that provides the tuple.
Re: Robo's esp'ecial ESP8266 fork
Hi, Is your fork merged into the main micropython yet? (I don't know about the pre-compiled python pull.)
I'm going to try loading your micropython fork into a node.it esp8266 board from sweetpeas.se (a kickstarter that recently completed and delivered)
I'm going to try loading your micropython fork into a node.it esp8266 board from sweetpeas.se (a kickstarter that recently completed and delivered)
John Griessen blog.kitmatic.com
Re: Robo's esp'ecial ESP8266 fork
I just tried compiling the ESP8266 fork on debian with the toolchain from https://github.com/pfalcon/esp-open-sdk and got this error message:
Ideas what went wrong?
Code: Select all
xtensa-lx106-elf-gcc -I../lib/netutils -I. -I.. -I../stmhal -I../lib/mp-readline -I../lib/netutils -I../lib/timeutils -Ibuild -I/opt/esp-open-sdk/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr/include -Idevices -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -nostdlib -DUART_OS=1 -fsingle-precision-constant -Wdouble-promotion -D__ets__ -DICACHE_FLASH -fno-inline-functions -Wl,-EL -mlongcalls -mtext-section-literals -Os -DNDEBUG -fdata-sections -ffunction-sections -c -MD -o build/main.o main.c
main.c:40:28: fatal error: user_interface.h: No such file or directory
#include "user_interface.h"
John Griessen blog.kitmatic.com