reboot after text paste?

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:

reboot after text paste?

Post by gojimmypi » Wed Mar 23, 2016 1:05 am

I've been having problems with the "Ctrl-E" (right click to paste) and "Ctrl-D" to send a block of text to the ESP8266 via Putty. I would occasionally get error messages for code that otherwise looks ok. Sometimes it would appear some text got "lost" in transit. And now while pasting, I ended up with a reboot:

Code: Select all

===
=== from maNLR jump failed

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 30312, room 16
tail 8
chksum 0x10
load 0x3ffe8000, len 1000, room 0
tail 8
chksum 0xbe
load 0x3ffe83f0, len 360, room 0
tail 8
chksum 0x64
csum 0x64
▒l▒▒▒▒2▒▒sob▒▒▒l▒▒
B▒$
"쌜▒▒▒l▒▒▒b▒#$`don't use rtc mem data
(...some garbage chars removed...)
l#l▒▒ln▒prcould not open file 'boot.py' for reading

#4 ets_task(40100278, 3, 3fff4658, 4)
MicroPython v1.6-336-g6f5af76-dirty on 2016-03-16; ESP module with ESP8266
Type "help()" for more information.
Anyone else see anything similar?

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

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

And on this topic - is there any sort of editor or better mechanism for getting code onto the ESP8266?

thanks

wendlers
Posts: 47
Joined: Wed Mar 16, 2016 10:07 pm

Re: reboot after text paste?

Post by wendlers » Wed Mar 23, 2016 7:09 am

gojimmypi wrote: And on this topic - is there any sort of editor or better mechanism for getting code onto the ESP8266?
Have you tried the "pyboard.py" utility from the repo?

https://github.com/micropython/micropyt ... pyboard.py

You could use it from the command line to push code from a file to the ESP and execute it. E.g. push the content of "myfile.py" to the ESP:

Code: Select all

python pyboard.py --device /dev/ttyUSB0 myfile.py
If "myfile.py" execution outputs something, pyboard will follow that output and display it.

Or you could execute a single line of Python code like so:

Code: Select all

python pyboard.py --device /dev/ttyUSB0 -c 'print("hello wolrd!")'

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

Re: reboot after text paste?

Post by gojimmypi » Wed Mar 23, 2016 6:01 pm

thanks for that! yes, the "pyboard.py" works perfectly to upload! (well, from my Raspberry Pi). This forum has a good thread with tips & suggestions for the Linux option; I posted my comments here: http://forum.micropython.org/viewtopic. ... t=10#p9623

I also have python 3.5 on my Windows 7 machine, and pyboard.py initially gave this error:

Code: Select all

D:\Python>python pyboard.py --device COM10
Traceback (most recent call last):
  File "pyboard.py", line 327, in <module>
    main()
  File "pyboard.py", line 314, in main
    pyb = Pyboard(args.device, args.baudrate, args.user, args.password, args.wait)
  File "pyboard.py", line 125, in __init__
    import serial
ImportError: No module named 'serial'
so I installed pyserial https://pypi.python.org/pypi/pyserial (see also https://github.com/pyserial/pyserial). The fatal error went away, but still does not work:

Code: Select all

D:\Python>python pyboard.py --device COM10 -c 'print("hello world")'

D:\Python>python pyboard.py --device COM10 myI2C.py
Traceback (most recent call last):
  File "<stdin>", line 1
SyntaxError: invalid syntax

D:\Python>
Note that the print "Hello World" seems to do nothing: no error, no message. And uploading the same file I have on the Rpi, instead fails. (I would receive similar errors when pasting text into putty).

Is "pyserial" what I should have installed?

Perhaps a crappy Windows device driver? The UART on my board is recognized in Windows as Silicon Labs CP210x USB to UART Bridge (COM10). I confirmed the Windows settings are 115200 8N1, no flow control.

is there a way to adjust the baud rate on the ESP8266? (thinking a slower rate may be more windows friendly?)

I've also experimented with the advanced settings "Use FIFO buffers" on & off... no luck.

any other tips for a Windows user? (other than "use Linux instead" ;) )

thanks!

wendlers
Posts: 47
Joined: Wed Mar 16, 2016 10:07 pm

Re: reboot after text paste?

Post by wendlers » Wed Mar 23, 2016 7:39 pm

Hi,
Is "pyserial" what I should have installed?
Yes. PySerial is the module needed for the "pyboard.py".
Note that the print "Hello World" seems to do nothing: no error, no message
Have you tried to make "pyboard" follow the output - e.g. like so:

Code: Select all

python pyboard.py --device COM10 --follow -c "print('hello world')"

Code: Select all

D:\Python>python pyboard.py --device COM10 myI2C.py
Traceback (most recent call last):
  File "<stdin>", line 1
SyntaxError: invalid syntax
The error you get here is the Exception that happend on the ESP. This means, that your file has been uploaded, but that micropython was not happy with it because of an syntax error.
Perhaps a crappy Windows device driver? The UART on my board is recognized in Windows as Silicon Labs CP210x USB to UART Bridge (COM10). I confirmed the Windows settings are 115200 8N1, no flow control.


I think if it would need some crappy driver, it would not offer the COM port. The settings you mention are fine. But since I really have no glue about Windows, I could not help much here.
is there a way to adjust the baud rate on the ESP8266? (thinking a slower rate may be more windows friendly?)
I think this is done here:

Code: Select all

esp8266/esp_mphal.c:    uart_init(UART_BIT_RATE_115200, UART_BIT_RATE_115200);
The following rates should be supported:

Code: Select all

UART_BIT_RATE_9600
UART_BIT_RATE_19200
UART_BIT_RATE_38400
UART_BIT_RATE_57600
UART_BIT_RATE_74880
UART_BIT_RATE_115200
UART_BIT_RATE_230400
UART_BIT_RATE_256000
UART_BIT_RATE_460800
UART_BIT_RATE_921600
regards,
stefan

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

Re: reboot after text paste?

Post by gojimmypi » Wed Mar 23, 2016 8:30 pm

Hi Stefan & thanks for your response :)
wendlers wrote:
Note that the print "Hello World" seems to do nothing: no error, no message
Have you tried to make "pyboard" follow the output - e.g. like so:

Code: Select all

python pyboard.py --device COM10 --follow -c "print('hello world')"
the "--follow" is interesting; it prints hello world then drops me into an (inescapable) python prompt in Linux. From Windows, it prints garbage then drops me into a python prompt:

Code: Select all

D:\Python>python pyboard.py --device COM10 --follow -c 'print("hello world")'
╓K╡à╤Ñ╜╣╣
>>>
here, the result makes me think that the baudrate is wrong. but it appears 115200 is the default, and even when explicitly specifying it, I see the same results (no message, cannot exit nor type at REPL)

Code: Select all

D:\Python>python pyboard.py --device COM10 --follow --baudrate 115200 -c 'print("hello world")'

>>>

note I'm able to successfully connect with putty in Windows: COM10; 8N1, 115200, no flow control. (although I do have the occasional bulk-paste problem per this thread topic):

Code: Select all

>>>
PYB: soft reboot
could not open file 'boot.py' for reading
MicroPython v1.6-336-g6f5af76-dirty on 2016-03-16; ESP module with ESP8266
Type "help()" for more information.
>>> print("hello world")
hello world
>>>
wendlers wrote: The error you get here is the Exception that happend on the ESP. This means, that your file has been uploaded, but that micropython was not happy with it because of an syntax error.
hmm... it is the same text that I am able to upload on the RPi with success. I'm thinking the file is uploaded, but for some reason garbled in transit.
wendlers wrote:

Code: Select all

esp8266/esp_mphal.c:    uart_init(UART_BIT_RATE_115200, UART_BIT_RATE_115200);
oooh. being hard-coded, my only option is to recompile, eh? probably not a task I'll be able to do today, but something I should learn. I came across this interesting article on that topic: http://www.esp8266.com/wiki/doku.php?id=toolchain after reading the esp-open-sdk is required for MicroPython rebuild: http://forum.micropython.org/viewtopic.php?f=16&t=1689

I'm probably in the minority in wanting to use Windows... but that's where all my cool development tools are.

<sigh> I wonder if all my hassle is self-inflicted by using a (non-officially supported) china import board. It does however work really well otherwise, and the NodeMCU Lua seemed to be completely happy.

thanks again for your suggestions.

wendlers
Posts: 47
Joined: Wed Mar 16, 2016 10:07 pm

Re: reboot after text paste?

Post by wendlers » Thu Mar 24, 2016 7:22 am

I wonder if all my hassle is self-inflicted by using a (non-officially supported) china import board. It does however work really well otherwise, and the NodeMCU Lua seemed to be completely happy.
I use the china boards a lot my self (LoLin and Geekcreit). As far as I can tell, they work very well with Micropython (and they should come with the same ESP as the Huzzah).

wendlers
Posts: 47
Joined: Wed Mar 16, 2016 10:07 pm

Re: reboot after text paste?

Post by wendlers » Thu Mar 24, 2016 7:29 am

Oh, and I totally forgot to mention, that there is a GUI Tool called ESPlorer. It claims to also support MicroPython. Also I did not try it with MP, I could confirm it works well with Lua. Maybe have a look:

http://esp8266.ru/esplorer/

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

Re: reboot after text paste?

Post by gojimmypi » Thu Mar 24, 2016 8:23 pm

wendlers wrote: I use the china boards a lot my self (LoLin and Geekcreit). As far as I can tell, they work very well with Micropython (and they should come with the same ESP as the Huzzah).
That's good to know! I'm curious if you've used your LoLin board in a Linux environment? My Amica board gets recognized without problem, but the LoLin does not (no dev/ttyUSB0 shows up). The LoLin however works great from Windows.

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

Re: reboot after text paste?

Post by gojimmypi » Thu Mar 24, 2016 8:44 pm

fwiw - here's an example of the garbled text pasted into Putty in MicroPython "Ctrl-E" mode from Windows. There are 114 lines all exactly the same created in Notepad. Part way in, the text gets garbled.

Code: Select all

...initial lines omitted...
=== print("hello world")
=== print("hello world")
=== print("hello world")
=== print("hello world")
=== print("hworld")
=== print("hello world"nt("hello w)
=== print("hello world")
=== prinllo world")
=== prt("hello worl
=== print("helrld")
=== print("hello world")
=== ("hello worlprint("hello wold")
=== print(o world")
=== print("hello worlrint("hellod")
=== print("hello world")
=== prihello world")int("hello wor")
=== print("hworld")
=== print("hello world"nt("hello world")
=== print("heorld")
=== prinllo world")t("hello world")
=== print("helrld")
=== printlo world")
=== print("hello world")print("hellold")
Traceback (most recent call last):
  File "<stdin>", line 89
SyntaxError: invalid syntax
I've even tried 3 different USB cables from 3 different manufacturers... one just a foot long. All give the same result.

Again - this is the "Amica" board - using the Silicon Labs CP210x on Windows. (works fine on the RPi)

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: reboot after text paste?

Post by dhylands » Thu Mar 24, 2016 10:45 pm

I ran into problems like this even with the pyboard.

In my usb-ser-mon.py I added a small delay between each character and that resolved the problem.

I know some windows terminal programs (like TeraTerm) allow for a character delay.

Post Reply