digitalme.co

[TIL] Set up PlatformIO for development on the Adafruit QT Py RP2040

Cover Image for [TIL] Set up PlatformIO for development on the Adafruit QT Py RP2040
Max Scheffler
Max Scheffler

After using many different ESP32 dev boards and building my own PCBs with a range of ESPs, I wanted to give the Raspberry Pi Pico a go. I fired up VS Code after assembling my dev board and started typing in the board name QT Py 2040. I was sure to find the board right away and get coding. Alas, only some unrelated boards showed up:

View of the project creation dialog of the PlatformIO extension in Visual Studio Code. The search query is "qt py" and the results only show non Pico related qt pys.
No Pico related boards in PlatformIO project creator.

An explanation of what's going on can be found on the related GH issue . I followed the setup guide from earlephilhower's arduino-pico repository. Once done, we can take the platform.ini and update it to look as follows:

[env]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
framework = arduino
board_build.core = earlephilhower

[env:qtpy2040]
board = adafruit_qtpy

Note the board name adafruit_qtpy which I found by browsing the variants folder in the earlephilhower\arduino-pico repo.

One last hurdle was to flash the board for the first time. The Pico comes with native USB support and can emulate all kinds of USB devices. This is used to emulate a COM interface that allows further flashing of the board. However, that functionality is part of the flashed image. So we will need to get it flashed initially in a different way. After some figuring out, here are the steps that worked for me on Windows:

  1. Build the project with PlatformIO. It will generate a file in the project directory .pio\build\qtpy2040\firmware.uf2.
  2. On the board, hold down the BOOT button while power cycling. Either by unplugging and plugging in the USB cable or by pressing the RST button.
  3. A new USB drive RPI-RP2 should show up.
  4. Copy the firmware.uf2 onto the drive.
  5. The board should reset and run the new code. It should also show up a new COM interface. 🎉