dhylands / rshell

Remote Shell for MicroPython
MIT License
955 stars 136 forks source link

import binascii if ubinascii not found #181

Closed jerryneedell closed 2 years ago

jerryneedell commented 2 years ago

Circuitpython uses binascii instead of ubinascii. This PR adds a try/except to each import of ubinascii and if it fails, binascii is imported as unbinascii.

This allows shell to be used on CircuitPython Boards that support binascii. Note: some of the "smaller" (e.g. samd21) builds of Circuitpython do not include binascii so rshell cannot be used for them.

This PR was created to support boards like the ESP32C3 which do not have access to the file system via USB. It is likely of limited use for other builds.

This was tested on the ESP32-C3N4(espressif_esp32c3_devkit_1_n4) builds of CircuitPython which has the CircuitPython filesystem writeable by default. This is because the ESP32C3 has no native USB and the usual mounting of the file system as a USB device is not supported. shell is able to read and write to the ESP32C3 file system.

On most CircuitPython builds, the File System is read-only to CIrcuitPython (It is accessible as a USB drive). This means any attempts to write to /pyboard/ will fail. The file system can be made writeable by remounting it in a boot.py script but in general, just copying files to the USB device is much simpler. rshell can still be used to access the REPL and read from the file system. It was tested on an RP2040 Pico and a QTPY ESP32S2.

It was mostly created to demonstrate that the use os binascii in place of ubinascii works. This has come up in the past. See #179