-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Hi, this is follow-up for micropython/micropython#13786, to not unnecessarily clutter that issue.
So up-front I think I mixed up things in my initial comment, so to clarify the mechanisms mpremote
uses:
-
fs_get
(for direct file transfer e.g. inmpremote cp
): https://github.com/micropython/micropython/blob/42eab32a36f70840c7e670a61269fb795d43991b/tools/mpremote/mpremote/transport_serial.py#L391
This logic uses the standard-python byte-array escaping mechanism. That would escape0x04
but leave ascii characters unchanged, your logic forfs_put
already has that optimization and even tests two different options for an encoding. This works with the webrepl code as is. -
mpremote mount
: https://github.com/micropython/micropython/blob/42eab32a36f70840c7e670a61269fb795d43991b/tools/mpremote/mpremote/transport_serial.py#L719
The mount protocol uses binary file transfer and prefixes packages with a length parameter. This requires a REPL stdout stream that is able to handle arbitrary bytes, as mount "protocol" is inherently binary. The stream is naturally segmented due to the individual read/write commands. For developing locally, I really like thempremote mount
functionality, as it allows virtually immediate "synchronization" without having to use on-device flash, and allowing to load development code directly into device RAM.
When talking about the optimization, I think I mixed things up with the mount
-logic.