out of mpfshell, rshell and ampy only mpfshell continues working after putting main.py on a board

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
johannes
Posts: 8
Joined: Mon Oct 22, 2018 1:29 am

out of mpfshell, rshell and ampy only mpfshell continues working after putting main.py on a board

Post by johannes » Fri Oct 26, 2018 3:24 am

Ampy version: 1.0.7
Rshell version: 0.0.16
Mpfshell version: 0.8.1
Board: Wemos Lolin D32
System: Debian Buster

I already have submitted the following issues to the `ampy` and `rshell` github repositories [1,2]. Since i'm not sure, whether it's really related to the software, i post a summary of the issue here and maybe i'm lucky and someone can lead me in the right direction.

Best regards

################################################################################################

Steps to reproduce the issue with `rshell`
  1. Erase the flash with `esptool.py --chip esp32 erase_flash`
  2. Flash Micropython to the board with `esptool.py --baud 600000 --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20181024-v1.9.4-674-g27ca9ab8b.bin`
  3. Put `main.py` on the board with ` rshell -b 115200 -p /dev/ttyUSB0 rsync . /pyboard`
  4. Press the reset button on the board so that `main.py` runs (Execution of `main.py` starts without any issues -> LEDs start blinking)
  5. Try to put `main.py` on the board again with `rshell -b 115200 -p /dev/ttyUSB0 rsync . /pyboard`
After step 5 `rshell` exits with

Code: Select all

Connecting to /dev/ttyUSB0 ...
b'OK\r\nets Jun  8 2016 00:22:57\r\n\r\nrst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)\r\nconfigsip: 0, SPIWP:0xee\r\nclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00\r\nmode:DIO, clock div:2\r\nload:0x3fff0018,len:4\r\nload:0x3fff001c,len:4732\r\nload:0x40078000,len:7496\r\nload:0x40080400,len:5512\r\nentry 0x4008114c\r\n\x1b[0;33mW (86) boot: PRO CPU has been reset by WDT.\x1b[0m\r\n\x1b[0;33mW (86) boot: WDT reset info: PRO CPU PC=0x40080200\x1b[0m\r\n\x1b[0;33mW (86) boot: WDT reset info: APP CPU PC=0xb2dd3d3b\x1b[0m\r\n\x1b[0;32mI (463) cpu_start: Pro cpu up.\x1b[0m\r\n\x1b[0;32mI (463) cpu_start: Single core mode\x1b[0m\r\n\x1b[0;32mI (463) heap_init: Initializing. RAM available for dynamic allocation:\x1b[0m\r\n\x1b[0;32mI (467) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM\x1b[0m\r\n\x1b[0;32mI (473) heap_init: At 3FFC4F68 len 0001B098 (108 KiB): DRAM\x1b[0m\r\n\x1b[0;32mI (479) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM\x1b[0m\r\n\x1b[0;32mI (485) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM\x1b[0m\r\n\x1b[0;32mI (492) heap_init: At 40091604 len 0000E9FC (58 KiB): IRAM\x1b[0m\r\n\x1b[0;32mI (498) cpu_start: Pro cpu start user code\x1b[0m\r\n\x1b[0;32mI (68) cpu_start: Starting scheduler on PRO CPU.\x1b[0m\r\nalloc_emergency_exception_buf done\r\nLet\'s start blinking\r\nMicroPython v1.9.4-674-g27ca9ab8b on 2018-10-24; ESP32 module with ESP32\r\nType "help()" for more information.\r\n>>> '
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/rshell/main.py", line 1197, in connect
    ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/rshell", line 11, in <module>
    load_entry_point('rshell==0.0.16', 'console_scripts', 'rshell')()
  File "/usr/local/lib/python3.6/dist-packages/rshell/command_line.py", line 4, in main
    rshell.main.main()
  File "/usr/local/lib/python3.6/dist-packages/rshell/main.py", line 2730, in main
    real_main()
  File "/usr/local/lib/python3.6/dist-packages/rshell/main.py", line 2692, in real_main
    connect(args.port, baud=args.baud, wait=args.wait, user=args.user, password=args.password)
  File "/usr/local/lib/python3.6/dist-packages/rshell/main.py", line 1203, in connect
    connect_serial(port, baud=baud, wait=wait)
  File "/usr/local/lib/python3.6/dist-packages/rshell/main.py", line 1227, in connect_serial
    dev = DeviceSerial(port, baud, wait)
  File "/usr/local/lib/python3.6/dist-packages/rshell/main.py", line 1473, in __init__
    Device.__init__(self, pyb)
  File "/usr/local/lib/python3.6/dist-packages/rshell/main.py", line 1285, in __init__
    self.root_dirs = ['/{}/'.format(dir) for dir in self.remote_eval(listdir, '/')]
  File "/usr/local/lib/python3.6/dist-packages/rshell/main.py", line 1390, in remote_eval
    return eval(self.remote(func, *args, **kwargs))
  File "/usr/local/lib/python3.6/dist-packages/rshell/main.py", line 1368, in remote
    self.pyb.enter_raw_repl()
  File "/usr/local/lib/python3.6/dist-packages/rshell/pyboard.py", line 193, in enter_raw_repl
    raise PyboardError('could not enter raw repl')
rshell.pyboard.PyboardError: could not enter raw repl

Steps to reproduce the issue with `ampy`

1. Erase the flash with `esptool.py --chip esp32 erase_flash`
2. Flash Micropython to the board with `esptool.py --baud 600000 --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20181024-v1.9.4-674-g27ca9ab8b.bin`
3. Put `main.py` on the board with ` ampy -p /dev/ttyUSB0 put main.py`
4. Run `main.py` with `ampy -p /dev/ttyUSB0 run main.py` (Execution of `main.py` starts without any issues -> LEDs start blinking)
5. Try to put `main.py` on the board again with `ampy -p /dev/ttyUSB0 put main.py`

After step 5 `ampy` exits with

Code: Select all

Traceback (most recent call last):
  File "/home/johannes/.local/bin/ampy", line 11, in <module>
    sys.exit(cli())
  File "/home/johannes/.local/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/johannes/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/johannes/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/johannes/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/johannes/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/johannes/.local/lib/python3.6/site-packages/ampy/cli.py", line 263, in put
    board_files.put(remote, infile.read())
  File "/home/johannes/.local/lib/python3.6/site-packages/ampy/files.py", line 209, in put
    self._pyboard.exec_("f = open('{0}', 'wb')".format(filename))
  File "/home/johannes/.local/lib/python3.6/site-packages/ampy/pyboard.py", line 265, in exec_
    ret, ret_err = self.exec_raw(command)
  File "/home/johannes/.local/lib/python3.6/site-packages/ampy/pyboard.py", line 256, in exec_raw
    self.exec_raw_no_follow(command);
  File "/home/johannes/.local/lib/python3.6/site-packages/ampy/pyboard.py", line 253, in exec_raw_no_follow
    raise PyboardError('could not exec command')
ampy.pyboard.PyboardError: could not exec command
Steps to reproduce what i have done with `mpfshell`
  1. Erase the flash with `esptool.py --chip esp32 erase_flash`
  2. Flash Micropython to the board with `esptool.py --baud 600000 --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20181024-v1.9.4-674-g27ca9ab8b.bin`
  3. Put `main.py` on the board with ` mpfshell -n -c "open ttyUSB0; put main.py"`
  4. Press the reset button on the board so that `main.py` runs.
  5. Try to put `main.py` on the board again with `mpfshell -n -c "open ttyUSB0; put main.py" without any issues
  6. Look at the code of `main.py` with `mpfshell -c "open ttyUSB0"` and invoke `cat main.py` from within `mpfshell`
Step 6 puts the following on the screen (as proof that everything works fine with `mpfshell`):

Code: Select all

Connected to esp32

** Micropython File Shell v0.8.1, sw@kaltpost.de **
-- Running on Python 2.7 using PySerial 3.4 --

mpfs [/]> cat main.py
import machine
from machine import Pin
from machine import Timer
import micropython


micropython.alloc_emergency_exception_buf(256)

print("alloc_emergency_exception_buf done")

io23 = Pin(23, Pin.OUT)
io05 = Pin(5, Pin.OPEN_DRAIN)

io23.value(1)
io05.value(0)

timer1 = Timer(-1)
timer1.init(mode=Timer.PERIODIC, period=100, callback=lambda t:io23.value(not io23.value()))

timer2 = Timer(-2)
timer2.init(mode=Timer.PERIODIC, period=100, callback=lambda t:io05.value(not io05.value()))

print("Let's start blinking")

mpfs [/]>
[1]: https://github.com/adafruit/ampy/issues ... -374198286
[2]: https://github.com/dhylands/rshell/issu ... -433260583

Post Reply