adafruit / Adafruit_CircuitPython_ESP_ATcontrol

Use the ESP AT command sent to communicate with the Interwebs
MIT License
20 stars 17 forks source link

AT+RST causes nRF52840 UART to hang #5

Closed jerryneedell closed 5 years ago

jerryneedell commented 5 years ago

I'v noticed that if an AT+RST command is executed na nrf52840 board communication with the uart appears to lock up.

This is done routinely in the espatcommand_simpltest.py by the lines

if not esp.soft_reset():
    esp.hard_reset()
    esp.soft_reset()

it works fine if I just comment these out for now, but a real fix should be found but anyone using an nrf52840 should be aware of this.

This does not happen on the SAMD51... AT+RST does generate a big blast of data across the UART so there may be something in the nrf52 that does not handle this well.

ladyada commented 5 years ago

yeah its a burst - if you can make it reproducible we could file an issue !

jerryneedell commented 5 years ago

yup -- If I can't find a way to clear it, I'll see if I can come up with a good way to trigger it without an AT ESP8266 as the trigger then file an issue. It'll be hard for anyone to debug if you need an AT ESP8266 ;-)

jerryneedell commented 5 years ago

One way to clear this condition is to deinit then re-init the uart. Would it be acceptable to pass the TX/RX pins into espatcommands and let it create the uart so it can also it can deinit/init the uart if necessary? or should this be a CP issue and be fixed. I will open a CP issue. this is easily repoduced.

ladyada commented 5 years ago

i want to avoid passing in pins cause then you can't use pyserial. you could always call deinit() whenever you like tho, want to do that before/after hardreset? also, its a CP issue, @hathach will be looking at it in about a week (he needs to get hardware)

jerryneedell commented 5 years ago

opened https://github.com/adafruit/circuitpython/issues/1407
if we deinit, we can't re-init since we won't know pins used... unless there is a way to find them. I think we should just fix it in CP.

ladyada commented 5 years ago

oh yeah hmm good point

hathach commented 5 years ago

I just received the Huzzarh hardware, is setting up circuitpython port to test with.

Update:

could deploy circuitpython to huzzah breakout, but couldn't upload this library using ampy. Not sure why

$ ampy -d 1.5 --port /dev/ttyUSB0 put adafruit_espatcontrol.mpy /lib/adafruit_espatcontrol.mpy
Traceback (most recent call last):
  File "/home/hathach/.local/bin/ampy", line 11, in <module>
    sys.exit(cli())
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/hathach/.local/lib/python3.6/site-packages/ampy/cli.py", line 263, in put
    board_files.put(remote, infile.read())
  File "/home/hathach/.local/lib/python3.6/site-packages/ampy/files.py", line 209, in put
    self._pyboard.exec_("f = open('{0}', 'wb')".format(filename))
  File "/home/hathach/.local/lib/python3.6/site-packages/ampy/pyboard.py", line 267, in exec_
    raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\r\n  File "<stdin>", line 1, in <module>\r\r\nOSError: [Errno 19] Unsupported operation\r\n')

Ok I try to os.mkdir() and and it complains as well

Adafruit CircuitPython 4.0.0-alpha.5-26-g5e4b3a8fb-dirty on 2018-12-26; ESP module with ESP8266
>>> import os                                                                                                                            
>>> os.mkdir("/lib")                                                                                     
Traceback (most recent call last):                                                                       
  File "<stdin>", line 1, in <module>                                                                    
OSError: [Errno 19] Unsupported operation      

tried to put the file to root doesn't help either. @jerryneedell I haven't run cpython on esp8266 before. Maybe I miss something. Break out board is connected via FTDI cable.

ampy -d 1.5 --port /dev/ttyUSB0 put adafruit_espatcontrol.mpy
Traceback (most recent call last):
  File "/home/hathach/.local/bin/ampy", line 11, in <module>
    sys.exit(cli())
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/hathach/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/hathach/.local/lib/python3.6/site-packages/ampy/cli.py", line 263, in put
    board_files.put(remote, infile.read())
  File "/home/hathach/.local/lib/python3.6/site-packages/ampy/files.py", line 209, in put
    self._pyboard.exec_("f = open('{0}', 'wb')".format(filename))
  File "/home/hathach/.local/lib/python3.6/site-packages/ampy/pyboard.py", line 267, in exec_
    raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\r\n  File "<stdin>", line 1, in <module>\r\r\nOSError: [Errno 1] Permission denied\r\n')
ladyada commented 5 years ago

this is... fixed? please re-open if it still comes up!