How XRP Code Editor interact with firmware?

Is there any documentation about how XRP Code Editor interacts with XRP firmware? I am new to XRP. In other ST-based controllers, I see a USB drive to upload Python codes when I connect the controller via USB. However, with XRP firmware, I see a COM port instead. I guess that COM approach allows XRP Code Editor to use Bluetooth. But how do we use other Python IDEs (VScode, PyCharm, etc) to upload Python source code?

Hi there!

Some MicroPython boards (eg. STM32) show up as a mass storage device (CircuitPython does the same for all boards). However most MicroPython boards actually do not show up as a mass storage device, which is intentional; they instead enumerate as a serial device, and all interactions happen through the serial port.

Why? Well, there’s a long discussion here that you can read with a good post from Damien (lead MicroPython developer) outlining the reasoning. The TLDR is that MicroPython can be configured to show up as a mass storage device (MSC), but it’s not default because of file system limitations. In order to use MSC, the board must be running a FAT filesystem, which is much less performant, more prone to corruption, can have desync problems, etc. If MSC is disabled, then better filesystems that are optimized for microcontrollers (eg. LittleFS) can be used.

We have internally talked about whether to enable MSC for the XRP Controller. It’s actually incredibly simple, just need to add #define MICROPY_HW_USB_MSC 1 to the board definition, and then it just works. It provides a big benefit (drag and drop file management, can edit directly in VS Code or any other editor, etc.), and I personally really want to enable it. However we decided against it for a few reasons, at least for now. The big reason is that we just didn’t have enough time to properly test it, identify all the edge case problems that could happen, and determine solutions and documentation for how to address them. The performance hit was extremely noticeable, the worst of which I found was deleting files (multiple orders of magnitude slower). And I had constant desync problems, where modifying files via the MSC interface or XRPCode would not show up in the other until I reset the board. So it’s not that we don’t want to enable MSC, it’s just that it has pretty substantial downsides; we’d need to find good solutions to these before we’d feel comfortable enabling it.

But how do we use other Python IDEs (VScode, PyCharm, etc) to upload Python source code?

There are a few common tools for interfacing with MicroPython boards via the serial interface. If you’re comfortable with command-line interfaces, mpremote is the standard MicroPython tool. If you prefer to use an IDE of some kind, Thonny is probably the most popular MicroPython IDE. Both of those can be used to upload your Python code.

Other IDEs have some amount of MicroPython support, though I don’t know as much about them. Looks like there’s a MicroPython extension for PyCharm that you could try out. I know the MicroPico extension for VS Code can interact with some MicroPython boards, but currently not all (there’s an open issue about it here, though the developer may not be maintaining the project any more). And XRPCode can be used to upload files as well.

Hope this helps!

1 Like

Hi,
You may try Arduino Labs
" Arduino Lab for MicroPython is a lightweight editor for MicroPython programs, supporting connecting a board, code upload, file transfer and provides an interactive REPL shell." >> from Arduino.cc. They have 2 versions:
One web based: similar to XRP_Code_Editor that needs Chrome, Edge to work. The other, you load to the desktop. Easy to use.

Will take a look at that, thanks!