Pimoroni Explorer: problem setup C/C++ project

Hi! I’m trying to get C/C++ code working on the Pimoroni Explorer board, but I haven’t had any success so far.

MicroPython works perfectly, so the hardware seems fine. But for my project I need C/C++. I’ve tried multiple setups: using pico-sdk, pimoroni-pico, pico-examples, Arduino IDE, a Debug Probe, and going through available documentation, but none of it worked.

It seems that most tutorials and projects are targeted specifically at Pico boards, and Explorer (with RP2350 chip) isn’t officially listed. In some cases CMake asks to specify PICO_BOARD, but “explorer” is not among the available options. I tried building with all RP2350-based configurations I could find, but nothing succeeded.

Has anyone managed to get a working C/C++ setup for Pimoroni Explorer? Any pointers, minimal example, or configuration help would be greatly appreciated!

I was having trouble getting a basic c++ project to display on the included display of the explorer. I was finally able to get it to work by adding the compile definition PICO_PIO_USE_GPIO_BASE=1 to my CMakeLists file.

I think this is because the built in display uses GPIO 32-39 for the data bus but to access those pins with the generated PIO header could not access these pins. Setting PICO_PIO_USE_GPIO_BASE=1 allows it to access those pins. The full change to the CMakeLists.txt file was adding

add_compile_definitions(PICO_PIO_USE_GPIO_BASE=1)

Some more information on the compile flag can be found in here
https://www.raspberrypi.com/documentation/pico-sdk/hardware.html

Thanks for reply @matt1!
Unfortunately this also does not work for me. Maybe I am trying wrongly.

Have you used this device? https://shop.pimoroni.com/products/explorer
And which repositary do you run? Pico-sdk, pimoroni-pico or something else?
Also which board definition do you use? I have suspicion that none of them is for my board and that is reason why it goes bad.

It would be huge help if you send me some minimal functional example, if you have one. Thanks!

Yes, that looks like the device I am using.

Using the VS code extension GitHub - raspberrypi/pico-vscode: The official VS Code extension for Raspberry Pi Pico development. It includes several features to simplify project creation and deployment. I create a basic c++ project. I then add GitHub - pimoroni/pimoroni-pico: Libraries and examples to support Pimoroni Pico add-ons in C++ and MicroPython. as a submodule under libs/pimoroni-pico from the base of my new project (If you do it this way you may want to comment out the last line of the pimoroni-pico CMakeLists file to not build all the examples). Once I have that I modify my projects CMakeLists file and main.cpp file to look something like this.

# Generated Cmake Pico project file

cmake_minimum_required(VERSION 3.13)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Initialise pico_sdk from installed location
# (note this can come from environment, CMake cache etc)

# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==
if(WIN32)
    set(USERHOME $ENV{USERPROFILE})
else()
    set(USERHOME $ENV{HOME})
endif()
set(sdkVersion 2.2.0)
set(toolchainVersion 14_2_Rel1)
set(picotoolVersion 2.2.0-a4)
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
if (EXISTS ${picoVscode})
    include(${picoVscode})
endif()
# ====================================================================================
set(PICO_BOARD pico2 CACHE STRING "Board type")

# Pull in Raspberry Pi Pico SDK (must be before project)
include(pico_sdk_import.cmake)

project(example C CXX ASM)

# Initialise the Raspberry Pi Pico SDK
pico_sdk_init()

# Enable PIO support for the 5th bit of GPIO pins
add_compile_definitions(PICO_PIO_USE_GPIO_BASE=1)

add_executable(example main.cpp )

pico_set_program_name(example "example")
pico_set_program_version(example "0.1")

# Modify the below lines to enable/disable output over UART/USB
pico_enable_stdio_uart(example 0)
pico_enable_stdio_usb(example 1)

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/libs/pimoroni-pico)

target_link_directories(
    example
    PRIVATE
    ${CMAKE_CURRENT_LIST_DIR}/libs/pimoroni-pico
)

# Add the standard library to the build
target_link_libraries(
    example
    pico_stdlib
    pimoroni_bus
    pico_graphics
    st7789
)

target_include_directories(
    example
    PRIVATE
    ${CMAKE_CURRENT_LIST_DIR}/libs/pimoroni-pico
)

# Add the standard include files to the build
target_include_directories(example PRIVATE
        ${CMAKE_CURRENT_LIST_DIR}
)

pico_add_extra_outputs(example)

And the main.cpp file

#include "pico/stdlib.h"

#include "common/pimoroni_bus.hpp"
#include "drivers/st7789/st7789.hpp"
#include "libraries/pico_graphics/pico_graphics.hpp"

using namespace pimoroni;

#define DISPLAY_WIDTH 320
#define DISPLAY_HEIGHT 240

ParallelPins parallel_bus = {
    .cs = 27,
    .dc = 28,
    .wr_sck = 30,
    .rd_sck = 31,
    .d0 = 32,
    .bl = 26
};

ST7789 st7789(
    DISPLAY_WIDTH,
    DISPLAY_HEIGHT,
    ROTATE_0,
    parallel_bus
);

PicoGraphics_PenRGB565 graphics(
    st7789.width,
    st7789.height,
    nullptr
);

int main() {
    stdio_init_all();

    while (true) {
        graphics.set_pen(0, 0, 0);
        graphics.clear();

        graphics.set_pen(0, 120, 120);
        graphics.text("Hello world!", Point(20, 140), 300, 4);

        st7789.update(&graphics);
        sleep_ms(1000);
    }
}

1 Like

@matt1 huge thanks! This now finally works for me. ;-)

If someone reading this, still has problem running it, hit me up.