Skip to content

Conversation

@smittytone
Copy link

I'm not offering this for merging per se, more to see if you're interested in pull in updates like this: to support other RP2040-based devices.

Happy to make changes too.

Cheers,

Tony

@smittytone
Copy link
Author

Updated with better device selection: the user sets the value of USE_QTPY in CMakeLists.txt and CMake config and then building, etc. proceed accordingly. Default is Picoprobe on Pico (USE_QTPY == 0)

@thezim
Copy link

thezim commented Sep 3, 2021

I think using the default board defines instead of a new define is a better route. On most of the existing boards define PICO_DEFAULT_I2C_SDA_PIN map to the STEMMA/QWIIC connector already and hard definitions in picoprobe are not needed. Defining PICO_BOARD sets it all in motion, see section 2.6.1. Preprocessor Variables via Board Configuration File of the SDK documentation.

Here is an example I tested.

#ifdef ADAFRUIT_QTPY_RP2040 || SPARKFUN_PROMICRO #define PROBE_PIN_OFFSET PICO_DEFAULT_I2C_SDA_PIN #else #define PROBE_PIN_OFFSET 2 #endif 

However PICO_DEFAULT_LED_PIN becomes undefined. But on the plus sided PICO_DEFAULT_WS2812_PIN is defined for board that have them. Some boards like the SparkFun Thing Plus has both and in that case I say the the default LED should be used. I have not dug too deep but there may be boards with no available LED, regular to WS281x. The WS281x only is a case to like it is for my SparkFun Pro Micro.

@kilograham
Copy link
Contributor

yes, better to use the default pin defines so it works on everything
PICO_DEFAULT_WS2812_PIN and PICO_DEFAULT_LED_PIN should be defined on all boards that have them and undefined on those that don't.
Some of the examples to do with toggling LED pins for example will output a compiler warning on boards that don't have a LED pins

There is also a placeholder issue raspberrypi/pico-sdk#188 to create a simple abstraction for signaling status/something on either LED or WS2812

@smittytone
Copy link
Author

As per above, I've updated config to use PICO_BOARD as the initialisation point, with the standard value entered there to define what's needed for a specific board. I've added a couple more — @dhalbert’s SparkFun Pro Micro and the Adafruit Feather, the focus being on boards I have with STEMMA ports — and made use of SDK-set #define values wherever possible. One case were it's not: the GPIO pin number for SWD CLK on the QTPy which is not the same as the standard SDA pin.

I've also brought the RGB LED colour setting into CMakeLists.txt to reduce the number of edits a user might have to make to other files if they're building for a known board.

Added a Read Me too, as that's what I do for a living.

PS. I've crudely 'fixed' the undefined PICO_DEFAULT_LED_PIN issue, but there must be better approach that doesn't send folk to the command line, surely?

@smittytone smittytone changed the title Add support for Adafruit QTPy RP2040 Add support for Adafruit QTPy RP2040 (and other boards) Sep 11, 2021
endif()

if (NOT PICO_BOARD STREQUAL "pico")
target_sources(${EXECUTABLE_NAME} PRIVATE src/ws2812.c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be assuming that any board which isn't a Raspberry Pi Pico will always have a WS2812 LED, which I guess won't always be the case? Probably better to do something like set(HAS_WS2812 1) in the bit above where you're checking individual board-names?

@@ -0,0 +1,25 @@
# Picoprobe

A Picoprobe is a Raspberry Pi RP2040-based Single-Wire Debug (SWB) adaptor. You can make one from a Raspberry Pi Pico — hence the name — or almost any third-party RP2040-based board. Use it to connect your RP2040-based application board to your personal computer for debugging through `gdb`, directly or via an IDE such as Microsoft Visual Studio Code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single-Wire Debug -> Serial Wire Debug
SWB -> SWD


A Picoprobe is a Raspberry Pi RP2040-based Single-Wire Debug (SWB) adaptor. You can make one from a Raspberry Pi Pico — hence the name — or almost any third-party RP2040-based board. Use it to connect your RP2040-based application board to your personal computer for debugging through `gdb`, directly or via an IDE such as Microsoft Visual Studio Code.

The original version of this code only supported the Pico. This update adds support for three more boards, each of which provides a [STEMMA QT connector](https://learn.adafruit.com/introducing-adafruit-stemma-qt/what-is-stemma-qt)/[Quicc](https://www.sparkfun.com/qwiic) for easy cabling to the application board under test. These connectors are intended for use with I²C devices, but here we’re using their pins for GPIO and power.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense for README.md to talk about "This update..." ? (this is the README, not a CHANGELOG)
Quicc -> Qwiic ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what is worth mentioning is the that if you are using the STEMMA/Qwiic board is that UART lines will not be passed through. Using the base board has that advantage as you don't need to plug in both your pico probe and the target board to USB.


The original version of this code only supported the Pico. This update adds support for three more boards, each of which provides a [STEMMA QT connector](https://learn.adafruit.com/introducing-adafruit-stemma-qt/what-is-stemma-qt)/[Quicc](https://www.sparkfun.com/qwiic) for easy cabling to the application board under test. These connectors are intended for use with I²C devices, but here we’re using their pins for GPIO and power.

The code also uses the WS2812 RGB LED on those boards that have one as an SWD activity indicator.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "on those boards that have one" should be in parentheses?


The code also uses the WS2812 RGB LED on those boards that have one as an SWD activity indicator.

If your chosen board is not one of those so far supported by the Picoprobe code, you should be able to use with just a few small code changes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use with -> use it with ?


## Build the Picoprobe code

To build for your own Picoprobe:
Copy link
Contributor

@lurch lurch Sep 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"To build Picoprobe for your own board:" ?

message("Building for Adafruit Feather RP2040 with WS2812")
elseif (PICO_BOARD STREQUAL "sparkfun_promicro")
message("Building for SparkFun Pro Micro RP2040 with WS2812")
else()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this else() be elseif (PICO_BOARD STREQUAL "pico") ?

Comment on lines 77 to +79
#ifndef PICO_DEFAULT_LED_PIN
#error PICO_DEFAULT_LED_PIN is not defined, run PICOPROBE_LED=<led_pin> cmake
// #error PICO_DEFAULT_LED_PIN is not defined, run PICOPROBE_LED=<led_pin> cmake
#define PICOPROBE_LED 0 // To avoid compiler errors -- is there a better way to do this?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you want something like #if !defined(PICO_DEFAULT_LED_PIN) && !defined(PICO_DEFAULT_WS2812_PIN) ?

@smittytone smittytone closed this Sep 12, 2021
# "adafruit_feather_rp2040" for the Adafruit Feather RP2040
# "sparkfun_promicro" for the SparkFun Pro Micro RP2040

set(PICO_BOARD "pico")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be defined in this file? A PICO_BOARD environment variable works too. Not having to modify any files make building even easier.

Linux/MacOS

export PICO_BOARD=SPARKFUN_PROMICRO cmake .

WIndows

SET PICO_BOARD=SPARKFUN_PROMICRO cmake .

PowerShell Core (All OS'es)

$env:PICO_BOARD=SPARKFUN_PROMICRO cmake .

To build for your own Picoprobe:

1. Edit the `CmakeLists.txt` file and change the value of `PICO_BOARD` in line 16.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line number change over time. Better to reference this by name and not by line number. Less work later.

@lurch
Copy link
Contributor

lurch commented Sep 13, 2021

Why was this closed @smittytone ?

@smittytone
Copy link
Author

I've closed it because I don't think it's getting anywhere. I opened the request to see if there was any interest on the part of the Foundation in extending this. That question hasn't been answered. I've had some useful suggestions for improvements, which I have applied, and a fair few opinions, but nothing in the way of direction, and I think that's what is required at this stage. Someone with the authority to do so needs to set a framework for how other devices get added, and oversee their addition as punters submit them. I proposed one approach, and anyone can view my fork to see how it works. I'm open to others, and I'm also happy to reopen this PR if the Foundation thinks that's the way to go.

@lurch
Copy link
Contributor

lurch commented Sep 14, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants