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

Overview

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.

    tinyusb 
    opened by dshadoff 62
  • 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.

    opened by wa1tnr 49
  • 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()

    opened by Wiz-IO 41
  • 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
    
    opened by joshuag1000 32
  • 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.

    opened by Gadgetoid 31
  • 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

    opened by nonchip 30
  • 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]?

    enhancement 
    opened by thejpster 28
  • 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.

    cmsis 
    opened by flit 25
  • Compiling Error: duplicate 'inline'

    Compiling Error: duplicate 'inline'

    opened by splch 21
  • 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.

    opened by nsk126 20
  • 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

    opened by marcelvanherk 19
  • Cannot create a new section modifying the default linker script.

    Cannot create a new section modifying the default linker script.

    I do not know if this is the right forum, but I tried the raspberry pi forums to no avail.

    My requirement is to have a portion of the RAM reserved for holding code created at runtime, and for the section to be writable. Plus, I want to load some of its content by copy a portion of the FLASH at boot-up. The purpose is to have dynamic generation of code.

    I have a minimal sample that is modeled after the USB stdio sample for the SDK examples. It simply prints a string. I have attempted to create a modified linker script (based on the default script) as follows:

    main.cpp:

    #include <stdio.h>
    
    extern "C" void forth();
    
    int main()
    {
        forth();
        return 0;
    }
    
    

    forth() is defined in an assembly file called test.s

    test.s:

    .syntax unified
    .thumb
    
    .section .data
    .align 2
    data: .asciz "ABC12345"
    
    .section .user_section, "awx" @ putting function in .user_section
    @ .section .text
    .align 2
    .global forth 
    .thumb_func
    forth:
        PUSH    {LR}
        BL      stdio_init_all
        LDR     R0, =data
        BL      puts
        POP     {PC}
    

    The linker file has the following mods:

    MEMORY
    {
        FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 2048k
        RAM(rwx) : ORIGIN =  0x20000000, LENGTH = 128k
        FORTH(rwx) : ORIGIN =  0x20020000, LENGTH = 128k
        SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
        SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
    }
    

    and the section definition of user_section as follows:

    .user_section : {
            *(.user_section.*)
            . = ALIGN(4);
        } > FORTH AT> FLASH
    

    The .dis file looks like this:

    Sections:
    Idx Name          Size      VMA       LMA       File off  Algn
      0 .boot2        00000100  10000000  10000000  00001000  2**0
                      CONTENTS, ALLOC, LOAD, READONLY, CODE
      1 .text         000071e8  10000100  10000100  00001100  2**3
                      CONTENTS, ALLOC, LOAD, READONLY, CODE
      2 .rodata       000016b0  100072e8  100072e8  000082e8  2**3
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
      3 .binary_info  00000020  10008998  10008998  00009998  2**2
                      CONTENTS, ALLOC, LOAD, DATA
      4 .ram_vector_table 000000c0  20000000  20000000  0000b038  2**2
                      CONTENTS
      5 .data         00000460  200000c0  100089b8  0000a0c0  2**4
                      CONTENTS, ALLOC, LOAD, READONLY, CODE
      6 .uninitialized_data 00000000  20000520  20000520  0000b0f8  2**0
                      CONTENTS
      7 .user_section 00000038  20020000  10008e18  0000b000  2**3
                      CONTENTS, ALLOC, LOAD, READONLY, CODE
      8 .scratch_x    00000000  20040000  20040000  0000b0f8  2**0
                      CONTENTS
      9 .scratch_y    00000000  20041000  20041000  0000b0f8  2**0
                      CONTENTS
     10 .bss          00000d84  20000520  20000520  0000b520  2**3
                      ALLOC
     11 .heap         00000800  200012a4  200012a4  0000b0f8  2**2
                      CONTENTS, READONLY
    

    The .dis file appears to be correct, but the program does not run. If I change the section to just .text (see comment in test.s), it works fine. If I additionally use the copy_to_ram linker script distributed with the SDK, the code is loaded in RAM on boot. What I want is a combination of the two, in that user_section should be copied from FLASH to ram and should allow for additional code to be placed at runtime.

    I think I am doing all the right things but am stumped as to what I am missing. Any suggestions on making this work are appreciated.

    opened by shripathi-kamath 0
  • picoasm and gnu assembler

    picoasm and gnu assembler

    HI An option would be fine to generate an assembler compatible .h file or a #ifdef to exlude the C specific lines. (to keeping the public #defines only)

    opened by HondaRulez 2
  • Improve incremental build speeds by about 100%

    Improve incremental build speeds by about 100%

    This pull request speeds up incremental building of an application using the Pico SDK. I think the incremental build time is really important for productivity: you want to make a change to the code and then see the results a few seconds later without getting distracted by other things during long build times.

    Status quo

    On Windows under MSYS2, using version 1.4.0 of the pico-sdk (2e6142b), when I do an incremental build of the hello_pio example in commit a7ad171 of pico-examples, it takes about 5.9 seconds and here is the output:

    $ time make | ts '[%.S]'
    [48.859133] [  0%] Performing build step for 'ELF2UF2Build'
    [49.452387] [100%] Built target elf2uf2
    [49.700331] [  0%] No install step for 'ELF2UF2Build'
    [50.031675] [  0%] Completed 'ELF2UF2Build'
    [50.511903] [  0%] Built target ELF2UF2Build
    [50.808588] [  0%] Performing build step for 'PioasmBuild'
    [51.372992] [100%] Built target pioasm
    [51.672983] [  0%] No install step for 'PioasmBuild'
    [51.947172] [  0%] Completed 'PioasmBuild'
    [52.510109] [  0%] Built target PioasmBuild
    [52.791404] [  0%] Built target hello_pio_hello_pio_h
    [53.350379] [  0%] Built target bs2_default
    [53.651092] [ 50%] Built target bs2_default_padded_checksummed_asm
    [54.030474] [100%] Built target hello_pio
    
    real    0m5.940s
    user    0m0.105s
    sys     0m0.304s
    

    In this 5.9 second build, it looks like nearly 4 seconds are being spent to check if elf2uf2 and pioasm need to be rebuilt.

    This is actually the shortest possible build time because I did not change any code. If I modify pio/hello_pio/hello.c, the build time goes up to about 7 s. (These build times are not reliable and seem to vary by a second or so if I wait and try them later.)

    Solution

    This pull request removes the lines that say BUILD_AWAYS 1 # force dependency checking in the calls to ExternalProject_Add in tools/FindPioasm.cmake and tools/FindELF2UF2.cmake. With this change, an incremental build of hello_pio with no code changes takes 2.7 seconds:

    $ time make | ts '[%.S]'
    [54.426106] [  0%] Built target PioasmBuild
    [54.721123] [  0%] Built target hello_pio_hello_pio_h
    [55.045993] [  0%] Built target bs2_default
    [55.316484] [ 50%] Built target bs2_default_padded_checksummed_asm
    [55.625261] [ 50%] Built target ELF2UF2Build
    [56.083132] [100%] Built target hello_pio
    
    real    0m2.720s
    user    0m0.090s
    sys     0m0.105s
    

    If there has been a code change, that time goes up to about 3.6 seconds.

    It's not clear exactly why BUILD_ALWAYS is set to 1. The comment on that line is brief, and the code has been like that since the initial release of the Pico SDK. Note that with the BUILD_ALWAYS line removed, pioasm and elf2uf2 will not be automatically recompiled when the source code of those projects changes. To benefit from changes in those projects, users will have to remove their build directory and start again, or they can just go into build/pioasm or build/elf2uf2 and run make. I would hope that these utilities are stable enough that this will not cause major problems for most of the users, and the users would appreciate the faster build times. If you ever want to force everyone to rebuild those tools after a particularly important change, I would think you could do something like change the CMake target name (that should force everyone to rebuild those tools once, instead of making them rebuild them every time they compile their code). You could even bake the SDK version number into the CMake target name to make this process automatic (I haven't tried that).

    Future work

    By the way, there are some signs that the code in FindPioasm.cmake and FindELF2UF2.cmake are not really operating the way one would expect. Each file has three different if statements to check whether we have found/configured the external utility, and those checks could be reduced to one. (I succeeded in doing that on an unpublished branch.) Also, due to the way CMake variable and target scopes work, I found that the code in those files runs many times in a project like pico-examples that builds multiple RP2040 applications, even though you would think it would just run once. I might make another pull request later to further improve these files. Would there be any interest in allowing the use of external pioasm and elf2uf2 utilities found on the PATH, which is probably the best way to speed up incremental build times?

    opened by DavidEGrayson 1
  • #713 Hack to add SPI slave support

    #713 Hack to add SPI slave support

    Three SDK functions potentially attempt to change the SPI configuration while it is enabled. I hacked it to disable the module then change the configuration. It will attempt to re-enable the SPI if enabled. I do not save and restore other settings. I am not sure if this is required or not.

    Tested with the following code: (Quick and dirty)

    #include <stdio.h>
    #include "pico/stdio.h"
    #include "hardware/gpio.h"
    #include "hardware/spi.h"
    
    int main() {
        // Setup USB Serial
        stdio_init_all();
    
        // Setup SPI0 Pins
        for (int i = 0; i < 4; i++) {
            gpio_init(i + 2);
            gpio_set_function(i + 2, GPIO_FUNC_SPI);
        }
        gpio_set_dir(3, true);
    
        // Setup and enable SPI0-slave
        spi_init(spi0, 1000000);
        spi_set_format(spi0, 8, SPI_CPOL_0, SPI_CPHA_1, SPI_MSB_FIRST);
        spi_set_slave(spi0, true);
    
        while(1) {
            // Test SPI0-slave function
            if (spi_is_readable(spi0)) {
                uint8_t c;
                spi_read_blocking(spi0, 0, &c, 1);
                printf("%c ", c);
            }
        }
    }
    
    opened by daveythacher 1
  • SVD file is missing USB host-only registers and fields

    SVD file is missing USB host-only registers and fields

    The SVD file is missing a register and a field at the moment that are only used for USB host operation. Both overlap with device-only registers/fields.

    The register is EPx control. It can be found at USB DPSRAM offset 0x100, or the bottom of table 393 in the RP2040 datasheet (p.g. 386). This overlaps with the device-only EP0 buffer 0.

    The field doesn't really have a name concrete name, but it is called interrupt interval in the TinyUSB code. It can be found in bits 16:25 of the endpoint control registers, or table 394 of the RP2040 datasheet (p.g. 386). This overlaps with the interrupt on stall and interrupt on NAK fields.

    opened by yodaldevoid 3
Releases(1.4.0)
  • 1.4.0(Jun 30, 2022)

    This release adds wireless support for the Raspberry Pi Pico W, adds support for other new boards, and contains various bug fixes, documentation improvements, and minor improvements/added functionality. You can see the full list of individual commits here.

    New Board Support

    The following boards have been added and may be specified via PICO_BOARD:

    • pico_w
    • datanoisetv_rp2040_dsp
    • solderparty_rp2040_stamp_round_carrier

    Wireless Support

    • Support for the Raspberry Pi Pico W is now included with the SDK (PICO_BOARD=pico_w). The Pico W uses a driver for the wireless chip called cyw43_driver which is included as a submodule of the SDK. You need to initialize this submodule for Pico W wireless support to be available. Note that the LED on the Pico W board is only accessible via the wireless chip and can be accessed via cyw43_arch_gpio_put() and cyw43_arch_gpio_get() (part of the pico_cyw43_arch library described below). As a result of the LED being on the wireless chip, there is no PICO_DEFAULT_LED_PIN setting and the default LED based examples in pico-examples do not work with the Pico W.

    • IP support is provided by lwIP which is also included as a submodule which you should initialize if you want to use it.

      The following libraries exposing lwIP functionality are provided by the SDK:

      • pico_lwip_core (included in pico_lwip)
      • pico_lwip_core4 (included in pico_lwip)
      • pico_lwip_core6 (included in pico_lwip)
      • pico_lwip_netif (included in pico_lwip)
      • pico_lwip_sixlowpan (included in pico_lwip)
      • pico_lwip_ppp (included in pico_lwip)
      • pico_lwip_api (this is a blocking API that may be used with FreeRTOS and is not included in pico_lwip)

      As referenced above, the SDK provides a pico_lwip which aggregates all of the commonly needed lwIP functionality. You are of course free to use the substituent libraries explicitly instead.

      The following libraries are provided that contain the equivalent lwIP application support:

      • pico_lwip_snmp
      • pico_lwip_http
      • pico_lwip_makefsdata
      • pico_lwip_iperf
      • pico_lwip_smtp
      • pico_lwip_sntp
      • pico_lwip_mdns
      • pico_lwip_netbios
      • pico_lwip_tftp
      • pico_lwip_mbedtls
    • Integration of the IP stack and the cyw43_driver network driver into the user's code is handled by pico_cyw43_arch. Both the IP stack and the driver need to do work in response to network traffic, and pico_cyw43_arch provides a variety of strategies for servicing that work. Four architecture variants are currently provided as libraries:

      • pico_cyw43_arch_lwip_poll - For using the RAW lwIP API (NO_SYS=1 mode) with polling. With this architecture the user code must periodically poll via cyw43_arch_poll() to perform background work. This architecture matches the common use of lwIP on microcontrollers, and provides no multicore safety
      • pico_cyw43_arch_lwip_threadsafe_background - For using the RAW lwIP API (NO_SYS=1 mode) with multicore safety, and automatic servicing of the cyw43_driver and lwIP in the background. User polling is not required with this architecture, but care should be taken as lwIP callbacks happen in an IRQ context.
      • pico_cyw43_arch_lwip_sys_freertos - For using the full lwIP API including blocking sockets in OS mode (NO_SYS=0), along with multicore/task safety, and automatic servicing of the cyw43_driver and the lwIP stack in a separate task. This powerful architecture works with both SMP and non-SMP variants of the RP2040 port of FreeRTOS-Kernel. Note you must set FREERTOS_KERNEL_PATH in your build to use this variant.
      • pico_cyw43_arch_none - If you do not need the TCP/IP stack but wish to use the on-board LED or other wireless chip connected GPIOs.

      See the library documentation or the pico/cyw43_arch.h header for more details.

    Notable Library Changes/Improvements

    hardware_dma

    • Added dma_unclaim_mask() function for un-claiming multiple DMA channels at once.
    • Added channel_config_set_high_priority() function to set the channel priority via a channel config object.

    hardware_gpio

    • Improved the documentation for the pre-existing gpio IRQ functions which use the "one callback per core" callback mechanism, and added a gpio_set_irq_callback() function to explicitly set the callback independently of enabling per pin GPIO IRQs.

    • Reduced the latency of calling the existing "one callback per core" GPIO IRQ callback.

    • Added new support for the user to add their own shared GPIO IRQ handler independent of the pre-existing "one callback per core" callback mechanism, allowing for independent usage of GPIO IRQs without having to share one handler. See the documentation in hardware/irq.h for full details of the functions added:

      • gpio_add_raw_irq_handler()
      • gpio_add_raw_irq_handler_masked()
      • gpio_add_raw_irq_handler_with_order_priority()
      • gpio_add_raw_irq_handler_with_order_priority_masked()
      • gpio_remove_raw_irq_handler()
      • gpio_remove_raw_irq_handler_masked()
    • Added a gpio_get_irq_event_mask() utility function for use by the new "raw" IRQ handlers.

    hardware_irq

    • Added user_irq_claim(), user_irq_unclaim(), user_irq_claim_unused() and user_irq_is_claimed() functions for claiming ownership of the user IRQs (the ones numbered 26-31 and not connected to any hardware). Uses of the user IRQs have been updated to use these functions. For stdio_usb, the PICO_STDIO_USB_LOW_PRIORITY_IRQ define is still respected if specified, but otherwise an unclaimed one is chosen.
    • Added an irq_is_shared_handler() function to determine if a particular IRQ uses a shared handler.

    pico_sync

    • Added a sem_try_acquire() function, for non blocking acquisition of a semaphore.

    pico_stdio

    • stderr is now supported and goes to the same destination as stdout.
    • Zero timeouts for getchar_timeout_us() are now correctly honored (previously they were a 1us minimum).

    stdio_usb

    • stdio over USB can now be used even if you are linking to tinyusb_device yourself. If you have a CDC device in your device descriptors, you can use pico_enable_stdio_usb(TARGET 1) in your CMakeLists.txt
    • The use of a 1ms timer to handle background TinyUSB work has been replaced with use of a more interrupt driven approach using a user IRQ for better performance. Note this new feature is disabled if shared IRQ handlers are disabled via PICO_DISABLE_SHARED_IRQ_HANDLERS=1

    miscellaneous

    • get_core_num() has been moved to pico/platform.h from hardware/sync.h.
    • The C library function realloc() is now multicore safe too.
    • The minimum PLL frequency has been increased from 400Mhz to 750Mhz to improve stability across operating conditions. This should not affect the majority of users in any way, but may impact those trying to set particularly low clock frequencies. If you do wish to return to the previous minimum, you can set PICO_PLL_VCO_MIN_FREQ_MHZ back to 400. There is also a new PICO_PLL_VCO_MAX_FREQ_MHZ which defaults to 1600.

    Build

    • Compilation with GCC 12 is now supported.
    Source code(tar.gz)
    Source code(zip)
  • 1.3.1(May 18, 2022)

    This release contains numerous bug fixes and documentation improvements which are not all listed here; you can see the full list of individual commits here.

    New Board Support

    The following boards have been added and may be specified via PICO_BOARD:

    • adafruit_kb2040
    • adafruit_macropad_rp2040
    • eetree_gamekit_rp2040
    • garatronic_pybstick26_rp2040 (renamed from pybstick26_rp2040)
    • pimoroni_badger2040
    • pimoroni_motor2040
    • pimoroni_servo2040
    • pimoroni_tiny2040_2mb
    • seeed_xiao_rp2040
    • solderparty_rp2040_stamp_carrier
    • solderparty_rp2040_stamp
    • wiznet_w5100s_evb_pico

    Notable Library Changes/Improvements

    hardware_dma

    • New documentation has been added to the dma_channel_abort() function describing errata RP2040-E13, and how to work around it.

    hardware_irq

    • Fixed a bug related to removing and then re-adding shared IRQ handlers. It is now possible to add/remove handlers as documented.
    • Added new documentation clarifying the fact the shared IRQ handler ordering "priorities" have values that increase with higher priority vs Cortex M0+ IRQ priorites which have values that decrease with priority!

    hardware_pwm

    • Added a pwm_config_set_clkdiv_int_frac() method to complement pwm_config_set_clkdiv_int() and pwm_config_set_clkdiv().

    hardware_pio

    • Fixed the pio_set_irqn_source_mask_enabled() method which previously affected the wrong IRQ.

    hardware_rtc

    • Added clarification to rtc_set_datetime() documentation that the new value may not be visible to a rtc_get_datetime() very soon after, due to crossing of clock domains.

    pico_platform

    • Added a busy_wait_at_least_cycles() method as a convenience method for a short tight-loop counter-based delay.

    pico_stdio

    • Fixed a bug related to removing stdio "drivers". stdio_set_driver_eabled() can now be used freely to dynamically enable and disable drivers during runtime.

    pico_time

    • Added an is_at_the_end_of_time() method to check if a given time matches the SDK's maximum time value.

    Runtime

    • A bug in __ctzdi2() aka __builtin_ctz(uint64_t) was fixed.

    Build

    • Compilation with GCC 11 is now supported.
    • PIOASM_EXTRA_SOURCE_FILES is now actually respected.

    pioasm

    • Input files with Windows (CRLF) line endings are now accepted.
    • A bug in the python output was fixed.

    elf2uf2

    • Extra padding was added to the UF2 output of misaligned or non-contiguous binaries to work around errata RP2040-E14.

    Note the 1.3.0 release of the SDK incorrectly squashed the history of the changes. A new merge commit has been added to restore the full history, and the 1.3.0 tag has been updated

    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Nov 1, 2021)

    This release contains numerous bug fixes and documentation improvements. Additionally, it contains the following notable changes/improvements:

    Updated TinyUSB to 0.12.0

    • The lib/tinyusb submodule has been updated from 0.10.1 to 0.12.0. See https://github.com/hathach/tinyusb/releases/tag/0.11.0 and https://github.com/hathach/tinyusb/releases/tag/0.12.0 for release notes.
    • Improvements have been made for projects that include TinyUSB and also compile with enhanced warning levels and -Werror. Warnings have been fixed in rp2040 specific TinyUSB code, and in TinyUSB headers, and a new cmake function suppress_tinyusb_warnings() has been added, that you may call from your CMakeLists.txt to suppress warnings in other TinyUSB C files.

    New Board Support

    The following boards have been added and may be specified via PICO_BOARD:

    • adafruit_trinkey_qt2040
    • melopero_shake_rp2040
    • pimoroni_interstate75
    • pimoroni_plasma2040
    • pybstick26_rp2040
    • waveshare_rp2040_lcd_0.96
    • waveshare_rp2040_plus_4mb
    • waveshare_rp2040_plus_16mb
    • waveshare_rp2040_zero

    Updated SVD, hardware_regs, hardware_structs

    The RP2040 SVD has been updated, fixing some register access types and adding new documentation.

    The hardware_regs headers have been updated accordingly.

    The hardware_structs headers which were previously hand coded, are now generated from the SVD, and retain select documentation from the SVD, including register descriptions and register bit-field tables.

    e.g. what was once

    typedef struct {
        io_rw_32 ctrl;
        io_ro_32 fstat;
        ...
    

    becomes:

    // Reference to datasheet: https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf#tab-registerlist_pio
    //
    // The _REG_ macro is intended to help make the register navigable in your IDE (for example, using the "Go to Definition" feature)
    // _REG_(x) will link to the corresponding register in hardware/regs/pio.h.
    //
    // Bit-field descriptions are of the form:
    // BITMASK [BITRANGE]: FIELDNAME (RESETVALUE): DESCRIPTION
    
    typedef struct {
        _REG_(PIO_CTRL_OFFSET) // PIO_CTRL
        // PIO control register
        // 0x00000f00 [11:8]  : CLKDIV_RESTART (0): Restart a state machine's clock divider from an initial phase of 0
        // 0x000000f0 [7:4]   : SM_RESTART (0): Write 1 to instantly clear internal SM state which may be otherwise difficult...
        // 0x0000000f [3:0]   : SM_ENABLE (0): Enable/disable each of the four state machines by writing 1/0 to each of these four bits
        io_rw_32 ctrl;
    
        _REG_(PIO_FSTAT_OFFSET) // PIO_FSTAT
        // FIFO status register
        // 0x0f000000 [27:24] : TXEMPTY (0xf): State machine TX FIFO is empty
        // 0x000f0000 [19:16] : TXFULL (0): State machine TX FIFO is full
        // 0x00000f00 [11:8]  : RXEMPTY (0xf): State machine RX FIFO is empty
        // 0x0000000f [3:0]   : RXFULL (0): State machine RX FIFO is full
        io_ro_32 fstat;
        ...
    

    Behavioral Changes

    There were some behavioral changes in this release:

    pico_sync

    SDK 1.2.0 previously added recursive mutex support using the existing (previously non-recursive) mutex_ functions. This caused a performance regression, and the only clean way to fix the problem was to return the mutex_ functions to their pre-SDK 1.2.0 behavior, and split the recursive mutex functionality out into separate recursive_mutex_ functions with a separate recursive_mutex_ type.

    Code using the SDK 1.2.0 recursive mutex functionality will need to be changed to use the new type and functions, however as a convenience, the pre-processor define PICO_MUTEX_ENABLE_SDK120_COMPATIBILITY may be set to 1 to retain the SDK 1.2.0 behavior at the cost of an additional performance penalty. The ability to use this pre-processor define will be removed in a subsequent SDK version.

    pico_platform

    • pico.h and its dependencies have been slightly refactored so it can be included by assembler code as well as C/C++ code. Thie ensures that assembler code and C/C++ code follow the same board configuration/override order and see the same configuration defines. This should not break any existing code, but is notable enough to mention.
    • pico/platform.h is now fully documented.

    pico_standard_link

    -Wl,max-page-size=4096 is now passed to the linker, which is beneficial to certain users and should have no discernible impact on the rest.

    Other Notable Improvements

    hardware_base

    • Added xip_noalloc_alias(addr), xip_nocache_alias(addr), xip_nocache_noalloc_alias(addr) macros for converting a flash address between XIP aliases (similar to the hw_xxx_alias(addr) macros).

    hardware_dma

    • Added dma_timer_claim(), dma_timer_unclaim(), dma_claim_unused_timer() and dma_timer_is_claimed() to manage ownership of DMA timers.
    • Added dma_timer_set_fraction() and dma_get_timer_dreq() to facilitate pacing DMA transfers using DMA timers.

    hardware_i2c

    • Added i2c_get_dreq() function to facilitate configuring DMA transfers to/from an I2C instance.

    hardware_irq

    • Added irq_get_priority().
    • Fixed implementation when PICO_DISABLE_SHARED_IRQ_HANDLERS=1 is specified, and allowed irq_add_shared_handler to be used in this case (as long as there is only one handler - i.e. it behaves exactly like irq_set_exclusive_handler),
    • Sped up IRQ priority initialization which was slowing down per core initialization.

    hardware_pio

    • pio_encode_ functions in hardware/pico_instructions.h are now documented.

    hardware_pwm

    • Added pwm_get_dreq() function to facilitate configuring DMA transfers to a PWM slice.

    hardware_spi

    • Added spi_get_dreq() function to facilitate configuring DMA transfers to/from an SPI instance.

    hardware_uart

    • Added uart_get_dreq() function to facilitate configuring DMA transfers to/from a UART instance.

    hardware_watchdog

    • Added watchdog_enable_caused_reboot() to distinguish a watchdog reboot caused by a watchdog timeout after calling watchdog_enable() from other watchdog reboots (e.g. that are performed when a UF2 is dragged onto a device in BOOTSEL mode).

    pico_bootrom

    • Added new constants and function signature typedefs to pico/bootrom.h to facilitate calling bootrom functions directly.

    pico_multicore

    • Improved documentation in pico/multicore.h; particularly, multicore_lockout_ functions are newly documented.

    pico_platform

    • PICO_RP2040 is now defined to 1 in PICO_PLATFORM=rp2040 (i.e. normal) builds.

    pico_stdio

    • Added puts_raw() and putchar_raw() to skip CR/LF translation if enabled.
    • Added stdio_usb_connected() to detect CDC connection when using stdio_usb.
    • Added PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS define that can be set to wait for a CDC connection to be established during initialization of stdio_usb. Note: value -1 means indefinite. This can be used to prevent initial program output being lost, at the cost of requiring an active CDC connection.
    • Fixed semihosting_putc which was completely broken.

    pico_usb_reset_interface

    • This new library contains pico/usb_reset_interface.h split out from stdio_usb to facilitate inclusion in external projects.

    CMake build

    • OUTPUT_NAME target property is now respected when generating supplemental files (.BIN, .HEX, .MAP, .UF2)

    pioasm

    • Operator precedence of *, /, -, + have been fixed
    • Incorrect MicroPython output has been fixed.

    elf2uf2

    • A bug causing an error with binaries produces by certain other languages has been fixed.
    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Jun 3, 2021)

    This release contains numerous bug fixes and documentation improvements. Additionally it contains the following improvements/notable changes:

    Updated TinyUSB to 0.10.1

    The lib/tinyusb submodule has been updated from 0.8.0 and now tracks upstream https://github.com/hathach/tinyusb.git. It is worth making sure you do a

    git submodule sync
    git submodule update
    

    to make sure you are correctly tracking upstream TinyUSB if you are not checking out a clean pico-sdk repository.

    Note also that moving ffrom TinyUSB 0.8.0 to TinyUSB 0.10.1 may require some minor changes to your USB code.

    New/improved board headers

    • New board headers support for PICO_BOARDs arduino_nano_rp240_connect, pimoroni_picolipo_4mb and pimoroni_picolipo_16mb
    • Missing/new #defines for default SPI and I2C pins have been added

    Added CMSIS core headers

    CMSIS core headers (e.g. core_cm0plus.h and RP2040.h) are made available via cmsis_core INTERFACE library. Additionally, CMSIS standard exception naming is available via PICO_CMSIS_RENAME_EXCEPTIONS=1

    API improvements

    pico_sync

    • Added support for recursive mutexes via recursive_mutex_init() and auto_init_recursive_mutex()
    • Added mutex_enter_timeout_us()
    • Added critical_section_deinit()
    • Added sem_acquire_timeout_ms() and sem_acquire_block_until()

    hardware_adc

    • Added adc_get_selected_input()

    hardware_clocks

    • clock_get_hz() now returns actual achieved frequency rather than desired frequency

    hardware_dma

    • Added dma_channel_is_claimed()
    • Added new methods for configuring/acknowledging DMA IRQs. dma_irqn_set_channel_enabled(), dma_irqn_set_channel_mask_enabled(), dma_irqn_get_channel_status(), dma_irqn_acknowledge_channel() etc.

    hardware_exception

    New library for setting ARM exception handlers:

    • Added exception_set_exclusive_handler(), exception_restore_handler(), exception_get_vtable_handler()

    hardware_flash

    • Exposed previously private function flash_do_cmd() for low level flash command execution

    hardware_gpio

    • Added gpio_set_input_hysteresis_enabled(), gpio_is_input_hysteresis_enabled(), gpio_set_slew_rate(), gpio_get_slew_rate(), gpio_set_drive_strength(), gpio_get_drive_strength(). gpio_get_out_level(), gpio_set_irqover()

    hardware_i2c

    • Corrected a number of incorrect hardware register definitions
    • A number of edge case in the i2c code fixed

    hardware_interp

    • Added interp_lane_is_claimed(), interp_unclaim_lane_mask()

    hardware_irq

    • Notably fixed the PICO_LOWEST/HIGHEST_IRQ_PRIORITY values which were backwards!

    hardware_pio

    • Added new methods for configuring/acknowledging PIO interrupts (pio_set_irqn_source_enabled(), pio_set_irqn_source_mask_enabled(), pio_interrupt_get(), pio_interrupt_clear() etc.)
    • Added pio_sm_is_claimed()

    hardware_spi

    • Added spi_get_baudrate()
    • Changed spi_init() to return the set/achieved baud rate rather than void
    • Changed spi_is_writable() to return bool not size_t (it was always 1/0)

    hardware_sync

    • Notable documentation improvements for spin lock functions
    • Added spin_lock_is_claimed()

    hardware_timer

    • Added busy_wait_ms() to match busy_wait_us()
    • Added hardware_alarm_is_claimed()

    pico_float/pico_double

    • Correctly save/restore divider state if floating point is used from interrupts

    pico_int64_ops

    • Added PICO_INT64_OPS_IN_RAM flag to move code into RAM to avoid veneers when calling code is in RAM

    pico_runtime

    • Added ability to override panic function by setting PICO_PANIC_FUNCTION=foo to the use foo as the implementation, or setting PICO_PANIC_FUNCITON= to simply breakpoint, saving some code space

    pico_unique_id

    • Added pico_get_unique_board_id_string().

    General code improvements

    • Cleanup up some additional classes of compiler warnings
    • Adding some missing const to method parameters

    SVD

    • USB DPRAM for device mode is now included

    pioasm

    • Added #pragma once to C/C++ output

    RTOS interoperability

    Improvements designed to make porting RTOSes either based on the SDK or supporting SDK code easier.

    • Added PICO_DIVIDER_DISABLE_INTERRUPTS flag to optionally configure all uses of the hardware divider to be guarded by disabling interrupts, rather than requiring on the RTOS to save/restore the divider state on context switch
    • Added new abstractions to pico/lock_core.h to allow an RTOS to inject replacement code for SDK based low level wait, notify and sleep/timeouts used by synchonization primitives in pico_sync and for sleep_ methods. If an RTOS implements these few simple methods, then all SDK semaphore, mutex, queue, sleep methods can be safely used both within/to/from RTOS tasks, but also to communicate with non RTOS task aware code, whether it be existing libraries and IRQ handlers or code running perhaps (though not necessarily) on the other core

    CMake build changes

    Substantive changes have been made to the CMake build, so if you are using a hand crafted non-CMake build, you will need to update your compile/link flags. Additionally changed some possibly confusing status messages from CMake build generation to be debug only

    Boot Stage 2

    • New boot stage 2 for AT25SF128A
    Source code(tar.gz)
    Source code(zip)
  • 1.1.2(Apr 7, 2021)

  • 1.1.1(Apr 1, 2021)

  • 1.1.0(Mar 5, 2021)

    New Feature Highlights

    • Added board headers for Adafruit, Pimoroni & SparkFun boards

      • new values for PICO_BOARD are adafruit_feather_rp2040, adafruit_itsybitsy_rp2040, adafruit_qtpy_rp2040, pimoroni_keybow2040, pimoroni_picosystem, pimoroni_tiny2040, sparkfun_micromod, sparkfun_promicro, sparkfun_thingplus, in addition to the existing pico and vgaboard.
      • Added additional definitions for a default SPI, I2C pins as well as the existing ones for UART
      • Allow default pins to be undefined (not all boards have UART for example), and SDK will compile but warn as needed in the absence of default.
      • Added additional definition for a default WS2812 compatible pin (currently unused).
    • New reset options

      • Added pico_bootsel_via_double_reset library to allow reset to BOOTSEL mode via double press of a RESET button
      • When using pico_stdio_usb i.e. stdio connected via USB CDC to host, setting baud rate to 1200 (by default) can optionally be used to reset into BOOTSEL mode.
      • When using pico-stdio_usb i.e. stdio connected via USB CDC to host, an additional interface may be added to give picotool control over resetting the device.
    • Build improvement for non SDK or existing library builds

      • Removed additional compiler warnings (note register headers now use _u(x) macro for unsigned values though).
      • Made build more clang friendly.

    This release also contains many bug fixes, documentation updates and minor improvements.

    Note: there are some nominally backwards incompatible changes not worthy of a major version bump: - PICO_DEFAULT_UART_ defines now default to undefined if there is no default rather than -1 previously - The broken multicore_sleep_core1() API has been removed; multicore_reset_core1 is already available to put core 1 into a deep sleep.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Feb 1, 2021)

    • add pico_get_unique_id method to return a unique identifier for a Pico board using the identifier of the external flash
    • exposed all 4 pacing timers on the DMA peripheral (previously only 2 were exposed)
    • fixed ninja build (i.e. cmake -G ninja .. ; ninja)
    • minor other improvements and bug fixes

    Additionally, a low level change was made to the way flash binaries start executing after boot_stage2. This was at the request of folks implementing other language runtimes. It is not generally of concern to end users, however it did require a change to the linker scripts so if you have cloned those to make modifications then you need to port across the relevant changes. If you are porting a different language runtime using the SDK boot_stage2 implementations then you should be aware that you should now have a vector table (rather than executable code) - at 0x10000100

    Source code(tar.gz)
    Source code(zip)
Owner
Raspberry Pi
Raspberry Pi
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

Richard Birkby 34 Dec 3, 2022
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

null 19 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

Álvaro Fernández Rojas 156 Dec 23, 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

null 1 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

Raspberry Pi 1.6k Jan 1, 2023
🦠 µ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

Sleepy Monax 57 Dec 11, 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

null 4 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.

Darko Lukić 19 Jun 19, 2022
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

null 42 Dec 29, 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

stacksmashing 28 Dec 11, 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

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

martijn 22 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

NuclearPhoenix 11 Jan 3, 2023
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.

null 272 Dec 30, 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

null 22 Dec 7, 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

Phil Schatzmann 59 Jan 2, 2023
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

null 39 Nov 9, 2022
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

null 52 Jan 7, 2023
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

Earle F. Philhower, III 929 Jan 5, 2023
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

Kevin Boone 65 Jan 8, 2023