howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
gojimmypi
Posts: 36
Joined: Wed Mar 02, 2016 8:01 pm
Contact:

howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by gojimmypi » Thu Mar 10, 2016 3:54 am

Damien & team - thank you! Awesome kickstarter project :D :D

I have a ebay/china import ESP8266 NodeMCU "Amica" board like this one:

http://www.ebay.com/itm/400923947498

I know that the email said only esptool.py was supported to download firmware, but I used the the NodeMCU-flasher:

https://github.com/nodemcu/nodemcu-flasher (see the Win64/Release for pre-compiled code)

Here are the settings I used:

Baudrate: 460800
Flash size 8MB
Flash Speed 40Mz
SPI Mode DIO

I get something like this in the log:

Code: Select all

Note:Program flash success.
... lots of them...
Note:Program flash success.
Note:Serial port disconnected.
With a config address set to 0x00000

(I did load the nodemcu-flasher-master\Resources\Binaries\blank.bin also at 0x00000 before flashing on one board, and then not on another: both worked)

Note that when finished flashing, the tool does not reset on its own, so power cycle or press reset button to actually get MicroPython firware working.

When I connect with putty (using 115200 8/N/1, no parity, no flow control), I get this:

Code: Select all

▒▒▒▒"l▒r▒$▒$cl▒▒$n▒p{
                     could not find module 'boot'

#4 ets_task(40100268, 3, 3fff4658, 4)
MicroPython v1.5.2-395-g5f6d12c on 2016-03-08; ESP module with ESP8266
Type "help()" for more information.
>>>
which looks very promising! woohoo!!
Attachments
ESP8266 Hello World MicroPython.PNG
ESP8266 Hello World MicroPython.PNG (8.34 KiB) Viewed 20244 times

gojimmypi
Posts: 36
Joined: Wed Mar 02, 2016 8:01 pm
Contact:

Re: howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by gojimmypi » Fri Mar 11, 2016 6:25 pm

follow-up: if you came here looking for info on flashing MicroPython onto an ESP8266 with NodeMCU-Flasher tool (and *not* esptool.py Flasher)... then you should know know that there are some settings that could be retained. See http://forum.micropython.org/viewtopic. ... 9343#p9333.

Adafruit has an excellent online tutorial for both methods here: https://learn.adafruit.com/building-and ... h-firmware

sibir
Posts: 9
Joined: Tue Jan 17, 2017 1:18 pm

Re: howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by sibir » Tue Jan 17, 2017 2:10 pm

Hi there,

I believe I bought the same board on Amazon listed as "HiLetgo NodeMCU LUA WiFi Internet ESP8266 Development Board ESP-12E"

I installed the Silicon Labs CP210x driver and flashed my board with esp8266-20161110-v1.8.6.bin using the nodeMCU tool (ESP8266Flasher.exe) just as you did and all looked good. (No need to press FLASH button because USB takes care of it).

But I never got a boot message or prompt. When I connect with a terminal program and press the reset button I just get some garbage like: `þ1M@üÊúã9ì @l°ÔþEÂ[]À$t

After I flash the board with nodeMCU (internal default provided with ESP8266Flasher), connect with a terminal, and press RST I get one line of garbage first but then a boot message and a prompt. So I know the ESP8266Flasher works. But what else can be wrong?

sibir
Posts: 9
Joined: Tue Jan 17, 2017 1:18 pm

Re: howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by sibir » Wed Jan 18, 2017 4:12 am

It appears after flashing my ESP8266 with microPython the serial port speed is 115200 (8N1 no flow control).
I went through all other speeds and only 115200 worked. nodeMCU was more forgiving...
A reset still produces a chunk of garbage but then I get the Python prompt.

tonyp
Posts: 2
Joined: Wed Jan 18, 2017 6:54 pm

Re: howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by tonyp » Wed Jan 18, 2017 7:29 pm

I flashed the current stable micropython (MicroPython v1.8.6-7-gefd0927 on 2016-11-10; ESP module with ESP8266) with the ESP8266Flasher.exe utility and found this thread after googling about some problem I noticed.

So, I'd like to ask if apart from being able to 'play' interactively with micropython, does the filesystem behave correctly for some more useful work?

This is on NodeMCU v1.0 with 4MB flash (incidentally bought from the China seller on eBay) so there should be enough memory for it to work.

I get this:

>>> import os
>>> os.listdir()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV
>>>

>>> esp.flash_size()
4194304

>>> esp.info()
_text_start=40100000
_text_end=40107d18
_irom0_text_start=40209000
_irom0_text_end=4028a2cc
_data_start=3ffe8000
_data_end=3ffe8444
_rodata_start=3ffe8450
_rodata_end=3ffe9008
_bss_start=3ffe9008
_bss_end=3fff8c28
_heap_start=3fff8c28
_heap_end=3fffc000
qstr:
n_pool=1
n_qstr=9
n_str_data_bytes=98
n_total_bytes=2018
GC:
36288 total
4000 : 32288
1=37 2=8 m=120

Any ideas?

sibir
Posts: 9
Joined: Tue Jan 17, 2017 1:18 pm

Re: howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by sibir » Thu Jan 19, 2017 2:36 am

For me it works:

MicroPython v1.8.7-7-gb5a1a20a3 on 2017-01-09; ESP module with ESP8266
Type "help()" for more information.
>>> os.listdir()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'os' is not defined
>>> import os
>>> os.listdir()
['boot.py']
>>>

tonyp
Posts: 2
Joined: Wed Jan 18, 2017 6:54 pm

Re: howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by tonyp » Thu Jan 19, 2017 12:19 pm

I figured out the problem.

Apparently due to having experimented with various versions of Lua before the memory needed some cleaning.

It *appears* that ESP8266Flasher.exe does not erase the whole flash before programming the new image. (Possibly it only erases the section to be programmed. I don't know, but obviously something isn't completely erased before programming the new image.)

I tried with esptool.py (and Python27), using the write_flash command, and got the same problem: the filesystem was not working correctly.
Finally I tried to do it in three steps: first erase the flash with the erase_flash command, then write_flash, and to be sure verify_flash command using the esptool.py

So, here's my take that works 100% for loading either Micropython or Lua. Here's the part for Micropython:

c:\Python27\python.exe \Python27\Lib\site-packages\esptool.py --port COM8 --baud 460800 erase_flash
c:\Python27\python.exe \Python27\Lib\site-packages\esptool.py --port COM8 --baud 460800 write_flash --flash_size=detect 0 esp8266-20170108-v1.8.7.bin
c:\Python27\python.exe \Python27\Lib\site-packages\esptool.py --port COM8 --baud 460800 verify_flash --flash_size=detect 0 esp8266-20170108-v1.8.7.bin

I hope this helps others encountering the same problem.

JayBk
Posts: 1
Joined: Sat Mar 04, 2017 2:47 am

Re: howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by JayBk » Sat Mar 04, 2017 2:51 am

[quote="tonyp"]I figured out the problem.

So, here's my take that works 100% for loading either Micropython or Lua. Here's the part for Micropython:

c:\Python27\python.exe \Python27\Lib\site-packages\esptool.py --port COM8 --baud 460800 erase_flash
c:\Python27\python.exe \Python27\Lib\site-packages\esptool.py --port COM8 --baud 460800 write_flash --flash_size=detect 0 esp8266-20170108-v1.8.7.bin
c:\Python27\python.exe \Python27\Lib\site-packages\esptool.py --port COM8 --baud 460800 verify_flash --flash_size=detect 0 esp8266-20170108-v1.8.7.bin

I hope this helps others encountering the same problem.[/quote]

Hey, I was having some trouble recently. Stumbled across this ans saw what you posted. I decided to use esptool.py and try what you did and everything ran flawlessly. Just wanted to thank you for the solution!

ggm3888
Posts: 2
Joined: Sat Mar 25, 2017 6:30 pm

Re: howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by ggm3888 » Sat Mar 25, 2017 6:32 pm

Sometimes you can find an ESP8266 that has been pre-loaded with micropython on ebay.

icenov
Posts: 9
Joined: Sun Mar 12, 2017 1:27 am

Re: howto: Flash MicroPython with nodemcu flasher and connect with putty on Windows

Post by icenov » Mon Mar 27, 2017 9:26 pm

I was also having problems loading micropython on my esp8266 using Linux terminal. Similar symptoms of no response except blue led almost continuously flashing. Followed your guide and now it works! Thank you!
I used gtkterm and esptool.py.

Post Reply