0

QT Py RP2040 C Pico SDK Question
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

QT Py RP2040 C Pico SDK Question

by rbeiter on Mon Apr 19, 2021 8:15 pm

Hello,

I'm having an odd problem getting Pico C SDK code to run on the QT Py RP2040.

Compiling the code to a UF2 package and installing it after activating the UF2 bootloader mount works great - the sample application runs and toggles A0 as expected once the RP2040 resets after the UF2 is initially updated.

Once power is removed/re-applied or the RESET button is tapped though, the application no longer runs.

Sample project lives here: https://github.com/rbeiter/qt-py-rp2040-blink

Are any other configurations required when using the C Pico SDK instead of Circuit Python? I tried installing the Circuit Python UF2 package just to ensure it wasn't a board issue, and Circuit Python starts up and runs the applied python code fine every time.

Thank you,
Randy

rbeiter
 
Posts: 4
Joined: Mon Apr 19, 2021 8:09 pm

Re: QT Py RP2040 C Pico SDK Question

by mikeysklar on Tue Apr 20, 2021 4:10 pm

Randy,

We don't have a lot of experience with the C Pico SDK, but a quick google search suggests that you need to put in some code in runtime_init() so everything gets cleared up upon reset / power off.

https://www.raspberrypi.org/forums/view ... p?t=300981
https://github.com/dwelch67/raspberrypi-pico

mikeysklar
 
Posts: 4559
Joined: Mon Aug 01, 2016 8:10 pm

Re: QT Py RP2040 C Pico SDK Question

by rbeiter on Thu Apr 22, 2021 8:26 am

Thank you for the link to dwelch67's repository - I was able to get David's blinker00 project running on the QT Py RP2020 consistently. Still working out why the Pico SDK's `runtime_init()` isn't accomplishing this setup on the QT Py RP2040 like it does on the Pico board, but this definitely gets me further!

Cheers,
Randy

rbeiter
 
Posts: 4
Joined: Mon Apr 19, 2021 8:09 pm

Re: QT Py RP2040 C Pico SDK Question

by rbeiter on Thu Apr 22, 2021 5:21 pm

A follow-up note - it appears the issue with the Pico SDK seems specific to the QT Py RP2040, I just tried with an ItsyBitsy RP2040 and the code in my original post works after reset/power cycle with no changes other than setting
Code: Select all | TOGGLE FULL SIZE
set(PICO_BOARD adafruit_itsybitsy_RP2040)
in the CMakeLists.txt.

rbeiter
 
Posts: 4
Joined: Mon Apr 19, 2021 8:09 pm

Re: QT Py RP2040 C Pico SDK Question

by mikeysklar on Fri Apr 23, 2021 2:33 pm

Interesting. I wonder if this is a possible bootloader difference between the QtPy and ItsyBitsy? Is there something else you can think of that would be different between them?

mikeysklar
 
Posts: 4559
Joined: Mon Aug 01, 2016 8:10 pm

Re: QT Py RP2040 C Pico SDK Question

by rbeiter on Fri Apr 23, 2021 3:21 pm

Bootloader was one of the things I thought of that I haven't been able to compare in depth. As far as I can tell, the first stage bootloader on the RP2040 is non-upgradable/rewritable?

I used picotool to verify code is getting loaded into similar spots between the binaries, and the disassembly of the QT Py and itsybitsy binaries seem to differ only by pin access addresses for the peripherals. Also verified both boards use the same SPI flash chip and compared the board configs in the Pico SDK for differences - saw only expected pin number differences. Interestingly both boards claim 4MB flash instead of 8, but changing that had no effect.

The wildcard through all of this to me is why circuit python (bigger) and the minimum no-sdk (smaller) binaries start up as expected. I'd suspect it was loading to ram instead of flash, but the behavior there should be to pop back to the UF2 share file system which it doesn't do.

If the QT Py had SWD exposed, I'd try to see if it was getting into my code at all. I may try connecting to the SWD pins on the RP2040 directly as a next debugging attempt, they're tiny but accessible.

rbeiter
 
Posts: 4
Joined: Mon Apr 19, 2021 8:09 pm

Re: QT Py RP2040 C Pico SDK Question

by mikeysklar on Fri Apr 23, 2021 7:24 pm

Good luck making the connection to those SWD pins on the QtPy. I was kind of surprised to see that SWDIO / SWCLK were not broken out as we do that on pretty much all the other RP2040/M0/M4 boards that I can think of. Good work investigating this.

mikeysklar
 
Posts: 4559
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.