The Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build system necessary

Raspberry Pi Pico SDK

The Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build system necessary to write programs for the RP2040-based devices such as the Raspberry Pi Pico in C, C++ or assembly language.

The SDK is designed to provide an API and programming environment that is familiar both to non-embedded C developers and embedded C developers alike. A single program runs on the device at a time and starts with a conventional main() method. Standard C/C++ libraries are supported along with C level libraries/APIs for accessing all of the RP2040's hardware include PIO (Programmable IO).

Additionally the SDK provides higher level libraries for dealing with timers, synchronization, USB (TinyUSB) and multi-core programming along with various utilities.

The SDK can be used to build anything from simple applications, to fully fledged runtime environments such as MicroPython, to low level software such as RP2040's on-chip bootrom itself.

Additional libraries/APIs that are not yet ready for inclusion in the SDK can be found in pico-extras.

Documentation

See Getting Started with the Raspberry Pi Pico for information on how to setup your hardware, IDE/environment and for how to build and debug software for the Raspberry Pi Pico and other RP2040-based devices.

See Raspberry Pi Pico C/C++ SDK to learn more about programming using the SDK, to explore more advanced features, and for complete PDF-based API documentation.

See Online Raspberry Pi Pico SDK API docs for HTML-based API documentation.

Example code

See pico-examples for example code you can build.

Quick-start your own project

These instructions are extremely terse, and Linux-based only. For detailed steps, instructions for other platforms, and just in general, we recommend you see Raspberry Pi Pico C/C++ SDK

  1. Install CMake (at least version 3.13), and GCC cross compiler

    sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
    
  2. Set up your project to point to use the Raspberry Pi Pico SDK

    • Either by cloning the SDK locally (most common) :

      1. git clone this Raspberry Pi Pico SDK repository

      2. Copy pico_sdk_import.cmake from the SDK into your project directory

      3. Set PICO_SDK_PATH to the SDK location in your environment, or pass it (-DPICO_SDK_PATH=) to cmake later.

      4. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.13)
        
        # initialize the SDK based on PICO_SDK_PATH
        # note: this must happen before project()
        include(pico_sdk_import.cmake)
        
        project(my_project)
        
        # initialize the Raspberry Pi Pico SDK
        pico_sdk_init()
        
        # rest of your project
        
    • Or with the Raspberry Pi Pico SDK as a submodule :

      1. Clone the SDK as a submodule called pico-sdk

      2. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.13)
        
        # initialize pico-sdk from submodule
        # note: this must happen before project()
        include(pico-sdk/pico_sdk_init.cmake)
        
        project(my_project)
        
        # initialize the Raspberry Pi Pico SDK
        pico_sdk_init()
        
        # rest of your project
        
    • Or with automatic download from GitHub :

      1. Copy pico_sdk_import.cmake from the SDK into your project directory

      2. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.13)
        
        # initialize pico-sdk from GIT
        # (note this can come from environment, CMake cache etc)
        set(PICO_SDK_FETCH_FROM_GIT on)
        
        # pico_sdk_import.cmake is a single file copied from this SDK
        # note: this must happen before project()
        include(pico_sdk_import.cmake)
        
        project(my_project)
        
        # initialize the Raspberry Pi Pico SDK
        pico_sdk_init()
        
        # rest of your project
        
  3. Write your code (see pico-examples or the Raspberry Pi Pico C/C++ SDK documentation for more information)

    About the simplest you can do is a single source file (e.g. hello_world.c)

    #include <stdio.h>
    #include "pico/stdlib.h"
    
    int main() {
        setup_default_uart();
        printf("Hello, world!\n");
        return 0;
    }

    And add the following to your CMakeLists.txt:

    add_executable(hello_world
        hello_world.c
    )
    
    # Add pico_stdlib library which aggregates commonly used features
    target_link_libraries(hello_world pico_stdlib)
    
    # create map/bin/hex/uf2 file in addition to ELF.
    pico_add_extra_outputs(hello_world)

    Note this example uses the default UART for stdout; if you want to use the default USB see the hello-usb example.

  4. Setup a CMake build directory. For example, if not using an IDE:

    $ mkdir build
    $ cd build
    $ cmake ..
    
  5. Make your target from the build directory you created.

    $ make hello_world
  6. You now have hello_world.elf to load via a debugger, or hello_world.uf2 that can be installed and run on your Raspberry Pi Pico via drag and drop.

Comments
  • host_hid mouse data displaced

    host_hid mouse data displaced

    Some wired mice (such as the official Raspberry Pi mouse) work with the host_hid USB example code in pico-examples - in fact, it seems that at the moment, only wired mice are recognized (although this is not the issue I wish to report here).

    At least some wired mice which have side buttons (i.e. back/forward) have displaced data:

    • button presses appear in the (hid_mouse_report_t).x element rather than (hid_mouse_report_t).button;
    • x movement appears in (hid_mouse_report_t).y rather than (hid_mouse_report_t).x .
    • (hid_mouse_report_t).button remains 1 (i.e. left button pressed)

    (note: the mouse works fine on a RPi 400)

    I am reporting this here as pico-sdk holds a non-current version of tinyusb, and it doesn't seem to be straightforward to test with the current tinyusb on pico hardware at the moment.

    This may be solved with the newer version of tinyusb in pico-sdk 1.2.0 ... this issue can serve as a placeholder until that is available for test; if pico-sdk and tinyusb are in sync at that time (and if the issue is not yet resolved), I will be happy to report the issue upstream. I am also happy to gather any diagnostic information required (if the process is explained).

    For the moment, the existence of a report may be helpful to other users, to indicate current known system limitations.

  • Adafruit qtpy rp2040 target starts CDC/ACM USB only once - suspect flash timing

    Adafruit qtpy rp2040 target starts CDC/ACM USB only once - suspect flash timing

    Changed:

    PICO_FLASH_SPI_CLKDIV from 2 to 4
    (to slow the clock, by halving it)
    

    Reference system Linux host PC will not enumerate /dev/ttyACM0 (or related device names) except upon UF2 firmware upload.

    UF2 upload is fine and program will run once, until power is removed. Then, never again.

    This patch is meant to allow the (end-user authored) firmware/program to run repeatedly, including cycling power to the target board.

    First (SPI clock divisor) value tried was '4' (from '2').

    No other experiments done, in search of the optimal clock divisor.

    Not at all sure what the clock divisor 'does'.

    Simple guess:

    Going from 2, to 4 would 'halve' the clock frequency (divide it by 2).

    Halving the frequency would cause the subsystem to evolve all events more slowly, which apparently helps in enumeration of the CDC/ACM device to the host PC.

  • USB stdio & SDK 1.1.0

    USB stdio & SDK 1.1.0

    maybe is issues...

    pico_stdio_usb\reset_interface.c:63:32: error: 'SRAM_END' undeclared (first use in this function); #include "hardware/regs/addressmap.h"

    pico_stdio_usb\stdio_usb.c:17:8: error: unknown type name 'mutex_t' #include "pico/mutex.h"

    pico_stdio_usb\stdio_usb.c:19:13: warning: function declaration isn't a prototype [-Wstrict-prototypes] static void low_priority_worker_irq()

  • Tests fail when using gcc 12

    Tests fail when using gcc 12

    I ran cmake .. && make in a build directory on the pico-sdk using gcc 12 and the kitchen_sink test failed. I'm not sure if I have configured something incorrectly or not but i believe it is caused by the latest version of gcc as these tests did pass using an older version of gcc. I have attached the build log below so you can see where it went wrong.

    PICO_SDK_PATH is MyPath/pico-sdk
    Defaulting PICO_PLATFORM to rp2040 since not specified.
    Defaulting PICO platform compiler to pico_arm_gcc since not specified.
    -- Defaulting build type to 'Release' since not specified.
    PICO compiler is pico_arm_gcc
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /usr/bin/arm-none-eabi-gcc
    Build type is Release
    Defaulting PICO target board to pico since not specified.
    Using board configuration from MyPath/pico-sdk/src/boards/include/boards/pico.h
    -- Found Python3: /usr/bin/python3.10 (found version "3.10.4") found components: Interpreter 
    TinyUSB available at MyPath/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: MyPath/pico-sdk/build
    Scanning dependencies of target bs2_default
    [  1%] Building ASM object src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
    [  1%] Linking ASM executable bs2_default.elf
    [  1%] Built target bs2_default
    [  1%] Creating directories for 'ELF2UF2Build'
    [  1%] No download step for 'ELF2UF2Build'
    [  1%] No update step for 'ELF2UF2Build'
    [  1%] No patch step for 'ELF2UF2Build'
    [  1%] Performing configure step for 'ELF2UF2Build'
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: MyPath/pico-sdk/build/elf2uf2
    [  1%] Performing build step for 'ELF2UF2Build'
    [ 50%] Building CXX object CMakeFiles/elf2uf2.dir/main.cpp.o
    [100%] Linking CXX executable elf2uf2
    [100%] Built target elf2uf2
    [  1%] No install step for 'ELF2UF2Build'
    [  1%] Completed 'ELF2UF2Build'
    [  1%] Built target ELF2UF2Build
    [  1%] Generating bs2_default.bin
    [  1%] Generating bs2_default_padded_checksummed.S
    [  1%] Built target bs2_default_padded_checksummed_asm
    Scanning dependencies of target pico_stdlib_test
    [  7%] Built target pico_stdlib_test
    Scanning dependencies of target pico_time_test
    [ 13%] Built target pico_time_test
    Scanning dependencies of target pico_divider_test
    [ 19%] Built target pico_divider_test
    Scanning dependencies of target pico_divider_nesting_test_with_dirty_check
    [ 25%] Built target pico_divider_nesting_test_with_dirty_check
    Scanning dependencies of target pico_divider_nesting_test_with_disable_irq
    [ 31%] Built target pico_divider_nesting_test_with_disable_irq
    Scanning dependencies of target pico_float_test
    [ 37%] Built target pico_float_test
    Scanning dependencies of target pico_double_test
    [ 43%] Built target pico_double_test
    Scanning dependencies of target kitchen_sink
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/kitchen_sink.c.obj
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_adc/adc.c.obj
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_claim/claim.c.obj
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/pico_platform/platform.c.obj
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_sync/sync.c.obj
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_clocks/clocks.c.obj
    [ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_gpio/gpio.c.obj
    [ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq.c.obj
    [ 44%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq_handler_chain.S.obj
    [ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/sem.c.obj
    [ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/lock_core.c.obj
    [ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/time.c.obj
    [ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/timeout_helper.c.obj
    [ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_timer/timer.c.obj
    [ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/datetime.c.obj
    [ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/pheap.c.obj
    [ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/queue.c.obj
    [ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/mutex.c.obj
    [ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/critical_section.c.obj
    [ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_pll/pll.c.obj
    [ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_vreg/vreg.c.obj
    [ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_watchdog/watchdog.c.obj
    [ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_xosc/xosc.c.obj
    [ 46%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_divider/divider.S.obj
    [ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_exception/exception.c.obj
    [ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_dma/dma.c.obj
    [ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_flash/flash.c.obj
    In file included from MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:8:
    In function 'rom_func_lookup_inline',
        inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:69:91:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(ui[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/kitchen_sink.c.obj
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_adc/adc.c.obj
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_claim/claim.c.obj
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/pico_platform/platform.c.obj
    [ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_sync/sync.c.obj
    [ 43%] Building C object testnt16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:70:67:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:71:76:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:72:76:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:92:91:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:93:67:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:94:82:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:95:76:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:125:91:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:126:67:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    In function 'rom_func_lookup_inline',
        inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:127:76:
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
      129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
          |                                                                  ^~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
      120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
          |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
    MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
      130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
          |                                         ^~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    make[2]: *** [test/kitchen_sink/CMakeFiles/kitchen_sink.dir/build.make:438: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_flash/flash.c.obj] Error 1
    make[1]: *** [CMakeFiles/Makefile2:1796: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/all] Error 2
    make: *** [Makefile:91: all] Error 2
    
  • I2C: Strange behaviour trying to read PA1010D GPS

    I2C: Strange behaviour trying to read PA1010D GPS

    I've been testing the PA1010D i2c GPS (happy to supply one to anyone who's got a head for mysteries) with the Pico, starting with CircuitPython and reducing down to a minimum amount of C++ SDK code to reproduce.

    Long story short, it will stall hard after about one i2c read using Pico's hardware I2C.

    Using either CircuitPython bitbangio or the I2C PIO driver from the Pico Examples it will read perfectly happily and - indeed - in the same setup for testing this I've had valid GPS data pouring out using a CircuitPython example and bitbangio in lieu of hardware i2c.

    Works:

    #include <stdio.h>
    #include "pico/stdlib.h"
    #include "pio_i2c.h"
    
    #define PIN_SDA 4
    #define PIN_SCL 5
    
    int main() {
        stdio_init_all();
    
        PIO pio = pio0;
        uint sm = 0;
        uint offset = pio_add_program(pio, &i2c_program);
        i2c_program_init(pio, sm, offset, PIN_SDA, PIN_SCL);
    
        uint addr = 0x10;
    
        while (1) {
            int ret;
            uint8_t rxdata[11];
            ret = pio_i2c_read_blocking(pio, sm, addr, rxdata, 10);
            rxdata[10] = '\n';
            printf(rxdata);
            sleep_ms(1000);
        }
        return 0;
    }
    

    Stalls:

    #include <stdio.h>
    #include "pico/stdlib.h"
    #include "hardware/i2c.h"
    
    int main() {
        stdio_init_all();
    
        i2c_init(i2c0, 100 * 1000);
        gpio_set_function(4, GPIO_FUNC_I2C);
        gpio_set_function(5, GPIO_FUNC_I2C);
        gpio_pull_up(4);
        gpio_pull_up(5);
    
        int addr = 0x10;
    
        while (1) {
            int ret;
            uint8_t rxdata[11];
            ret = i2c_read_blocking(i2c0, addr, rxdata, 10, false);
            rxdata[10] = '\n';
            printf(rxdata);
            sleep_ms(1000);
        }
        return 0;
    }
    
    

    I've played with the i2c baud rate to no avail. The hardware i2c seems to inevitably get stuck in this loop:

            do {
                abort_reason = i2c->hw->tx_abrt_source;
                abort = (bool) i2c->hw->clr_tx_abrt;
                if (timeout_check) {
                    timeout = timeout_check(ts);
                    abort |= timeout;
                }
            } while (!abort && !i2c_get_read_available(i2c));
    

    CircuitPython suggested that either Data or Clock was pulled low, preventing the detection of i2c pull-ups once this state is entered. Using C++ to sleuth this further suggests that SDA is held low. It would seem to be the GPS itself that's entered a bad state and is holding SDA low. Why Pico's hardware i2c would cause it to do this totally eludes me. Unplugging the GPS and re-inserting it seems to clear this state.

    Weirder still. If I get the GPS into a bad state whereupon it's totally unresponsive to hardware I2C, running the PIO I2C example will get it working again. I've tried this a few times. It's... odd.

    And. I'm baffled.

  • cannot access XIP from sram build

    cannot access XIP from sram build

    while hardware_flash provides functions to write/erase the flash when running from sram (type no_flash), i'd need to both read from and execute into XIP, but sram builds don't (seem to) provide a way of enabling boot_stage2 and the sdk doesn't (seem to) provide any other function to initialize the flash for XIP.

    manually adding boot_stage2 as a target_link_library fails too because then the linker complains about there not being a libboot_stage2.so

    could you please provide a "load into and run from sram" mode that doesn't disable flash access (= includes boot_stage2)?

    EDIT: apparently there seems to be some weirdness with flash_enter_cmd_xip while using usb CDC, but also please just add a "run from sram but with boot2" step, because "run from sram" does not always have to mean "no_flash"

    Update

    figured out the correct sequence for enabling XIP via boot2 (located inside XIP) thanks to @Wren6991: https://github.com/raspberrypi/pico-sdk/issues/412#issuecomment-842208538

    also I provide a full working "blink" example containing a neat header+source file you can use over there: https://gitlab.com/nonchip/pi-pico-xipram

  • Why does second stage bootloader not set VTOR and SP?

    Why does second stage bootloader not set VTOR and SP?

    Having to make 0x100 in flash a function as opposed to a vector table complicates the use of other programming languages and SDKs, which assume flash starts with a vector table.

    Is there a reason why the second stage bootloader doesn't set VTOR to 0x1000_0100, SP to [0x1000_0100] and then jump to [0x1000_0104]?

  • Add CMSIS-Core headers

    Add CMSIS-Core headers

    Please add standard CMSIS-Core headers and register definitions. Ideally these would replace the bespoke headers to avoid fracturing of the ecosystem.

    The common CMSIS header files are here. It's not uncommon to include the entire CMSIS_5 repo as a submodule, and it's just as common to copy the headers into your SDK.

    CMSIS-Core documentation

    CMSIS-standard register definitions can be generated with the SVDConv utility.

  • Compiling Error: duplicate 'inline'

    Compiling Error: duplicate 'inline'

  • Using Eigen with Pico-sdk

    Using Eigen with Pico-sdk

    I put Eigen into the same directory as my project and added the below line into CMakeLists.txt.

    target_include_directories( 
        eigen/   
    )
    

    When I try to run a simple Eigen program below(found it on their website), I'm getting many errors.

    #include <iostream>
    #include <Eigen/Dense>
     
    using Eigen::MatrixXd;
     
    int main()
    {
      MatrixXd m(2,2);
      m(0,0) = 3;
      m(1,0) = 2.5;
      m(0,1) = -1;
      m(1,1) = m(1,0) + m(0,1);
      std::cout << m << std::endl;
    }
    

    Output:

    In file included from /home/user/dev/PicoEKF/eigen/Eigen/Core:160:0,
                     from /home/user/dev/PicoEKF/eigen/Eigen/Dense:1,
                     from /home/user/dev/PicoEKF/src/main.cpp:12:
    /home/user/dev/PicoEKF/eigen/Eigen/src/Core/util/Meta.h:235:25: error: 'invoke_result' in namespace 'std' does not name a template type
       typedef typename std::invoke_result<F, ArgTypes...>::type type1;
                             ^~~~~~~~~~~~~
    /home/user/dev/PicoEKF/eigen/Eigen/src/Core/util/Meta.h:235:38: error: expected unqualified-id before '<' token
       typedef typename std::invoke_result<F, ArgTypes...>::type type1;
                                          ^
    /home/user/dev/PicoEKF/eigen/Eigen/src/Core/util/Meta.h:236:24: error: 'type1' was not declared in this scope
       typedef remove_all_t<type1> type;
                            ^~~~~
    /home/user/dev/PicoEKF/eigen/Eigen/src/Core/util/Meta.h:236:29: error: template argument 1 is invalid
       typedef remove_all_t<type1> type;
                                 ^
    /home/user/dev/PicoEKF/eigen/Eigen/src/Core/util/Meta.h:241:25: error: 'invoke_result' in namespace 'std' does not name a template type
       typedef typename std::invoke_result<F, ArgTypes...>::type type1;
                             ^~~~~~~~~~~~~
    /home/user/dev/PicoEKF/eigen/Eigen/src/Core/util/Meta.h:241:38: error: expected unqualified-id before '<' token
       typedef typename std::invoke_result<F, ArgTypes...>::type type1;
                                          ^
    /home/user/dev/PicoEKF/eigen/Eigen/src/Core/util/Meta.h:242:24: error: 'type1' was not declared in this scope
       typedef remove_all_t<type1> type;
                            ^~~~~
    /home/user/dev/PicoEKF/eigen/Eigen/src/Core/util/Meta.h:242:29: error: template argument 1 is invalid
       typedef remove_all_t<type1> type;
                                 ^
    In file included from /home/user/dev/PicoEKF/eigen/Eigen/Core:164:0,
                     from /home/user/dev/PicoEKF/eigen/Eigen/Dense:1,
                     from /home/user/dev/PicoEKF/src/main.cpp:12:
    /home/user/dev/PicoEKF/eigen/Eigen/src/Core/util/Memory.h:1176:12: error: 'std::destroy_at' has not been declared
     using std::destroy_at;
                ^~~~~~~~~~
    In file included from /home/user/dev/PicoEKF/eigen/Eigen/SVD:37:0,
                     from /home/user/dev/PicoEKF/eigen/Eigen/Dense:5,
                     from /home/user/dev/PicoEKF/src/main.cpp:12:
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h: In member function 'void Eigen::internal::qr_preconditioner_impl<MatrixType, Options, 192, 1, true>::allocate(const SVDType&)':
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h:76:7: error: 'destroy_at' is not a member of 'Eigen::internal'
           internal::destroy_at(&m_qr);
           ^~~~~~~~
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h: In member function 'void Eigen::internal::qr_preconditioner_impl<MatrixType, Options, 192, 0, true>::allocate(const SVDType&)':
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h:122:7: error: 'destroy_at' is not a member of 'Eigen::internal'
           internal::destroy_at(&m_qr);
           ^~~~~~~~
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h: In member function 'void Eigen::internal::qr_preconditioner_impl<MatrixType, Options, 0, 1, true>::allocate(const SVDType&)':
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h:168:7: error: 'destroy_at' is not a member of 'Eigen::internal'
           internal::destroy_at(&m_qr);
           ^~~~~~~~
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h: In member function 'void Eigen::internal::qr_preconditioner_impl<MatrixType, Options, 0, 0, true>::allocate(const SVDType&)':
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h:224:7: error: 'destroy_at' is not a member of 'Eigen::internal'
           internal::destroy_at(&m_qr);
           ^~~~~~~~
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h: In member function 'void Eigen::internal::qr_preconditioner_impl<MatrixType, Options, 128, 1, true>::allocate(const SVDType&)':
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h:276:7: error: 'destroy_at' is not a member of 'Eigen::internal'
           internal::destroy_at(&m_qr);
           ^~~~~~~~
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h: In member function 'void Eigen::internal::qr_preconditioner_impl<MatrixType, Options, 128, 0, true>::allocate(const SVDType&)':
    /home/user/dev/PicoEKF/eigen/Eigen/src/SVD/JacobiSVD.h:331:7: error: 'destroy_at' is not a member of 'Eigen::internal'
    CMakeFiles/PicoEKF.dir/build.make:75: recipe for target 'CMakeFiles/PicoEKF.dir/src/main.cpp.obj' failed
           internal::destroy_at(&m_qr);
           ^~~~~~~~
    

    Edit: Added the Eigen program I used for better understanding.

  • Overhead in single SPI calls

    Overhead in single SPI calls

    I found SPI slow on the pico.

    This is a test program:

    #include <hardware/spi.h> #include <hardware/gpio.h>

    spi_cpol_t cccpol; spi_cpha_t cccpha;

    void setup() { gpio_set_function(16, GPIO_FUNC_SPI); gpio_set_function(17, GPIO_FUNC_SPI); gpio_set_function(18, GPIO_FUNC_SPI); gpio_set_function(19, GPIO_FUNC_SPI);

    spi_init(spi0, 100000000); cccpol = SPI_CPOL_0; cccpha = SPI_CPHA_0; }

    void loop() { for (int i=0; i<65536; i++) { uint16_t ret16; uint16_t data16=0; uint8_t ret8; uint8_t data8=0; spi_set_format(spi0, 8, cccpol, cccpha, SPI_MSB_FIRST); spi_write_read_blocking(spi0, &data8, &ret8, 1); spi_set_format(spi0, 16, cccpol, cccpha, SPI_MSB_FIRST); spi_write16_read16_blocking(spi0, &data16, &ret16, 1); spi_write16_read16_blocking(spi0, &data16, &ret16, 1); } }`

    This is the SPI clock signal, 1 division is 1us.

    image

    There is almost a 1us overhead per call. Is this expected? Thanks, Marcel

  • Debug raspberrypi pico using openocd's daplink error

    Debug raspberrypi pico using openocd's daplink error

    When I use the openocd command to debug raspberrypi pico, I get an error: openocd configuration:

    rp2040.svd cmsis-dap.cfg rp2040.cfg arm-none-eabi-gdb.exe adapter speed 1000

    Open On-Chip Debugger 0.12.0-rc2 (2022-10-26-14:02)
    Licensed under GNU GPL v2
    For bug reports, read
            http://openocd.org/doc/doxygen/bugs.html
    adapter speed: 1000 kHz
    
    CDRTOSConfigure
    Info : Listening on port 50001 for tcl connections
    Info : Listening on port 50002 for telnet connections
    Info : CMSIS-DAP: SWD supported
    Info : CMSIS-DAP: JTAG supported
    Info : CMSIS-DAP: Atomic commands supported
    Info : CMSIS-DAP: FW Version = 1.10
    Info : CMSIS-DAP: Interface Initialised (SWD)
    Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
    Info : CMSIS-DAP: Interface ready
    Info : clock speed 1000 kHz
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : SWD DPIDR 0x0bc12477, DLPIDR 0x00000001
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: CMSIS-DAP command 0x1d not implemented
    Error: CMSIS-DAP command SWD_Sequence failed.
    Info : Read incorrect DLPIDR 0xf0000001 (possibly CTRL/STAT value)
    Error: Failed to connect multidrop rp2040.dap1
    

    Hoping to get some answers,thank you!

  • Disable LWIP_DHCP not possible, because DHCP is hardcoded in the SDK

    Disable LWIP_DHCP not possible, because DHCP is hardcoded in the SDK

    Hi all,

    I've searched a solution to get native static ip addresses supported without any use of DHCP. DHCP is using time, energy and computing. Therefore it makes sense, to have an option to define static addresses. LWIP supports setting static addresses via net_if. Is there a plan to have an option to enable / disable DHCP and use of manual static addresses?

    Thx

    Kr

    pingu

  • lwip-mqtt: sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty #1

    lwip-mqtt: sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty #1

    Hi all,

    I'm using pico_cyw43_arch_lwip_threadsafe_background with the lwip mqtt library. Anyways, I'm getting:

    *** PANIC *** sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty`

    The implementation is based on pico-sdk/lib/lwip/contrib/examples/mqtt/mqtt_example.c :

    int main() { stdio_init_all(); if(cyw43_arch_init_with_country(CYW43_COUNTRY_GERMANY)) { printf("Failed to initialise cyw43_arch\n"); } cyw43_arch_enable_sta_mode(); if(cyw43_arch_wifi_connect_timeout_ms(WIFI_SSID, WIFI_PASSWORD, CYW43_AUTH_WPA2_AES_PSK, 10000)) { printf("Failed to connect to WiFi\n"); } mqtt_example_init(); while(true) { printf("loop\n"); sleep_ms(1000); } return 0; }

    I've also implemented it from scratch with the documentation pico-sdk/lib/lwip/doc/mqtt_client.txt with the same result.

    I've also tested the implementation of https://github.com/cniles/picow-iot with the same result.

    Do you have an idea? Maybe there are issues with the sys_timers of the library itself?

    Is the mqtt-library only supported with FreeRTOS or also working with pico_cyw43_arch_lwip_threadsafe_background?

    Thank you!

    Kr

    pingufreak

  • Feature to Set USB device as self powered device

    Feature to Set USB device as self powered device

    Overview

    I was working in a project which I need to use Raspberry Pi Pico as USB self powered device. Power is supplied from VSYS. Since there is a diode between VBUS and VSYS, with this we can able to make self powered USB devices. Ref: Raspberry Pi Pico datasheet

    We also need to set USB Configuration Descriptor attribute (bmAttributes) to make it happen.

    https://www.keil.com/pack/doc/mw/USB/html/_u_s_b__configuration__descriptor.html https://www.beyondlogic.org/usbnutshell/usb5.shtml

    Please check the PR #1105

    USBD_MAX_POWER_MA

    Btw, even if we set the USB as self powered device there are still 2 resistor on the VBUS side. If we calculate the power consumption of the VBUS side,

     R1 + R10 is 15.6KΩ 
     5V /  15.6KΩ = 0.3mA
    

    That's why USBD_MAX_POWER_MA is set to 1.

    #define USBD_MAX_POWER_MA (1)
    
    Screenshot 2022-11-21 at 12 43 41

    Usage

    add this to your CMakeLists.txt file and USB will be self power device in USB Configuration Descriptor. add_definitions(-DPICO_STDIO_USB_DEVICE_SELF_POWERED=1)

    Test

    Bus powered
    ~$ lsusb -s 3:3 -v | grep bmAttributes
        bmAttributes         0x80
            bmAttributes            3
            bmAttributes            2
            bmAttributes            2
            
    Self powered (-DPICO_STDIO_USB_DEVICE_SELF_POWERED=1)
    ~$ lsusb -s 3:6 -v | grep bmAttributes
        bmAttributes         0xc0
            bmAttributes            3
            bmAttributes            2
            bmAttributes            2
    
Tetris on a Raspberry Pi Pico mounted on a Pimoroni Pico Explorer

PicoTetris Classic Tetris game running on a Raspberry Pi Pico microcontroller. Pico C port by Richard Birkby Original JavaScript implementation - Jake

Sep 3, 2022
Breakout game for Raspberry Pi Pico with Pimoroni Pico Display pack
Breakout game for Raspberry Pi Pico with Pimoroni Pico Display pack

breakout_rpi_pico Breakout game for Raspberry Pi Pico with Pimoroni Pico Display pack Prebuilt binary (breakout.uf2) is here. To build your own binary

Oct 15, 2022
Pico-uart-bridge - Raspberry Pi Pico UART-USB bridge

Raspberry Pi Pico USB-UART Bridge This program bridges the Raspberry Pi Pico HW UARTs to two independent USB CDC serial devices in order to behave lik

Nov 25, 2022
Prueba del Raspberry PI PICO con un display Raspberry PI TFT 3.5"

Raspberry-PI-PICO-display-RPI35 Prueba del Raspberry PI PICO con un display Raspberry PI TFT 3.5" Con ayuda de la libreria https://github.com/khoih-pr

Nov 10, 2021
Raspberry Pi Pico SDK Examples

Raspberry Pi Pico SDK Examples Getting started See Getting Started with the Raspberry Pi Pico and the README in the pico-sdk for information on gettin

Nov 19, 2022
🦠 µnix is a UNIX-like operating system for the raspberry pi pico.
🦠 µnix is a UNIX-like operating system for the raspberry pi pico.

The µnix Operating System "µnix", "munix" or, "micro unix" aims to be a micro kernel based operating system targeting the Raspberry Pi Pico. "µnix" is

Nov 7, 2022
U.C.S.D PASCAL System II for the Raspberry Pico

U.C.S.D PASCAL System II for the Raspberry Pico. The UCSD p-System is a portable operating system that was popular in the early days of personal compu

Nov 17, 2021
Raspberry Pi Pico (RP2040) and Micro-ROS (ROS 2) Integration

The Pico is an amazing microcontroller and I couldn't wait for ROS 2 support or Arduino Core, so here is my approach. Once the Arduino Core for RP2040 is out it will be easier to use micro_ros_arduino.

Jun 19, 2022
A laser cut Dreamcast Pop'n Music controller and integrated memory card using the Raspberry Pi Pico's Programmable IO
A laser cut Dreamcast Pop'n Music controller and integrated memory card using the Raspberry Pi Pico's Programmable IO

Dreamcast Pop'n Music Controller Using Raspbery Pi Pico (RP2040) Intro This is a homebrew controller for playing the Pop'n Music games on the Sega Dre

Oct 25, 2022
A small arcade game utilizing the Raspberry Pi Pico and 20 arcade buttons!

Pico Light Arcade This is the code for the Pico Light Arcade game that can be seen here: https://twitter.com/ghidraninja/status/1422900329369178113 Ha

Feb 21, 2022
The pico can be used to program other devices. Raspberry pi made such an effort. However there is no board yet, that is open-source and can be used with OpenOCD as a general-purpose programmer
The pico can be used to program other devices. Raspberry pi made such an effort. However there is no board yet, that is open-source and can be used with OpenOCD as a general-purpose programmer

pico-probe-programmer The pico can be used to program other devices. Raspberry pi made such an effort. However there is no board yet, that is open-sou

Oct 15, 2022
📚🪛 Arduino library to calibrate and improve ADC measurements with the Raspberry Pi Pico.

Arduino-Pico-Analog-Correction Arduino library to calibrate and improve ADC measurements with the Raspberry Pi Pico. Can compensate ADC offsets, calcu

Nov 12, 2022
built-in CMSIS-DAP debugger tailored especially for the RP2040 “Raspberry Pi Pico”

RP2040 has two ARM Cortex-M0+ cores, and the second core normally remains dormant. pico-debug runs on one core in a RP2040 and provides a USB CMSIS-DAP interface to debug the other core. No hardware is added; it is as if there were a virtual debug pod built-in.

Nov 15, 2022
Fractal rendering for Raspberry Pi Pico microcontroller

picofract Mandelbrot Set rendering demo for Raspberry Pi Pico microcontroller with Pico Display Pack. Building If you already have the Pimoroni SDK bu

Nov 19, 2022
Arduino API for the Raspberry Pico

Raspberry PI Pico - Arduino API On Friday I was receiving my Raspberry PI Pico and I had the opportunity to play around with it. Actually most of the

Oct 25, 2022
x86 emulator on Raspberry Pi Pico
x86 emulator on Raspberry Pi Pico

picox86 x86 emulator on Raspberry Pi Pico https://user-images.githubusercontent.com/10139098/110543817-13299080-812b-11eb-9c88-674cdae919fc.mp4 PCB fr

Nov 9, 2022
Web Server based on the Raspberry Pico using an ESP8266 with AT firmware for WiFi
Web Server based on the Raspberry Pico using an ESP8266 with AT firmware for WiFi

PicoWebServer This program runs on a Raspberry Pico RP2040 to provide a web server when connected to an Espressif ESP8266. This allows the Pico to be

Oct 6, 2022
Raspberry Pi Pico Arduino core, for all RP2040 boards
Raspberry Pi Pico Arduino core, for all RP2040 boards

Arduino-Pico Raspberry Pi Pico Arduino core, for all RP2040 boards This is a port of the RP2040 (Raspberry Pi Pico processor) to the Arduino ecosystem

Nov 25, 2022
A programming environment for Lua for the Raspberry Pi Pico microcontroller

picolua A programming environment for Lua for the Raspberry Pi Pico microcontroller. Version 0.3, April 2021 What is this? picolua is a proof-of-conce

Nov 22, 2022