Replies: 1 comment
-
I could use (to note: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Installing a Moddable SDK project onto the Pico is a little too manual. Each time it is necessary to unplug (or otherwise power cycle) the device while holding down the BOOTSEL button. That's like programming Espressif ESP8266 and ESP32 boards that lack auto-programming circuitry. To streamline builds, I'd like to eliminate the extra step.
Espressif devices use a clever hardware trick both to reboot the device and to enter programming mode. They use the RTS and DTR pins on the serial port to control this. The Pico uses USB to connect to the computer (at least by default) so the physical RTS and DTR pins aren't available. But... they are logically present over the USB CDC connection. Maybe it is possible to emulate the Espressif behavior on the Pico?
The CDC support in TinyUSB invokes an optional
tud_cdc_line_state_cb
callback function whenever the RTS or DTR pins change state. By implementing that function in the Moddable SDK Pico port, we can receive the same RTS and DTR signals as on the Espressif boards and interpret them to both reboot and enter programming mode.Here's a simple implementation that I added to debugger.c.:
If you add this to your build, you get a couple of new capabilities. First, you can debug the currently installed JavaScript app on the Pico without having to also install. Here's the command:
Second, you can force the Pico into programming mode without having to hold down the BOOTSEL button while cycling the power. To do that, use the (undocumented)
-programming
option withserial2xsbug
. You'll need to adjust the serial driver path to match your installation.Here's an example. When you see the "RPI-RP2" disk appear on the desktop, the Pico is ready for programming.
This only works if the Moddable SDK is installed with the
tud_cdc_line_state_cb
function above and a serial connection has been established over USB. If not, you still need to do the power-cycle-with-BOOTSEL-pressed dance.The next step is to integrate this into the build so that it automatically triggers programming mode before installing the firmware image. This also needs to be tested on Linux and Windows. The serial drivers may behave a little differently there which may require some more complex logic in
tud_cdc_line_state_cb
.Beta Was this translation helpful? Give feedback.
All reactions