Ported to esp8266!?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Ported to esp8266!?

Post by kfricke » Mon Feb 09, 2015 3:30 pm

fyi: There have already been 9 unique visitors to the link containing my build of the ESP8266 firmware during the last 6 hours. So a little bit of interest seems to be there ;)

raz123
Posts: 2
Joined: Sun Feb 08, 2015 2:47 am

Re: Ported to esp8266!?

Post by raz123 » Mon Feb 09, 2015 5:04 pm

kfricke wrote:Sure, check this link (valid only for two days!). Good luck with it and please report back here!
I tried your build. Results:

Code: Select all

>>> import pyb; dir(pyb)
['__name__', 'info', 'freq', 'millis', 'elapsed_millis', 'micros', 'elapsed_micros', 'delay', 'udelay', 'sync', 'hard_reset']

>>> import io
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: module not found

>>> import collections
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: module not found
As you can see, the pyb module doesn't contain much for now.
Interestingly, the io and collections module seem to be missing, though the documentation explicitly mentions them:
- Builtin modules: gc, array, collections, io, struct, sys.

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Ported to esp8266!?

Post by kfricke » Mon Feb 09, 2015 7:25 pm

Hm. Finally i got some time and a fine soldering iron to solder my ESP8266 module to start into UART mode. But i am unable to connect to it. My FTDI module's TX LED flashes a few times and then esptool.py just tells "Exception: Failed to connect".

I have wired up my ESP8266 module using the 3.3V line from a pyBoard (should provide enough mA for the ESP8266 to bot up, correct?). GND is shared between pyBoard, ESP8266 module and the FTDI.

When plugging the pyboard into USB the PWR LED on my ESP8266 lights up and i can receive some rubbish on my serial console using the obvious wrong baud rate. During boot the ESP8266 uses a strange baud rate of 75000 which my picocom denies to use.
But seeing that rubbish makes me believe the UART mode has been entered and i should be able to use the esptool.py to takl to it.

Any clues!?

fast62
Posts: 1
Joined: Mon Feb 09, 2015 12:00 pm

Re: Ported to esp8266!?

Post by fast62 » Mon Feb 09, 2015 8:50 pm

hello

sorry for poor my english
after Flashing ESP with firmware-combined , i would like try to connect WIFI .....
but unknow comand.....

try
import pyb is OK

pyb.hard_reset() is OK
and some other comand
but now ...

Thankyou

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Ported to esp8266!?

Post by kfricke » Tue Feb 10, 2015 11:07 am

The port is far from complete or usable. The intent of my post is to try this port out on more ESP8266 hardware and spread the word about MicroPython in the ESP8266 community.
Missing features might frighten some users, but also pulls attention of those who might be able to assist in porting the missing features.

My personal experience with this port sadly still ends at the point where i want to flash my ESP8266. I am still playing with my FTDI adapter (an USB BUB II) which seems to be a little odd. Tonight i will try one of my Raspberry Pis for this purpose. At least the esptool.py should work without the other parts of the ESP toolchain.

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Ported to esp8266!?

Post by kfricke » Wed Feb 11, 2015 12:57 pm

Finally i have solved my issues. Now blaming my stupid somehow borked FTDI adapter (USB BUB II from modern devices) i simply used my Bus Pirate to flash the ESP board, which worked like a charm!

Using the ESP port is quite cool, yet not that usable. You can do the following...

Code: Select all

>>> import esp
>>> esp.scan(print)
Prints out all discovered SSIDs of your WLAN environment to the REPL.

Code: Select all

>>> esp.connect('<ssid>', '<wlan-psk>')
Check your WLAN router for a new host and be amazed!

Code: Select all

>>> esp.disconnect()
Does the obvious.

You already made really cool stuff come true, pfalcon and Damien (and all others involved)!

The flash chip on the ESP board is connected using SPI, so would it be possible to safely access unused areas and store/retrieve your own data there using SPI from MicroPython?

There is no kind of socket support on the ESP, or did i simply miss it? This seems to be an issue a supporter not really used to writing C code and python-bindings (like me) can not tackle, right!?

What parts of the pyb module make sense to be tested or enhanced with concrete examples? My Olimex board has lots of ports i can play with. I am just starting to think about examples we could create to show something to the ESP8266.com community.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Ported to esp8266!?

Post by pfalcon » Thu Feb 12, 2015 3:11 pm

kfricke wrote:@pfalcon: On the official ESP8266 forum i got a request for wifi connection examples. Can you provide some? Due to the fact outlined in my previous post i have not been able to work on this yet. Thanks!
I'm on business trip, so cannot reply quickly, sorry.

Do you mean official forum on bbs.esspressif.com or unofficial on esp8266.com. I don't remember seeing topic about micropython on official Espressif's forum, it's nice if it got there.

So, you can:

Code: Select all

import esp
esp.connect("access_point", "password")
To connect to access point.

Code: Select all

esp.disconnect()
To disconnect.

And

Code: Select all

esp.status()
to check connections status (connected, disconnected, and tried to connect with wrong password should all give different values).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Ported to esp8266!?

Post by kfricke » Thu Feb 12, 2015 4:39 pm

Thanks pfalcon, i figured those exampels out myself already. And also did post them on the esp8266.com (community) forum. If i find some time i will dig through the Esspressif forum and post something there as well.

Meanwhile I would like to (re)start a discussion regarding the ESP8266 port here...

The issue #992: ESP port needs wifi converted into discussion on how to implement really sophisticated socket support on the ESP8266.

My humble opinion regarding this whole port is the following:

The mentioned issue/discussion is an example of over-engineering in the first place. What this "co-operative-mode"/"event-driven platform" port really needs is a 1:1 mapping of the ESP IoT API.
Stateless stuff first (flash access, client UDP communication, ADC, GPIO, sleep modes, timers). Connection based (state-full) thingies second (TCP networking, server focused networking, AT commands) and maybe someday a high-level and socket comfortable Python API.
The "stateless stuff first" approach could avoid most problems based on the event-driven nature of this platform. Callbacks without the the ability to pass user-data can be tackled later when implementing the state-full thingies.

I think most projects based on the ESP8266 tend to be over-engineer as well. Why would one implement a network server on such an limited device? It is cheap as hell and could theoretically run in battery mode (using proper sleep modes and communication methods). So the main strength of this device is the wireless LAN transport media.
Keep it simple and possible to implement a MicroPython driven sensor network! If not MicroPython might miss a foot on the IoT ground, which is defined these days.
Actuators based on this platform should be the second milestone for this port. And networked server gadgets the last, if reasonable at all!

Implementing the initial WIFI stuff as pfalcon did is really great. This way even i can add missing API calls which need no allocated memory on the C code side of this port. (just give me some examples and a C noob can add buggy code ;-) )

Can it be possible to add python code on this platform by adding it into the flash image(s)? It could work by simply flashing some pre-compiled binaries and add a third firmware-brick containing the python code you want to "flash onto" the ESP. The esptool (not ".py") does the job of combining firmware binaries, right?

And not to forget a third topic for this post: Did someone implement a MicroPython "driver" based on the AT-command firmware on the ESP? This approach would need another MicroPython platform (e.g. pyBoard) and connect the ESP module using UART.

sfabris
Posts: 1
Joined: Sat Nov 22, 2014 11:27 pm

Re: Ported to esp8266!?

Post by sfabris » Fri Feb 13, 2015 5:09 pm

kfricke wrote:Finally i have solved my issues. Now blaming my stupid somehow borked FTDI adapter (USB BUB II from modern devices)
Just my two cents on your ftdi adapter: it has a 10k resistor on TX line. It works OK with Arduinos, while esp doesn't like it. Remove it (short the pad) and will work.

I know this because it got me crazy.

Ciao

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: Ported to esp8266!?

Post by kfricke » Fri Feb 13, 2015 9:05 pm

sfabris wrote:
kfricke wrote:Finally i have solved my issues. Now blaming my stupid somehow borked FTDI adapter (USB BUB II from modern devices)
Just my two cents on your ftdi adapter: it has a 10k resistor on TX line. It works OK with Arduinos, while esp doesn't like it. Remove it (short the pad) and will work.

I know this because it got me crazy.
Thanks for this explanation. Good to know. Before I did only use it with my JeeNodes (basically 3.3V Arduinos with built-in RF), so i did stupidly assume to be able to use it for other 3.3V targets :?

Post Reply