Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout Error with Raspberry Pi Pico - using version 0.0.29 #149

Open
RyanGaudion opened this issue Mar 1, 2021 · 14 comments
Open

Timeout Error with Raspberry Pi Pico - using version 0.0.29 #149

RyanGaudion opened this issue Mar 1, 2021 · 14 comments

Comments

@RyanGaudion
Copy link

I'm using the most recent version released 2 days ago (0.0.29) on Windows 10 however I get timeouts whenever I try to copy files to my Pico. Here are the commands I have used:

rshell
cd Desktop/
cp main.py /pyboard/main.py

I have also tried these variations of the rshell command:

rshell -a
rshell -p COM3 --buffer-size 512
Both of which also timeout (timeout waiting for first EOF reception)

Saving the files through Thonny works as intended so the file itself shouldn't be an issue.

@RyanGaudion
Copy link
Author

Copy of Command Line:

C:\Users\user>rshell
Connecting to COM3 (buffer-size 128)...
Trying to connect to REPL  connected
Retrieving sysname ... rp2
Testing if sys.stdin.buffer exists ... Y
Retrieving root directories ... /main.py/
Setting time ... Mar 01, 2021 20:22:50
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
Welcome to rshell. Use the exit command to exit rshell.
C:\Users\user> cd Desktop/
C:\Users\user/Desktop> cp main.py /pyboard/main.py
Copying 'C:\Users\user/Desktop/main.py' to '/pyboard/main.py' ...
Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Python\Python37\Scripts\rshell-script.py", line 11, in <module>
    load_entry_point('rshell==0.0.29', 'console_scripts', 'rshell')()
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\command_line.py", line 4, in main
    rshell.main.main()
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 3084, in main
    real_main()
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 3067, in real_main
    shell.cmdloop(cmd_line)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 1872, in cmdloop
    cmd.Cmd.cmdloop(self)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 1902, in onecmd
    self.onecmd_exec("".join(group))
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 1913, in onecmd_exec
    return cmd.Cmd.onecmd(self, line)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\cmd.py", line 217, in onecmd
    return func(arg)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 2329, in do_cp
    if not cp(src_filename, dst_filename):
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 685, in cp
    filesize, xfer_func=send_file_to_remote)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 1616, in remote
    output, _ = self.pyb.follow(timeout=20)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\pyboard.py", line 218, in follow
    raise PyboardError('timeout waiting for first EOF reception')
rshell.pyboard.PyboardError: timeout waiting for first EOF reception

@davehylands
Copy link
Collaborator

I think I screwed up the 0.0.29 release. Can you try 0.0.30 instead?

Also, you shouldn't have to specify a buffer size. It should default to 128 (which is the default for the pico).

@RyanGaudion
Copy link
Author

RyanGaudion commented Mar 2, 2021

Hi @davehylands , thanks for the quick reply - just tried with v0.0.30 and it throws the same error:

C:\Users\user>rshell --v
0.0.30

C:\Users\user>rshell
Connecting to COM3 (buffer-size 128)...
Trying to connect to REPL  connected
Retrieving sysname ... rp2
Testing if sys.stdin.buffer exists ... Y
Retrieving root directories ...
Setting time ... Mar 02, 2021 13:33:55
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
Welcome to rshell. Use the exit command to exit rshell.
C:\Users\user> cd Desktop/
C:\Users\user/Desktop> cp main.py /pyboard/main.py
Copying 'C:\Users\user/Desktop/main.py' to '/pyboard/main.py' ...
Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Python\Python37\Scripts\rshell-script.py", line 11, in <module>
    load_entry_point('rshell==0.0.30', 'console_scripts', 'rshell')()
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\command_line.py", line 4, in main
    rshell.main.main()
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 3084, in main
    real_main()
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 3067, in real_main
    shell.cmdloop(cmd_line)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 1872, in cmdloop
    cmd.Cmd.cmdloop(self)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 1902, in onecmd
    self.onecmd_exec("".join(group))
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 1913, in onecmd_exec
    return cmd.Cmd.onecmd(self, line)
  File "c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\cmd.py", line 217, in onecmd
    return func(arg)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 2329, in do_cp
    if not cp(src_filename, dst_filename):
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 685, in cp
    filesize, xfer_func=send_file_to_remote)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\main.py", line 1616, in remote
    output, _ = self.pyb.follow(timeout=20)
  File "C:\Users\user\AppData\Roaming\Python\Python37\site-packages\rshell\pyboard.py", line 218, in follow
    raise PyboardError('timeout waiting for first EOF reception')
rshell.pyboard.PyboardError: timeout waiting for first EOF reception

@davehylands
Copy link
Collaborator

So the fix that makes things work better for some people is this line here:

#rp2: time.sleep_ms(20)

It shows as a comment, but the rshell code "uncomments" any lines that start with #rp2: when the board is a Pico. If you run with rshell -d then you should see that line as uncommented when copying a file.

You could try increasing/decreasing that timeout to see if it helps you.

If you clone the github repository:

git clone https://github.com/dhylands/rshell.git

You can run rshell from the local tree by using:

cd rshell
./r.py ...use whatever rshell options you want here...

@RyanGaudion
Copy link
Author

RyanGaudion commented Apr 19, 2021

@davehylands - thank you for your response and sorry for the long delay in getting back to you. Changing line 1107 to the below resolved the issue:
#rp2: time.sleep_ms(50)

@RyanGaudion
Copy link
Author

@davehylands - I've created a pull request (#154) for this - let me know if I have missed anything within the PR

@davehylands
Copy link
Collaborator

@RyanGaudion PR looks fine. I just need to find some time to make a new release.

@ilan-schemoul
Copy link

In my case increasing the buffer size saved me #168

@willbelr
Copy link

willbelr commented Dec 16, 2021

In my case increasing the buffer size saved me #168

I got the same problem with the Pico. The delay did not help, but setting RPI_PICO_USB_BUFFER_SIZE to 256 did work

rshell 0.0.30-1, Arch Linux

$ rshell
Connecting to /dev/ttyACM0 (buffer-size 128)...
Trying to connect to REPL  connected
Retrieving sysname ... rp2
Testing if sys.stdin.buffer exists ... Y
Retrieving root directories ... /main.py/
Setting time ... Dec 16, 2021 15:33:40
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 1970
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.
/home/user> cp ~/scripts/macropad/main.upy /pyboard/main.py
Copying '/home/user/scripts/macropad/main.upy' to '/pyboard/main.py' ...
timed out or error in transfer to remote: b''

@MasterYuan418
Copy link

Same as you, PyboardError('timeout waiting for first EOF reception')
on 0.0.31, while coping an 256KB file to Pico. Windows 10

@reunano
Copy link

reunano commented Aug 7, 2023

Im getting this error on a LEGO large hub : timed out or error in transfer to remote: b''
Will you be able to guide me on how to trouble shoot? Thank you!

@willbelr
Copy link

willbelr commented Aug 7, 2023

Im getting this error on a LEGO large hub : timed out or error in transfer to remote: b'' Will you be able to guide me on how to trouble shoot? Thank you!

Try using rshell --buffer-size 256

@reunano
Copy link

reunano commented Aug 8, 2023

Thank you for trying to help. This did not solve the issue I still get: /remote/remote.mpy' to '/pyboard/spike/remote.mpy' ...
timed out or error in transfer to remote: b''

@ilium007
Copy link

ilium007 commented Dec 20, 2024

Same here on rshell 0.0.36 and Pico W

Tried setting buffer to 256 (below) but also fails with default buffer of 32.

rshell --buffer-size 256 --port /dev/cu.usbmodem2301 -d
Debug = True
Port = /dev/cu.usbmodem2301
Baud = 115200
User = micro
Password = python
Wait = 0
List = 0
nocolor = 0
ascii = 0
Timing = 0
Quiet = 0
BUFFER_SIZE = 256
Cmd = []
Using buffer-size of 256
Connecting to /dev/cu.usbmodem2301 (buffer-size 256)...
Trying to connect to REPL  connected
Retrieving sysname ... ----- About to send 205 bytes of code to the pyboard -----
def sysname():
    try:
        import os
        return repr(os.uname().sysname)
    except:
        return repr('unknown')
output = sysname()
if output is None:
    print("None")
else:
    print(output)

-----
-----Response-----
b"'rp2'\r\n"
-----
rp2
Testing if ubinascii.unhexlify exists ... ----- About to send 286 bytes of code to the pyboard -----
def test_unhexlify():
    try:
        import ubinascii
    except:
        import binascii as ubinascii
    try:
        _ = ubinascii.unhexlify
        return True
    except:
        return False
output = test_unhexlify()
if output is None:
    print("None")
else:
    print(output)

-----
-----Response-----
b'True\r\n'
-----
Y
Retrieving root directories ... ----- About to send 150 bytes of code to the pyboard -----
def listdir(dirname):
    import os
    return os.listdir(dirname)
output = listdir('/')
if output is None:
    print("None")
else:
    print(output)

-----
-----Response-----
b"['main.py']\r\n"
-----
/main.py/
Setting time ... ----- About to send 1250 bytes of code to the pyboard -----
def set_time(rtc_time):
    rtc = None
    try:
        import pyb
        rtc = pyb.RTC()
        rtc.datetime(rtc_time)
    except:
        try:
            import pycom
            rtc_time2 = (rtc_time[0], rtc_time[1], rtc_time[2], rtc_time[4], rtc_time[5], rtc_time[6])
            import machine
            rtc = machine.RTC()
            rtc.init(rtc_time2)
        except:
            try:
                import machine
                rtc = machine.RTC()
                try:
                    rtc.datetime(rtc_time)
                except:
                    rtc.init(rtc_time)
            except:
                try:
                    import os
                    if os.uname().sysname == 'rp2':
                        setup_0 = rtc_time[0] << 12 | rtc_time[1] << 8 | rtc_time[2]
                        setup_1 = (rtc_time[3] % 7) << 24 | rtc_time[4] << 16 | rtc_time[5] << 8 | rtc_time[6]
                        machine.mem32[0x4005c004] = setup_0
                        machine.mem32[0x4005c008] = setup_1
                        machine.mem32[0x4005c00c] |= 0x10
                except:
                    pass
output = set_time((2024, 12, 20, 5, 21, 3, 4, 0))
if output is None:
    print("None")
else:
    print(output)

-----
-----Response-----
b'None\r\n'
-----
Dec 20, 2024 21:03:04
Evaluating board_name ... ----- About to send 479 bytes of code to the pyboard -----
def board_name(default):
    try:
        import board
        try:
            name = board.name
        except AttributeError:
            name = default
    except ImportError:
        name = default
    except BaseException as err:
        print('Error encountered executing board.py')
        import sys
        sys.print_exception(err)
        name = default
    return repr(name)
output = board_name('pyboard')
if output is None:
    print("None")
else:
    print(output)

-----
-----Response-----
b"'pyboard'\r\n"
-----
pyboard
Retrieving time epoch ... ----- About to send 215 bytes of code to the pyboard -----
def get_time_epoch():
    import time
    try:
      return time.gmtime(0)
    except:
      return (2000, 1, 1, 0, 0, 0, 0, 0)
output = get_time_epoch()
if output is None:
    print("None")
else:
    print(output)

-----
-----Response-----
b'(1970, 1, 1, 0, 0, 0, 3, 1)\r\n'
-----
Jan 01, 1970
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.
/Users/xxxx/Micropython> cp microdot.py /pyboard/microdot.py
Executing "cp microdot.py /pyboard/microdot.py"
----- About to send 215 bytes of code to the pyboard -----
def get_mode(filename):
    import os
    try:
        return os.stat(filename)[0]
    except OSError:
        return 0
output = get_mode('/microdot.py')
if output is None:
    print("None")
else:
    print(output)

-----
-----Response-----
b'0\r\n'
-----
Copying '/Users/xxxx/Micropython/microdot.py' to '/pyboard/microdot.py' ...
----- About to send 1816 bytes of code to the pyboard -----
def recv_file_from_host(src_file, dst_filename, filesize, dst_mode='wb'):
    import sys
    try:
        import ubinascii
    except:
        import binascii as ubinascii
    import os
    if False:
        try:
            import micropython
            micropython.kbd_intr(-1)
        except:
            pass
    try:
        import time
        with open(dst_filename, dst_mode) as dst_file:
            bytes_remaining = filesize
            if not False:
                bytes_remaining *= 2
            buf_size = 256
            write_buf = bytearray(buf_size)
            read_buf = bytearray(buf_size)
            while bytes_remaining > 0:
                sys.stdout.write('\x06')
                read_size = min(bytes_remaining, buf_size)
                buf_remaining = read_size
                buf_index = 0
                while buf_remaining > 0:
                    if False:
                        bytes_read = sys.stdin.buffer.readinto(read_buf, read_size)
                    else:
                        bytes_read = sys.stdin.readinto(read_buf, read_size)
                    time.sleep_ms(20)
                    if bytes_read > 0:
                        write_buf[buf_index:bytes_read] = read_buf[0:bytes_read]
                        buf_index += bytes_read
                        buf_remaining -= bytes_read
                if False:
                    dst_file.write(write_buf[0:read_size])
                else:
                    dst_file.write(ubinascii.unhexlify(write_buf[0:read_size]))
                if hasattr(os, 'sync'):
                    os.sync()
                bytes_remaining -= read_size
        return True
    except:
        return False
output = recv_file_from_host(None, '/microdot.py', 966996)
if output is None:
    print("None")
else:
    print(output)

-----
timed out or error in transfer to remote: b'F'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants