Compare commits

...

243 commits

Author SHA1 Message Date
graham sanderson
95ea6acad1 SDK 2.1.0 release 2024-11-24 23:44:29 -06:00
graham sanderson
beb2449622 Update picotool dependency to 2.1.0 (not strictly required, but we prefer people to be on the latest) 2024-11-24 23:43:46 -06:00
graham sanderson
2a1e1af6af Add missing CYW43_DEFAULT_PIN_WL_CS to pimoroni_pico_plus2_w_rp2350.h 2024-11-24 20:33:51 -06:00
Gonzalo Larralde
b7e255d18d
Add board file for Pimoroni Pico Plus 2 W (#2092)
* Add board pimoroni_pico_plus2_w_rp2350.
2024-11-24 20:04:39 -06:00
yh-sb
58e253ce04
Fix implicit declaration warning (#2093)
pico-sdk/src/rp2_common/pico_flash/flash.c:155:33: warning: implicit declaration of function 'make_timeout_time_ms'
pico-sdk/src/rp2_common/pico_flash/flash.c:156:77: warning: implicit declaration of function 'time_reached'
2024-11-24 19:44:36 -06:00
Graham Sanderson
5f607a9829
Comment out CMake cyw43 vars which aren't really that useful in general i don't think (#2090) 2024-11-24 11:27:10 -06:00
Graham Sanderson
a6ae2e6e4a
Fix compilation warnings (#2089) 2024-11-23 13:41:51 -06:00
yh-sb
3c39eecea3
Fix CMake build. (#2088)
hardware_watchdog depends from pico_bootrom due to header pico/bootrom.h

BUILD.bazel also has this dependency.
2024-11-23 13:02:57 -06:00
Luke Wren
65d118c342
RISC-V __mulsf3: handle exponent increase due to rounding (#2086) 2024-11-23 13:02:03 -06:00
Graham Sanderson
39a7f97116
Cleanup/clarification of PIO behavior with >32 pins (#2085) 2024-11-22 13:13:15 -06:00
Graham Sanderson
3dce58f21b
support both struct timespec and struct tm variants of the aon timer APIs (#2079)
* support both struct timespec and struct tm variants of the aon timer APIs since use of one type on RP2040 and the other on RP2350 require pulling in C library code. Provide weak pico_ wrappers for localtime_r and mktime so that the user can override the conversion functions
2024-11-22 12:11:02 -06:00
will-v-pi
2692d9a4cb
Propogate changed pico_cmake_set_default values to the compilation (#2034)
* Propogate non-default pico_cmake_set_default values through to compile definitions

Add PICO_BOARD_CMAKE_OVERRIDES common scope variable, to contain any pico_cmake_set_default
CMake variables which have been overwritten. This allows passing CMake arguments to the
build, without needing extra target_compile_definitions.

Also add pico_cmake_set_default PICO_RP2350_A2_SUPPORTED to enable/disable the E10 abs-block fix

* Fix more board files missing pico_cmake_set_default PICO_RP2350_A2_SUPPORTED

* Apply @lurch's patch to check_board_header.py
2024-11-21 17:47:51 -06:00
armandomontanez
338f99ff1c
Initial Pico/2 W Bazel support (#2049)
* Initial Pico 2 W Bazel support

Improves compatibility with Pico W and Pico 2 W by fixing issues that
prevented correct linking of wireless libraries.

* Improve correctness and configurability

* Require newer rules_python

* Require rules_python@0.36.0

* Fix missing compatibility expressions

* Minor tweaks

* Minor cleanup

* Update suggested version in Bazel README

* More README tweaks

* Improve Bazel btstack build correctness
2024-11-21 16:58:02 -06:00
Graham Sanderson
08ea1d89a9
prevent self-deadlock with PICOLIBC due to calloc/realloc internally calling malloc/free (#2069) 2024-11-21 16:53:24 -06:00
Luke Wren
7b07b0b6a1
Save/restore QMI window 1 registers across calls to flash_exit_xip(). (#2082)
* Save/restore QMI window 1 registers across calls to flash_exit_xip().

This works around the RP2350 ROM reinitialising window 1 even when it
does not actually issue an XIP exit sequence to that QSPI device. If no
exit sequence is issued, then the original configuration still applies.

This is not valid in the case where the ROM *does* issue an XIP exit
sequence to the second chip select, because the original mode is no
longer valid once the device is in the serial command state. The ROM
does this when FLASH_DEVINFO (loaded from OTP, stored in boot RAM) has a
nonzero size for chip select 1. To distinguish the two cases, this patch
adds getters/setters for FLASH_DEVINFO.

If chip select 1 has a nonzero size in FLASH_DEVINFO then the ROM's
register changes for window 1 are not reverted, and instead the
hardware_flash code makes additional changes to ensure writes also work
(as the ROM only reinitialises for reads).

This means that, in the case you have opted into ROM support for the
second chip select by setting a nonzero CS1 size in FLASH_DEVINFO, the
device on chip select 1 will continue to function correctly, but full
performance won't be restored until it is reinitialised. The best way to
handle this is initialising both chip select devices in your XIP setup
function (your boot2).

* Fix whitespace. Fix handling of PICO_FLASH_SIZE_BYTES == 0.
2024-11-21 16:52:34 -06:00
Graham Sanderson
9762b00c13
disable all IRQs in dma_chanel_cleanup - fixes for RP2350 (#2060) 2024-11-21 16:52:04 -06:00
Graham Sanderson
6bb44dd07d
Make all float->int/frac conversions round to nearest by default (#2065)
* making pio_calculate_clkdiv8_from_float round to the neareset 1/256 (not lower 1/256)

* chage rounding of all float clkdivs to round to neareset; default to nearest (which is a backwards incompatible change, but I think OK), and add ability to turn it off

* fix copy/paste errors in PICO_CONFIG

* Calculate size of FRAC field using its own MSB and LSB, rather than hoping that INT_LSB is in the right place

* Add a new REG_FIELD_WIDTH macro, and make the calculation of the clock-dividers more consistent

---------

Co-authored-by: Andrew Scheller <andrew.scheller@raspberrypi.com>
2024-11-21 16:48:33 -06:00
Graham Sanderson
5a98889434
add rom_reset_usb_boot_extra which supports >32 pins and ACTIVE_LOW; change existing uses to use this (#2084) 2024-11-21 16:48:05 -06:00
Graham Sanderson
6bb3ccf822
some minor pioasm fixes for #1950 (#2056) 2024-11-21 11:56:22 -06:00
Jack Wilsdon
8970241772
Fix flash_safe_execute timeout under FreeRTOS (#2021)
In some cases, the flash lockout task can start on the wrong core and
not have time to move to the correct core before exit is called. This
causes a timeout as the exit function is looking at the wrong core when
checking for the lockout task.
2024-11-21 11:24:17 -06:00
Luke Wren
36fefb5f30
Implement pico_bootsel_via_double_reset with the POWMAN DOUBLE_TAP flag on RP2350. (#2083)
The existing RAM implementation does not work because asserting the RUN pin holds SRAM in power-down.
2024-11-21 10:31:33 -06:00
Graham Sanderson
90bfb532a7
provide slightly meaningless _start symbol for boot_stage2 to make LLVM lld happy (#2080) 2024-11-21 10:10:12 -06:00
Graham Sanderson
31c1be5d5c
make panic loop back to breakpoint FWIW, and remove spurious header (#2062) 2024-11-21 10:00:38 -06:00
Andrew Scheller
f3459a45d4
Update documented max PIN values, to accomodate RP2350B (#2072) 2024-11-20 20:28:54 -06:00
Andrew Scheller
e17a82d291
Change __always_inline to __force_inline to suppress GCC errors (#2078) 2024-11-20 18:06:50 -06:00
newbrain
105a2b89d5
Update pwm.h (#2077)
NUM_DMA_IRQS was used instead of NUM_PWM_IRQS
2024-11-20 18:05:50 -06:00
will-v-pi
6bf5d9bf7d
Enforce ordering of pico_add_extra_outputs and picotool functions (#2054)
* Thow FATAL_ERROR when using post-processing functions after pico_add_extra_outputs

* Remove property definition, and rename to `PICOTOOL_PROCESSING_CONFIGURED` and `picotool_check_configurable`

* done -> configured
2024-11-20 16:43:05 -06:00
Graham Sanderson
9a2b75e26e
prevent early macro expansion in PICOBIN_..._AS_BITS() macros (#2068) 2024-11-20 16:42:19 -06:00
will-v-pi
74db3c2d86
Update work area size from 3064 to 3264, and recommend 3.25K (#2073) 2024-11-20 16:41:48 -06:00
Andrew Scheller
d3080e777f
Slight tweak to the config-extraction scripts. (#2070)
* Slight tweak to the config-extraction scripts.
A small logic bug meant they were reporting more false-positive warnings than they should have been.

* Small code tidy-up
2024-11-20 16:41:28 -06:00
Peter Harper
54d4f3a8f7
Add some missing pio functions (#2074)
Adds some 64 versions to work with rp2350b and more than 32 pins.
Change cyw43 code to use the new function.

Fixes #1834
2024-11-20 16:38:05 -06:00
Graham Sanderson
46283dd00f
github action upgrades (#2075)
* Windows workflow: bump cmake version

* Actions: update all workflows to checkout@v4
2024-11-20 11:02:03 -06:00
Graham Sanderson
06a244b2b5
fix incorrect disassembly of MOV rx_fifo (#2067) 2024-11-20 10:57:22 -06:00
Graham Sanderson
c2118cc005
allow PICO_CORE1_STACK_SIZE=0 (#2058) 2024-11-20 10:56:25 -06:00
Graham Sanderson
08bf6a7faa
use configured uart_instance rather than default instance for flushing stdio uart (#2066) 2024-11-20 10:45:20 -06:00
Andrew Scheller
2a4dbd9b7c
Small comment typo (#2064) 2024-11-20 10:44:50 -06:00
Andrew Scheller
c4b55f6346
Fix the name of a PICO_CMAKE_CONFIG (#2061)
Looks like this change accidentally got omitted from #1926
2024-11-19 19:12:48 -06:00
Graham Sanderson
e99c43b670
fix method name spelling (#2057) 2024-11-19 16:14:56 -06:00
Peter Harper
482dd59b5e
Abilty to limit iterations in hci processing loop (#1998)
Fixes #1455
2024-11-19 14:11:47 -06:00
Andrew Scheller
b122c42989
More CYW43 config tweaks (#2033)
- Re-synchronise the PICO_CMAKE_CONFIG: entries with the corresponding PICO_CONFIG: entries
 - Fix a silly typo I made in #2002
 - Enhance config-extraction scripts to catch similar typos in future
2024-11-19 14:10:40 -06:00
Liam Fraser
363302f780
Move to TinyUSB release 0.17.0 (#2053) 2024-11-19 14:08:44 -06:00
Liam Fraser
35fcc34747
Clocks doxygen: Remove incorrect clk_ref auxsrc value LPOSC. LPOSC is a primary source of clk_ref. Fixes issue #2047 (#2052) 2024-11-19 14:03:13 -06:00
Earle F. Philhower, III
5f6c432806
Fix minor uninitialized warnings from G++ 12.3.0 (#1786)
Use empty initializer list for struct clearing, avoiding a pedantic
warning from G++ 12 and 14.

Fixes #1785
2024-11-19 13:42:46 -06:00
armandomontanez
89691ed879
Do not assume submodule root directory in presubmit (#2040)
Tweaks compare_build_systems.py slightly so that it does not assume the
root directory of submodules, which arguably made the implementation a
little less intuitive.
2024-11-18 17:33:00 -06:00
armandomontanez
11e7801ba4
Remove repeated source file from pico_btstack (#2042)
Removes a duplicate reference to btstack's src/mesh/mesh.c file in the
CMake build.
2024-11-18 17:32:29 -06:00
graham sanderson
37e42578b0 bump macOS build action to macos-latest from deprecated macos-12 2024-11-18 17:32:00 -06:00
Peter Harper
8d1378dcd2
Remove Segger RTT from pico-btstack (#1995)
* Remove btstack Segger RTT from pico-btstack

We now have this in the SDK so adding it again in pico-btstack leads to
link errors.

But it's possible to use the btstack RTT functionality by defining
ENABLE_SEGGER_RTT=1, and if we're not using pico_stio_rtt we still need
to add the btstack RTT source.

* Fix build issues when RTT is enabled

Fixes https://github.com/raspberrypi/pico-examples/issues/565
2024-11-18 17:29:34 -06:00
Dryw Wade
fe018f92ab
Add SparkFun ThingPlus RP2350 (#2038)
* Add SparkFun Thing Plus RP2350

* Add pico_cmake_set_default to Thing Plus RP2350
2024-11-18 17:25:16 -06:00
Philip Howard
7ceca315f1
PPP2 and Plasma2350: SPICE to SPCE. (#2048)
As per discussion on https://github.com/adafruit/circuitpython/pull/9803

Change "SPICE" to "SPCE" for consistency.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2024-11-18 17:25:01 -06:00
Gregory Neverov
d6e3fa06f1
Fixes to picolibc_interface (#1795)
* Fixes to picolibc_interface

- Don't include bindings for tinystdio if picolibc was compiled with POSIX_IO.
- Add times() function, which seems to be missed, in the same pattern as settimeofday/gettimeofday.
2024-11-18 17:24:37 -06:00
Andrew Scheller
d0db3780fd
Fix typo in rom_get_partition_table_info doxygen (#2041) 2024-11-18 17:13:21 -06:00
Earle F. Philhower, III
0f847db371
Remove ARM assembly from RISC-V CYW43 SPI PIO (#2045)
Add hand-coded assembly RISC-V version of swap16x2 for CYW32 SPI PIO
driver.

Fixes #2044
2024-11-18 17:11:39 -06:00
armandomontanez
1b64cac8d6
Extend build system checks (#2039)
* Adds check that ensures the Bazel and CMake Pico SDK version strings
  stay in sync.
* Adds check that ensures the Bazel pins for external dependencies stays
  in sync with the git submodule pins.
* Updates cyw43-driver pin in Bazel.
* Makes the checks for some build configurability options non-blocking.
2024-11-13 14:11:49 -06:00
Graham Sanderson
06b7c1cf9e
Change div_int_frac methods to be suffixed by the number of bits of fraction e.g. div_int_frac8 (#1926) 2024-11-12 11:18:42 -06:00
Luke Wren
f9eb48bd91
Add XIP cache maintenance API (fixes #2005) (#2013)
* Add XIP cache maintenance API (fixes #2005)

Also add a cache clean to hardware_flash implementations, to avoid
losing pending writes on the subsequent invalidate.

* Fix comment typos, add to docs index, remove unnecessary defaulting of XIP_CACHE assertions on FLASH

* Fix sense of unsigned wrapping test

* update bazel build

---------

Co-authored-by: graham sanderson <graham.sanderson@raspberrypi.com>
2024-11-11 12:09:30 -06:00
Graham Sanderson
09a9379ea9
Add explicit alignment for embedded_end_block (#2017) 2024-11-11 11:13:12 -06:00
Machdyne UG
c7e562604e
add support for machdyne werkzeug rp2040 board (#2023)
* add support for machdyne werkzeug rp2040 board

* boards/machdyne_werkzeug: set default flash size for cmake

---------

Co-authored-by: inc <87362+inc@users.noreply.github.com>
2024-11-11 10:44:55 -06:00
Peter Harper
68778b1135
Clear i2c abort reason less often. (#2026)
It seems to be possible to get stuck in the loop which is checking for
abort. It can take 100s of iterations before an abort happens and on
each iteration we're clearing the abort interrupt even when it's not
required. If we only clear the abort when needed the lockup doesn't seem
to be reproducible.

Fixes #2025
2024-11-11 10:09:08 -06:00
Peter Harper
4726a56d24
Update cyw43-driver to latest main. (#2032) 2024-11-11 10:07:29 -06:00
Andrew Scheller
f642b763be
Move CYW43-related PICO_CONFIG lines to cyw43_driver.h (#2002) 2024-11-08 19:04:53 -06:00
Graham Sanderson
5c6fece28a
Minor header cleanups and ASM compatibility (#2019) 2024-11-08 19:04:02 -06:00
Peter Harper
750bfaeed3
Mesh support (#2001)
* Add `pico_btstack_mesh` CMake library to link BlueTooth Mesh capabilities hidden in BTstack

* Add pico_btstack_mesh to docs

---------

Co-authored-by: theshteves <stevenkneiser@gmail.com>
2024-11-08 19:03:21 -06:00
Peter Harper
4196f2c17e
Avoid hang in stdio_set_chars_available_callback (#2020)
The function is setting the callback after enabing the interrupt which
can cause a hang if a receive character is already pending.
Similarly we also have to clear the callback pointer only after the
interrupt is disabled.

Fixes #2009
2024-11-08 18:34:30 -06:00
Tobias Simetsreiter
1aa049f14b
update glibc header sys/cdefs.h include guard (#2029) 2024-11-08 18:33:11 -06:00
will-v-pi
2331e6f203
Fix dependency on files used by picotool (#2027)
Add the key files and partition table JSON to the link dependencies, to ensure the postprocessing is run when any of them are updated. Link dependencies seem to be the simplest way, as the elf file needs re-linking anyway given it has been post-processed, so this doesn't add any unecessary extra processing.

Without this fix, if you modify a pt.json file or a private key, the ouptut binary will not have the correct pt/key.
2024-11-08 18:27:30 -06:00
Peter Harper
809a423fb0
Fix some header dependencies (#2031)
Fixes #1929
2024-11-08 18:09:13 -06:00
andygpz11
6587f5cc9a
Add the required SYS_CLK_HZ definition to the suggested cmake output (#2022)
Fixes #2014
2024-11-06 10:24:10 -06:00
Earle F. Philhower, III
11961b97e4
Very minor typos in contributing.md (#1939) 2024-11-05 14:07:38 -06:00
Earle F. Philhower, III
ca0c0db979
Fix GCC14.1 compile error in w25x10cls.S (#2000)
GCC14 doesn't like the 2-character temporary label "00" and throws an error
.../pico-sdk/src/rp2040/boot_stage2/boot2_w25x10cl.S: Assembler messages:
.../pico-sdk/src/rp2040/boot_stage2/boot2_w25x10cl.S:147: Error: junk at end of line, first unrecognized character is `0'
.../pico/rp2040/pico-sdk/src/rp2040/boot_stage2/boot2_w25x10cl.S:150: Error: garbage following instruction -- `beq 00b'

Convert it to a single number, "1", like in other boot2xxx.S files

Fixes #1999
2024-11-05 14:06:04 -06:00
armandomontanez
e48a2e158c
[Bazel] Update rules_cc to v0.0.10 (#1989)
Updates rules_cc to v0.0.10 to reduce the steps required to get started
with creating a Bazel-based Pi Pico project.
2024-11-05 14:05:44 -06:00
Peter Harper
d649c6c77a
Add some tests (#1978)
* Test for best_effort_wfe_or_timeout sev issue

best_effort_wfe_or_timeout should not ignore an outstanding sev
See https://github.com/raspberrypi/pico-sdk/issues/1812

* Test for alarm being set in the past issue

See https://github.com/raspberrypi/pico-sdk/issues/1953
2024-11-05 17:27:19 +00:00
Graham Sanderson
bd130eddff
Remove code bloat in public SDK for 64K roms (#2016) 2024-11-05 10:57:22 -06:00
Graham Sanderson
8905de509f
Add missing instruction to vestigial copro_dis.py (#2018) 2024-11-05 10:54:26 -06:00
Graham Sanderson
37c6b24b1b
Add missing instruction to vestigial copro_dis.py (#2018) 2024-11-05 10:53:19 -06:00
Philip Howard
50322234b7
boards/pimoroni_plasma2350.h: correct flash size. (#2015)
Correct flash size from 8MB to 4MB to avoid wrapped addresses causing
firmware to be overwritten by the user filesystem in MicroPython.

Signed-off-by: Phil Howard <github@gadgetoid.com>
2024-11-04 13:12:11 -06:00
Hugh Nixon
98c114a8ee
Updated hardware/pio.h to correct the comment for the third (PIO 2) hardware PIO instance (#2004) 2024-11-04 13:11:46 -06:00
Dave Roth
37085889b0
Add RP2350 specific values to the exception_number enum (#1988) 2024-10-17 13:56:35 -05:00
Peter Harper
91dfbd01e8
Fix issue with free rtos execute sync (#1979)
Stop handle_sync_func_call removing the worker. Depending on thread priority
this can occur after the memory has gone out of scope in
async_context_freertos_execute_sync.

Fixes #1962
2024-10-17 13:55:20 -05:00
Peter Harper
66c7f0f607
Move cyw32 pin definitions (#1982)
It was probably not a good idea to put the default pin definitions in
cyw43_configport.h as they're specific to pico_w and Micropython needs
these but it has it's own version of cyw43_configport.h
2024-10-17 13:53:49 -05:00
armandomontanez
07d6dc1315
[Bazel] Fix bazel build, add presubmit (#1973)
* [Bazel] Fix bazel build, add presubmit

* Fixes a missing dep in the Bazel build breaking the host build.
* Automagically finds all board headers.
* Improves presubmit script polish for GH Action readiness.
* Adds a GitHub action workflow for the Bazel build.
* Disable failing checks
* Disables Windows, as there's a mix of real build errors and
  overly-ambitious checks that don't work on Windows.
* Disables extra checks temporarily since it's currently failing.
2024-10-12 17:41:43 -05:00
Petr Hosek
03a82f3d2f
Update Clang toolchain used by Bazel (#1976)
LLVM-libc baremetal build now includes `mktime` so we no longer need to
provide our own declaration in the polyfill header.
2024-10-12 11:24:18 -05:00
chrisboross
fa91723371
Update hellbender_0001.h (#1967)
Updating flash sizes to match BOM
2024-10-01 18:46:39 -05:00
Graham Sanderson
c675dfeaa5
fix mis-spelling of PICO_CLOCK_AJDUST_PERI_CLOCK_WITH_SYS_CLOCK (#1966) 2024-10-01 09:48:23 -05:00
Caleb Jamison
761bb1dba0
hellbender_0001 board file (#1957)
* hellbender_0001 board file

* Fix FTRX_RX_PIN, Fix define names to match filename
2024-09-30 16:17:45 -05:00
Graham Sanderson
bd5523cc64
Improve best_effort_wfe_or_timeout (#1822)
* #1812 improvements to best_effort_wfe_or_timeout

* Fix best_effort_wfe_or_timeout further by not having the IRQ ever move the alarm target backwards
2024-09-30 09:43:55 -05:00
Dhiru Kholia
cf8301f3e6
Doc fix for aon_timer on RP2350 (#1960) 2024-09-30 09:39:58 -05:00
Graham Sanderson
e2e0fd51c3
remove support for A0 & A1 versions of RP2350 (#1958) 2024-09-30 09:39:36 -05:00
Giampiero Baggiani
075e829cd9
Update i2c_slave.c: clock stretching comment fix (#1811)
* Update i2c_slave.c: clock stretching comment fix

This changed since 89914870ae06b2418c8ecc7e21af00d2dd77f8cb

* Update i2c_slave.c
2024-09-27 23:54:47 -05:00
Matt Bennett
ff373b33dc
Fixes #1891 Update pico_configure_ip4_address comments (#1892)
* Update pico_configure_ip4_address comments

Update pico_configure_ip4_address CMakeLists.txt function comments to correct compile definition names

* Swap compile definitions in comments

Swap compile definitions order in pico_configure_ip4_address to group more naturally.
2024-09-27 23:54:12 -05:00
Andrew Scheller
78533ec119
Specify minimum cmake version for generic_board.cmake (#1879) 2024-09-27 23:53:44 -05:00
Stanislav Rubint
20cf7119f4
removed dangling #ifdef __cplusplus (#1941) 2024-09-27 23:52:39 -05:00
Peter Harper
66335f1dc7
Clarify that RP2350 gets its unique id from OTP (#1942)
* Clarify that RP2350 gets its unique id from OTP

Fixes #1915

* Wrap rp2040_specific and rp2350_specific bits
2024-09-27 23:51:39 -05:00
Dave Roth
8c08f2b8ff
Export linker scripts in the bazel build. (#1944)
* Export linker scripts in the bazel build.

Make the rp2040 and rp2350 linker scripts available in downstream
projects bazel builds.

* Move exports_files below the package declaration.
2024-09-27 23:50:22 -05:00
Andrew Featherstone
0e5ef0f40f
Fix hardware_alarm_irq_handler when using Timer 1 (#1949)
Correct the logic for determining `timer_num`. Previously this would
always evaluate to 0 due to using `alarm_num` instead of `irq_num`.

Fixes #1948.
2024-09-27 23:49:22 -05:00
Andrew Scheller
a0f828fb16
Fix doxygen typo (#1945) 2024-09-27 23:48:58 -05:00
Peter Harper
9f56a47dca
Avoid setting an alarm in the past (#1954)
* Avoid setting an alarm in the past

Fixes #1953

* Call ta_time_us_64 when needed

Remove local "now" variable.
2024-09-26 10:56:05 -05:00
graham sanderson
d08f36cd1c fix assertion failure in rp2350_chip_version 2024-09-20 12:18:18 -05:00
David Goffredo
780817a8c7
Fix comments next to enum gpio_irq_level values. (#1928)
The comments for the values of `enum gpio_irq_level` mix up zero and
one. This commit replaces "0" with "1" and vice versa where appropriate
in those comments.
2024-09-18 14:17:18 -05:00
Peter Harper
af2f42613e
Changes for pico2_w (#1816)
* Add board file for pico2_w

This is a copy of pico2 with the definitions from pico_w added.
Set PICO_BOARD=pico2_w

* Simplify CYW43 PIO config

cyw43_spi_init contains code to find a free PIO and state machine. This
can all be replaced with pio_claim_free_sm_and_add_program_for_gpio_range

* Make CYW43 gpio pins configurable at build time

The CYW43 gpio pins are currently hardcoded. Give the defines better
names and make them overrideable at build time.

Note: CYW43_PIN_WL_REG_ON and CYW43_PIN_WL_HOST_WAKE are already used by
the driver via cyw43_hal_* functions

* Fix pio initialisation

Need to make sure the pio can work with all the gpios

* Add missing doxygen for cyw43_set_pio_clock_divisor

* Support dynamic configuration of cyw43 gpio pins

Add CYW43_PIN_WL_DYNAMIC that means cyw43 gpio pins can be changed at
runtime.

Then CYW43_PIN_WL_* calls cyw43_get_pin_wl to get the gpio out of
the array.

cyw43_set_pins_wl can be used to change the cyw43 gpio pins although
care is needed when calling this?

* Some fixes for cyw32 gpio > 32

* Allow CYW43 to be configured with cmake

* Add default config of CYW43_WL_GPIO_COUNT to cyw43_configport.h

* Fix some review comments

Add some PICO_CMAKE_CONFIG
Stop using gpio_*_mask64 functions
2024-09-18 14:16:41 -05:00
Graham Sanderson
6500c59d70
Add busy_wait_at_leasy_cycles to host (#1925) 2024-09-11 18:33:33 -05:00
Mete Balcı
42e234f8f3
#1909 fix system_RP2350 typos (#1910) 2024-09-11 10:48:35 -05:00
Thomas Watson
0ed2840306
boot_stage2: improve reproducibility (#1907)
Specifying the final boot2 source file as a link library here causes the
final `.elf` to be linked directly with that `.S`, which causes it to be
compiled into an object file with a name like `/tmp/<random chars>.o`.
This temporary object name is embedded in the final `.elf`, so the
`.elf`'s contents change after each link even if none of the input files
change, breaking reproducibility.

Fix the issue by specifying the source file as the source for an
object-only library, then specifying the library's object files as the
target link libraries, so the source is compiled in a separate step and
only the object is passed to the linker.
2024-09-11 10:43:32 -05:00
seesturm
ec0037b508
Enable building with Bazel on Raspberry PI OS machines (#1921)
* Adding RaspberryPI OS as build host

* Add rp2350 for build on Raspberry PI OS
2024-09-11 10:34:44 -05:00
CMD
f12ac1c2c1
RISC-V inline assembly constraints fix - platform.h (#1923)
Changed the constraint from "l" (specific to ARM) to the general "r" in inline assembly used for RISC-V architecture.

This ensures most compilers are able to compile this header file.
2024-09-11 10:08:15 -05:00
armandomontanez
0f38151002
[Bazel] Update version string to 2.0.1-develop (#1885)
Updates the Bazel module version string to match the current CMake
version string for the develop branch.
2024-09-10 18:49:04 -05:00
Graham Sanderson
398ac2baf9
Some small fixes/improvements for pico_minimize_runtime (#1919)
* add PANIC and AUTO_INIT_MUTEX to pico_minimize_runtime; fix build with PICO_PANIC_FUNCTION=

* add pico_minimize_runtime for host builds - does nothing

* Add ALL option to pico_minimize_runtime
2024-09-10 18:45:25 -05:00
armandomontanez
b49d4ec949
Fix Bazel build breakages (#1908)
* Fix Bazel build breakages

* Adds support for new PICO_DEFAULT_UART_BAUD_RATE option.
* Fixes issues related to Picotool and boot_picoboot_headers.
* Adds pico_float RISC-V pieces to the Bazel build (not yet fully
  tested).
* Adds the missing adafruit board header to the Bazel build.

* Exclude hazard3 float test in Bazel validation script

* Restore missing dependency in hardware_boot_lock
2024-09-10 18:44:55 -05:00
Koji KITAYAMA
3a79149d2c
Fix a compile error by using clang-x86_64-pc-windows-msvc (#1890) 2024-09-05 11:37:39 -05:00
will-v-pi
dfb573818f
Use lib instead of CMAKE_INSTALL_LIBDIR for pioasm install (#1865) 2024-09-03 16:26:43 -05:00
Dranoel
f13306c8a7
Fix typo in documentation of PICO_RAND_ENTROPY_SRC_TRNG (#1794) 2024-09-03 16:21:33 -05:00
graham sanderson
b3cadb7de2 fix RISC-V build 2024-09-01 09:45:02 -05:00
Sylwester
d957c738db
Add RP2350 PicoADK variant (#1787) 2024-09-01 09:33:41 -05:00
Andrew Scheller
b98970f71e
PIO doxygen typo (#1894) 2024-09-01 09:31:41 -05:00
Nhan Cao
3bc866395c
Adding I2C Burst Reading/Writing feature (#1495)
* Adding I2C Burst Reading/Writing feature

* Add functions to header file.

Fixing: https://github.com/raspberrypi/pico-sdk/pull/1495

* Some missing changes

Rename the functions. Lose the "mode" and "blocking" needs to be at the
end.
Just set restart_on_next in the caller rather than adding a parameter.

---------

Co-authored-by: anhnhancao <nhan@earable.ai>
Co-authored-by: Peter Harper <peter.harper@raspberrypi.com>
2024-08-30 12:55:25 -05:00
Stefan Kerkmann
3cb21c8134
pico_bootrom: bootrom.h: fix -Wstrict-prototypes (#1888)
The refactoring of these functions removed the (void) in the function
declarations - thus compiling with -Wstrict-prototypes will yell at us
at compile time.

Signed-off-by: Stefan Kerkmann <karlk90@pm.me>
2024-08-30 11:45:58 -05:00
Luke Wren
d886df6eb0
Add fast single-precision add/sub/mul for Hazard3 (#1883)
* Add fast single-precision add/sub/mul for Hazard3

* Make test output less noisy. Map -nan to -inf in vector gen. Move random vectors to separate files.

* Re-disable USB stdout for pico_float_test by default...

* Disable pico/float.h exports on RISC-V as these functions aren't implemented

* Add hazard3 instructions to asm_helper. Split hazard3.h to support this.

You can still include hazard3.h to get everything. This just allows you
to pull in less.
2024-08-30 11:36:30 -05:00
Graham Sanderson
876f331033
bump picotool to the develop branch (#1886) 2024-08-29 19:14:50 -05:00
Graham Sanderson
ff5401f3b2
separate actual shared bootrom header into boot_bootrom_headers, as pico_bootrom which is focused on calling the bootrom now has non trivial dependencies like pico_flash (#1881) 2024-08-29 19:07:23 -05:00
Graham Sanderson
91864a0d6e
fix bug in sm_config_set_in_pin_count (#1880)
* fix bug in sm_config_set_in_pin_count

* comment updates
2024-08-29 11:17:06 -05:00
graham sanderson
2d60604b6e Revert "bootrom build includes pico_bootrom but not bootrom.h which is the only thing which requires pico_flash... slightly hacky fix to not include pico_flash if not available"
This reverts commit 4bbf701b4b.
2024-08-28 18:51:10 -05:00
graham sanderson
4bbf701b4b bootrom build includes pico_bootrom but not bootrom.h which is the only thing which requires pico_flash... slightly hacky fix to not include pico_flash if not available 2024-08-28 12:40:14 -05:00
will-v-pi
a2a4c2041e
Don't run coprodis on Risc-V or RP2040 binaries (#1875) 2024-08-27 11:22:15 -05:00
Graham Sanderson
dd4aacbd1c
fix linker script bug using ALL of RAM (#1872) 2024-08-27 11:13:28 -05:00
Andrew Scheller
d639292fea
Update extract configs (#1845)
* Update config-extraction scripts to work with multiple chips

* Standardise wording between common options

* Various config-related fixes

* Update pico_rand to use correct busctrl_hw struct-name

* Don't start config descriptions with "The ..."
2024-08-27 11:11:42 -05:00
Andrew Scheller
a700b7784b
Small pico_pre_load_platform.cmake tweak (#1867)
Make one of the messages more accurate, in the event that the user changes `PICO_DEFAULT_RP2350_PLATFORM`
2024-08-24 15:03:54 -05:00
will-v-pi
a46addba7b
Fix stdio_usb with reset interface disabled on Windows (#1857)
* Only use bcdUSB = 0x0200 with MS_OS_20 descriptor enabled

* Add comment
2024-08-24 14:54:44 -05:00
will-v-pi
bc598fff27
Fix #1861 - MAX_EXCEPTION_NUM is the highest number, so check should be > not >= (#1866) 2024-08-24 14:54:06 -05:00
Andrew Scheller
7d5d9276a8
Workaround gcc/newlib issue on Ubuntu 24 (#1863) 2024-08-23 10:59:36 -05:00
Peter Harper
aa8cf17732
Fix assert in gpio_set_irq_enabled (#1864)
* Fix assert in gpio_set_irq_enabled
2024-08-23 10:58:38 -05:00
Taylor Cramer
7dc10d7aad
Bazel: disable link_extra_lib when building bootloader (#1854)
Fixes #1853
2024-08-22 11:56:51 -05:00
will-v-pi
9b16c797b4
Reorder pins in bi_pins_with_names to work with mask (#1858) 2024-08-22 11:56:16 -05:00
will-v-pi
598ba01ec8
Add build-essential to README command line install (#1859)
* Add build-essential to README command line install

* Update README.md
2024-08-22 11:43:52 -05:00
J
4cb5c1ccf1
bazel build: Fix compilation bugs for Pico-W support (#1797)
* Add @pico-sdk prefix to bazel/config in lwip.BUILD

Without this, we're trying to refer to a subpackage of
the lwip directory called bazel/config, which doesn't
exist. See similar references in this file.

* bazelbuild: Fix compilation errors with pico_lwip and freertos

This fixes two general problems.

* pico_lwip_contrib_freertos misspelled several things
  (omitted contrib/ dir prefix, didn't have @pico-sdk in front of
  out references to pico-sdk targets)

  This is fixed simply by fixing the spellings.

* Circular dependency between pico_lwip_core and pico_lwip_contrib_freertos.
  In NO_SYS=0 mode, lwip wants to include sys_arch.h. But sys_arch.h
  is defined in pico_lwip_contrib_freertos. sys_arch.c in turn wants
  to include lwip's opt.h and arch.h, among other things. So it needs
  to depend on pico_lwip_core.

  This is fixed by extracting all the headers into a common rule which
  can be depended on by both targets, then depending on it in the
  relevant targets.

Additionally, for the LWIP+FreeRTOS build to work correctly, we need
to actually depend on the pico_lwip_contrib_freertos rule from
pico_lwip_core. This the purpose of the select in the deps of
pico_lwip_core.

* bazel+cyw43: Fix compilation errors.

This fixes issues with the cyw43 driver
build rules in Bazel:

* Before this, the btstack would always be included
  even if it could not be used. If the user did not
  specify a btstack config, this would cause a
  compilation error. Now, we condition the linking
  and building of the btstack on whether there is
  a config for it.
* Before, the btbus was not properly linked.

* Implements code review feedback
2024-08-22 11:30:26 -05:00
will-v-pi
4a272778cd
Disable interrupts while doing flash_op, explicit_buy, and chain_image (#1835)
* Disable interrupts for some rom functions

* Use flash_safe_execute

* Inline and rename helpers
2024-08-22 11:29:35 -05:00
Graham Sanderson
eba6adb4e1
#1851 fix signature of hardware_alarm_get_irq_num (#1852) 2024-08-20 13:26:08 -05:00
Scott Shawcroft
19d5f4c0d7
Add board definition for Adafruit Feather 2350 (#1784) 2024-08-20 13:12:17 -05:00
David Goffredo
eaaa4a5ab3
typo in documentation of __time_critical_func (#1792)
I was reading through my PDF copy of the SDK docs, and I think that there's a typo in this example. The macro is `__time_critical_func` but the example spells it `__time_critical`.
2024-08-20 13:03:46 -05:00
Ikko Eltociear Ashimine
fa88c125b8
Update aon_timer.h (#1809)
specifed -> specified
2024-08-20 12:48:45 -05:00
Andrew Scheller
9a41722dd3
More board header checks (#1814)
* Modify check_board_header.py to work with both RP2040- and RP2350-based boards

* Tweaks to the board-header files so that they pass check_board_header.py

* Update tools/check_board_header.py
so that it handles pico_cmake_set_default the same way as cmake/generic_board.cmake does
2024-08-20 12:47:20 -05:00
Andrew Scheller
1bdd006c8d
Small doxygen fixes (#1828) 2024-08-20 12:41:49 -05:00
will-v-pi
7be79e8abe
Fix picobin inclusion from assembler with NO_PICO_PLATFORM (#1832)
Needs to copy the _u(x) definition from platform_defs.h
2024-08-20 12:40:52 -05:00
Nikhil Dabas
789ea75c63
Ensure makefsdata.py generates valid variable names (#1841)
* Ensure makefsdata.py generates valid variable names

* Use mimetypes library in makefsdata.py

* Avoid generating duplicate variable names
2024-08-20 12:31:45 -05:00
graham sanderson
e930bf3261 Deprecate copro_dis.py - keep for now as it is used by bootrom build 2024-08-20 09:48:50 -05:00
graham sanderson
9430469e18 Revert "Delete tools/copro_dis.py (#1833)"
This reverts commit b271208071.
2024-08-20 09:48:50 -05:00
Graham Sanderson
fab47c8071
Fix Cmsis irq regression (#1821)
* #1817 fix regression with CMSIS interrupt renaming
2024-08-20 08:52:41 -05:00
will-v-pi
8886f272a9
Fix Windows CI build (#1846)
* Use powershell for windows CI build

* Remove unnecessary warning
2024-08-19 12:49:54 -05:00
Graham Sanderson
cd71c8953e
Fix missing Binary Info for boot_stage2 (#1844)
* fix boot stage2 not showing up in binary info; sync rp2040 and rp230 bs2 CMakeLists.txt
2024-08-19 12:47:29 -05:00
Graham Sanderson
62df126ad5
#1805 fix merge issue in pico_atomic which ended up with using IRQ disble instead of spin lock (#1838) 2024-08-19 12:13:51 -05:00
Andrew Scheller
b271208071
Delete tools/copro_dis.py (#1833)
This functionality has been moved into `picotool`, so remove this Python script to avoid confusion
2024-08-16 12:21:27 -05:00
graham sanderson
7a0f1f03dd #1829 .HEX files missing since SDK2.0.0 2024-08-15 14:15:29 -05:00
will-v-pi
a6f21b6e10
Include Platform Paths files for the host (#1826)
This fixes searching for installed picotool/pioasm on Windows, and generally improves default find_package behaviour
2024-08-15 11:29:22 -05:00
Peter Harper
e049f5063f
Support serial flash with 16 byte unique id (#1819)
* Support serial flash with 16 byte unique id

Flash devices like IS25LP016D have a 16 byte unique id. Reading just the
first 8 bytes causes devices to have duplicate unique ids as the numbers
only differ in the final 8 bytes.

Support overriding FLASH_UNIQUE_ID_SIZE_BYTES in the board header. Use
the final 8 bytes for the unique id.

Fixes #1641
2024-08-15 11:23:15 -05:00
J
a2642f93a4
.gitignore: Add .cache (#1825)
This is where clangd puts a bunch of junk,
so it's nice to have it ignored for folks who
use clangd.
2024-08-15 11:04:08 -05:00
graham sanderson
424e21ec07 #1788 fix missing static_assert message 2024-08-14 17:57:36 -05:00
graham sanderson
8177366292 bump version for sdk 2.0.1-develop 2024-08-14 16:12:37 -05:00
Andrew Scheller
f4a691a2c7
Update doxygen group for clock functions (#1808)
Fixes #1806
2024-08-12 16:01:07 -07:00
graham sanderson
efe2103f9b SDK 2.0.0 release 2024-08-08 08:54:38 -05:00
Andrew Scheller
45984e276f
Small tweak to extract_configs.py (#1776)
Always write the path as "abosolute" (relative to the root of pico-sdk) as that makes searching for it (when building the RP2040 datasheet) much faster. This matches the behaviour of extract_build_defines.py and extract_cmake_configs.py
2024-07-25 15:13:00 -05:00
andygpz11
b3bf690d0a
Clarify uart_write_blocking() API vs UART still busy sending (#1274) (#1709) 2024-07-25 11:12:21 -05:00
Andrew Scheller
9f85f25640
Add extra checks to check_board_header.py (#1775)
* Small whitespace fixup

* typo bugfix

* Small refactoring of check_board_header.py

* Make structure of rp2040_interface_pins.json more explicit, so that it can be more easily extended

* Move definition of valid-pins from python to json

* Check that each interface includes all (minimally) expected pins
Note that UART_CTS, UART_RTS & SPI_CSN are classed as optional

* Split "expected_functions" into "required" (all of these pins must be present) and "one_of" (at least one of these pins must be present)
2024-07-25 09:47:26 -05:00
WallyWare
6624098756
Add board file for Pi-Plates MICROPi (#1487) 2024-07-24 07:21:54 -05:00
graham sanderson
41b4d3adb4 rename gpio_set_function_mask to gpio_set_function_masked to match naming schema of other gpio functions 2024-07-24 07:00:37 -05:00
George Peppard
7c5b426a0f
Add gpio_set_function_mask function (#1462) 2024-07-24 06:47:59 -05:00
Gigahawk
af9b47c668
Add board definition for Adafruit Feather RP2040 with USB Type A Host (#1761) 2024-07-24 06:29:53 -05:00
Chris Burton
b45632b06e
Add 8086 USB Interposer board (#1767) 2024-07-24 06:27:38 -05:00
Peter Harper
5ec40711f4
Some doc issues (#1772)
* Fix doxygen for uart example

Fixes https://github.com/raspberrypi/pico-sdk/issues/1685

* Clarify uart write

will block until data "has been sent to the UART transmit buffer"

Fixes https://github.com/raspberrypi/pico-sdk/issues/1481

* Add note to flash API about erasing sectors

Fixes: https://github.com/raspberrypi/pico-sdk/issues/650
2024-07-23 13:00:41 -05:00
Peter Harper
6328fffc71
Update LwIP to 2.2.0 (#1769)
Fixes #1565
2024-07-22 10:01:24 -05:00
graham sanderson
7f37af837b add missing rtt cmake functions for host 2024-07-20 20:58:34 -05:00
Andrew Fernandes
0996a9e354
Add support for SEGGER RTT STDIO (updated) (#1411) 2024-07-20 20:52:41 -05:00
felixdoerre
c93c3f49ec
Use CYW43_PRINTF macro in cyw43-support code. (#1745)
Without this change, using cyw43 has a dependency on printf code for printing
error message. Everywhere else in cyw43-code this dependency is masked with the
CYW43_PRINTF-macro. This PR extends the usage of the CYW43-PRINTF macro to the
SPI-support code.
2024-07-09 10:32:43 -05:00
graham sanderson
b1abf96cec Revert "Add C11 standard atomic support (#1645)"
This reverts commit 01dec6fb6f.
2024-07-08 18:54:48 -05:00
Stephen Street
01dec6fb6f
Add C11 standard atomic support (#1645)
* Add runtime support for stdatomics

* Fix lock calculation and enable atomic_flag support
2024-07-08 18:38:06 -05:00
Mr. Jake
86aab81c47
IRQ enabling guard (when no callback set) (#1504) 2024-07-07 12:57:50 -05:00
Graham Sanderson
74b9ea4d46
use best_effort_wfe_or_timeout instead of wfe (#1404) 2024-07-07 11:42:07 -05:00
Jack Wilsdon
778221ba99
Add missing semicolon (#1750) 2024-06-27 17:45:55 -05:00
Graham Sanderson
73e719691d
#1748 replace incorrect license (#1749) 2024-06-27 09:58:42 -05:00
aizaki77
8b0146c142
Fixed an issue that caused incorrect settings when the SPI clock was less than 244141Hz. (#1633) 2024-06-27 09:28:46 -05:00
MarcinKlosowskiMobica
f5b7a9135b
corrected issue#1536 - used correct define to create a configuration mask (#1613) 2024-06-21 14:38:48 -05:00
Sonya Vasquez
9290bdde58
fix harware_alarm_irq_number typo (#1619) 2024-06-21 14:38:20 -05:00
Peter S. Hollander
2de70c79c2
Fix PICO_DEOPTIMIZED_DEBUG not updating compiler flags (#1620)
* Fix PICO_DEOPTIMIZED_DEBUG not updating compiler flags

Setting CMAKE_${LANG}_FLAGS_DEBUG_INIT specifically only sets the flags for the Debug config the first time it is configured by CMake, pulling the initially-configured flags from CMakeCache.txt on subsequent configurations. This causes PICO_DEOPTIMIZED_DEBUG to not have any effect after the initial configuration, causing breakpoint issues when debugging certain functions.

Clearing the cache of the debug flags allows the flags to be updated every configuration, and appended to appropriately (such as with "-g").

See Issue #1618 and the comments of Pull Request #1620 for further details.

Fixes #1618
2024-06-21 14:37:33 -05:00
Maarten van der Schrieck
f5fea7f09b
pico_cyw43_driver/cyw43_bus_pio_spi.c: make SPI_PROGRAM_NAME and CLOCK_DIV configurable in makefile (#1499) 2024-06-21 14:35:51 -05:00
Peter Harper
5d36c90331
Make it easier to configure default baud rate (#1648)
To make stdio logging quicker it's probably a good idea to set the default
uart speed 921600, but it's only configurable by adding this define to
your project. Make it configurable from the cmake command line.
2024-06-21 14:31:52 -05:00
Pontus Oldberg
5118b4aae8
Adds support for the iLabs opendec02 decoder. (#1667) 2024-06-21 14:31:04 -05:00
Andrew Scheller
cea8211834
Fix FIFO size in Doxygen in hardware/adc.h (#1720)
See https://github.com/raspberrypi/pico-feedback/issues/357
2024-06-21 14:30:13 -05:00
Andrew Scheller
5be87f1e22
Clarify that DMA timer fraction must be <= 1 (#1723) 2024-06-21 14:29:47 -05:00
Andrew Scheller
0e5cef3ffa
Boards header updates (#1724)
* Add script to automatically validate board header files

* Fix small automatically-found inconsistencies in various board header files

* Tweak and add board header file from abandoned PR #1174
2024-06-21 14:26:45 -05:00
Hiroyuki OYAMA
333974fd6c
Corrects errors in returning constant labels (#1735) 2024-06-21 14:24:44 -05:00
Peter Harper
a567349aae
Update btstack v1.6.1 (#1736)
* Update btstack to v1.6.1

* Add build changes for btstack v1.6.1
2024-06-21 14:23:50 -05:00
Peter Harper
f193ed6bc9
Update cyw43-driver to fix build warnings (#1739)
This resolves kitchensink build issues
2024-06-21 14:22:14 -05:00
J
c526ec1c3d
custom_(un)lock_tcpip_core: link properly in C++ (#1738) 2024-06-20 09:07:32 -05:00
armandomontanez
6ff3e4fab2
Expand bazel build to include configuration options and broader support. (#1731)
* Add host Bazel build

Updates target_compatible_with across the repo to ensure that wildcard
builds for both host and rp2040 succeed.

* Get unit tests building

* Add Python script to identify build system differences

Uses the build system tags to make it easier to identify differences
between the CMake and Bazel builds.

* Temporarily disable pico divider test

* Support PICO_BARE_METAL in Bazel

* Support PICO_NO_GC_SECTIONS in Bazel

* Support boot2 configuration in Bazel

Adds support for PICO_DEFAULT_BOOT_STAGE2 and
PICO_DEFAULT_BOOT_STAGE2_FILE in the Bazel build.

* Allowlist some CMake-only options

* Support CXX configuration options in Bazel

* Move multiple_choice_flag.bzl

* Support all pico boards

* Support linking multiple stdio implementations

Changes the Bazel build so stdio implementations are no longer mutually
exclusive.

* Add PICO_BOOT_STAGE2_LINK_IMAGE

* Support PICO_CMSIS_PATH in Bazel

* Support PICO_USE_DEFAULT_MAX_PAGE_SIZE in Bazel

* Silence PICO_CMSIS_VENDOR and PICO_CMSIS_DEVICE differences

* Support PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS in Bazel

* Properly support version defines

* Support embedding binary info in Bazel

* Embed build type in binary

* Support different linker scripts in Bazel build

* Finish out missing PICO_BUILD_DEFINE in Bazel build

* Support PICO_NO_TARGET_NAME

* Reorganize initial configuration options in Bazel

Cleans up and reorganizes some of the initial configuration options
added to the Bazel build so everything is consistent.

* Add builds for pioasm and elf2uf2

* Use Python rules from rules_python

* Actually link in output formats in pioasm tool

* Make tools have public visibility

* Add UF2 Bazel aspect

* Add TODOs for pioasm/uf2 helpers

* Fix compile flag typo

* Update Bazel SDK configuration strings to match recent CMake changes

* Fix pico_divider test

* Clean up straggling TODOs

* Clarify pico_stdio_test compatibility

* Initial Bazel Pico W support

* Add new files from develop

* Clean up compatibility expressions in Bazel build

* Clean up rp2 constraint handling in Bazel

* More Bazel docs cleanup

* Format Bazel build files

* Consolidate transitions in the Pico SDK

* Make every _allowlist_function_transition explicit

* More docs cleanup

* Add a few missing defines

* Improve PICO_CONFIG_HEADER correctness in Bazel

* Minor docs clarifications
2024-06-13 09:50:04 -05:00
Peter Harper
0dc17e5149
Update cyw43_driver to v1.0.3 (#1732) 2024-06-13 09:03:46 -05:00
Christian Halter
a391f641b6
Added Newsan's Archi board (#1730)
Co-authored-by: Christian Halter <christian.halter@newsan.com.ar>
2024-06-12 13:42:25 -05:00
Peter Harper
a456964c19
Fix btstack compilation (#1726)
hardware/flash.h has been removed from pico/flash.h in the fix
for #1699. This breaks btstack compilation. Let's fix it.
2024-06-10 10:03:09 -05:00
Ahmet Kizilay
3ee062318f
set git tag for the SDK (#1630)
with this change we can use PICO_SDK_FETCH_GIT_TAG to specify a release tag for the Pico SDK to download.

example usage:
```
set(PICO_SDK_FETCH_FROM_GIT true)
set(PICO_SDK_FETCH_FROM_GIT_TAG "1.5.1")
include(pico_sdk_import.cmake)
```
2024-06-04 20:04:21 -05:00
Mykle
79977dbc4a
Update dma.h (#1678)
Fix inline doc for dma_timer_set_fraction()
2024-06-04 20:00:55 -05:00
J
e84eedff32
Remove unneeded includes from pico_flash. (#1699) 2024-06-04 19:59:59 -05:00
Andrew Scheller
115eae7c66
Add scripts to extract PICO_CMAKE_CONFIG and PICO_BUILD_DEFINE entries (#1708)
Tidy up a couple of PICO_CMAKE_CONFIG and PICO_BUILD_DEFINE entries
2024-06-04 19:59:28 -05:00
armandomontanez
abce1d427c
Introduce initial Bazel build (#1705)
* Build boot_stage2 with Bazel

Introduces the initial foundations of a Bazel build, including a
toolchain, critical generated headers, platform patterns, and enough
BUILD files to build boot_stage2.

* Bazel libraries to support picotool

* Move SDK defines to toolchain

* Switch to `archive_override` in MODULE.bazel

Uses archive_override where applicable to allow transitive bzlmod deps
to propagate.

* Multiplatform objcopy selection in Bazel build

Makes an objcopy alias that redirects to the objcopy tool for the
current exec platform, which allows boot_stage2 to build on Linux,
macOS, and Windows.

* Generate Bazel build files

Adds initial set of generated Bazel build files. Note that these do not
yet build, as dependency cycles are present.

* Fix dependency cycles in Bazel build

Fixes many dependency cycles, some were unintentionally created by the
build file generator, others are true dependency cycles that require
manual workarounds.

* Silence warning in pico_stdio Bazel build

Silences a stray warning in the Bazel build.

* Fix wildcard Bazel build

This makes `bazel build //...` succeed, and also prevents the fetching
of toolchains that aren't compatible with the current execution
environment (i.e. Windows computers will no longer try to download macOS
toolchains).

* Get the SDK working

Finishes out the remainder of the work required to successfully compile
a working blinky example.

* Fix UART stdio dependencies in Bazel build

Fixes some dependencies around pico_stdlib so that pico_stdlib links
properly and UART stdio works.

* Add linux support to Bazel build

* Get Bazel deps from registry

Adds external an external registry for resolving Bazel module
dependencies.

* Fix host configuration for picotool

Provides the appropriate defines for host builds to support the picotool
build.

* Remove -ffreestanding from Bazel toolchain

The -ffreestanding toolchain flag is quite strict, so remove it from the
Bazel toolchain.

* Remove unused .bzl file

* Reduce Bazel compiler flags

Cuts out most of the Bazel toolchain flags and only specifies the
bare-minimum set of flags. Also, adds wrapper linker flags for functions
the SDK wraps.

* Get USB serial working

Adds initial TinyUSB support and enough integration to get USB serial
working.

* Remove "Generated build file"

Removes comments that indicates BUILD.bazel files are generated. This
was used during initial bringup to indicate hand-crafted vs
automatically generated BUILD.bazel files.

* Do not build USB libraries unless configured

Prevents USB libraries from being built unless the build is properly
configured to use them.

* Switch to rules_cc toolchains

Moves toolchain configuration to use the new rules in rules_cc.

* Minor cleanup in parse_version.py

Cleans up trailing whitespace and runs the black formatter on
parse_version.py.

* Simplify constraint dimensions in Bazel build

Consolidates the class/chip constraint settings to be a single
constraint_setting with a config_setting that represents the rp2 class.

* Update pin of rules_cc in Bazel build

Includes a necessary fix for the target_compatible_with expression in
the cc_toolchain to work as intended.

* Move toolchains from pico.bzl to BUILD.bazel

Moves toolchain definitions from pico.bzl to BUILD.bazel to make them
easier to find and read.

* Run buildifier on Bazel build files

Fix trivial formatting issues by running buildifier on all BUILD.bazel
files.

* Make objcopy rule

Makes a simple objcopy rule to remove direct references to the ARM
toolchains.

* Fix link flags in Bazel build

Critical flags were not being applied to link steps. This applies -mcpu
and -mthumb to the link steps to make the produced binaries work again.

* Mention missing host build support

* Fix various Bazel library rules

* pico_bit_ops was incomplete.
* pico_double and pico_float were trying to link in the "none"
  implementation.

* Extend Bazel build documentation

Improves documentation and comments across the Bazel build.

* Clean up auxilary tools in Bazel build

Switches genrules to use skylib rules to simplify things. Reworks
version header generation to use the Bazel module version rather than
parsing CMake.

* Update boot_stage2 Bazel build file

Moves `includes` to be enumerated on the correct library.

* Add WORKSPACE version fallback

WORKSPACE Bazel projects don't support querying module version, so add a
fallback of '0.0.1-WORKSPACE' so the build can succeed.

* Fix malloc handling in Bazel build

* Fix Bazel dependency cycle in pico_malloc

* Prevent malloc from being linked into boot_stage2

Prevents Bazel from ever trying to link malloc into the boot_stage2
binary.

* Remove custom bootloader platform

A dedicated boot_stage2 platform introduces a lot of complexity that
needs to be more thought-through.
2024-06-04 18:50:32 -05:00
dthomas981
23dec9d38c
Correct clk_sys auxsrc definition for XOSC (#1571) 2024-05-21 13:37:43 +01:00
Agustín Mista
f81537d9e0
Add board definition for Cytron Maker Pi RP2040 (#1473) 2024-05-19 19:49:27 -05:00
Andrew Scheller
a6c65b426d
Small kitchen-sink fixes (#1707)
- tweak CMakeLists.txt and kitchen_sink.c to be in a more similar order
- add some "missing" headers to kitchen_sink.c
2024-05-19 19:26:30 -05:00
Andrew Scheller
dcc2241a16
Add a script to create a header file including all other header files (#319) 2024-05-19 17:44:03 -05:00
Mr. Jake
3f41d7d2ee
Added comments referencing spin-lock lock/unlock read/writes (#1501) 2024-05-19 17:03:32 -05:00
Patrick Plenefisch
7d238ea2cc
[pioasm] Fix build warning due to extra parameters (#1625) 2024-05-19 16:48:53 -05:00
Peter Harper
0d56f52b7b
Add some missing i2c function documentation (#1650)
Add i2c_get_index for consistency - just calls i2c_hw_index
2024-05-19 16:36:27 -05:00
Mr. Jake
f1f3bd6bf6
Disable FIFO IRQ when doing reset of core1 (same as with launching) (#1447)
* fifo irq disabled during core1 reset

* silence warning about unused variable in multicore.c
2024-05-18 19:53:37 -05:00
Joseph Bellahcen
5941969380
Improved const correctness of rtc functions (#1460) 2024-05-18 19:42:51 -05:00
Peter Harper
ac8f277e5a
Fix stdio_set_chars_available_callback for usb (#1649)
When you get a callback to tell you a character is available, you should
be able to call getchar_timeout_us, but it's not working for USB

Fixes #1603

Co-authored-by: Andrew Gordon <arg@gordondesign.ltd.uk>
2024-05-18 18:59:47 -05:00
Siarhei Volkau
fcd5333f6b
remove dead code in __aeabi_dcmpun (#1703)
two tail instructions were unreachable
2024-05-18 18:33:03 -05:00
Patricio Whittingslow
a0f4cd4096
Implement Pioasm for Go (TinyGo) (#1604)
Co-authored-by: Kenneth Bell <ken@netleap.io>
Co-authored-by: Christian Ege <ch@ege.io>
2024-05-07 17:39:28 -05:00
Nellie McKesson
b27f13b83b
reformatting doxygen comment markup (#1660) 2024-03-22 09:09:44 -05:00
J. Neuschäfer
0c65e1d755
pico/mutex.h: Fix typo in comment (#1637) 2024-02-15 08:45:35 -06:00
timg236
c9cce7a312
pico_generate_pio_header: Create OUTPUT_DIR (#1610)
Previously, if a custom OUTPUT_DIR was specified but didn't exist
then this command would fail.

Fixes: https://github.com/raspberrypi/pico-sdk/issues/1609
2024-01-19 08:57:16 -06:00
rppicomidi
f1c6fc8b6d
Fix #1442: Allow adding alternative .gatt file import paths (#1445)
* fix feature request #1442

* Do not require -I before each addtional path

* Fix pico_btstack_make_gatt_header warning

gatt header files are always made into the "generated" folder so you get
a warning if you have more than one target generating a gatt header with
the same name.

Also, simplify the expansion of ARGN

* Improve pico_btstack_make_gatt_header description

---------

Co-authored-by: Peter Harper <peter.harper@raspberrypi.com>
2024-01-16 09:43:57 -06:00
Peter Harper
62bb486f2a
Add tool for lwip httpd server (#1600)
It would be helpful to be able to use the lwip httpd server, but it
generates the content using a tool written in C. This is problematic as
it requires a native compiler to build the tools.

Add a python tool to generate the httpd content and a cmake function to
make use of it.
2024-01-16 09:20:17 -06:00
hubiscode
8353cb61e3
Fix spelling mistake, add documentation (#1444)
* USB descriptor string length.

Implement a mechanism to set the maximum string length used in
tud_descriptor_string_cb() by defining USBD_DESC_STR_MAX. If
USBD_DESC_STR_MAX is not defined, the behavior remains unchanged and the
previous default value of 20 is used. A compile time error is produced
if USBD_DESC_STR_MAX is higher than 127 since the length of the string
plus header is returned in a single byte as (2 * len + 2). Similarly, a
compile time error is generated if the length is defined as less than 17
in order to ensure that there is enough room for the 16-character serial
number plus header.

* Fix spelling mistake.

Renamed irq_hander_chain_free_slot_head to irq_handler_chain_free_slot_head
(added missing l).

* Add documentation for gpio_add_raw_irq_handler functions.

Added a note that irq_add_shared_handler() is used internally and that
the function will assert if the maximum number of shared handlers would
be exceeded.
2024-01-12 20:41:22 -06:00
Maarten van der Schrieck
4d19007607
rp2_common/pico_standard_link: linker script fixes (#1539)
The resulting elf binaries contained an unusual section that leads to an error
when objcopy attempts to update a section (e.g. when using the picowota
combined build mechanism).

This seemed to be due to the order of sections, where two RAM-only sections
were split by a RAM/FLASH section. By moving the RAM-only sections together,
this issue disappeared.
2024-01-12 16:18:42 -06:00
Andrew Scheller
73dce4e540
Doxygen comment typo (#1463) 2024-01-12 15:59:57 -06:00
Brandon Ros
6bb38a87fa
fix cybt_mem_read debug log typo (#1480) 2024-01-12 15:59:29 -06:00
Andre Zeps
ff2e2028ea
Fixes #1468 (#1497)
* Fixes shadowing of a global declaration

Required for GCC 12.2.1

* Change other function pointers to be _func to be consistent

---------

Co-authored-by: Andre Zeps <andre.zeps@googlemail.com>
Co-authored-by: Graham Sanderson <graham.sanderson@gmail.com>
2024-01-12 15:55:43 -06:00
Graham Sanderson
46bddd6b54
save about 100 bytes of code (release) size for simple UART usage (#1431) 2024-01-12 09:41:37 -06:00
Timo Kokkonen
3274cc8aec
Fix CWE-686 in tools/elf2uf2/main.cpp:132 (#1585)
* Fix CWE-686: This argument should be of type 'void *' but is of type 'unsigned int'.

* Switch %p to %08x.
2024-01-08 12:33:21 -06:00
Peter Harper
d7bbadb291
Add a cmake function for configuring IP addresses (#1424)
The fix for the following issue adds some macros to configure default
ip addresses. These are expressed in hex which is a bit non-obvious to
set. So add a macro to convert from a string to the hex representation.

https://github.com/georgerobotics/cyw43-driver/issues/41
2024-01-05 09:33:41 -06:00
Peter Harper
9f45e3c905
Freertos background asserts if IPv6 is enabled (#1591)
If LWIP_IPV6=1 a request to update the multicast list occurs in a
callback in the low priority interrupt.

This makes an ioctl call into the driver, at the end of which is a call
to cyw43_await_background_or_timeout_us (see CYW43_DO_IOCTL_WAIT).
It is attempting to delay until there's "some work to do".

For Freertos this fails an assertion as an attempt is made to acquire a
semaphore in interrupt context.

Fixes #1590
2023-12-21 07:51:21 -06:00
Paul Grayson
9ff8a98df6
Add board definition for upcoming Pololu Zumo 2040 Robot (#1475) 2023-12-15 13:49:19 +00:00
Andrew Scheller
538b901290
Add watchdog parameter-validation, and fix up misleading comments (#1567) 2023-12-15 13:48:02 +00:00
Ghorban M. Tavakoly
e5e30b40fd
CMake cmake_minimum_required Deprecation Warning (#1546)
* Add ...3.27 to the cmake_minimum_required, and make minimum 3.13 everywhere


Signed-off-by: Ghorban M. Tavakoly <gmt3141@gmail.com>
Co-authored-by: Graham Sanderson <graham.sanderson@raspberrypi.com>
2023-12-15 13:45:42 +00:00
Joshua H
01804acb0a
added weact studio board variants (#1437) 2023-12-15 13:40:43 +00:00
Stanislav Rubint
4e3951df26
added Xerxes RP2040 board to includes (#1459) 2023-12-15 13:39:16 +00:00
Alynx Zhou
7dcb984214
Fix waveshare_rp2040_zero USB unrecognize after unplug and replug (#1421)
Some RP2040-Zero boards from WaveShare can only be recognized via USB
after flashing UF2 into it, and if you unplug and replug it, nothing
happens on both USB host and device, RP2040-Zero seems just not booting.

According to @ArkBrj, it seems that setting `PICO_FLASH_SPI_CLKDIV` to
`2` makes the clock chip exceed the spec, setting it to `4` fixes this
bug.

I tested it with the blink program in pico-examples, this does fix the
bug for me.

Fixes <https://github.com/raspberrypi/pico-sdk/issues/1304>.
2023-12-15 13:38:14 +00:00
Andrew Scheller
7ed83dd2d3
Add calls to tight_loop_contents in a few more places. (#1401)
Fixes #1290
2023-12-15 13:36:51 +00:00
Earle F. Philhower, III
d92e26afca
Remove unused warning in async_context_freertos (#1574)
Fixes #1573
2023-12-14 12:01:14 +00:00
Mr. Jake
21cf892b77
Added stdio.h include to pico malloc when debug enabled (#1503) 2023-12-14 11:45:25 +00:00
Patrick Plenefisch
8787bc9b4d
pioasm: Add JSON output format for machine consumption (#1394) 2023-12-14 11:37:01 +00:00
Graham Sanderson
263a6680aa
workflow update for macOS to fix bad GCC install 2023-09-05 11:09:05 -05:00
Graham Sanderson
8262a08af3
rom_hword_as_ptr should use __force_inline (#1494) 2023-09-05 10:34:02 -05:00
Graham Sanderson
8e169346a9
remove incorrect repeating_timer assertion, which fails if the timer fires during creation (#1488) 2023-08-29 11:29:12 -05:00
Stefan Becker
f85d67961c
tools: fix CMake deprecation warnings (#1477)
Running a build with a newer CMake version results in a deprecation
warning from the tools subdirectory

    [13/108] Performing configure step for 'PioasmBuild'
    loading initial cache file /.../build/pico-sdk/src/rp2_common/pico_cyw43_driver/pioasm/tmp/PioasmBuild-cache-Release.cmake
    CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
      Compatibility with CMake < 3.5 will be removed from a future version of
      CMake.

      Update the VERSION argument <min> value or use a ...<max> suffix to tell
      CMake that the project does not need compatibility with older versions.

Raise the minimum version requirement for the tools to the same version
that is required in the top-level CMakeLists.txt anyway.
2023-08-17 11:02:18 -05:00
Paul Mucur
81b3200df4
Fix documentation for gpio_set_irq_enabled (#1470)
Add missing column separator for the table of gpio_irq_level values.

Fixes https://github.com/raspberrypi/pico-sdk/issues/1469
2023-08-14 08:28:17 -05:00
Earle F. Philhower, III
fbb0783eb5
Fix boot2_is25lp080.S section naming (#1430)
When the BOOT2.S files were updated, the section name in the IS25LP080 code was set to "text" and not ".text".

The missing "." causes the actual boot code to be thrown out since the rest of the infrastructure expects "section .text" and not "section text"

Re-add the missing period.
2023-06-15 09:53:25 -05:00
graham sanderson
88fa39165e Merge branch 'master' into develop 2023-06-13 17:28:01 -05:00
graham sanderson
9f9936140c start 1.5.2 development 2023-06-13 16:20:45 -05:00
1020 changed files with 368284 additions and 66351 deletions

4
.bazelignore Normal file
View file

@ -0,0 +1,4 @@
# Don't accidentally pick up external CMake deps with Bazel build files.
build
# Don't treat submodules as part of this project.
lib

6
.bazelrc Normal file
View file

@ -0,0 +1,6 @@
# Silence all C/C++ warnings in external code.
common --per_file_copt=external/.*@-w
common --host_per_file_copt=external/.*@-w
# Produce useful output when the build fails.
common --verbose_failures

1
.bazelversion Normal file
View file

@ -0,0 +1 @@
7.2.1

75
.github/workflows/bazel_build.yml vendored Normal file
View file

@ -0,0 +1,75 @@
name: Bazel presubmit checks
on:
push:
pull_request:
jobs:
bazel-build-check:
strategy:
matrix:
# TODO: Windows is currently broken.
os: [ubuntu-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Bazel
uses: bazel-contrib/setup-bazel@0.9.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
# Only needed to drive the presbumit scripts.
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Fetch latest Picotool
uses: actions/checkout@v4
with:
repository: raspberrypi/picotool
ref: develop
fetch-depth: 0
path: lib/picotool
- name: Full Bazel build with develop Picotool
run: python3 tools/run_all_bazel_checks.py --program=build --picotool-dir=lib/picotool
# Checks that the current BCR-requested version of Picotool builds.
- name: Bazel Picotool backwards compatibility
run: bazel build @picotool//:picotool
other-bazel-checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Bazel
uses: bazel-contrib/setup-bazel@0.9.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
# Only needed to drive the presbumit scripts.
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Fetch latest Picotool
uses: actions/checkout@v4
with:
repository: raspberrypi/picotool
ref: develop
fetch-depth: 0
path: lib/picotool
- name: Other Bazel checks
run: python3 tools/run_all_bazel_checks.py --program=other --picotool-dir=lib/picotool

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="gcc-arm-embedded" version="10.2.1" />
<package id="cmake" version="3.25.2" installArguments="ADD_CMAKE_TO_PATH=System" />
<package id="cmake" version="3.31.0" installArguments="ADD_CMAKE_TO_PATH=System" />
<package id="mingw" version="12.2.0" />
<package id="ninja" version="1.11.1" />
</packages>

View file

@ -23,7 +23,7 @@ jobs:
mkdir -p "${{ github.workspace }}"
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init

View file

@ -9,7 +9,7 @@ on:
jobs:
build:
runs-on: macos-12
runs-on: macos-latest
steps:
- name: Clean workspace
run: |
@ -17,14 +17,13 @@ jobs:
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init
- name: Install dependencies
run: |
brew install cmake
brew tap ArmMbed/homebrew-formulae
brew install arm-none-eabi-gcc
brew install --cask gcc-arm-embedded
- name: Build Project
# bash required otherwise this mysteriously (no error) fails at "Generating cyw43_bus_pio_spi.pio.h"

View file

@ -20,7 +20,7 @@ jobs:
mkdir -p "${{ github.workspace }}"
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init

View file

@ -55,7 +55,7 @@ jobs:
mkdir -p "${{ github.workspace }}"
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init

View file

@ -17,15 +17,14 @@ jobs:
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}/pico-sdk"
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init
- name: Install dependencies
run: choco install .github/workflows/choco_packages.config
- name: Build Project
# bash required otherwise this mysteriously (no error) fails at "Generating cyw43_bus_pio_spi.pio.h"
shell: bash
shell: pwsh
run: |
mkdir build
cd build

8
.gitignore vendored
View file

@ -1,5 +1,13 @@
.idea
.vscode
cmake-*
.cache
.DS_Store
build
build-*
bazel-*
# Ignore until https://github.com/bazelbuild/bazel/issues/20369 is fixed.
MODULE.bazel.lock
__pycache__/

0
BUILD.bazel Normal file
View file

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.13...3.27)
# Note: this CMakeLists.txt can be used as a top-level CMakeLists.txt for the SDK itself. For all other uses
# it is included as a subdirectory via the pico_sdk_init() method provided by pico_sdk_init.cmake
@ -15,6 +15,11 @@ if (NOT TARGET _pico_sdk_inclusion_marker)
pico_register_common_scope_var(PICO_C_COMPILER_IS_CLANG)
pico_register_common_scope_var(PICO_C_COMPILER_IS_GNU)
pico_register_common_scope_var(PICO_C_COMPILER_IS_IAR)
pico_register_common_scope_var(PICO_SDK_VERSION_MAJOR)
pico_register_common_scope_var(PICO_SDK_VERSION_MINOR)
pico_register_common_scope_var(PICO_SDK_VERSION_REVISION)
pico_register_common_scope_var(PICO_SDK_VERSION_PRE_RELEASE_ID)
pico_register_common_scope_var(PICO_SDK_VERSION_STRING)
message("Build type is ${CMAKE_BUILD_TYPE}")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
@ -38,6 +43,9 @@ if (NOT TARGET _pico_sdk_inclusion_marker)
add_sub_list_dirs(PICO_SDK_PRE_LIST_DIRS)
add_sub_list_files(PICO_SDK_PRE_LIST_FILES)
# needed by certain functions
set(PICO_TOOLS_DIR "${CMAKE_CURRENT_LIST_DIR}/tools" CACHE INTERNAL "")
add_subdirectory(tools)
add_subdirectory(src)
@ -61,4 +69,3 @@ if (NOT TARGET _pico_sdk_inclusion_marker)
pico_promote_common_scope_vars()
endif()
endif()

View file

@ -22,4 +22,4 @@ If you are contributing new or updated code please match the existing code style
### Licensing
Code in this repository is lisensed under the [BSD-3 License](LICENSE.TXT). By contributing content to this repository you are agreeing to place your contributions under this licence.
Code in this repository is licensed under the [BSD-3 License](LICENSE.TXT). By contributing content to this repository you are agreeing to place your contributions under this license.

150
MODULE.bazel Normal file
View file

@ -0,0 +1,150 @@
module(
name = "pico-sdk",
version = "2.1.0",
)
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_python", version = "0.36.0")
bazel_dep(name = "picotool", version = "2.1.0")
bazel_dep(name = "rules_cc", version = "0.0.10")
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "arm_gcc_linux-aarch64",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "8fd8b4a0a8d44ab2e195ccfbeef42223dfb3ede29d80f14dcf2183c34b8d199a",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-aarch64-arm-none-eabi",
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-eabi.tar.xz",
)
http_archive(
name = "arm_gcc_linux-x86_64",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "6cd1bbc1d9ae57312bcd169ae283153a9572bd6a8e4eeae2fedfbc33b115fdbb",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi",
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz",
)
http_archive(
name = "arm_gcc_win-x86_64",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "51d933f00578aa28016c5e3c84f94403274ea7915539f8e56c13e2196437d18f",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi",
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.zip",
)
http_archive(
name = "arm_gcc_mac-x86_64",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "075faa4f3e8eb45e59144858202351a28706f54a6ec17eedd88c9fb9412372cc",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-x86_64-arm-none-eabi",
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz",
)
http_archive(
name = "arm_gcc_mac-aarch64",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "39c44f8af42695b7b871df42e346c09fee670ea8dfc11f17083e296ea2b0d279",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-arm64-arm-none-eabi",
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-arm64-arm-none-eabi.tar.xz",
)
http_archive(
name = "clang_linux-x86_64",
build_file = "//bazel/toolchain:clang.BUILD",
sha256 = "6c599d1aba568236064c340d7813324849896d5a4e2f3fd8225a8c31bfcbf884",
type = "zip",
url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/linux-amd64/+/git_revision:2b0a708f41dd6291ee744704d43febc975e3d026",
)
http_archive(
name = "clang_win-x86_64",
build_file = "//bazel/toolchain:clang.BUILD",
sha256 = "f49ba4123ee3958f2b47289d017a5b3f1ca01f82dd7a2168c45412c18101fd13",
type = "zip",
# Windows doesn't like `:` in the produced filename, so replace it with `%3A`.
url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/windows-amd64/+/git_revision:2b0a708f41dd6291ee744704d43febc975e3d026".replace("git_revision:", "git_revision%3A"),
)
http_archive(
name = "clang_mac-x86_64",
build_file = "//bazel/toolchain:clang.BUILD",
sha256 = "d3516f2eb4c12d17ae77ee84c9226fbea581d4fb806910ceac4717d5adfcf748",
type = "zip",
url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/mac-amd64/+/git_revision:2b0a708f41dd6291ee744704d43febc975e3d026",
)
http_archive(
name = "clang_mac-aarch64",
build_file = "//bazel/toolchain:clang.BUILD",
sha256 = "68e551f41c7e9473063b09819f6ab8ec6e7e53677f4078189656cb14dc52984b",
type = "zip",
url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/mac-arm64/+/git_revision:2b0a708f41dd6291ee744704d43febc975e3d026",
)
new_git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
# TODO: Provide tinyusb as a proper Bazel module.
new_git_repository(
name = "tinyusb",
build_file = "//src/rp2_common/tinyusb:tinyusb.BUILD",
commit = "5217cee5de4cd555018da90f9f1bcc87fb1c1d3a", # keep-in-sync-with-submodule: lib/tinyusb
remote = "https://github.com/hathach/tinyusb.git",
)
# TODO: Provide btstack as a proper Bazel module.
new_git_repository(
name = "btstack",
build_file = "//src/rp2_common/pico_btstack:btstack.BUILD",
commit = "2b49e57bd1fae85ac32ac1f41cdb7c794de335f6", # keep-in-sync-with-submodule: lib/btstack
remote = "https://github.com/bluekitchen/btstack.git",
)
# TODO: Provide cyw43-driver as a proper Bazel module.
new_git_repository(
name = "cyw43-driver",
build_file = "//src/rp2_common/pico_cyw43_driver:cyw43-driver.BUILD",
commit = "cf924bb04c8984675ca0fc2178f082e404e048c3", # keep-in-sync-with-submodule: lib/cyw43-driver
remote = "https://github.com/georgerobotics/cyw43-driver.git",
)
# TODO: Provide lwip as a proper Bazel module.
new_git_repository(
name = "lwip",
build_file = "//src/rp2_common/pico_lwip:lwip.BUILD",
commit = "0a0452b2c39bdd91e252aef045c115f88f6ca773", # keep-in-sync-with-submodule: lib/lwip
remote = "https://github.com/lwip-tcpip/lwip.git",
)
register_toolchains(
"//bazel/toolchain:linux-aarch64-rp2040",
"//bazel/toolchain:linux-aarch64-rp2350",
"//bazel/toolchain:linux-x86_64-rp2040",
"//bazel/toolchain:linux-x86_64-rp2350",
"//bazel/toolchain:win-x86_64-rp2040",
"//bazel/toolchain:win-x86_64-rp2350",
"//bazel/toolchain:mac-x86_64-rp2040",
"//bazel/toolchain:mac-x86_64-rp2350",
"//bazel/toolchain:mac-aarch64-rp2040",
"//bazel/toolchain:mac-aarch64-rp2350",
# Require users to opt-in to the Pico SDK's toolchains.
dev_dependency = True,
)
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
configure_coverage_tool = True,
python_version = "3.9",
)
use_repo(python, "pythons_hub")
register_toolchains(
"@pythons_hub//:all",
dev_dependency = True,
)
register_toolchains(
"@rules_python//python/runtime_env_toolchains:all",
dev_dependency = True,
)

View file

@ -1,31 +1,31 @@
# 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
necessary to write programs for the RP-series microcontroller-based devices such as the Raspberry Pi Pico or Raspberry Pi Pico 2
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).
C-level libraries/APIs for accessing all of the RP-series microcontroller's hardware including 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.
Additionally, the SDK provides higher level libraries for dealing with timers, synchronization, Wi-Fi and Bluetooth networking, USB and multicore programming. These libraries should be comprehensive enough that your application code rarely, if at all, needs to access hardware registers directly. However, if you do need or prefer to access the raw hardware registers, you will also find complete and fully-commented register definition headers in the SDK. There's no need to look up addresses in the datasheet.
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.
The SDK can be used to build anything from simple applications, fully-fledged runtime environments such as MicroPython, to low level software
such as the RP-series microcontroller's on-chip bootrom itself.
The design goal for entire SDK is to be simple but powerful.
Additional libraries/APIs that are not yet ready for inclusion in the SDK can be found in [pico-extras](https://github.com/raspberrypi/pico-extras).
# Documentation
See [Getting Started with the Raspberry Pi Pico](https://rptl.io/pico-get-started) 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 [Getting Started with the Raspberry Pi Pico-Series](https://rptl.io/pico-get-started) for information on how to setup your
hardware, IDE/environment and how to build and debug software for the Raspberry Pi Pico and other RP-series microcontroller based devices.
See [Connecting to the Internet with Raspberry Pi Pico W](https://rptl.io/picow-connect) to learn more about writing
applications for your Raspberry Pi Pico W that connect to the internet.
See [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk) to learn more about programming using the
See [Raspberry Pi Pico-Series C/C++ SDK](https://rptl.io/pico-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](https://rptl.io/pico-doxygen) for HTML-based API documentation.
@ -42,12 +42,18 @@ _latest stable release_ of the SDK. If you need or want to test upcoming feature
# 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](https://rptl.io/pico-c-sdk)
## Using Visual Studio Code
1. Install CMake (at least version 3.13), and GCC cross compiler
You can install the [Raspberry Pi Pico Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=raspberry-pi.raspberry-pi-pico) in VS Code.
## Unix command line
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-Series C/C++ SDK](https://rptl.io/pico-c-sdk)
1. Install CMake (at least version 3.13), python 3, a native compiler, and a GCC cross compiler
```
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
sudo apt install cmake python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
```
1. Set up your project to point to use the Raspberry Pi Pico SDK
@ -59,7 +65,7 @@ instructions for other platforms, and just in general, we recommend you see [Ras
3. Setup a `CMakeLists.txt` like:
```cmake
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.13...3.27)
# initialize the SDK based on PICO_SDK_PATH
# note: this must happen before project()
@ -79,7 +85,7 @@ instructions for other platforms, and just in general, we recommend you see [Ras
1. Setup a `CMakeLists.txt` like:
```cmake
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.13...3.27)
# initialize pico-sdk from submodule
# note: this must happen before project()
@ -137,7 +143,7 @@ instructions for other platforms, and just in general, we recommend you see [Ras
# rest of your project
```
1. Write your code (see [pico-examples](https://github.com/raspberrypi/pico-examples) or the [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk) documentation for more information)
1. Write your code (see [pico-examples](https://github.com/raspberrypi/pico-examples) or the [Raspberry Pi Pico-Series C/C++ SDK](https://rptl.io/pico-c-sdk) documentation for more information)
About the simplest you can do is a single source file (e.g. hello_world.c)
@ -146,7 +152,7 @@ instructions for other platforms, and just in general, we recommend you see [Ras
#include "pico/stdlib.h"
int main() {
setup_default_uart();
stdio_init_all();
printf("Hello, world!\n");
return 0;
}
@ -176,12 +182,11 @@ instructions for other platforms, and just in general, we recommend you see [Ras
$ cmake ..
```
When building for a board other than the Raspberry Pi Pico, you should pass `-DPICO_BOARD=board_name` to the `cmake` command above, e.g. `cmake -DPICO_BOARD=pico_w ..`
to configure the SDK and build options accordingly for that particular board.
When building for a board other than the Raspberry Pi Pico, you should pass `-DPICO_BOARD=board_name` to the `cmake` command above, e.g. `cmake -DPICO_BOARD=pico2 ..` or `cmake -DPICO_BOARD=pico_w ..` to configure the SDK and build options accordingly for that particular board.
Doing so sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain
Specifying `PICO_BOARD=<booardname>` sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain
cases also enables the use of additional libraries (e.g. wireless support when building for `PICO_BOARD=pico_w`) which cannot
be built without a board which provides the requisite functionality.
be built without a board which provides the requisite hardware functionality.
For a list of boards defined in the SDK itself, look in [this directory](src/boards/include/boards) which has a
header for each named board.
@ -191,4 +196,8 @@ instructions for other platforms, and just in general, we recommend you see [Ras
$ make hello_world
```
1. 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.
1. 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-series device via drag and drop.
# RISC-V support on RP2350
See [Raspberry Pi Pico-series C/C++ SDK](https://rptl.io/pico-c-sdk) for information on setting up a build environment for RISC-V on RP2350.

0
WORKSPACE Normal file
View file

63
bazel/BUILD.bazel Normal file
View file

@ -0,0 +1,63 @@
load("@rules_python//python:defs.bzl", "py_binary")
package(default_visibility = ["//visibility:public"])
py_binary(
name = "generate_version_header",
srcs = ["generate_version_header.py"],
visibility = ["//:__subpackages__"],
)
# This isn't actually generated, it just uses the same name
# to make it show up easier in searches.
#
# Rather than generating lists of headers to match CMake, the Bazel build
# opts to have a static header that transitively include two known headers.
# By default, empty header files are included, and users/platforms are expected
# to specify an appropriate `cc_library` to replace them.
#
# You tell bazel which `cc_library` provides the respective headers by
# configuring these `label_flag`s:
#
# # Specify the library that provides "pico_config_extra_headers.h"
# --@pico-sdk//bazel/config:PICO_CONFIG_EXTRA_HEADER=//my_proj:my_custom_headers
#
# # Specify the library that provides "pico_config_platform_headers.h"
# --@pico-sdk//bazel/config:PICO_CONFIG_PLATFORM_HEADER=//my_proj:my_custom_platform_headers
cc_library(
name = "generate_config_header",
hdrs = ["include/pico/config_autogen.h"],
includes = ["include"],
visibility = ["//:__subpackages__"],
deps = [
"//bazel/config:PICO_CONFIG_EXTRA_HEADER",
"//bazel/config:PICO_CONFIG_PLATFORM_HEADER",
],
)
genrule(
name = "empty_extra_headers_file",
outs = ["generated_extra_include/pico_config_extra_headers.h"],
cmd = "echo > $@",
cmd_bat = "copy NUL $@",
visibility = ["//visibility:private"],
)
cc_library(
name = "no_extra_headers",
hdrs = ["generated_extra_include/pico_config_extra_headers.h"],
includes = ["generated_extra_include"],
visibility = ["//visibility:private"],
)
# An empty stub, useful for label_flag flags that need to point to a library,
# but for some purposes the library needs to be a no-op.
cc_library(
name = "empty_cc_lib",
)
# A library incompatible with everything. Use to mark an invalid configuration.
cc_library(
name = "incompatible_cc_lib",
target_compatible_with = ["@platforms//:incompatible"],
)

115
bazel/README.md Normal file
View file

@ -0,0 +1,115 @@
# Bazel build
## Using the Pico SDK in a Bazel project.
### Add pico-sdk as a dependency
First, in your `MODULE.bazel` file, add a dependency on the Pico SDK and
`rules_cc`:
```python
bazel_dep(name = "pico-sdk", version = "2.1.0")
```
### Register toolchains
These toolchains tell Bazel how to compile for ARM cores. Add the following
to the `MODULE.bazel` for your project:
```python
register_toolchains(
"@pico-sdk//bazel/toolchain:linux-x86_64-rp2040",
"@pico-sdk//bazel/toolchain:linux-x86_64-rp2350",
"@pico-sdk//bazel/toolchain:win-x86_64-rp2040",
"@pico-sdk//bazel/toolchain:win-x86_64-rp2350",
"@pico-sdk//bazel/toolchain:mac-x86_64-rp2040",
"@pico-sdk//bazel/toolchain:mac-x86_64-rp2350",
"@pico-sdk//bazel/toolchain:mac-aarch64-rp2040",
"@pico-sdk//bazel/toolchain:mac-aarch64-rp2350",
)
```
### Ready to build!
You're now ready to start building Pico Projects in Bazel! When building,
don't forget to specify `--platforms` so Bazel knows you're targeting the
Raspberry Pi Pico:
```console
$ bazelisk build --platforms=@pico-sdk//bazel/platform:rp2040 //...
```
## SDK configuration
An exhaustive list of build system configuration options is available in
`//bazel/config:BUILD.bazel`.
### Selecting a different board
A different board can be selected specifying `--@pico-sdk//bazel/config:PICO_BOARD`:
```console
$ bazelisk build --platforms=//bazel/platform:rp2040 --@pico-sdk//bazel/config:PICO_BOARD=pico_w //...
```
If you have a bespoke board definition, you can configure the Pico SDK to use it
by pointing `--@pico-sdk//bazel/config:PICO_CONFIG_HEADER` to a `cc_library`
that defines `PICO_BOARD` and either a `PICO_CONFIG_HEADER` define or a
`pico/config_autogen.h` header. Make sure any required `includes`, `hdrs`, and
`deps` are also provided.
## Generating UF2 firmware images
Creation of UF2 images can be done as explicit build steps on a per-binary
rule basis, or through an aspect. Running a wildcard build with the
`pico_uf2_aspect` enabled is the easiest way to create a UF2 for every ELF
firmware image.
```console
$ bazelisk build --platforms=@pico-sdk//bazel/platform:rp2040 \
--aspects @pico-sdk//tools:uf2_aspect.bzl%pico_uf2_aspect \
--output_groups=+pico_uf2_files \
//...
```
## Building the Pico SDK itself
### First time setup
You'll need Bazel (v7.0.0 or higher) or Bazelisk (a self-updating Bazel
launcher) to build the Pico SDK.
We strongly recommend you set up
[Bazelisk](https://bazel.build/install/bazelisk).
You will also need a working compiler configured if you wish to build Picotool
or pioasm.
* Linux: `sudo apt-get install build-essential` or similar.
* macOS: `xcode-select --install`
* Windows: [Install MSVC](https://visualstudio.microsoft.com/vs/features/cplusplus/)
### Building
To build all of the Pico SDK, run the following command:
```console
$ bazelisk build --platforms=//bazel/platform:rp2040 //...
```
## Known issues and limitations
The Bazel build for the Pico SDK is relatively new, but most features and
configuration options available in the CMake build are also available in Bazel.
You are welcome and encouraged to file issues for any problems and limitations
you encounter along the way.
Currently, the following features are not supported:
* Pico W wireless libraries work, but may not have complete feature parity with
the CMake build.
* Bazel does not yet provide RISC-V support for Pico 2/RP2350.
* The pioasm parser cannot be built from source via Bazel.
* Windows MSVC wildcard build (`bazel build //...`) does not work when targeting
host.
## Contributing
When making changes to the Bazel build, please run the Bazel validation script
to ensure all supported configurations build properly:
```console
$ ./tools/run_all_bazel_checks.py
```
If you need to check against a local version of Picotool, you can run the script
with `--picotool-dir`:
```console
$ ./tools/run_all_bazel_checks.py --picotool-dir=/path/to/picotool
```

290
bazel/config/BUILD.bazel Normal file
View file

@ -0,0 +1,290 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_flag")
package(default_visibility = ["//visibility:public"])
# PICO_BAZEL_CONFIG: PICO_TOOLCHAIN, The toolchain to use, type=string, default=gcc, group=build
string_flag(
name = "PICO_TOOLCHAIN",
build_setting_default = "gcc",
values = [
"gcc",
"clang",
],
)
# PICO_BAZEL_CONFIG: PICO_BOARD, Board name being built for, type=string, default=pico or pico2, group=build, docref=cmake-platform-board-config
string_flag(
name = "PICO_BOARD",
build_setting_default = "pico",
)
# PICO_BAZEL_CONFIG: PICO_BARE_METAL, Flag to exclude anything except base headers from the build, type=bool, default=0, group=build
bool_flag(
name = "PICO_BARE_METAL",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_NO_GC_SECTIONS, Disable `-ffunction-sections` `-fdata-sections` and `--gc-sections`, type=bool, default=0, advanced=true, group=pico_standard_link
bool_flag(
name = "PICO_NO_GC_SECTIONS",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_BOOT_STAGE2_FILE, Boot stage 2 file to use; this should point to a filegroup with the .S file to use, type=string, group=build
label_flag(
name = "PICO_DEFAULT_BOOT_STAGE2_FILE",
build_setting_default = "//src/rp2_common:build_selected_boot2",
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_BOOT_STAGE2, Simpler alternative to specifying PICO_DEFAULT_BOOT_STAGE2_FILE where the latter is set to src/rp2_common/boot_stage2/{PICO_DEFAULT_BOOT_STAGE2}.S, type=string, default=compile_time_choice, group=build
string_flag(
name = "PICO_DEFAULT_BOOT_STAGE2",
build_setting_default = "compile_time_choice",
)
# PICO_BAZEL_CONFIG: PICO_BOOT_STAGE2_LINK_IMAGE, [Bazel only] The final boot_stage2 image target to link in. Use this to fully override/replace boot_stage2, default=@pico-sdk//src/rp2_common:boot_stage2, group=build
label_flag(
name = "PICO_BOOT_STAGE2_LINK_IMAGE",
build_setting_default = "//src/rp2_common:boot_stage2",
)
# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_EXCEPTIONS, Enable CXX exception handling, type=bool, default=0, group=pico_cxx_options
bool_flag(
name = "PICO_CXX_ENABLE_EXCEPTIONS",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_RTTI, Enable CXX rtti, type=bool, default=0, group=pico_cxx_options
bool_flag(
name = "PICO_CXX_ENABLE_RTTI",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_CXA_ATEXIT, Enable cxa-atexit, type=bool, default=0, group=pico_cxx_options
bool_flag(
name = "PICO_CXX_ENABLE_CXA_ATEXIT",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_UART, Option to globally enable stdio UART for all targets by default, type=bool, default=1, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_UART",
build_setting_default = True,
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_UART_BAUD_RATE, Define the default UART baudrate, type=int, max=921600, default=115200, group=hardware_uart
int_flag(
name = "PICO_DEFAULT_UART_BAUD_RATE",
build_setting_default = 115200,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_USB, Option to globally enable stdio USB for all targets by default, type=bool, default=0, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_USB",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_SEMIHOSTING, Option to globally enable stdio semi-hosting for all targets by default, type=bool, default=0, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_SEMIHOSTING",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_RTT, Option to globally enable stdio RTT for all targets by default, type=bool, default=0, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_RTT",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_MULTICORE_ENABLED, OPTION: Enable multicore handling, type=bool, default=1, group=pico_stdlib
bool_flag(
name = "PICO_MULTICORE_ENABLED",
build_setting_default = True,
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_DOUBLE_IMPL, The default implementation for pico_double to link. auto selects an appropriate default for the current platform. rp2040 is only supported on the rp2040. dcp is only supported on rp2350, type=string, default=auto, group=build
string_flag(
name = "PICO_DEFAULT_DOUBLE_IMPL",
build_setting_default = "auto",
values = [
"auto",
"compiler",
"dcp",
"rp2040",
"none",
],
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_FLOAT_IMPL, The default implementation for pico_float to link. auto selects an appropriate default for the current platform. rp2040 is only supported on the rp2040. vfp and dcp are only supported on rp2350, type=string, default=auto, group=build
string_flag(
name = "PICO_DEFAULT_FLOAT_IMPL",
build_setting_default = "auto",
values = [
"auto",
"compiler",
"dcp",
"rp2040",
"vfp",
"none",
],
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_DIVIDER_IMPL, The default implementation for pico_divider to link. hardware uses accelerated divide instructions while compiler allows the compiler to decide how to handle divide instructions. auto uses the platform default (hardware on RP2040 and compiler on RP2350), type=string, default=auto, group=build
string_flag(
name = "PICO_DEFAULT_DIVIDER_IMPL",
build_setting_default = "auto",
values = [
"auto",
"hardware",
"compiler",
],
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_PRINTF_IMPL, The default implementation for pico_printf to link. compiler lets the compiler control printf behavior while pico provides a pico-specific implementation, type=string, default=double, group=build
string_flag(
name = "PICO_DEFAULT_PRINTF_IMPL",
build_setting_default = "pico",
values = [
"pico",
"compiler",
"none",
],
)
# PICO_BAZEL_CONFIG: PICO_ASYNC_CONTEXT_IMPL, The default implementation for pico_async_context to link, type=string, default=threadsafe_background, group=build
string_flag(
name = "PICO_ASYNC_CONTEXT_IMPL",
build_setting_default = "threadsafe_background",
values = [
"poll",
"threadsafe_background",
"freertos",
],
)
# PICO_BAZEL_CONFIG: PICO_BINARY_INFO_ENABLED, Whether to include binary info in final firmware, type=bool, default=1, group=pico_stdlib
bool_flag(
name = "PICO_BINARY_INFO_ENABLED",
build_setting_default = True,
)
# PICO_BAZEL_CONFIG: PICO_CMSIS_PATH, Label of a cc_ibrary providing CMSIS core, type=string, default="included stub CORE only impl", group=build
label_flag(
name = "PICO_CMSIS_PATH",
build_setting_default = "//src/rp2_common/cmsis:cmsis_core",
)
# PICO_BAZEL_CONFIG: PICO_USE_DEFAULT_MAX_PAGE_SIZE, Don't shrink linker max page to 4096, type=bool, default=0, advanced=true, group=pico_standard_link
bool_flag(
name = "PICO_USE_DEFAULT_MAX_PAGE_SIZE",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS, Maximum number of milliseconds to wait during initialization for a CDC connection from the host (negative means indefinite) during initialization, type=int, default=0, group=pico_stdio_usb
int_flag(
name = "PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS",
build_setting_default = 0,
)
# PICO_BAZEL_CONFIG: PICO_TINYUSB_LIB, [Bazel only] The library that provides TinyUSB, default=@tinyusb//:tinyusb, group=build
label_flag(
name = "PICO_TINYUSB_LIB",
build_setting_default = "@tinyusb//:tinyusb",
)
# TODO: Bazel build for mbedtls at @mbedtls//:mbedtls.
# PICO_BAZEL_CONFIG: PICO_MBEDTLS_LIB, [Bazel only] The library that provides mbedtls, default=@mbedtls//:mbedtls, group=build
label_flag(
name = "PICO_MBEDTLS_LIB",
build_setting_default = "//bazel:incompatible_cc_lib",
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_BINARY_INFO, [Bazel only] The library that provides custom_pico_binary_info to link into all binaries, default=//src/rp2_common/pico_standard_binary_info:default_binary_info, group=pico_standard_link
label_flag(
name = "PICO_DEFAULT_BINARY_INFO",
build_setting_default = "//src/rp2_common/pico_standard_binary_info:default_binary_info",
)
# PICO_BAZEL_CONFIG: PICO_BAZEL_BUILD_TYPE, The type of build (e.g. Debug or Release) to embed in binary info, type=string, default=pico, group=build
string_flag(
name = "PICO_BAZEL_BUILD_TYPE",
build_setting_default = "Debug",
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_LINKER_SCRIPT, [Bazel only] The library that provides a linker script to link into all binaries, default=//src/rp2_common/pico_crt0:default_linker_script, group=pico_standard_link
label_flag(
name = "PICO_DEFAULT_LINKER_SCRIPT",
build_setting_default = "//src/rp2_common/pico_crt0:default_linker_script",
)
# PICO_BAZEL_CONFIG: PICO_NO_TARGET_NAME, Don't define PICO_TARGET_NAME, type=bool, default=0, group=build
bool_flag(
name = "PICO_NO_TARGET_NAME",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_CONFIG_EXTRA_HEADER, [Bazel only] The cc_library that provides "pico_config_extra_headers.h", default=//bazel:no_extra_headers, group=pico_base
label_flag(
name = "PICO_CONFIG_EXTRA_HEADER",
build_setting_default = "//bazel:no_extra_headers",
)
# PICO_BAZEL_CONFIG: PICO_CONFIG_PLATFORM_HEADER, [Bazel only] The cc_library that provides "pico_config_platform_headers.h" and defines PICO_BOARD, default=//src/common/pico_base_headers:default_platform_headers, group=pico_base
label_flag(
name = "PICO_CONFIG_PLATFORM_HEADER",
build_setting_default = "//src/boards:default",
)
# PICO_BAZEL_CONFIG: PICO_CONFIG_HEADER, [Bazel only] The cc_library that defines PICO_CONFIG_HEADER or pico/config_autogen.h and other SDK critical defines (overrides PICO_BOARD setting), default=//bazel:generate_config_header, group=pico_base
label_flag(
name = "PICO_CONFIG_HEADER",
build_setting_default = "//bazel:generate_config_header",
)
# PICO_BAZEL_CONFIG: PICO_CLIB, [Bazel only] The flavor of libc porting layer to use. auto infers the correct value to use from PICO_TOOLCHAIN, group=pico_standard_link
string_flag(
name = "PICO_CLIB",
build_setting_default = "auto",
values = [
"auto",
"llvm_libc",
"newlib",
"picolibc",
],
)
# PICO_BAZEL_CONFIG: PICO_BTSTACK_CONFIG, [Bazel only] The cc_library that provides btstack_config.h, default=//bazel:empty_cc_lib, group=wireless
label_flag(
name = "PICO_BTSTACK_CONFIG",
build_setting_default = "//bazel:empty_cc_lib",
)
# PICO_BAZEL_CONFIG: PICO_BT_ENABLE_BLE, [Bazel only] Whether or not to link in BLE portions of the btstack as part of //src/rp2_common/pico_btstack. Also defines ENABLE_BLE=1, type=bool, default=False, group=wireless
bool_flag(
name = "PICO_BT_ENABLE_BLE",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_BT_ENABLE_CLASSIC, [Bazel only] Whether or not to link in classic BT portions of the btstack as part of //src/rp2_common/pico_btstack. Also defines ENABLE_CLASSIC=1, type=bool, default=False, group=wireless
bool_flag(
name = "PICO_BT_ENABLE_CLASSIC",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_BT_ENABLE_MESH, [Bazel only] Whether or not to link in mesh BT portions of the btstack as part of //src/rp2_common/pico_btstack. Also defines ENABLE_MESH=1, type=bool, default=False, group=wireless
bool_flag(
name = "PICO_BT_ENABLE_MESH",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_LWIP_CONFIG, [Bazel only] The cc_library that provides lwipopts.h, default=//bazel:empty_cc_lib, group=wireless
label_flag(
name = "PICO_LWIP_CONFIG",
build_setting_default = "//bazel:empty_cc_lib",
)
# PICO_BAZEL_CONFIG: PICO_FREERTOS_LIB, [Bazel only] The cc_library that provides FreeRTOS, default=//bazel:empty_cc_lib, group=wireless
label_flag(
name = "PICO_FREERTOS_LIB",
build_setting_default = "//bazel:empty_cc_lib",
)

View file

@ -0,0 +1,254 @@
load("//bazel/util:label_flag_matches.bzl", "label_flag_matches")
package(default_visibility = ["//visibility:public"])
# This constraint represents the dimension that guides the Pico SDK build. This
# constraint will only ever enumerate specific MCUs (and the host), and does NOT
# cover the differences from board-to-board.
constraint_setting(
name = "sdk_target",
default_constraint_value = "host",
)
# This constraint value is used to guide the host build.
constraint_value(
name = "host",
constraint_setting = ":sdk_target",
)
# This constraint value is used to guide parts of the build that are specific
# to the rp2040.
constraint_value(
name = "rp2040",
constraint_setting = ":sdk_target",
)
# This constraint value is used to guide parts of the build that are specific
# to the rp2350.
constraint_value(
name = "rp2350",
constraint_setting = ":sdk_target",
)
constraint_setting(
name = "wireless_support",
default_constraint_value = "no_wireless",
)
constraint_value(
name = "no_wireless",
constraint_setting = ":wireless_support",
)
constraint_value(
name = "cyw43_wireless",
constraint_setting = ":wireless_support",
)
config_setting(
name = "is_pico_w",
flag_values = {"//bazel/config:PICO_BOARD": "pico_w"},
)
config_setting(
name = "is_pico2_w",
flag_values = {"//bazel/config:PICO_BOARD": "pico2_w"},
)
config_setting(
name = "pico_toolchain_clang_enabled",
flag_values = {"//bazel/config:PICO_TOOLCHAIN": "clang"},
)
config_setting(
name = "pico_toolchain_gcc_enabled",
flag_values = {"//bazel/config:PICO_TOOLCHAIN": "gcc"},
)
config_setting(
name = "pico_baremetal_enabled",
flag_values = {"//bazel/config:PICO_BARE_METAL": "True"},
)
config_setting(
name = "pico_no_gc_sections_enabled",
flag_values = {"//bazel/config:PICO_NO_GC_SECTIONS": "True"},
)
config_setting(
name = "pico_cxx_enable_exceptions_enabled",
flag_values = {"//bazel/config:PICO_CXX_ENABLE_EXCEPTIONS": "True"},
)
config_setting(
name = "pico_cxx_enable_rtti_enabled",
flag_values = {"//bazel/config:PICO_CXX_ENABLE_RTTI": "True"},
)
config_setting(
name = "pico_cxx_enable_cxa_atexit_enabled",
flag_values = {"//bazel/config:PICO_CXX_ENABLE_RTTI": "True"},
)
config_setting(
name = "pico_stdio_uart_enabled",
flag_values = {"//bazel/config:PICO_STDIO_UART": "True"},
)
config_setting(
name = "pico_stdio_usb_enabled",
flag_values = {"//bazel/config:PICO_STDIO_USB": "True"},
)
config_setting(
name = "pico_stdio_semihosting_enabled",
flag_values = {"//bazel/config:PICO_STDIO_SEMIHOSTING": "True"},
)
config_setting(
name = "pico_stdio_rtt_enabled",
flag_values = {"//bazel/config:PICO_STDIO_RTT": "True"},
)
config_setting(
name = "pico_multicore_enabled",
flag_values = {"//bazel/config:PICO_MULTICORE_ENABLED": "True"},
)
config_setting(
name = "pico_float_auto_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "auto"},
)
config_setting(
name = "pico_float_compiler_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "compiler"},
)
config_setting(
name = "pico_float_dcp_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "dcp"},
)
config_setting(
name = "pico_float_rp2040_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "rp2040"},
)
config_setting(
name = "pico_float_vfp_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "vfp"},
)
config_setting(
name = "pico_double_auto_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "auto"},
)
config_setting(
name = "pico_double_compiler_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "compiler"},
)
config_setting(
name = "pico_double_dcp_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "dcp"},
)
config_setting(
name = "pico_double_rp2040_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "rp2040"},
)
config_setting(
name = "pico_divider_hardware_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DIVIDER_IMPL": "hardware"},
)
config_setting(
name = "pico_divider_auto_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DIVIDER_IMPL": "auto"},
)
config_setting(
name = "pico_printf_pico_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_PRINTF_IMPL": "pico"},
)
config_setting(
name = "pico_printf_compiler_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_PRINTF_IMPL": "compiler"},
)
config_setting(
name = "pico_async_context_poll_enabled",
flag_values = {"//bazel/config:PICO_ASYNC_CONTEXT_IMPL": "poll"},
)
config_setting(
name = "pico_async_context_threadsafe_background_enabled",
flag_values = {"//bazel/config:PICO_ASYNC_CONTEXT_IMPL": "threadsafe_background"},
)
config_setting(
name = "pico_async_context_freertos_enabled",
flag_values = {"//bazel/config:PICO_ASYNC_CONTEXT_IMPL": "freertos"},
)
config_setting(
name = "pico_use_default_max_page_size_enabled",
flag_values = {"//bazel/config:PICO_USE_DEFAULT_MAX_PAGE_SIZE": "True"},
)
config_setting(
name = "pico_no_target_name_enabled",
flag_values = {"//bazel/config:PICO_NO_TARGET_NAME": "True"},
)
config_setting(
name = "pico_clib_llvm_libc_enabled",
flag_values = {"//bazel/config:PICO_CLIB": "llvm_libc"},
)
config_setting(
name = "pico_clib_newlib_enabled",
flag_values = {"//bazel/config:PICO_CLIB": "newlib"},
)
config_setting(
name = "pico_clib_picolibc_enabled",
flag_values = {"//bazel/config:PICO_CLIB": "picolibc"},
)
config_setting(
name = "pico_bt_enable_ble_enabled",
flag_values = {"//bazel/config:PICO_BT_ENABLE_BLE": "True"},
)
config_setting(
name = "pico_bt_enable_classic_enabled",
flag_values = {"//bazel/config:PICO_BT_ENABLE_CLASSIC": "True"},
)
config_setting(
name = "pico_bt_enable_mesh_enabled",
flag_values = {"//bazel/config:PICO_BT_ENABLE_MESH": "True"},
)
label_flag_matches(
name = "pico_lwip_config_unset",
flag = "//bazel/config:PICO_LWIP_CONFIG",
value = "//bazel:empty_cc_lib",
)
label_flag_matches(
name = "pico_btstack_config_unset",
flag = "//bazel/config:PICO_BTSTACK_CONFIG",
value = "//bazel:empty_cc_lib",
)
label_flag_matches(
name = "pico_freertos_unset",
flag = "//bazel/config:PICO_FREERTOS_LIB",
value = "//bazel:empty_cc_lib",
)

117
bazel/defs.bzl Normal file
View file

@ -0,0 +1,117 @@
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:defs.bzl", "cc_library")
def _pico_generate_pio_header_impl(ctx):
generated_headers = []
for f in ctx.files.srcs:
out = ctx.actions.declare_file(
"{}_pio_generated/{}.h".format(ctx.label.name, f.basename),
)
generated_headers.append(out)
ctx.actions.run(
executable = ctx.executable._pioasm_tool,
arguments = [
"-o",
"c-sdk",
f.path,
out.path,
],
inputs = [f],
outputs = [out],
)
cc_ctx = cc_common.create_compilation_context(
headers = depset(direct = generated_headers),
includes = depset(direct = [generated_headers[0].dirname]),
)
return [
DefaultInfo(files = depset(direct = generated_headers)),
CcInfo(compilation_context = cc_ctx),
]
pico_generate_pio_header = rule(
implementation = _pico_generate_pio_header_impl,
doc = """Generates a .h header file for each listed pio source.
Each source file listed in `srcs` will be available as `[pio file name].h` on
the include path if you depend on this rule from a `cc_library`.
pico_generate_pio_header(
name = "my_fun_pio",
srcs = ["my_fun_pio.pio"],
)
# This library can #include "my_fun_pio.pio.h".
cc_library(
name = "libfoo",
deps = [":my_fun_pio"],
srcs = ["libfoo.c"],
)
""",
attrs = {
"srcs": attr.label_list(mandatory = True, allow_files = True),
"_pioasm_tool": attr.label(
default = "@pico-sdk//tools/pioasm:pioasm",
cfg = "exec",
executable = True,
),
},
provides = [CcInfo],
)
# Because the syntax for target_compatible_with when used with config_setting
# rules is both confusing and verbose, provide some helpers that make it much
# easier and clearer to express compatibility.
#
# Context: https://github.com/bazelbuild/bazel/issues/12614
def compatible_with_config(config_label):
"""Expresses compatibility with a config_setting."""
return select({
config_label: [],
"//conditions:default": ["@platforms//:incompatible"],
})
def incompatible_with_config(config_label):
"""Expresses incompatibility with a config_setting."""
return select({
config_label: ["@platforms//:incompatible"],
"//conditions:default": [],
})
def compatible_with_rp2():
"""Expresses a rule is compatible with the rp2 family."""
return incompatible_with_config("//bazel/constraint:host")
def compatible_with_pico_w():
"""Expresses a rule is compatible a Pico W."""
return select({
"@pico-sdk//bazel/constraint:cyw43_wireless": [],
"@pico-sdk//bazel/constraint:is_pico_w": [],
"@pico-sdk//bazel/constraint:is_pico2_w": [],
"//conditions:default": ["@platforms//:incompatible"],
})
def pico_board_config(name, platform_includes, **kwargs):
"""A helper macro for declaring a Pico board to use with PICO_CONFIG_HEADER.
This generates pico_config_platform_headers.h using the list of
includes provided in `platform_includes`, and the final artifact is
a cc_library that you can configure //bazel/config:PICO_CONFIG_HEADER to
point to.
"""
_hdr_dir = "{}_generated_includes".format(name)
_hdr_path = "{}/pico_config_platform_headers.h".format(_hdr_dir)
write_file(
name = "{}_platform_headers_file".format(name),
out = _hdr_path,
content = ['#include "{}"'.format(inc) for inc in platform_includes],
)
kwargs.setdefault("hdrs", [])
kwargs["hdrs"].append(_hdr_path)
kwargs.setdefault("includes", [])
kwargs["includes"].append(_hdr_dir)
cc_library(
name = name,
**kwargs
)

View file

@ -0,0 +1,58 @@
#!/usr/bin/env python3
"""Generate a version header for the Bazel build.
Splits a semantic version string into major, minor, and patch and uses the
provided template to produce a working version header.
"""
import argparse
import re
import sys
def _parse_args():
parser = argparse.ArgumentParser(
description=__doc__,
)
parser.add_argument(
"--version-string",
required=True,
help="SDK version string",
)
parser.add_argument(
"--template",
type=argparse.FileType("r"),
required=True,
help="Path to version.h.in",
)
parser.add_argument(
"-o",
"--output",
type=argparse.FileType("wb"),
default=sys.stdout.buffer,
help="Output file path. Defaults to stdout.",
)
return parser.parse_args()
_EXPANSION_REGEX = re.compile(r"(?:\$\{)([a-zA-Z]\w*)(?:\})")
def generate_version_header(version_string, template, output):
version_parts = version_string.split('.')
defines = {
"PICO_SDK_VERSION_MAJOR": version_parts[0],
"PICO_SDK_VERSION_MINOR": version_parts[1],
"PICO_SDK_VERSION_REVISION": version_parts[2].split('-')[0],
"PICO_SDK_VERSION_STRING": version_string,
}
output.write(
_EXPANSION_REGEX.sub(
lambda val: str(defines.get(val.group(1))),
template.read(),
).encode()
)
if __name__ == "__main__":
sys.exit(generate_version_header(**vars(_parse_args())))

View file

@ -0,0 +1,12 @@
// Rather than auto-generating as part of the build, this header
// is checked in directly.
//
// You can change what is included by configuring these `label_flag`s:
// --@pico-sdk//bazel/config:PICO_CONFIG_EXTRA_HEADER=//my_proj:my_custom_headers
// --@pico-sdk//bazel/config:PICO_CONFIG_PLATFORM_HEADER=//my_proj:my_custom_headers
// This header must be provided by //bazel/config:PICO_CONFIG_EXTRA_HEADER:
#include "pico_config_extra_headers.h"
// This header must be provided by //bazel/config:PICO_CONFIG_PLATFORM_HEADER:
#include "pico_config_platform_headers.h"

View file

@ -0,0 +1,59 @@
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cpp_toolchain", "use_cc_toolchain")
def _pico_btstack_make_gatt_header_impl(ctx):
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
)
out = ctx.actions.declare_file(
"{}_gatt_generated/{}.h".format(ctx.label.name, ctx.file.src.basename.removesuffix(".gatt")),
)
ctx.actions.run(
executable = ctx.executable._make_gat_header_tool,
arguments = [
ctx.file.src.path,
out.path,
"-I",
ctx.file._btstack_hdr.dirname,
] + [
],
inputs = [
ctx.file.src,
ctx.file._btstack_hdr,
],
outputs = [out],
)
cc_ctx = cc_common.create_compilation_context(
headers = depset(direct = [out]),
includes = depset(direct = [out.dirname]),
)
return [
DefaultInfo(files = depset(direct = [out])),
CcInfo(compilation_context = cc_ctx)
]
pico_btstack_make_gatt_header = rule(
implementation = _pico_btstack_make_gatt_header_impl,
attrs = {
"src": attr.label(mandatory = True, allow_single_file = True),
"_btstack_hdr": attr.label(
default = "@btstack//:src/bluetooth_gatt.h",
allow_single_file = True,
),
"_make_gat_header_tool": attr.label(
default = "@btstack//:compile_gatt",
cfg = "exec",
executable = True,
),
},
fragments = ["cpp"],
toolchains = use_cc_toolchain(),
)

View file

@ -0,0 +1,17 @@
package(default_visibility = ["//visibility:public"])
platform(
name = "rp2040",
constraint_values = [
"@pico-sdk//bazel/constraint:rp2040",
"@platforms//cpu:armv6-m",
],
)
platform(
name = "rp2350",
constraint_values = [
"@pico-sdk//bazel/constraint:rp2350",
"@platforms//cpu:armv8-m",
],
)

291
bazel/toolchain/BUILD.bazel Normal file
View file

@ -0,0 +1,291 @@
load("@rules_cc//cc/toolchains:args.bzl", "cc_args")
load("@rules_cc//cc/toolchains:args_list.bzl", "cc_args_list")
load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature")
load("@rules_cc//cc/toolchains:toolchain.bzl", "cc_toolchain")
load("configurable_feature.bzl", "configurable_toolchain_feature")
package(default_visibility = ["//visibility:public"])
cc_args(
name = "armv6m-none-eabi",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = ["--target=armv6m-none-eabi"],
)
cc_args(
name = "armv8m.main-none-eabi",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = ["--target=armv8m.main-none-eabi"],
)
cc_args(
name = "cortex-m0",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = [
"-mcpu=cortex-m0plus",
"-mthumb",
],
)
cc_args(
name = "cortex-m33",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = [
"-mcpu=cortex-m33",
"-march=armv8-m.main+fp+dsp",
"-mfloat-abi=softfp",
"-mthumb",
"-mcmse",
],
)
# :no_canonical_system_headers and :no_canonical_prefixes both prevent built-in
# compiler include directories from resolving to absolute paths. Prefer to use
# :bazel_no_absolute_paths, since it correctly guides based on the current
# compiler type.
cc_args(
name = "no_canonical_system_headers",
actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
args = ["-fno-canonical-system-headers"],
)
cc_args(
name = "no_canonical_prefixes",
actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
args = ["-no-canonical-prefixes"],
)
cc_args_list(
name = "bazel_no_absolute_paths",
args = select({
"//bazel/constraint:pico_toolchain_clang_enabled": [],
"//conditions:default": [":no_canonical_system_headers"],
}) + [":no_canonical_prefixes"],
)
cc_args(
name = "llvm-libc_args",
actions = ["@rules_cc//cc/toolchains/actions:link_actions"],
args = [
"-nostdlib++",
"-nostartfiles",
"-Wl,-lc++",
],
visibility = ["//visibility:private"],
)
cc_args(
name = "opt_debug_args",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = [
"-Og", # TODO: Make this configurable.
"-g3",
],
)
configurable_toolchain_feature(
name = "gc_sections",
copts = [
"-ffunction-sections",
"-fdata-sections",
],
linkopts = ["-Wl,--gc-sections"],
)
configurable_toolchain_feature(
name = "cxx_no_exceptions",
cxxopts = [
"-fno-exceptions",
"-fno-unwind-tables",
],
)
configurable_toolchain_feature(
name = "cxx_no_rtti",
cxxopts = ["-fno-rtti"],
)
configurable_toolchain_feature(
name = "cxx_no_cxa_atexit",
cxxopts = ["-fno-use-cxa-atexit"],
)
configurable_toolchain_feature(
name = "override_max_page_size",
linkopts = ["-Wl,-z,max-page-size=4096"],
)
# TODO: Make this shim unnecessary.
cc_args_list(
name = "all_opt_debug_args",
args = [":opt_debug_args"],
)
cc_feature(
name = "override_debug",
args = [":all_opt_debug_args"],
overrides = "@rules_cc//cc/toolchains/features:dbg",
)
HOSTS = (
("linux", "x86_64"),
("linux", "aarch64"),
("win", "x86_64"),
("mac", "x86_64"),
("mac", "aarch64"),
)
_HOST_OS_CONSTRAINTS = {
"linux": "@platforms//os:linux",
"win": "@platforms//os:windows",
"mac": "@platforms//os:macos",
}
_HOST_CPU_CONSTRAINTS = {
"x86_64": "@platforms//cpu:x86_64",
"aarch64": "@platforms//cpu:aarch64",
}
[cc_toolchain(
name = "arm_gcc_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
tool_map = "@arm_gcc_{}-{}//:all_tools".format(host_os, host_cpu),
args = select({
"//bazel/constraint:rp2040": [":cortex-m0"],
"//bazel/constraint:rp2350": [":cortex-m33"],
"//conditions:default": [],
}) + [
":bazel_no_absolute_paths",
],
exec_compatible_with = [
_HOST_CPU_CONSTRAINTS[host_cpu],
_HOST_OS_CONSTRAINTS[host_os],
],
tags = ["manual"], # Don't try to build this in wildcard builds.
known_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
"@pico-sdk//bazel/toolchain:override_debug",
"@pico-sdk//bazel/toolchain:gc_sections",
"@pico-sdk//bazel/toolchain:cxx_no_exceptions",
"@pico-sdk//bazel/toolchain:cxx_no_rtti",
"@pico-sdk//bazel/toolchain:cxx_no_cxa_atexit",
"@pico-sdk//bazel/toolchain:override_max_page_size",
],
enabled_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
"@pico-sdk//bazel/toolchain:override_debug",
] + select({
"//bazel/constraint:pico_no_gc_sections_enabled": [],
"//conditions:default": [":gc_sections"],
}) + select({
"//bazel/constraint:pico_cxx_enable_exceptions_enabled": [],
"//conditions:default": [":cxx_no_exceptions"],
}) + select({
"//bazel/constraint:pico_cxx_enable_rtti_enabled": [],
"//conditions:default": [":cxx_no_rtti"],
}) + select({
"//bazel/constraint:pico_cxx_enable_cxa_atexit_enabled": [],
"//conditions:default": [":cxx_no_cxa_atexit"],
}) + select({
"//bazel/constraint:pico_use_default_max_page_size_enabled": [],
"//conditions:default": [":override_max_page_size"],
}),
) for host_os, host_cpu in HOSTS]
[cc_toolchain(
name = "clang_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
tool_map = "@clang_{}-{}//:all_tools".format(host_os, host_cpu),
args = select({
"//bazel/constraint:rp2040": [
":armv6m-none-eabi",
":cortex-m0",
],
"//bazel/constraint:rp2350": [
":armv8m.main-none-eabi",
":cortex-m33",
],
"//conditions:default": [],
}) + [
":bazel_no_absolute_paths",
":llvm-libc_args",
],
exec_compatible_with = [
_HOST_CPU_CONSTRAINTS[host_cpu],
_HOST_OS_CONSTRAINTS[host_os],
],
tags = ["manual"], # Don't try to build this in wildcard builds.
known_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
"@pico-sdk//bazel/toolchain:override_debug",
"@pico-sdk//bazel/toolchain:gc_sections",
"@pico-sdk//bazel/toolchain:cxx_no_exceptions",
"@pico-sdk//bazel/toolchain:cxx_no_rtti",
"@pico-sdk//bazel/toolchain:cxx_no_cxa_atexit",
"@pico-sdk//bazel/toolchain:override_max_page_size",
],
enabled_features = [
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
"@pico-sdk//bazel/toolchain:override_debug",
] + select({
"//bazel/constraint:pico_no_gc_sections_enabled": [],
"//conditions:default": [":gc_sections"],
}) + select({
"//bazel/constraint:pico_cxx_enable_exceptions_enabled": [],
"//conditions:default": [":cxx_no_exceptions"],
}) + select({
"//bazel/constraint:pico_cxx_enable_rtti_enabled": [],
"//conditions:default": [":cxx_no_rtti"],
}) + select({
"//bazel/constraint:pico_cxx_enable_cxa_atexit_enabled": [],
"//conditions:default": [":cxx_no_cxa_atexit"],
}) + select({
"//bazel/constraint:pico_use_default_max_page_size_enabled": [],
"//conditions:default": [":override_max_page_size"],
}),
) for host_os, host_cpu in HOSTS]
[toolchain(
name = "{}-{}-rp2040".format(host_os, host_cpu),
exec_compatible_with = [
_HOST_CPU_CONSTRAINTS[host_cpu],
_HOST_OS_CONSTRAINTS[host_os],
],
target_compatible_with = [
"@pico-sdk//bazel/constraint:rp2040",
],
toolchain = select({
"//bazel/constraint:pico_toolchain_clang_enabled": "clang_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
"//conditions:default": ":arm_gcc_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
}),
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
) for host_os, host_cpu in HOSTS]
[toolchain(
name = "{}-{}-rp2350".format(host_os, host_cpu),
exec_compatible_with = [
_HOST_CPU_CONSTRAINTS[host_cpu],
_HOST_OS_CONSTRAINTS[host_os],
],
target_compatible_with = [
"@pico-sdk//bazel/constraint:rp2350",
],
toolchain = select({
"//bazel/constraint:pico_toolchain_clang_enabled": "clang_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
"//conditions:default": ":arm_gcc_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
}),
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
) for host_os, host_cpu in HOSTS]

152
bazel/toolchain/clang.BUILD Normal file
View file

@ -0,0 +1,152 @@
load("@bazel_skylib//rules/directory:directory.bzl", "directory")
load("@bazel_skylib//rules/directory:subdirectory.bzl", "subdirectory")
load("@rules_cc//cc/toolchains:tool.bzl", "cc_tool")
load("@rules_cc//cc/toolchains:tool_map.bzl", "cc_tool_map")
load("@rules_cc//cc/toolchains:args.bzl", "cc_args")
load("@rules_cc//cc/toolchains:args_list.bzl", "cc_args_list")
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
# Directory-based rules in this toolchain only referece things in
# lib/ or include/ subdirectories.
directory(
name = "toolchain_root",
srcs = glob([
"lib/**",
"include/**",
]),
)
cc_tool_map(
name = "all_tools",
tools = {
"@rules_cc//cc/toolchains/actions:assembly_actions": ":asm",
"@rules_cc//cc/toolchains/actions:c_compile": ":clang",
"@rules_cc//cc/toolchains/actions:cpp_compile_actions": ":clang++",
"@rules_cc//cc/toolchains/actions:link_actions": ":lld",
"@rules_cc//cc/toolchains/actions:objcopy_embed_data": ":llvm-objcopy",
"@rules_cc//cc/toolchains/actions:strip": ":llvm-strip",
"@rules_cc//cc/toolchains/actions:ar_actions": ":llvm-ar",
},
)
# TODO: https://github.com/bazelbuild/rules_cc/issues/235 - Workaround until
# Bazel has a more robust way to implement `cc_tool_map`.
alias(
name = "asm",
actual = ":clang",
)
cc_tool(
name = "clang",
src = select({
"@platforms//os:windows": "//:bin/clang.exe",
"//conditions:default": "//:bin/clang",
}),
data = glob([
"bin/llvm",
"lib/clang/*/include/**",
"include/armv*-unknown-none-eabi/**",
]),
)
cc_tool(
name = "clang++",
src = select({
"@platforms//os:windows": "//:bin/clang++.exe",
"//conditions:default": "//:bin/clang++",
}),
data = glob([
"bin/llvm",
"lib/clang/*/include/**",
"include/armv*-unknown-none-eabi/**",
"include/c++/v1/**",
]),
)
cc_tool(
name = "lld",
src = select({
"@platforms//os:windows": "//:bin/clang++.exe",
"//conditions:default": "//:bin/clang++",
}),
data = glob([
"bin/llvm",
"bin/lld*",
"bin/ld*",
"lib/**/*.a",
"lib/**/*.so*",
"lib/**/*.o",
"lib/armv*-unknown-none-eabi/**",
"lib/clang/*/lib/armv*-unknown-none-eabi/**",
]),
)
cc_tool(
name = "llvm-ar",
src = select({
"@platforms//os:windows": "//:bin/llvm-ar.exe",
"//conditions:default": "//:bin/llvm-ar",
}),
data = glob(["bin/llvm"]),
)
cc_tool(
name = "llvm-libtool-darwin",
src = select({
"@platforms//os:windows": "//:bin/llvm-libtool-darwin.exe",
"//conditions:default": "//:bin/llvm-libtool-darwin",
}),
data = glob(["bin/llvm"]),
)
cc_tool(
name = "llvm-objcopy",
src = select({
"@platforms//os:windows": "//:bin/llvm-objcopy.exe",
"//conditions:default": "//:bin/llvm-objcopy",
}),
data = glob(["bin/llvm"]),
)
cc_tool(
name = "llvm-objdump",
src = select({
"@platforms//os:windows": "//:bin/llvm-objdump.exe",
"//conditions:default": "//:bin/llvm-objdump",
}),
data = glob(["bin/llvm"]),
)
cc_tool(
name = "llvm-cov",
src = select({
"@platforms//os:windows": "//:bin/llvm-cov.exe",
"//conditions:default": "//:bin/llvm-cov",
}),
data = glob(["bin/llvm"]),
)
cc_tool(
name = "llvm-strip",
src = select({
"@platforms//os:windows": "//:bin/llvm-strip.exe",
"//conditions:default": "//:bin/llvm-strip",
}),
data = glob(["bin/llvm"]),
)
cc_tool(
name = "clang-tidy",
src = select({
"@platforms//os:windows": "//:bin/clang-tidy.exe",
"//conditions:default": "//:bin/clang-tidy",
}),
data = glob([
"bin/llvm",
"include/**",
"lib/clang/**/include/**",
]),
)

View file

@ -0,0 +1,42 @@
load("@rules_cc//cc/toolchains:args.bzl", "cc_args")
load("@rules_cc//cc/toolchains:args_list.bzl", "cc_args_list")
load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature")
def configurable_toolchain_feature(name, copts = [], cxxopts = [], linkopts = []):
all_args = []
if copts:
cc_args(
name = name + "_cc_args",
actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
args = copts,
)
all_args.append(name + "_cc_args")
if cxxopts:
cc_args(
name = name + "_cxx_args",
actions = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"],
args = cxxopts,
)
all_args.append(name + "_cxx_args")
if linkopts:
cc_args(
name = name + "_link_args",
actions = ["@rules_cc//cc/toolchains/actions:link_actions"],
args = linkopts,
)
all_args.append(name + "_link_args")
cc_args_list(
name = name + "_args",
args = all_args,
)
cc_feature(
name = name,
feature_name = name,
args = [":{}_args".format(name)],
)

View file

@ -0,0 +1,131 @@
load("@bazel_skylib//rules/directory:directory.bzl", "directory")
load("@bazel_skylib//rules/directory:subdirectory.bzl", "subdirectory")
load("@rules_cc//cc/toolchains:tool.bzl", "cc_tool")
load("@rules_cc//cc/toolchains:tool_map.bzl", "cc_tool_map")
load("@rules_cc//cc/toolchains:args.bzl", "cc_args")
load("@rules_cc//cc/toolchains:args_list.bzl", "cc_args_list")
package(default_visibility = ["//visibility:public"])
cc_tool_map(
name = "all_tools",
tools = {
"@rules_cc//cc/toolchains/actions:assembly_actions": ":asm",
"@rules_cc//cc/toolchains/actions:c_compile": ":arm-none-eabi-gcc",
"@rules_cc//cc/toolchains/actions:cpp_compile_actions": ":arm-none-eabi-g++",
"@rules_cc//cc/toolchains/actions:link_actions": ":arm-none-eabi-ld",
"@rules_cc//cc/toolchains/actions:objcopy_embed_data": ":arm-none-eabi-objcopy",
"@rules_cc//cc/toolchains/actions:strip": ":arm-none-eabi-strip",
"@rules_cc//cc/toolchains/actions:ar_actions": ":arm-none-eabi-ar",
},
)
# TODO: https://github.com/bazelbuild/rules_cc/issues/235 - Workaround until
# Bazel has a more robust way to implement `cc_tool_map`.
alias(
name = "asm",
actual = ":arm-none-eabi-gcc",
)
cc_tool(
name = "arm-none-eabi-ar",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-ar.exe",
"//conditions:default": "//:bin/arm-none-eabi-ar",
}),
)
cc_tool(
name = "arm-none-eabi-g++",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-g++.exe",
"//conditions:default": "//:bin/arm-none-eabi-g++",
}),
data = glob([
"**/*.spec",
"**/*.specs",
"arm-none-eabi/include/**",
"lib/gcc/arm-none-eabi/*/include/**",
"lib/gcc/arm-none-eabi/*/include-fixed/**",
"libexec/**",
]),
)
cc_tool(
name = "arm-none-eabi-gcc",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-gcc.exe",
"//conditions:default": "//:bin/arm-none-eabi-gcc",
}),
data = glob([
"**/*.spec",
"**/*.specs",
"arm-none-eabi/include/**",
"lib/gcc/arm-none-eabi/*/include/**",
"lib/gcc/arm-none-eabi/*/include-fixed/**",
"libexec/**",
]) +
# The assembler needs to be explicitly added. Note that the path is
# intentionally different here as `as` is called from arm-none-eabi-gcc.
# `arm-none-eabi-as` will not suffice for this context.
select({
"@platforms//os:windows": ["//:arm-none-eabi/bin/as.exe"],
"//conditions:default": ["//:arm-none-eabi/bin/as"],
}),
)
# This tool is actually just g++ under the hood, but this specifies a
# different set of data files to pull into the sandbox at runtime.
cc_tool(
name = "arm-none-eabi-ld",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-g++.exe",
"//conditions:default": "//:bin/arm-none-eabi-g++",
}),
data = glob([
"**/*.a",
"**/*.ld",
"**/*.o",
"**/*.spec",
"**/*.specs",
"**/*.so",
"libexec/**",
]),
)
cc_tool(
name = "arm-none-eabi-objcopy",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-objcopy.exe",
"//conditions:default": "//:bin/arm-none-eabi-objcopy",
}),
)
cc_tool(
name = "arm-none-eabi-strip",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-strip.exe",
"//conditions:default": "//:bin/arm-none-eabi-strip",
}),
)
cc_tool(
name = "arm-none-eabi-objdump",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-objdump.exe",
"//conditions:default": "//:bin/arm-none-eabi-objdump",
}),
)
# There is not yet a well-known action type for objdump.
cc_tool(
name = "arm-none-eabi-gcov",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-gcov.exe",
"//conditions:default": "//:bin/arm-none-eabi-gcov",
}),
)
# There is not yet a well-known action type for gcov.

View file

@ -0,0 +1,46 @@
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "OBJ_COPY_ACTION_NAME")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cpp_toolchain", "use_cc_toolchain")
def _objcopy_to_bin_impl(ctx):
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
)
objcopy_tool_path = cc_common.get_tool_for_action(
feature_configuration = feature_configuration,
action_name = OBJ_COPY_ACTION_NAME,
)
ctx.actions.run(
inputs = depset(
direct = [ctx.file.src],
transitive = [cc_toolchain.all_files],
),
executable = objcopy_tool_path,
outputs = [ctx.outputs.out],
arguments = [
ctx.file.src.path,
"-Obinary",
ctx.outputs.out.path,
],
)
objcopy_to_bin = rule(
implementation = _objcopy_to_bin_impl,
attrs = {
"src": attr.label(
allow_single_file = True,
mandatory = True,
doc = "File to use as input to objcopy command",
),
"out": attr.output(
mandatory = True,
doc = "Destination file for objcopy command",
),
},
fragments = ["cpp"],
toolchains = use_cc_toolchain(),
)

1
bazel/util/BUILD.bazel Normal file
View file

@ -0,0 +1 @@
package(default_visibility = ["//visibility:public"])

View file

@ -0,0 +1,37 @@
"""A wrapper that enables a `config_setting` matcher for label_flag flags."""
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
def _match_label_flag_impl(ctx):
matches = str(ctx.attr.expected_value.label) == str(ctx.attr.flag.label)
return [
config_common.FeatureFlagInfo(value = str(matches)),
BuildSettingInfo(value = matches),
]
_match_label_flag = rule(
implementation = _match_label_flag_impl,
attrs = {
"expected_value": attr.label(
mandatory = True,
doc = "The expected flag value",
),
"flag": attr.label(
mandatory = True,
doc = "The flag to extract a value from",
),
},
)
def label_flag_matches(*, name, flag, value):
_match_label_flag(
name = name + "._impl",
expected_value = native.package_relative_label(value),
flag = flag,
)
native.config_setting(
name = name,
flag_values = {":{}".format(name + "._impl"): "True"},
)

View file

@ -0,0 +1,38 @@
def declare_flag_choices(flag, choices):
"""Declares a `config_setting` for each known choice for the provided flag.
The name of each config setting uses the name of the `config_setting` is:
[flag label name]_[choice]
This can be used with select_choice() to map `config_setting`s to values.
Args:
flag: The flag that guides the declared `config_setting`s.
pkg: The package that declare_flag_choices() was declared in.
choice_map: A mapping of distinct choices to
"""
flag_name = flag.split(":")[1]
[
native.config_setting(
name = "{}_{}".format(flag_name, choice),
flag_values = {flag: choice},
)
for choice in choices
]
def flag_choice(flag, pkg, choice_map):
"""Creates a `select()` based on choices declared by `declare_choices()`.
Args:
flag: The flag that guides the select.
pkg: The package that `declare_flag_choices()` was called in.
choice_map: A mapping of distinct choices to the final intended value.
"""
return {
"{}:{}_{}".format(
pkg.split(":")[0],
flag.split(":")[1],
choice,
): val
for choice, val in choice_map.items()
}

43
bazel/util/sdk_define.bzl Normal file
View file

@ -0,0 +1,43 @@
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
def _pico_sdk_define_impl(ctx):
val = ctx.attr.from_flag[BuildSettingInfo].value
if type(val) == "string":
# Strings need quotes.
val = "\"{}\"".format(val)
elif type(val) == "bool":
# Convert bools to 0 or 1.
val = 1 if val else 0
cc_ctx = cc_common.create_compilation_context(
defines = depset(
direct = ["{}={}".format(ctx.attr.define_name, val)],
),
)
return [CcInfo(compilation_context = cc_ctx)]
pico_sdk_define = rule(
implementation = _pico_sdk_define_impl,
doc = """A simple rule that offers a skylib flag as a define.
These can be listed in the `deps` attribute of a `cc_library` to get access
to the value of a define.
Example:
bool_flag(
name = "my_flag",
build_setting_default = False,
)
pico_sdk_define(
name = "flag_define",
define_name = "MY_FLAG_DEFINE",
from_flag = ":my_flag",
)
""",
attrs = {
"define_name": attr.string(mandatory = True),
"from_flag": attr.label(mandatory = True),
},
)

167
bazel/util/transition.bzl Normal file
View file

@ -0,0 +1,167 @@
def _normalize_flag_value(val):
"""Converts flag values to transition-safe primitives."""
if type(val) == "label":
return str(val)
return val
def declare_transtion(attrs, flag_overrides = None, append_to_flags = None, executable = True):
"""A helper that drastically simplifies declaration of a transition.
A transition in Bazel is a way to force changes to the way the build is
evaluated for all dependencies of a given rule.
Imagine the following simple dependency graph:
->: depends on
a -> b -> c
Normally, if you set `defines` on a, they couldn't apply to b or c because
they are dependencies of a. There's no way for b or c to know about a's
settings, because they don't even know a exists!
We can fix this via a transition! If we put a transition in front of `a`
that sets --copts=-DFOO=42, we're telling Bazel to build a and all of its
dependencies under that configuration.
Note: Flags must be referenced as e.g. `//command_line_option:copt` in
transitions.
`declare_transition()` eliminates the frustrating amount of boilerplate. All
you need to do is provide a set of attrs, and then a `flag_overrides`
dictionary that tells `declare_transition()` which attrs to pull flag values
from. The common `src` attr tells the transition which build rule to apply
the transition to.
"""
def _flag_override_impl(settings, attrs):
final_overrides = {}
if flag_overrides != None:
final_overrides = {
key: _normalize_flag_value(getattr(attrs, value))
for key, value in flag_overrides.items()
}
if append_to_flags != None:
for flag, field in append_to_flags.items():
accumulated_flags = final_overrides.get(flag, settings.get(flag, []))
accumulated_flags.extend(
[str(val) for val in getattr(attrs, field)],
)
final_overrides[flag] = accumulated_flags
return final_overrides
output_flags = []
if flag_overrides != None:
output_flags.extend(flag_overrides.keys())
if append_to_flags != None:
output_flags.extend(append_to_flags.keys())
_transition = transition(
implementation = _flag_override_impl,
inputs = append_to_flags.keys() if append_to_flags != None else [],
outputs = output_flags,
)
def _symlink_artifact_impl(ctx):
out = ctx.actions.declare_file(ctx.label.name)
if executable:
ctx.actions.symlink(output = out, target_file = ctx.executable.src)
return [DefaultInfo(files = depset([out]), executable = out)]
ctx.actions.symlink(
output = out,
target_file = ctx.attr.src[0][DefaultInfo].files.to_list()[0],
)
return [DefaultInfo(files = depset([out]))]
return rule(
implementation = _symlink_artifact_impl,
executable = executable,
attrs = {
"src": attr.label(
cfg = _transition,
executable = executable,
mandatory = True,
),
} | attrs,
)
# This transition is applied before building the boot_stage2 image.
rp2040_bootloader_binary = declare_transtion(
attrs = {
"_malloc": attr.label(default = "//bazel:empty_cc_lib"),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
"_link_extra_libs": attr.label(default = "//bazel:empty_cc_lib"),
},
flag_overrides = {
# We don't want --custom_malloc to ever apply to the bootloader, so
# always explicitly override it here.
"//command_line_option:custom_malloc": "_malloc",
# Platforms will commonly depend on bootloader components in every
# binary via `link_extra_libs`, so we must drop these deps when
# building the bootloader binaries themselves in order to avoid a
# circular dependency.
"@bazel_tools//tools/cpp:link_extra_libs": "_link_extra_libs",
},
)
# This transition sets SDK configuration options required to build test binaries
# for the kitchen_sink suite of tests.
kitchen_sink_test_binary = declare_transtion(
attrs = {
"bt_stack_config": attr.label(mandatory = True),
"lwip_config": attr.label(mandatory = True),
"enable_ble": attr.bool(default = False),
"enable_bt_classic": attr.bool(default = False),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
flag_overrides = {
"@pico-sdk//bazel/config:PICO_BTSTACK_CONFIG": "bt_stack_config",
"@pico-sdk//bazel/config:PICO_LWIP_CONFIG": "lwip_config",
"@pico-sdk//bazel/config:PICO_BT_ENABLE_BLE": "enable_ble",
"@pico-sdk//bazel/config:PICO_BT_ENABLE_CLASSIC": "enable_bt_classic",
},
)
# This transition sets SDK configuration options required to build test binaries
# for the pico_float_test suite of tests.
pico_float_test_binary = declare_transtion(
attrs = {
"pico_printf_impl": attr.string(),
"extra_copts": attr.string_list(),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
flag_overrides = {
"@pico-sdk//bazel/config:PICO_DEFAULT_PRINTF_IMPL": "pico_printf_impl",
},
append_to_flags = {
"//command_line_option:copt": "extra_copts",
},
)
# This is a general purpose transition that applies the listed copt flags to
# all transitive dependencies.
extra_copts_for_all_deps = declare_transtion(
attrs = {
"extra_copts": attr.string_list(),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
append_to_flags = {
"//command_line_option:copt": "extra_copts",
},
)

View file

@ -1,4 +1,11 @@
# this is included because toolchain file sets SYSTEM_NAME=PICO
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
set(CMAKE_EXECUTABLE_SUFFIX .elf)
set(CMAKE_EXECUTABLE_SUFFIX .elf)
# include paths to find installed tools
if(CMAKE_HOST_WIN32)
include(Platform/WindowsPaths)
else()
include(Platform/UnixPaths)
endif()

41
cmake/generic_board.cmake Normal file
View file

@ -0,0 +1,41 @@
# For boards without their own cmake file, we look for a header file
cmake_minimum_required(VERSION 3.15)
# PICO_CMAKE_CONFIG: PICO_BOARD_HEADER_DIRS, List of directories to look for <PICO_BOARD>.h in. This may be specified the user environment, type=list, group=build
if (DEFINED ENV{PICO_BOARD_HEADER_DIRS})
set(PICO_BOARD_HEADER_DIRS $ENV{PICO_BOARD_HEADER_DIRS})
message("Using PICO_BOARD_HEADER_DIRS from environment ('${PICO_BOARD_HEADER_DIRS}')")
endif()
set(PICO_BOARD_HEADER_DIRS ${PICO_BOARD_HEADER_DIRS} CACHE STRING "PICO board header directories" FORCE)
list(APPEND PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/../src/boards/include/boards)
pico_find_in_paths(PICO_BOARD_HEADER_FILE PICO_BOARD_HEADER_DIRS ${PICO_BOARD}.h)
if (EXISTS ${PICO_BOARD_HEADER_FILE})
message("Using board configuration from ${PICO_BOARD_HEADER_FILE}")
list(APPEND PICO_CONFIG_HEADER_FILES ${PICO_BOARD_HEADER_FILE})
# we parse the header file to configure the defaults
file(STRINGS ${PICO_BOARD_HEADER_FILE} HEADER_FILE_CONTENTS)
while(HEADER_FILE_CONTENTS)
list(POP_FRONT HEADER_FILE_CONTENTS LINE)
if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
endif()
if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set_default[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
if (NOT DEFINED "${CMAKE_MATCH_1}")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
else()
list(APPEND PICO_BOARD_CMAKE_OVERRIDES ${CMAKE_MATCH_1})
endif()
endif()
endwhile()
else()
set(msg "Unable to find definition of board '${PICO_BOARD}' (specified by PICO_BOARD):\n")
list(JOIN PICO_BOARD_HEADER_DIRS ", " DIRS)
string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.h in ${DIRS} (additional paths specified by PICO_BOARD_HEADER_DIRS)\n")
list(JOIN PICO_BOARD_CMAKE_DIRS ", " DIRS)
string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.cmake in ${DIRS} (additional paths specified by PICO_BOARD_CMAKE_DIRS)")
message(FATAL_ERROR ${msg})
endif()

View file

@ -1,21 +1,135 @@
# PICO_CMAKE_CONFIG: PICO_PLATFORM, platform to build for e.g. rp2040/host, default=rp2040 or environment value, group=build
if (DEFINED ENV{PICO_PLATFORM} AND (NOT PICO_PLATFORM))
# PICO_BOARD is the root of config as it can define PICO_PLATFORM and other build vars
# PICO_CMAKE_CONFIG: PICO_BOARD, Board name being built for. This may be specified in the user environment, type=string, default=pico or pico2, group=build, docref=cmake-platform-board-config
if (DEFINED ENV{PICO_BOARD} AND NOT PICO_BOARD)
set(PICO_BOARD $ENV{PICO_BOARD})
message("Initializing PICO_BOARD from environment ('${PICO_BOARD}')")
endif()
# PICO_CMAKE_CONFIG: PICO_PLATFORM, Platform to build for e.g. rp2040/rp2350/rp2350-arm-s/rp2350-riscv/host. This may be specified in the user environment, type=string, default=based on PICO_BOARD or environment value, group=build, docref=cmake-platform-board-config
if (DEFINED ENV{PICO_PLATFORM} AND NOT PICO_PLATFORM)
set(PICO_PLATFORM $ENV{PICO_PLATFORM})
message("Using PICO_PLATFORM from environment ('${PICO_PLATFORM}')")
else()
message("Initializing PICO_PLATFORM from environment ('${PICO_PLATFORM}')")
endif()
set(PICO_SAVED_PLATFORM "${PICO_PLATFORM}")
# If PICO_PLATFORM is specified but not PICO_BOARD, we'll make a stab at defaulting
if (NOT PICO_DEFAULT_BOARD_rp2040)
set(PICO_DEFAULT_BOARD_rp2040 "pico")
endif()
if (NOT PICO_DEFAULT_BOARD_rp2350)
set(PICO_DEFAULT_BOARD_rp2350 "pico2")
endif()
if (NOT PICO_DEFAULT_BOARD_rp2350-arm-s)
set(PICO_DEFAULT_BOARD_rp2350-arm-s "pico2")
endif()
if (NOT PICO_DEFAULT_BOARD_rp2350-riscv)
set(PICO_DEFAULT_BOARD_rp2350-riscv "pico2")
endif()
if (NOT PICO_DEFAULT_BOARD_host)
set(PICO_DEFAULT_BOARD_host "none")
endif()
if (NOT PICO_DEFAULT_PLATFORM)
set(PICO_DEFAULT_PLATFORM "rp2040")
endif()
if (NOT PICO_BOARD)
if (NOT PICO_PLATFORM)
set(PICO_PLATFORM "rp2040")
pico_message("Defaulting PICO_PLATFORM to ${PICO_PLATFORM} since not specified.")
else()
message("PICO platform is ${PICO_PLATFORM}.")
# if we have neither BOARD nor PLATFORM default PLATFORM silently, so we don't end up with a board of "none"
# on platform that does have a default board (we want default PLATFORM and BOARD in that case)
set(PICO_PLATFORM ${PICO_DEFAULT_PLATFORM})
# set PICO_SAVED_PLATFORM so we don't print "Defaulting" again below
set(PICO_SAVED_PLATFORM ${PICO_DEFAULT_PLATFORM})
pico_message("Defaulting platform (PICO_PLATFORM) to '${PICO_PLATFORM}' since not specified.")
endif()
endif ()
if (PICO_DEFAULT_BOARD_${PICO_PLATFORM})
set(PICO_BOARD ${PICO_DEFAULT_BOARD_${PICO_PLATFORM}})
else()
set(PICO_BOARD "none")
endif()
pico_message("Defaulting target board (PICO_BOARD) to '${PICO_BOARD}' since not specified.")
else()
message("Target board (PICO_BOARD) is '${PICO_BOARD}'.")
endif()
set(PICO_BOARD ${PICO_BOARD} CACHE STRING "PICO target board (e.g. pico, pico2)" FORCE)
set(PICO_PLATFORM ${PICO_PLATFORM} CACHE STRING "PICO Build platform (e.g. rp2040, host)")
# PICO_CMAKE_CONFIG: PICO_BOARD_CMAKE_DIRS, List of directories to look for <PICO_BOARD>.cmake in. This may be specified in the user environment, type=list, group=build
if (DEFINED ENV{PICO_BOARD_CMAKE_DIRS})
set(PICO_BOARD_CMAKE_DIRS $ENV{PICO_BOARD_CMAKE_DIRS})
message("Using PICO_BOARD_CMAKE_DIRS from environment ('${PICO_BOARD_CMAKE_DIRS}')")
endif()
# PICO_CMAKE_CONFIG: PICO_CMAKE_PRELOAD_PLATFORM_FILE, custom CMake file to use to set up the platform environment, default=none, group=build
set(PICO_CMAKE_PRELOAD_PLATFORM_FILE "" CACHE INTERNAL "")
set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/platforms" CACHE INTERNAL "")
list(APPEND PICO_BOARD_CMAKE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../src/boards)
pico_find_in_paths(PICO_BOARD_CMAKE_FILE PICO_BOARD_CMAKE_DIRS ${PICO_BOARD}.cmake)
if (EXISTS "${PICO_BOARD_CMAKE_FILE}")
message("Using CMake board configuration from ${PICO_BOARD_CMAKE_FILE}")
include(${PICO_BOARD_CMAKE_FILE} board_config)
else()
include(generic_board)
endif()
list(APPEND PICO_INCLUDE_DIRS ${PICO_SDK_PATH}/src/boards/include) # so boards/foo.h can be explicitly included
# PICO_CMAKE_CONFIG: PICO_DEFAULT_RP2350_PLATFORM, Default actual platform to build for if rp2350 is specified for PICO_PLATFORM e.g. rp2350-arm-s/rp2350-riscv, type=string, default=rp2350-arm-s, group=build
if (DEFINED ENV{PICO_DEFAULT_RP2350_PLATFORM} AND NOT PICO_DEFAULT_RP2350_PLATFORM)
set(PICO_DEFAULT_RP2350_PLATFORM $ENV{PICO_DEFAULT_RP2350_PLATFORM})
endif()
if (NOT PICO_DEFAULT_RP2350_PLATFORM)
set(PICO_DEFAULT_RP2350_PLATFORM "rp2350-arm-s")
endif()
if (NOT COMMAND pico_expand_pico_platform)
function(pico_expand_pico_platform FUNC DO_MESSAGE)
if (${FUNC} STREQUAL "rp2350")
if (DO_MESSAGE)
message("Auto-converting non-specific PICO_PLATFORM='rp2350' to '${PICO_DEFAULT_RP2350_PLATFORM}'")
endif()
set(${FUNC} "${PICO_DEFAULT_RP2350_PLATFORM}" PARENT_SCOPE)
endif()
endfunction()
endif()
if (NOT PICO_PLATFORM)
set(PICO_PLATFORM ${PICO_DEFAULT_PLATFORM})
pico_message("Defaulting platform (PICO_PLATFORM) to '${PICO_PLATFORM}' since not specified.")
else()
if (NOT PICO_SAVED_PLATFORM)
pico_expand_pico_platform(PICO_PLATFORM 1)
pico_message("Defaulting platform (PICO_PLATFORM) to '${PICO_PLATFORM}' based on PICO_BOARD setting.")
else()
string(REGEX REPLACE "-.*" "" PICO_PLATFORM_PREFIX ${PICO_PLATFORM})
string(REGEX REPLACE "-.*" "" PICO_SAVED_PLATFORM_PREFIX ${PICO_SAVED_PLATFORM})
if (PICO_PLATFORM_PREFIX STREQUAL PICO_SAVED_PLATFORM_PREFIX)
# the PICO_PLATFORM specified based on the board is compatible based on the one we were
# already using, so use that
pico_expand_pico_platform(PICO_SAVED_PLATFORM 0)
set(PICO_PLATFORM ${PICO_SAVED_PLATFORM})
message("Pico Platform (PICO_PLATFORM) is '${PICO_PLATFORM}'.")
else()
message(FATAL_ERROR "PICO_PLATFORM is specified to be '${PICO_SAVED_PLATFORM}', but PICO_BOARD='${PICO_BOARD}' uses \
'${PICO_PLATFORM}' which is incompatible. You need to delete the CMake cache or build directory and reconfigure to proceed. \
The best practice is to use separate build directories for different platforms.")
endif()
endif()
endif()
unset(PICO_SAVED_PLATFORM)
if (PICO_PREVIOUS_PLATFORM AND NOT PICO_PREVIOUS_PLATFORM STREQUAL PICO_PLATFORM)
message(FATAL_ERROR "PICO_PLATFORM has been modified from '${PICO_SAVED_PLATFORM}' to '${PICO_PLATFORM}.\
You need to delete the CMake cache or build directory and reconfigure to proceed.\
The best practice is to use separate build directories for different platforms.")
endif()
set(PICO_PLATFORM ${PICO_PLATFORM} CACHE STRING "PICO Build platform (e.g. rp2040, rp2350, rp2350-riscv, host)" FORCE)
set(PICO_PREVIOUS_PLATFORM ${PICO_PLATFORM} CACHE STRING "Saved PICO Build platform (e.g. rp2040, rp2350, rp2350-riscv, host)" INTERNAL)
# PICO_CMAKE_CONFIG: PICO_CMAKE_PRELOAD_PLATFORM_FILE, Custom CMake file to use to set up the platform environment, type=string, group=build
set(PICO_CMAKE_PRELOAD_PLATFORM_FILE ${PICO_CMAKE_PRELOAD_PLATFORM_FILE} CACHE INTERNAL "")
if (NOT PICO_CMAKE_PRELOAD_PLATFORM_DIR)
set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/platforms")
endif()
set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${PICO_CMAKE_PRELOAD_PLATFORM_DIR}" CACHE INTERNAL "")
if (NOT PICO_CMAKE_PRELOAD_PLATFORM_FILE)
set(PICO_CMAKE_PRELOAD_PLATFORM_FILE ${PICO_CMAKE_PRELOAD_PLATFORM_DIR}/${PICO_PLATFORM}.cmake CACHE INTERNAL "")

View file

@ -1,9 +1,11 @@
# PICO_CMAKE_CONFIG: PICO_TOOLCHAIN_PATH, Path to search for compiler, default=none (i.e. search system paths), group=build
# PICO_CMAKE_CONFIG: PICO_TOOLCHAIN_PATH, Path to search for compiler, type=string, default=none (i.e. search system paths), group=build, docref=cmake-toolchain-config
set(PICO_TOOLCHAIN_PATH "${PICO_TOOLCHAIN_PATH}" CACHE INTERNAL "")
# Set a default build type if none was specified
set(default_build_type "Release")
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PREFIX_PATH)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Defaulting build type to '${default_build_type}' since not specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build, options are: 'Debug', 'Release', 'MinSizeRel', 'RelWithDebInfo'." FORCE)
@ -16,28 +18,59 @@ if (CMAKE_BUILD_TYPE STREQUAL "Default")
error("Default build type is NOT supported")
endif()
# PICO_CMAKE_CONFIG: PICO_COMPILER, Optionally specifies a different compiler (other than pico_arm_gcc.cmake) - this is not yet fully supported, default=none, group=build
# If PICO_COMPILER is specified, set toolchain file to ${PICO_COMPILER}.cmake.
if (DEFINED PICO_COMPILER)
if (DEFINED CMAKE_TOOLCHAIN_FILE)
get_filename_component(toolchain "${CMAKE_TOOLCHAIN_FILE}" NAME_WE)
if (NOT "${PICO_COMPILER}" STREQUAL "${toolchain}")
message(WARNING "CMAKE_TOOLCHAIN_FILE is already defined to ${toolchain}.cmake, you\
need to delete cache and reconfigure if you want to switch compiler.")
endif ()
else ()
set(toolchain_dir "${CMAKE_CURRENT_LIST_DIR}/preload/toolchains")
set(toolchain_file "${toolchain_dir}/${PICO_COMPILER}.cmake")
if (EXISTS "${toolchain_file}")
set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}" CACHE INTERNAL "")
else ()
# todo improve message
message(FATAL_ERROR "Toolchain file \"${PICO_COMPILER}.cmake\" does not exist, please\
select one from \"cmake/toolchains\" folder.")
endif ()
endif ()
message("PICO compiler is ${PICO_COMPILER}")
if (NOT (DEFINED PICO_COMPILER OR DEFINED CMAKE_TOOLCHAIN_FILE))
if (DEFINED PICO_DEFAULT_COMPILER)
pico_message("Defaulting compiler (PICO_COMPILER) to '${PICO_DEFAULT_COMPILER}' since not specified.")
set(PICO_COMPILER ${PICO_DEFAULT_COMPILER})
endif()
endif ()
# PICO_CMAKE_CONFIG: PICO_COMPILER, Specifies the compiler family to use, type=string, group=build, default=PICO_DEFAULT_COMPILER which is set based on PICO_PLATFORM, docref=cmake-toolchain-config
# If PICO_COMPILER is specified, set toolchain file to ${PICO_COMPILER}.cmake.
if (DEFINED PICO_COMPILER)
# maintain backwards compatibility with RP2040 SDK compilers
set(ORIG_PICO_COMPILER "${PICO_COMPILER}")
if (PICO_COMPILER STREQUAL "pico_arm_gcc")
if (PICO_PLATFORM STREQUAL "rp2040")
set(PICO_COMPILER "pico_arm_cortex_m0plus_gcc")
elseif(PICO_PLATFORM STREQUAL "rp2350")
set(PICO_COMPILER "pico_arm_cortex_m33_gcc")
endif()
elseif(PICO_COMPILER STREQUAL "pico_arm_clang")
if (PICO_PLATFORM STREQUAL "rp2040")
set(PICO_COMPILER "pico_arm_cortex_m0plus_clang")
elseif(PICO_PLATFORM STREQUAL "rp2350-arm-s")
set(PICO_COMPILER "pico_arm_cortex_m33_clang")
elseif(PICO_PLATFORM STREQUAL "rp2350-arm-ns")
set(PICO_COMPILER "pico_arm_cortex_m33_clang")
endif()
endif()
if (NOT PICO_COMPILER STREQUAL ORIG_PICO_COMPILER)
message("Accepting PICO_COMPILER value '${ORIG_PICO_COMPILER}' for compatibility, but using '${PICO_COMPILER}' instead")
endif()
if (NOT DEFINED PICO_TOOLCHAIN_DIR)
set(PICO_TOOLCHAIN_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/toolchains")
endif()
set(toolchain_file "${PICO_TOOLCHAIN_DIR}/${PICO_COMPILER}.cmake")
if (EXISTS "${toolchain_file}")
set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}")
else ()
# todo improve message
message(FATAL_ERROR "Toolchain file \"${PICO_COMPILER}.cmake\" does not exist, please\
select one from \"cmake/toolchains\" folder.")
endif ()
message("Configuring toolchain based on PICO_COMPILER '${PICO_COMPILER}'")
endif ()
if (PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE)
if (NOT "${PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE}" STREQUAL "${CMAKE_TOOLCHAIN_FILE}")
message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE was previously defined to ${PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE}, and now\
is being changed to ${CMAKE_TOOLCHAIN_FILE}. You\
need to delete the CMake cache and reconfigure if you want to switch compiler.\
The best practice is to use separate build directories for different platforms or compilers.")
endif ()
endif ()
set(PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE} CACHE INTERNAL "Saved CMAKE_TOOLCHAIN_FILE" FORCE)
unset(PICO_COMPILER CACHE)

View file

@ -0,0 +1,3 @@
set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m33_gcc")
set(PICO_CHIP rp2350)

View file

@ -1,7 +0,0 @@
if (NOT (DEFINED PICO_COMPILER OR DEFINED CMAKE_TOOLCHAIN_FILE))
pico_message("Defaulting PICO platform compiler to pico_arm_gcc since not specified.")
set(PICO_COMPILER "pico_arm_gcc")
endif ()

View file

@ -1 +1,2 @@
include(${CMAKE_CURRENT_LIST_DIR}/pico/pico.cmake)
set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m0plus_gcc")
set(PICO_CHIP rp2040)

View file

@ -0,0 +1,3 @@
set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m33_gcc")
set(PICO_CHIP rp2350)

View file

@ -0,0 +1,3 @@
set(PICO_DEFAULT_COMPILER "pico_riscv_gcc")
set(PICO_CHIP rp2350)

View file

@ -1,47 +0,0 @@
# NOTE: THIS IS A WIP ONLY PICO_ARM_GCC IS CURRENTLY SUPPORTED, however should work with LLVM Embedded Toolchain for ARM
# version 14.0.0 https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/tag/release-14.0.0
# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
# i.e. CMake<Lang>Information and whatnot
include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
# include our Platform/pico.cmake
set(CMAKE_SYSTEM_NAME PICO)
set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
# Find CLANG
pico_find_compiler(PICO_COMPILER_CC clang)
pico_find_compiler(PICO_COMPILER_CXX clang)
#pico_find_compiler(PICO_COMPILER_ASM armasm)
set(PICO_COMPILER_ASM "${PICO_COMPILER_CC}" CACHE INTERNAL "")
pico_find_compiler(PICO_OBJCOPY llvm-objcopy)
pico_find_compiler(PICO_OBJDUMP llvm-objdump)
# Specify the cross compiler.
set(CMAKE_C_COMPILER ${PICO_COMPILER_CC} CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER ${PICO_COMPILER_CXX} CACHE FILEPATH "C++ compiler")
set(CMAKE_C_OUTPUT_EXTENSION .o)
# todo should we be including CMakeASMInformation anyway - i guess that is host side
set(CMAKE_ASM_COMPILER ${PICO_COMPILER_ASM} CACHE FILEPATH "ASM compiler")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
set(CMAKE_INCLUDE_FLAG_ASM "-I")
set(CMAKE_OBJCOPY ${PICO_OBJCOPY} CACHE FILEPATH "")
set(CMAKE_OBJDUMP ${PICO_OBJDUMP} CACHE FILEPATH "")
# Add target system root to cmake find path.
get_filename_component(PICO_COMPILER_DIR "${PICO_COMPILER_CC}" DIRECTORY)
get_filename_component(CMAKE_FIND_ROOT_PATH "${PICO_COMPILER_DIR}" DIRECTORY)
# Look for includes and libraries only in the target system prefix.
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)
# Oz is preferred for Clang (verses CMake default -Os) see also https://gitlab.kitware.com/cmake/cmake/-/issues/22458
set(CMAKE_C_FLAGS_MINSIZEREL "-Oz -DNDEBUG")
set(ARM_TOOLCHAIN_COMMON_FLAGS "--target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m --sysroot ${PICO_COMPILER_DIR}/../lib/clang-runtimes/armv6m_soft_nofp")
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)

View file

@ -1,7 +1,7 @@
# NOTE: THIS IS A WIP ONLY PICO_ARM_GCC IS CURRENTLY SUPPORTED
# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
# i.e. CMake<Lang>Information and whatnot
include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/util/find_compiler.cmake)
# include our Platform/PICO.cmake
set(CMAKE_SYSTEM_NAME PICO)
@ -37,7 +37,5 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)
set(ARM_TOOLCHAIN_COMMON_FLAGS " --cpu=Cortex-M0plus")
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/util/set_flags.cmake)

View file

@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
# these are all the directories under LLVM embedded toolchain for ARM (newlib or pibolibc) and under llvm_libc
set(PICO_CLANG_RUNTIMES armv6m_soft_nofp armv6m-unknown-none-eabi)
set(PICO_COMMON_LANG_FLAGS "--target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m")
include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_clang_common.cmake)

View file

@ -0,0 +1,7 @@
set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
set(PICO_DEFAULT_GCC_TRIPLE arm-none-eabi)
# on ARM -mcpu should not be mixed with -march
set(PICO_COMMON_LANG_FLAGS " -mcpu=cortex-m0plus -mthumb")
include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)

View file

@ -0,0 +1,15 @@
# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
# i.e. CMake<Lang>Information and whatnot
set(CMAKE_SYSTEM_PROCESSOR cortex-m23)
set(PICO_DEFAULT_GCC_TRIPLE arm-none-eabi)
# todo amy should this be -mfloat-abi=hard?
set(PICO_COMMON_LANG_FLAGS " -mcpu=cortex-m23 -mthumb -march=armv8-m.base")
# todo probably need a setting here, also do we want `softfp`?
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mfloat-abi=softfp")
if (NOT PICO_NO_CMSE)
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mcmse")
endif()
include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)

View file

@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
# these are all the directories under LLVM embedded toolchain for ARM (newlib or pibolibc) and under llvm_libc
set(PICO_CLANG_RUNTIMES armv8m.main_soft_nofp armv8m.main-unknown-none-eabi)
set(PICO_COMMON_LANG_FLAGS "-mcpu=cortex-m33 --target=armv8m.main-none-eabi -mfloat-abi=softfp -march=armv8m.main+fp+dsp")
include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_clang_common.cmake)

View file

@ -0,0 +1,10 @@
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
set(PICO_DEFAULT_GCC_TRIPLE arm-none-eabi)
set(PICO_COMMON_LANG_FLAGS " -mcpu=cortex-m33 -mthumb -march=armv8-m.main+fp+dsp")
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mfloat-abi=softfp")
if (NOT PICO_NO_CMSE)
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mcmse")
endif()
include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)

View file

@ -1,52 +0,0 @@
# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
# i.e. CMake<Lang>Information and whatnot
include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
# include our Platform/PICO.cmake
set(CMAKE_SYSTEM_NAME PICO)
set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
if (NOT PICO_GCC_TRIPLE)
if (DEFINED ENV{PICO_GCC_TRIPLE})
set(PICO_GCC_TRIPLE $ENV{PICO_GCC_TRIPLE})
message("PICO_GCC_TRIPLE set from environment: $ENV{PICO_GCC_TRIPLE}")
else()
set(PICO_GCC_TRIPLE arm-none-eabi)
#pico_message_debug("PICO_GCC_TRIPLE defaulted to arm-none-eabi")
endif()
endif()
# Find GCC for ARM.
pico_find_compiler(PICO_COMPILER_CC ${PICO_GCC_TRIPLE}-gcc)
pico_find_compiler(PICO_COMPILER_CXX ${PICO_GCC_TRIPLE}-g++)
set(PICO_COMPILER_ASM "${PICO_COMPILER_CC}" CACHE INTERNAL "")
pico_find_compiler(PICO_OBJCOPY ${PICO_GCC_TRIPLE}-objcopy)
pico_find_compiler(PICO_OBJDUMP ${PICO_GCC_TRIPLE}-objdump)
# Specify the cross compiler.
set(CMAKE_C_COMPILER ${PICO_COMPILER_CC} CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER ${PICO_COMPILER_CXX} CACHE FILEPATH "C++ compiler")
set(CMAKE_C_OUTPUT_EXTENSION .o)
# todo should we be including CMakeASMInformation anyway - i guess that is host side
set(CMAKE_ASM_COMPILER ${PICO_COMPILER_ASM} CACHE FILEPATH "ASM compiler")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
set(CMAKE_INCLUDE_FLAG_ASM "-I")
set(CMAKE_OBJCOPY ${PICO_OBJCOPY} CACHE FILEPATH "")
set(CMAKE_OBJDUMP ${PICO_OBJDUMP} CACHE FILEPATH "")
# Add target system root to cmake find path.
get_filename_component(PICO_COMPILER_DIR "${PICO_COMPILER_CC}" DIRECTORY)
get_filename_component(CMAKE_FIND_ROOT_PATH "${PICO_COMPILER_DIR}" DIRECTORY)
# Look for includes and libraries only in the target system prefix.
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)
# on ARM -mcpu should not be mixed with -march
set(ARM_TOOLCHAIN_COMMON_FLAGS " -mcpu=cortex-m0plus -mthumb")
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)

View file

@ -0,0 +1,7 @@
set(CMAKE_SYSTEM_PROCESSOR hazard3)
set(PICO_DEFAULT_GCC_TRIPLE riscv32-unknown-elf riscv32-corev-elf)
set(PICO_COMMON_LANG_FLAGS " -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32")
include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)

View file

@ -0,0 +1,10 @@
# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
# i.e. CMake<Lang>Information and whatnot
set(CMAKE_SYSTEM_PROCESSOR hazard3)
set(PICO_DEFAULT_GCC_TRIPLE riscv32-unknown-elf riscv32-corev-elf)
set(PICO_COMMON_LANG_FLAGS " -march=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb_zcmp -mabi=ilp32")
include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)

View file

@ -7,10 +7,10 @@ endif ()
# Find the compiler executable and store its path in a cache entry ${compiler_path}.
# If not found, issue a fatal message and stop processing. PICO_TOOLCHAIN_PATH can be provided from
# commandline as additional search path.
function(pico_find_compiler compiler_path compiler_exe)
function(pico_find_compiler compiler_path compiler_exes)
# Search user provided path first.
find_program(
${compiler_path} ${compiler_exe}
${compiler_path} NAMES ${compiler_exes}
PATHS ENV PICO_TOOLCHAIN_PATH
PATH_SUFFIXES bin
NO_DEFAULT_PATH
@ -21,11 +21,21 @@ function(pico_find_compiler compiler_path compiler_exe)
if (DEFINED ENV{PICO_TOOLCHAIN_PATH})
message(WARNING "PICO_TOOLCHAIN_PATH specified ($ENV{PICO_TOOLCHAIN_PATH}), but ${compiler_exe} not found there")
endif()
find_program(${compiler_path} ${compiler_exe})
find_program(${compiler_path} NAMES ${compiler_exes})
endif ()
if ("${${compiler_path}}" STREQUAL "${compiler_path}-NOTFOUND")
set(PICO_TOOLCHAIN_PATH "" CACHE PATH "Path to search for compiler.")
message(FATAL_ERROR "Compiler '${compiler_exe}' not found, you can specify search path with\
list(JOIN compiler_exes " / " compiler_exes)
message(FATAL_ERROR "Compiler '${compiler_exes}' not found, you can specify search path with\
\"PICO_TOOLCHAIN_PATH\".")
endif ()
endfunction()
# Find the compiler executable and store its path in a cache entry ${compiler_path}.
# If not found, issue a fatal message and stop processing. PICO_TOOLCHAIN_PATH can be provided from
# commandline as additional search path.
function(pico_find_compiler_with_triples compiler_path triples compiler_suffix)
list(TRANSFORM triples APPEND "-${compiler_suffix}")
pico_find_compiler(${compiler_path} "${triples}")
set(${compiler_path} ${${compiler_path}} PARENT_SCOPE)
endfunction()

View file

@ -0,0 +1,97 @@
include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
# include our Platform/PICO.cmake
set(CMAKE_SYSTEM_NAME PICO)
# Find Clang
pico_find_compiler(PICO_COMPILER_CC clang)
pico_find_compiler(PICO_COMPILER_CXX clang++)
set(PICO_COMPILER_ASM "${PICO_COMPILER_CC}" CACHE INTERNAL "")
pico_find_compiler(PICO_OBJCOPY llvm-objcopy)
pico_find_compiler(PICO_OBJDUMP llvm-objdump)
# Specify the cross compiler.
set(CMAKE_C_COMPILER ${PICO_COMPILER_CC} CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER ${PICO_COMPILER_CXX} CACHE FILEPATH "C++ compiler")
set(CMAKE_ASM_COMPILER ${PICO_COMPILER_ASM} CACHE FILEPATH "ASM compiler")
# workaround for projects that don't enable ASM
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
set(CMAKE_INCLUDE_FLAG_ASM "-I")
set(CMAKE_OBJCOPY ${PICO_OBJCOPY} CACHE FILEPATH "")
set(CMAKE_OBJDUMP ${PICO_OBJDUMP} CACHE FILEPATH "")
foreach(LANG IN ITEMS C CXX ASM)
set(CMAKE_${LANG}_OUTPUT_EXTENSION .o)
endforeach()
# Add target system root to cmake find path.
get_filename_component(PICO_COMPILER_DIR "${PICO_COMPILER_CC}" DIRECTORY)
get_filename_component(CMAKE_FIND_ROOT_PATH "${PICO_COMPILER_DIR}" DIRECTORY)
# Look for includes and libraries only in the target system prefix.
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Oz is preferred for Clang (verses CMake default -Os) see also https://gitlab.kitware.com/cmake/cmake/-/issues/22458
foreach(LANG IN ITEMS C CXX ASM)
set(CMAKE_${LANG}_FLAGS_MINSIZEREL_INIT "-Oz -DNDEBUG")
endforeach()
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES PICO_CLIB)
foreach(PICO_CLANG_RUNTIME IN LISTS PICO_CLANG_RUNTIMES)
# LLVM embedded-toolchain for ARM style
find_path(PICO_COMPILER_SYSROOT NAMES include/stdio.h
HINTS
${PICO_COMPILER_DIR}/../lib/clang-runtimes/arm-none-eabi/${PICO_CLANG_RUNTIME}
${PICO_COMPILER_DIR}/../lib/clang-runtimes/${PICO_CLANG_RUNTIME}
)
if (PICO_COMPILER_SYSROOT)
if (NOT PICO_CLIB)
# this is a bit of a hack; to try to autodetect the C library used:
# `picolibc.h` seems to exist on the newer versions of LLVM embedded toolchain for ARM using picolibc whereas
# `newlib.h` appears in all versions, so isn't very useful
if (EXISTS "${PICO_COMPILER_SYSROOT}/include/picolibc.h")
message("Setting default C library to picolibc as LLVM appears to be using it")
set(PICO_CLIB "picolibc" CACHE INTERNAL "")
endif()
endif()
break()
endif()
# llvm_libc style
find_path(PICO_COMPILER_SYSROOT NAMES stdio.h
HINTS
${PICO_COMPILER_DIR}/../include/${PICO_CLANG_RUNTIME}
)
if (PICO_COMPILER_SYSROOT)
if (NOT PICO_CLIB)
message("Setting default C library to llvm_libc as LLVM appears to be using it")
set(PICO_CLIB "llvm_libc" CACHE INTERNAL "")
endif()
break()
endif()
endforeach()
# moving this here as a reminder from pico_standard_link; it was commented out theee, but if ever needed,
# it belongs here as part of LINKER_FLAGS_INIT
#target_link_options(pico_standard_link INTERFACE "LINKER:-fuse-ld=lld")
if (PICO_CLIB STREQUAL "llvm_libc")
# TODO: Remove -nostdlib++ once we include libc++ in the toolchain.
# TODO: Move -nostartfiles to the appropriate library.
foreach(TYPE IN ITEMS EXE SHARED MODULE)
set(CMAKE_${TYPE}_LINKER_FLAGS_INIT "-nostdlib++ -nostartfiles")
endforeach()
else()
if (NOT PICO_COMPILER_SYSROOT)
message(FATAL_ERROR "Could not find an llvm runtime for '${PICO_CLANG_RUNTIME}'")
endif()
set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} --sysroot ${PICO_COMPILER_SYSROOT}")
endif()
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)

View file

@ -0,0 +1,57 @@
include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
# include our Platform/PICO.cmake
set(CMAKE_SYSTEM_NAME PICO)
# PICO_CMAKE_CONFIG: PICO_GCC_TRIPLE, List of GCC_TRIPLES -- usually only one -- to try when searching for a compiler. This may be specified the user environment, type=int, default=PICO_DEFAULT_GCC_TRIPLE which is set based on PICO_COMPILER, group=pico_base, docref=cmake-toolchain-config
if (NOT PICO_GCC_TRIPLE)
if (DEFINED ENV{_SAVED_PICO_GCC_TRIPLE})
# saved within the same cmake invocation
set(PICO_GCC_TRIPLE $ENV{_SAVED_PICO_GCC_TRIPLE})
elseif (DEFINED ENV{PICO_GCC_TRIPLE})
set(PICO_GCC_TRIPLE $ENV{PICO_GCC_TRIPLE})
message("Initializing PICO_GCC_TRIPLE from environment ('${PICO_GCC_TRIPLE}')")
elseif(DEFINED PICO_DEFAULT_GCC_TRIPLE)
message("Defaulting PICO_GCC_TRIPLE to '${PICO_DEFAULT_GCC_TRIPLE}'")
set(PICO_GCC_TRIPLE ${PICO_DEFAULT_GCC_TRIPLE})
else()
message(FATAL_ERROR "PICO_DEFAULT_GCC_TRIPLE is not defined")
endif()
endif()
set(PICO_GCC_TRIPLE "${PICO_GCC_TRIPLE}" CACHE INTERNAL "")
set(ENV{_SAVED_PICO_GCC_TRIPLE} "${PICO_GCC_TRIPLE}")
# Find GCC
pico_find_compiler_with_triples(PICO_COMPILER_CC "${PICO_GCC_TRIPLE}" gcc)
pico_find_compiler_with_triples(PICO_COMPILER_CXX "${PICO_GCC_TRIPLE}" g++)
set(PICO_COMPILER_ASM "${PICO_COMPILER_CC}" CACHE INTERNAL "")
pico_find_compiler_with_triples(PICO_OBJCOPY "${PICO_GCC_TRIPLE}" objcopy)
pico_find_compiler_with_triples(PICO_OBJDUMP "${PICO_GCC_TRIPLE}" objdump)
# Specify the cross compiler.
set(CMAKE_C_COMPILER ${PICO_COMPILER_CC} CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER ${PICO_COMPILER_CXX} CACHE FILEPATH "C++ compiler")
set(CMAKE_ASM_COMPILER ${PICO_COMPILER_ASM} CACHE FILEPATH "ASM compiler")
# workaround for projects that don't enable ASM
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
set(CMAKE_INCLUDE_FLAG_ASM "-I")
set(CMAKE_OBJCOPY ${PICO_OBJCOPY} CACHE FILEPATH "")
set(CMAKE_OBJDUMP ${PICO_OBJDUMP} CACHE FILEPATH "")
foreach(LANG IN ITEMS C CXX ASM)
set(CMAKE_${LANG}_OUTPUT_EXTENSION .o)
endforeach()
# Add target system root to cmake find path.
get_filename_component(PICO_COMPILER_DIR "${PICO_COMPILER_CC}" DIRECTORY)
get_filename_component(CMAKE_FIND_ROOT_PATH "${PICO_COMPILER_DIR}" DIRECTORY)
# Look for includes and libraries only in the target system prefix.
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)

View file

@ -1,12 +1,19 @@
option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)
option(PICO_DEBUG_INFO_IN_RELEASE "Include debug info in release builds" 1)
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
foreach(LANG IN ITEMS C CXX ASM)
set(CMAKE_${LANG}_FLAGS_INIT "${ARM_TOOLCHAIN_COMMON_FLAGS}")
set(CMAKE_${LANG}_FLAGS_INIT "${PICO_COMMON_LANG_FLAGS}")
unset(CMAKE_${LANG}_FLAGS_DEBUG CACHE)
if (PICO_DEOPTIMIZED_DEBUG)
set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0")
else()
set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-Og")
endif()
if (PICO_DEBUG_INFO_IN_RELEASE)
set(CMAKE_${LANG}_FLAGS_RELEASE_INIT "-g")
set(CMAKE_${LANG}_FLAGS_MINSIZEREL_INIT "-g")
endif()
set(CMAKE_${LANG}_LINK_FLAGS "-Wl,--build-id=none")
# try_compile is where the feature testing is done, and at that point,

View file

@ -40,13 +40,26 @@ if(PICO_BUILD_DOCS)
endif()
set(DOXY_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doxygen")
set(DOXY_INPUT_DIRS "${PICO_DOXYGEN_PATHS}")
set(DOXY_EXCLUDE_DIRS "${PICO_DOXYGEN_EXCLUDE_PATHS}")
string(REPLACE ";" " " DOXY_INPUT_DIRS "${PICO_DOXYGEN_PATHS}")
string(REPLACE ";" " " DOXY_EXCLUDE_DIRS "${PICO_DOXYGEN_EXCLUDE_PATHS}")
string(REPLACE ";" " " DOXY_PREDEFINED "${PICO_DOXYGEN_PRE_DEFINES}")
string(REPLACE ";" " " DOXY_ENABLED_SECTIONS "${PICO_DOXYGEN_ENABLED_SECTIONS}")
set(DOXY_EXAMPLE_DIR "${PICO_EXAMPLES_PATH}")
# auto genereate additional section enables from library paths
foreach (DIR IN LISTS PICO_DOXYGEN_PATHS)
get_filename_component(NAME "${DIR}" NAME)
if (NOT DIR STREQUAL "src")
set(DOXY_ENABLED_SECTIONS "${DOXY_ENABLED_SECTIONS} ${NAME}")
endif()
endforeach ()
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
if (PICO_PLATFORM STREQUAL "rp2040")
set(PICO_DOXYGEN_TAG "(RP2040)")
elseif (PICO_PLATFORM STREQUAL "rp2350-arm-s" OR PICO_PLATFORM STREQUAL "rp2350-riscv")
set(PICO_DOXYGEN_TAG "(RP2350)")
endif()
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
add_custom_target(docs

View file

@ -1,6 +1,6 @@
PROJECT_NAME = "Raspberry Pi Pico SDK"
PROJECT_BRIEF = "Raspberry Pi Pico SDK documentation"
PROJECT_NUMBER = @PICO_SDK_VERSION_STRING@
PROJECT_NUMBER = @PICO_SDK_VERSION_STRING@ @PICO_DOXYGEN_TAG@
#STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
STRIP_FROM_PATH = @DOXY_INPUT_DIRS@
@ -50,15 +50,19 @@ EXTRACT_STATIC = YES
EXTRACT_ALL = NO
ALWAYS_DETAILED_SEC = NO
#REPEAT_BRIEF = NO
#REPEAT_BRIEF = NO
ENABLE_PREPROCESSING = YES
# Need these next options to ensure that functions with modifiers do not confuse the Doxygen parser.
# And any further function modifiers here.
MACRO_EXPANSION = YES
PREDEFINED = __not_in_flash_func(x) \
__time_critical_func(x) \
PREDEFINED = __not_in_flash_func(x)= \
__time_critical_func(x)= \
__not_in_flash(x)= \
__no_inline_not_in_flash(x)= \
__attribute__(x)= \
DOXYGEN_GENERATION=
DOXYGEN_GENERATION= \
@DOXY_PREDEFINED@
ENABLED_SECTIONS = @DOXY_ENABLED_SECTIONS@

View file

@ -6,67 +6,89 @@
// Here to organize documentation order
// for some reason cond/endcond work better here than if/endif
/**
* \defgroup hardware Hardware APIs
* This group of libraries provides a thin and efficient C API / abstractions to access the RP2040 hardware without having to read and write
* This group of libraries provides a thin and efficient C API / abstractions to access the RP-series microcontroller hardware without having to read and write
* hardware registers directly.
* @{
* \defgroup hardware_adc hardware_adc
* \defgroup hardware_base hardware_base
* \defgroup hardware_claim hardware_claim
* \defgroup hardware_clocks hardware_clocks
* \defgroup hardware_divider hardware_divider
* \defgroup hardware_dma hardware_dma
* \defgroup hardware_exception hardware_exception
* \defgroup hardware_flash hardware_flash
* \defgroup hardware_gpio hardware_gpio
* \defgroup hardware_i2c hardware_i2c
* \defgroup hardware_interp hardware_interp
* \defgroup hardware_irq hardware_irq
* \defgroup hardware_pio hardware_pio
* \defgroup hardware_pll hardware_pll
* \defgroup hardware_pwm hardware_pwm
* \defgroup hardware_resets hardware_resets
* \defgroup hardware_rtc hardware_rtc
* \defgroup hardware_spi hardware_spi
* \defgroup hardware_sync hardware_sync
* \defgroup hardware_timer hardware_timer
* \defgroup hardware_uart hardware_uart
* \defgroup hardware_vreg hardware_vreg
* \defgroup hardware_watchdog hardware_watchdog
* \defgroup hardware_xosc hardware_xosc
* \cond hardware_adc \defgroup hardware_adc hardware_adc \endcond
* \cond hardware_base \defgroup hardware_base hardware_base \endcond
* \cond hardware_bootlock \defgroup hardware_bootlock hardware_bootlock \endcond
* \cond hardware_claim \defgroup hardware_claim hardware_claim \endcond
* \cond hardware_clocks \defgroup hardware_clocks hardware_clocks \endcond
* \cond hardware_divider \defgroup hardware_divider hardware_divider \endcond
* \cond hardware_dcp \defgroup hardware_dcp hardware_dcp \endcond
* \cond hardware_dma \defgroup hardware_dma hardware_dma \endcond
* \cond hardware_exception \defgroup hardware_exception hardware_exception \endcond
* \cond hardware_flash \defgroup hardware_flash hardware_flash \endcond
* \cond hardware_gpio \defgroup hardware_gpio hardware_gpio \endcond
* \cond hardware_hazard3 \defgroup hardware_hazard3 hardware_hazard3 \endcond
* \cond hardware_i2c \defgroup hardware_i2c hardware_i2c \endcond
* \cond hardware_interp \defgroup hardware_interp hardware_interp \endcond
* \cond hardware_irq \defgroup hardware_irq hardware_irq \endcond
* \cond hardware_pio \defgroup hardware_pio hardware_pio \endcond
* \cond hardware_pll \defgroup hardware_pll hardware_pll \endcond
* \cond hardware_powman \defgroup hardware_powman hardware_powman \endcond
* \cond hardware_pwm \defgroup hardware_pwm hardware_pwm \endcond
* \cond hardware_pwm \defgroup hardware_pwm hardware_pwm \endcond
* \cond hardware_resets \defgroup hardware_resets hardware_resets \endcond
* \cond hardware_riscv \defgroup hardware_riscv hardware_riscv \endcond
* \cond hardware_riscv_platform_timer \defgroup hardware_riscv_platform_timer hardware_riscv_platform_timer \endcond
* \cond hardware_rtc \defgroup hardware_rtc hardware_rtc \endcond
* \cond hardware_rcp \defgroup hardware_rcp hardware_rcp \endcond
* \cond hardware_spi \defgroup hardware_spi hardware_spi \endcond
* \cond hardware_sha256 \defgroup hardware_sha256 hardware_sha256 \endcond
* \cond hardware_sync \defgroup hardware_sync hardware_sync \endcond
* \cond hardware_ticks \defgroup hardware_ticks hardware_ticks \endcond
* \cond hardware_timer \defgroup hardware_timer hardware_timer \endcond
* \cond hardware_uart \defgroup hardware_uart hardware_uart \endcond
* \cond hardware_vreg \defgroup hardware_vreg hardware_vreg \endcond
* \cond hardware_watchdog \defgroup hardware_watchdog hardware_watchdog \endcond
* \cond hardware_xip_cache \defgroup hardware_xip_cache hardware_xip_cache \endcond
* \cond hardware_xosc \defgroup hardware_xosc hardware_xosc \endcond
* \cond hardware_powman hardware_powman
* \cond hardware_hazard3 hardware_hazard3
* \cond hardware_riscv hardware_riscv
* @}
*
* \defgroup high_level High Level APIs
* This group of libraries provide higher level functionality that isn't hardware related or provides a richer
* set of functionality above the basic hardware interfaces
* @{
* \defgroup pico_async_context pico_async_context
* \defgroup pico_flash pico_flash
* \defgroup pico_i2c_slave pico_i2c_slave
* \defgroup pico_multicore pico_multicore
* \defgroup pico_rand pico_rand
* \defgroup pico_stdlib pico_stdlib
* \defgroup pico_sync pico_sync
* \defgroup pico_time pico_time
* \defgroup pico_unique_id pico_unique_id
* \defgroup pico_util pico_util
* \cond pico_aon_timer \defgroup pico_aon_timer pico_aon_timer \endcond
* \cond pico_async_context \defgroup pico_async_context pico_async_context \endcond
* \cond pico_bootsel_via_double_reset \defgroup pico_bootsel_via_double_reset pico_bootsel_via_double_reset \endcond
* \cond pico_flash \defgroup pico_flash pico_flash \endcond
* \cond pico_i2c_slave \defgroup pico_i2c_slave pico_i2c_slave \endcond
* \cond pico_multicore \defgroup pico_multicore pico_multicore \endcond
* \cond pico_rand \defgroup pico_rand pico_rand \endcond
* \cond pico_sha256 \defgroup pico_sha256 pico_sha256 \endcond
* \cond pico_stdlib \defgroup pico_stdlib pico_stdlib \endcond
* \cond pico_sync \defgroup pico_sync pico_sync \endcond
* \cond pico_time \defgroup pico_time pico_time \endcond
* \cond pico_unique_id \defgroup pico_unique_id pico_unique_id \endcond
* \cond pico_util \defgroup pico_util pico_util \endcond
* @}
*
* \defgroup third_party Third-party Libraries
* Third party libraries for implementing high level functionality.
* @{
* \cond tinyusb
* \defgroup tinyusb_device tinyusb_device
* \defgroup tinyusb_host tinyusb_host
* \endcond
* @}
*
* \defgroup networking Networking Libraries
* Functions for implementing networking
* @{
* \defgroup pico_btstack pico_btstack
* \defgroup pico_lwip pico_lwip
* \defgroup pico_cyw43_driver pico_cyw43_driver
* \defgroup pico_cyw43_arch pico_cyw43_arch
* \cond pico_btstack \defgroup pico_btstack pico_btstack \endcond
* \cond pico_lwip \defgroup pico_lwip pico_lwip \endcond
* \cond pico_cyw43_driver \defgroup pico_cyw43_driver pico_cyw43_driver \endcond
* \cond pico_cyw43_arch \defgroup pico_cyw43_arch pico_cyw43_arch \endcond
* @}
*
* \defgroup runtime Runtime Infrastructure
@ -74,30 +96,36 @@
* language level and C library functions, as well as CMake INTERFACE libraries
* abstracting the compilation and link steps in the SDK
* @{
* \defgroup boot_stage2 boot_stage2
* \defgroup pico_base pico_base
* \defgroup pico_binary_info pico_binary_info
* \defgroup pico_bit_ops pico_bit_ops
* \defgroup pico_bootrom pico_bootrom
* \defgroup pico_bootsel_via_double_reset pico_bootsel_via_double_reset
* \defgroup pico_cxx_options pico_cxx_options
* \defgroup pico_divider pico_divider
* \defgroup pico_double pico_double
* \defgroup pico_float pico_float
* \defgroup pico_int64_ops pico_int64_ops
* \defgroup pico_malloc pico_malloc
* \defgroup pico_mem_ops pico_mem_ops
* \defgroup pico_platform pico_platform
* \defgroup pico_printf pico_printf
* \defgroup pico_runtime pico_runtime
* \defgroup pico_stdio pico_stdio
* \defgroup pico_standard_link pico_standard_link
* \cond boot_stage2 \defgroup boot_stage2 boot_stage2 \endcond
* \cond pico_atomic \defgroup pico_atomic pico_atomic \endcond
* \cond pico_base_headers \defgroup pico_base pico_base \endcond
* \cond pico_binary_info \defgroup pico_binary_info pico_binary_info \endcond
* \cond pico_bootrom \defgroup pico_bootrom pico_bootrom \endcond
* \cond pico_bit_ops \defgroup pico_bit_ops pico_bit_ops \endcond
* \cond pico_cxx_options \defgroup pico_cxx_options pico_cxx_options \endcond
* \cond pico_clib_interface \defgroup pico_clib_interface pico_clib_interface \endcond
* \cond pico_crt0 \defgroup pico_crt0 pico_crt0 \endcond
* \cond pico_divider \defgroup pico_divider pico_divider \endcond
* \cond pico_double \defgroup pico_double pico_double \endcond
* \cond pico_float \defgroup pico_float pico_float \endcond
* \cond pico_int64_ops \defgroup pico_int64_ops pico_int64_ops \endcond
* \cond pico_malloc \defgroup pico_malloc pico_malloc \endcond
* \cond pico_mem_ops \defgroup pico_mem_ops pico_mem_ops \endcond
* \cond pico_platform \defgroup pico_platform pico_platform \endcond
* \cond pico_printf \defgroup pico_printf pico_printf \endcond
* \cond pico_runtime \defgroup pico_runtime pico_runtime \endcond
* \cond pico_runtime_init \defgroup pico_runtime_init pico_runtime_init \endcond
* \cond pico_stdio \defgroup pico_stdio pico_stdio \endcond
* \cond pico_standard_binary_info \defgroup pico_standard_binary_info pico_standard_binary_info \endcond
* \cond pico_standard_link \defgroup pico_standard_link pico_standard_link \endcond
* @}
*
* \defgroup misc External API Headers
* Headers for interfaces that are shared with code outside of the SDK
* @{
* \defgroup boot_picoboot boot_picoboot
* \defgroup boot_uf2 boot_uf2
* \cond boot_picobin_headers \defgroup boot_picobin_headers boot_picobin_headers \endcond
* \cond boot_picoboot_headers \defgroup boot_picoboot_headers boot_picoboot_headers \endcond
* \cond boot_uf2_headers \defgroup boot_uf2_headers boot_uf2_headers \endcond
* \cond pico_usb_reset_interface_headers \defgroup pico_usb_reset_interface_headers pico_usb_reset_interface_headers \endcond
* @}
*/

View file

@ -1,16 +1,16 @@
# Raspberry Pi Pico SDK
The Raspberry Pi Pico SDK (Software Development Kit), henceforth SDK, provides the headers, libraries and build system necessary to write programs for RP2040-based devices such as the Raspberry Pi Pico in C, C++ or assembly language. The SDK is designed to provide an API (Application Programming Interface) and programming environment that is familiar both to non-embedded C developers and embedded C developers alike.
The Raspberry Pi Pico SDK (Software Development Kit), henceforth SDK, provides the headers, libraries and build system necessary to write programs for RP-series microcontroller devices such as the Raspberry Pi Pico in C, C++ or assembly language. The SDK is designed to provide an API (Application Programming Interface) 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 with a conventional `main()` method. Standard C/C++ libraries are supported along with APIs for accessing the RP2040s hardware, including DMA, IRQs, and the wide variety of fixed-function peripherals and PIO (Programmable IO).
A single program runs on the device at a time with a conventional `main()` method. Standard C/C++ libraries are supported along with APIs for accessing the microcontroller's hardware, including DMA, IRQs, and the wide variety of fixed-function peripherals and PIO (Programmable IO).
Additionally the SDK provides higher-level libraries for dealing with timers, USB, synchronization and multi-core programming, along with additional high-level functionality built using PIO, such as audio. The SDK can be used to build anything from simple applications, or full-fledged runtime environments such as MicroPython, to low-level software such as the RP2040s on-chip bootrom itself.
Additionally the SDK provides higher-level libraries for dealing with timers, USB, synchronization and multi-core programming, along with additional high-level functionality built using PIO, such as audio. The SDK can be used to build anything from simple applications, or full-fledged runtime environments such as MicroPython, to low-level software such as the microcontroller's on-chip bootrom itself.
This documentation is generated from the SDK source tree using Doxygen. It provides basic information on the APIs used for each library, but does not provide usage information. Please refer to the Databooks for usage and more technical information.
## SDK Design
The RP2040 is a powerful chip, however it is an embedded environment, so both RAM and program space are at premium. Additionally the trade-offs between performance and other factors (e.g. edge-case error handling, runtime vs compile-time configuration) are necessarily much more visible to the developer than they might be on other higher-level platforms.
The RP-series microcontroller range are powerful chips, however they are used in an embedded environment, so both RAM and program space are at premium. Additionally the trade-offs between performance and other factors (e.g. edge-case error handling, runtime vs compile-time configuration) are necessarily much more visible to the developer than they might be on other higher-level platforms.
The intention within the SDK has been for features to just work out of the box, with sensible defaults, but also to give the developer as much control and power as possible (if they want it) to fine-tune every aspect of the application they are building and the libraries used.
@ -20,7 +20,7 @@ The SDK uses CMake to manage the build. CMake is widely supported by IDEs (Integ
Apart from being a widely-used build system for C/C++ development, CMake is fundamental to the way the SDK is structured, and how applications are configured and built.
The SDK builds an executable which is bare-metal, i.e. it includes the entirety of the code needed to run on the device (other than floating-point and other optimized code contained in the bootrom within the RP2040).
The SDK builds an executable which is bare-metal, i.e. it includes the entirety of the code needed to run on the device (other than device specific floating-point and other optimized code contained in the bootrom within the microcontroller).
## Examples

View file

@ -4,6 +4,8 @@ The full documentation for the RP2040 and Raspberry Pi Pico board can be found a
- [RP2040 Datasheet](https://rptl.io/rp2040-datasheet)
- [Raspberry Pi Pico Datasheet](https://rptl.io/pico-datasheet)
- [RP235x Datasheet](https://rptl.io/rp2040-datasheet)
- [Raspberry Pi Pico2 Datasheet](https://rptl.io/pico-datasheet)
- [Raspberry Pi Pico W Datasheet](https://rptl.io/picow-datasheet)
- [Hardware design with RP2040](https://rptl.io/rp2040-design)
- [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk)

View file

@ -18,9 +18,20 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
endif ()
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_TAG} AND (NOT PICO_SDK_FETCH_FROM_GIT_TAG))
set(PICO_SDK_FETCH_FROM_GIT_TAG $ENV{PICO_SDK_FETCH_FROM_GIT_TAG})
message("Using PICO_SDK_FETCH_FROM_GIT_TAG from environment ('${PICO_SDK_FETCH_FROM_GIT_TAG}')")
endif ()
if (PICO_SDK_FETCH_FROM_GIT AND NOT PICO_SDK_FETCH_FROM_GIT_TAG)
set(PICO_SDK_FETCH_FROM_GIT_TAG "master")
message("Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG")
endif()
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
set(PICO_SDK_FETCH_FROM_GIT_TAG "${PICO_SDK_FETCH_FROM_GIT_TAG}" CACHE FILEPATH "release tag for SDK")
if (NOT PICO_SDK_PATH)
if (PICO_SDK_FETCH_FROM_GIT)
@ -34,14 +45,14 @@ if (NOT PICO_SDK_PATH)
FetchContent_Declare(
pico_sdk
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
GIT_TAG master
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
GIT_SUBMODULES_RECURSE FALSE
)
else ()
FetchContent_Declare(
pico_sdk
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
GIT_TAG master
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
)
endif ()

@ -1 +1 @@
Subproject commit 72ef1732c954d938091467961e41f4aa9b976b34
Subproject commit 2b49e57bd1fae85ac32ac1f41cdb7c794de335f6

@ -1 +1 @@
Subproject commit 8ef38a6d32c54f850bff8f189bdca19ded33792a
Subproject commit cf924bb04c8984675ca0fc2178f082e404e048c3

@ -1 +1 @@
Subproject commit 239918ccc173cb2c2a62f41a40fd893f57faf1d6
Subproject commit 0a0452b2c39bdd91e252aef045c115f88f6ca773

@ -1 +1 @@
Subproject commit a77287f8fa6b76f74984121fdafc8563147435c8
Subproject commit 5a764e5555c64337ed17444410269ff21cb617b1

@ -1 +1 @@
Subproject commit 86c416d4c0fb38432460b3e11b08b9de76941bf5
Subproject commit 5217cee5de4cd555018da90f9f1bcc87fb1c1d3a

View file

@ -41,13 +41,6 @@ if (NOT TARGET _pico_sdk_pre_init_marker)
include(pico_utils)
message("PICO_SDK_PATH is ${CMAKE_CURRENT_LIST_DIR}")
include(pico_pre_load_platform)
# We want to configure correct toolchain prior to project load
# todo perhaps this should be included by the platform instead?
include(pico_pre_load_toolchain)
macro(pico_sdk_init)
if (NOT CMAKE_PROJECT_NAME)
message(WARNING "pico_sdk_init() should be called after the project is created (and languages added)")
@ -82,6 +75,7 @@ if (NOT TARGET _pico_sdk_pre_init_marker)
PICO_SDK_POST_LIST_FILES
PICO_CONFIG_HEADER_FILES
PICO_RP2040_CONFIG_HEADER_FILES
PICO_BOARD_CMAKE_OVERRIDES
)
macro(pico_promote_common_scope_vars)
@ -90,4 +84,10 @@ if (NOT TARGET _pico_sdk_pre_init_marker)
SET(${VAR} ${${VAR}} PARENT_SCOPE)
endforeach()
endmacro()
include(pico_pre_load_platform)
# We want to configure correct toolchain prior to project load
# todo perhaps this should be included by the platform instead?
include(pico_pre_load_toolchain)
endif()

View file

@ -1,18 +1,18 @@
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
set(PICO_SDK_VERSION_MAJOR 1)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
set(PICO_SDK_VERSION_MINOR 5)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
set(PICO_SDK_VERSION_REVISION 1)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
set(PICO_SDK_VERSION_MAJOR 2)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
set(PICO_SDK_VERSION_MINOR 1)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
set(PICO_SDK_VERSION_REVISION 0)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base
#set(PICO_SDK_VERSION_PRE_RELEASE_ID develop)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base
set(PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}")
if (PICO_SDK_VERSION_PRE_RELEASE_ID)

31
src/BUILD.bazel Normal file
View file

@ -0,0 +1,31 @@
package(default_visibility = ["//visibility:public"])
# This shim exists as a way to break internal header dependency cycles
# that occur within the dependency chain of the pico_platform target below.
alias(
name = "pico_platform_internal",
actual = select({
"//bazel/constraint:host": "//src/host/pico_platform:pico_platform_internal",
"//conditions:default": "//src/rp2_common:pico_platform_internal",
}),
visibility = [
"//src/common/boot_picobin_headers:__pkg__",
"//src/common/boot_picoboot_headers:__pkg__",
"//src/common/hardware_claim:__pkg__",
"//src/common/pico_base_headers:__pkg__",
"//src/common/pico_binary_info:__pkg__",
# These libraries sometimes need the host version even though they live
# in rp2_common.
"//src/rp2_common/boot_bootrom_headers:__pkg__",
"//src/rp2_common/hardware_boot_lock:__pkg__",
"//src/rp2_common/pico_flash:__pkg__",
],
)
alias(
name = "pico_platform",
actual = select({
"//bazel/constraint:host": "//src/host/pico_platform",
"//conditions:default": "//src/rp2_common:pico_platform",
}),
)

View file

@ -1,9 +1,15 @@
cmake_policy(SET CMP0079 NEW) # allow inserting of dependencies into our INTERFACE libraries
set(PICO_PLATFORM_CMAKE_FILE "" CACHE INTERNAL "")
set(PICO_PLATFORM_CMAKE_FILE "${PICO_PLATFORM_CMAKE_FILE}" CACHE INTERNAL "")
set(PICO_DOXYGEN_PATHS "" CACHE INTERNAL "") # generated each time
set(PICO_DOXYGEN_EXCLUDE_PATHS "" CACHE INTERNAL "") # generated each time
set(PICO_DOXYGEN_PRE_DEFINES "" CACHE INTERNAL "") # generated each time
set(PICO_DOXYGEN_ENABLED_SECTIONS "" CACHE INTERNAL "") # generated each time
if (NOT PICO_PLATFORM_CMAKE_DIR)
set(PICO_PLATFORM_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
endif()
if (NOT PICO_PLATFORM_CMAKE_FILE)
set(PICO_PLATFORM_CMAKE_FILE ${CMAKE_CURRENT_LIST_DIR}/${PICO_PLATFORM}.cmake CACHE INTERNAL "")
set(PICO_PLATFORM_CMAKE_FILE ${PICO_PLATFORM_CMAKE_DIR}/${PICO_PLATFORM}.cmake CACHE INTERNAL "")
endif ()
if (NOT EXISTS "${PICO_PLATFORM_CMAKE_FILE}")
@ -11,17 +17,28 @@ if (NOT EXISTS "${PICO_PLATFORM_CMAKE_FILE}")
Either specify a valid PICO_PLATFORM (or PICO_PLATFORM_CMAKE_FILE).")
endif ()
# Initialize board related build/compile settings
include(${CMAKE_CURRENT_LIST_DIR}/board_setup.cmake)
# call add_subdirectory(subdir) unless SKIP_SUBDIR evaluates to true
# second argument is optional path
function(pico_add_subdirectory subdir)
# todo add option to disable skip flag
string(TOUPPER ${subdir} subdir_upper)
# we do not include any path part of the subdir
get_filename_component(subdir_upper ${subdir_upper} NAME)
set(replace_flag SKIP_${subdir_upper})
if (NOT ${replace_flag})
add_subdirectory(${subdir})
else ()
string(TOUPPER ${subdir} subdir_upper)
set(replace_flag SKIP_${subdir_upper})
if (${ARGC} GREATER 1)
# argv1 is the root where the subdir is relative to
add_subdirectory(${ARGV1}/${subdir} ${subdir})
# todo make this optional?
pico_add_doxygen(${ARGV1}/${subdir})
else()
add_subdirectory(${subdir})
# todo make this optional?
pico_add_doxygen(${subdir})
endif()
else()
message("Not including ${subdir} because ${replace_flag} defined.")
endif ()
pico_promote_common_scope_vars()
@ -57,11 +74,12 @@ endfunction()
# add map file generation for the given target
function(pico_add_map_output TARGET)
pico_get_runtime_output_directory(${TARGET} output_path)
get_target_property(target_type ${TARGET} TYPE)
if ("EXECUTABLE" STREQUAL "${target_type}")
target_link_options(${TARGET} PRIVATE "LINKER:-Map=$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map")
target_link_options(${TARGET} PRIVATE "LINKER:-Map=${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map")
else ()
target_link_options(${TARGET} INTERFACE "LINKER:-Map=$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map")
target_link_options(${TARGET} INTERFACE "LINKER:-Map=${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map")
endif ()
endfunction()
@ -102,7 +120,7 @@ macro(pico_simple_hardware_headers_target NAME)
if (NOT TARGET hardware_${NAME}_headers)
add_library(hardware_${NAME}_headers INTERFACE)
target_include_directories(hardware_${NAME}_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_include_directories(hardware_${NAME}_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(hardware_${NAME}_headers INTERFACE pico_base_headers)
if (NOT PICO_NO_HARDWARE)
target_link_libraries(hardware_${NAME}_headers INTERFACE hardware_structs hardware_claim_headers)
@ -122,7 +140,7 @@ macro(pico_simple_hardware_headers_only_target NAME)
add_library(hardware_${NAME}_headers INTERFACE)
# a headers only target should still have an explicit _headers library for consistency
target_include_directories(hardware_${NAME}_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_include_directories(hardware_${NAME}_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(hardware_${NAME}_headers INTERFACE pico_base_headers)
if (NOT PICO_NO_HARDWARE)
target_link_libraries(hardware_${NAME}_headers INTERFACE hardware_structs)
@ -154,12 +172,30 @@ macro(pico_simple_hardware_impl_target NAME)
endif()
endmacro()
function(pico_add_doxygen_pre_define PRE_DEFINE)
list(APPEND PICO_DOXYGEN_PRE_DEFINES "${PRE_DEFINE}")
set(PICO_DOXYGEN_PRE_DEFINES "${PICO_DOXYGEN_PRE_DEFINES}" CACHE INTERNAL "")
endfunction()
function(pico_add_doxygen_enabled_section ENABLED_SECTION)
list(APPEND PICO_DOXYGEN_ENABLED_SECTIONS "${ENABLED_SECTION}")
set(PICO_DOXYGEN_ENABLED_SECTIONS "${PICO_DOXYGEN_ENABLED_SECTIONS}" CACHE INTERNAL "")
endfunction()
function(pico_add_doxygen SOURCE_DIR)
set(PICO_DOXYGEN_PATHS "${PICO_DOXYGEN_PATHS} ${SOURCE_DIR}" CACHE INTERNAL "")
if (NOT IS_ABSOLUTE "${SOURCE_DIR}")
get_filename_component(SOURCE_DIR "${SOURCE_DIR}" ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
list(APPEND PICO_DOXYGEN_PATHS "${SOURCE_DIR}")
set(PICO_DOXYGEN_PATHS "${PICO_DOXYGEN_PATHS}" CACHE INTERNAL "")
endfunction()
function(pico_add_doxygen_exclude SOURCE_DIR)
set(PICO_DOXYGEN_EXCLUDE_PATHS "${PICO_DOXYGEN_EXCLUDE_PATHS} ${SOURCE_DIR}" CACHE INTERNAL "")
if (NOT IS_ABSOLUTE "${SOURCE_DIR}")
get_filename_component(SOURCE_DIR "${SOURCE_DIR}" ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
list(APPEND PICO_DOXYGEN_EXCLUDE_PATHS "${SOURCE_DIR}")
set(PICO_DOXYGEN_EXCLUDE_PATHS "${PICO_DOXYGEN_EXCLUDE_PATHS}" CACHE INTERNAL "")
endfunction()
include(${PICO_PLATFORM_CMAKE_FILE})

View file

@ -1,31 +0,0 @@
# PICO_CMAKE_CONFIG: PICO_BOARD, The board name being built for. This is overridable from the user environment, type=string, default=pico, group=build
if (DEFINED ENV{PICO_BOARD})
set(PICO_BOARD $ENV{PICO_BOARD})
message("Using PICO_BOARD from environment ('${PICO_BOARD}')")
else()
if (NOT PICO_BOARD)
set(PICO_BOARD "pico")
pico_message("Defaulting PICO target board to ${PICO_BOARD} since not specified.")
else()
message("PICO target board is ${PICO_BOARD}.")
endif()
endif()
set(PICO_BOARD ${PICO_BOARD} CACHE STRING "PICO target board (e.g. pico)" FORCE)
# PICO_CMAKE_CONFIG: PICO_BOARD_CMAKE_DIRS, Directories to look for <PICO_BOARD>.cmake in. This is overridable from the user environment, type=list, default="", group=build
if (DEFINED ENV{PICO_BOARD_CMAKE_DIRS})
set(PICO_BOARD_CMAKE_DIRS $ENV{PICO_BOARD_CMAKE_DIRS})
message("Using PICO_BOARD_CMAKE_DIRS from environment ('${PICO_BOARD_CMAKE_DIRS}')")
endif()
list(APPEND PICO_BOARD_CMAKE_DIRS ${CMAKE_CURRENT_LIST_DIR}/boards)
pico_find_in_paths(PICO_BOARD_CMAKE_FILE PICO_BOARD_CMAKE_DIRS ${PICO_BOARD}.cmake)
if (EXISTS "${PICO_BOARD_CMAKE_FILE}")
message("Using CMake board configuration from ${PICO_BOARD_CMAKE_FILE}")
include(${PICO_BOARD_CMAKE_FILE} board_config)
else()
include(boards/generic_board.cmake)
endif()
list(APPEND PICO_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/boards/include) # so boards/foo.h can be explicitly included

54
src/boards/BUILD.bazel Normal file
View file

@ -0,0 +1,54 @@
load("//bazel:defs.bzl", "pico_board_config")
load("//bazel/util:multiple_choice_flag.bzl", "declare_flag_choices", "flag_choice")
package(default_visibility = ["//visibility:public"])
# Find all boards.
BOARD_CHOICE_FILES = glob(["include/boards/*.h"])
# Extract just the name of the board.
BOARD_CHOICES = [
path.removeprefix("include/boards/").removesuffix(".h")
for path in BOARD_CHOICE_FILES
]
BOARD_CHOICE_MAP = {c: [":{}".format(c)] for c in BOARD_CHOICES}
# PICO_BUILD_DEFINE: PICO_BOARD, Name of board, type=string, default=CMake PICO_BOARD variable, group=pico_base
[
pico_board_config(
name = board,
hdrs = BOARD_CHOICE_FILES,
defines = [
'PICO_BOARD=\\"{}\\"'.format(board),
],
includes = ["include"],
platform_includes = [
"cmsis/rename_exceptions.h",
"boards/{}.h".format(board),
],
deps = ["//src/rp2_common/cmsis:rename_exceptions"],
)
for board in BOARD_CHOICES
]
# Creates a config_setting for each known board option with the name:
# PICO_BOARD_[choice]
declare_flag_choices(
"//bazel/config:PICO_BOARD",
BOARD_CHOICES,
)
cc_library(
name = "default",
deps = select(
flag_choice(
"//bazel/config:PICO_BOARD",
":__pkg__",
BOARD_CHOICE_MAP,
) | {
"//bazel/constraint:host": [":none"],
"//conditions:default": [":none"],
},
),
)

View file

@ -1,23 +0,0 @@
# For boards without their own cmake file, simply include a header
# PICO_CMAKE_CONFIG: PICO_BOARD_HEADER_DIRS, Directories to look for <PICO_BOARD>.h in. This is overridable from the user environment, type=list, default="", group=build
if (DEFINED ENV{PICO_BOARD_HEADER_DIRS})
set(PICO_BOARD_HEADER_DIRS $ENV{PICO_BOARD_HEADER_DIRS})
message("Using PICO_BOARD_HEADER_DIRS from environment ('${PICO_BOARD_HEADER_DIRS}')")
endif()
set(PICO_BOARD_HEADER_DIRS ${PICO_BOARD_HEADER_DIRS} CACHE STRING "PICO board header directories" FORCE)
list(APPEND PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/include/boards)
pico_find_in_paths(PICO_BOARD_HEADER_FILE PICO_BOARD_HEADER_DIRS ${PICO_BOARD}.h)
if (EXISTS ${PICO_BOARD_HEADER_FILE})
message("Using board configuration from ${PICO_BOARD_HEADER_FILE}")
list(APPEND PICO_CONFIG_HEADER_FILES ${PICO_BOARD_HEADER_FILE})
else()
set(msg "Unable to find definition of board '${PICO_BOARD}' (specified by PICO_BOARD):\n")
list(JOIN PICO_BOARD_HEADER_DIRS ", " DIRS)
string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.h in ${DIRS} (additional paths specified by PICO_BOARD_HEADER_DIRS)\n")
list(JOIN PICO_BOARD_CMAKE_DIRS ", " DIRS)
string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.cmake in ${DIRS} (additional paths specified by PICO_BOARD_CMAKE_DIRS)")
message(FATAL_ERROR ${msg})
endif()

View file

@ -0,0 +1,86 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
//
//------------------------------------------------------------------------------------------
// Board definition for the 0xCB Helios
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_0XCB_HELIOS_H
#define _BOARDS_0XCB_HELIOS_H
// For board detection
#define _0XCB_HELIOS
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 0
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 0
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 1
#endif
// User LED and level shifted PIN
#ifndef PICO_DEFAULT_LED_PIN
#define PICO_DEFAULT_LED_PIN 17
#endif
#ifndef PICO_DEFAULT_WS2812_PIN
#define PICO_DEFAULT_WS2812_PIN 25
#endif
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 1
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 2
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 3
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 0
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 22
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 23
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 20
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 21
#endif
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// board has 16M onboard flash
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
#endif
#endif

View file

@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2040_H
#define _BOARDS_ADAFRUIT_FEATHER_RP2040_H
@ -81,10 +83,10 @@
#define PICO_FLASH_SPI_CLKDIV 4
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0

View file

@ -0,0 +1,92 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2040_USB_HOST_H
#define _BOARDS_ADAFRUIT_FEATHER_RP2040_USB_HOST_H
// For board detection
#define ADAFRUIT_FEATHER_RP2040_USB_HOST
// On some samples, the xosc can take longer to stabilize than is usual
#ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
#endif
//------------- UART -------------//
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 0
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 0
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 1
#endif
//------------- LED -------------//
#ifndef PICO_DEFAULT_LED_PIN
#define PICO_DEFAULT_LED_PIN 13
#endif
//------------- I2C -------------//
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 1
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 2
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 3
#endif
//------------- SPI -------------//
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 1
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 15
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 8
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 14
#endif
//------------- FLASH -------------//
// Use slower generic flash access
#define PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 4
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
#endif
#endif

View file

@ -0,0 +1,86 @@
/*
* Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// This header may be included by other board headers as "boards/adafruit_feather_rp2350.h"
// pico_cmake_set PICO_PLATFORM=rp2350
#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2350_H
#define _BOARDS_ADAFRUIT_FEATHER_RP2350_H
// For board detection
#define ADAFRUIT_FEATHER_RP2350
// --- RP2350 VARIANT ---
#define PICO_RP2350A 1
// --- UART ---
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 0
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 0
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 1
#endif
// --- LED ---
#ifndef PICO_DEFAULT_LED_PIN
#define PICO_DEFAULT_LED_PIN 7
#endif
#ifndef PICO_DEFAULT_WS2812_PIN
#define PICO_DEFAULT_WS2812_PIN 21
#endif
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 1
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 2
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 3
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 0
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 22
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 23
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 20
#endif
// --- FLASH ---
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
#endif

View file

@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_ADAFRUIT_ITSYBITSY_RP2040_H
#define _BOARDS_ADAFRUIT_ITSYBITSY_RP2040_H
@ -84,10 +86,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0

View file

@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_ADAFRUIT_KB2040_H
#define _BOARDS_ADAFRUIT_KB2040_H
@ -76,10 +78,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0

View file

@ -12,6 +12,8 @@
#ifndef _BOARDS_ADAFRUIT_MACROPAD_RP2040_H
#define _BOARDS_ADAFRUIT_MACROPAD_RP2040_H
// pico_cmake_set PICO_PLATFORM=rp2040
// For board detection
#define ADAFRUIT_MACROPAD_RP2040
@ -171,10 +173,10 @@
#define PICO_FLASH_SPI_CLKDIV 4
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_FLOAT_SUPPORT_ROM_V1
#define PICO_FLOAT_SUPPORT_ROM_V1 0

View file

@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_ADAFRUIT_QTPY_RP2040_H
#define _BOARDS_ADAFRUIT_QTPY_RP2040_H
@ -83,10 +85,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0

View file

@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_ADAFRUIT_TRINKEY_QT2040_H
#define _BOARDS_ADAFRUIT_TRINKEY_QT2040_H
@ -61,10 +63,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0

View file

@ -0,0 +1,107 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// FIXME delete this file before release (board file for Amethyst FPGA platform)
// pico_cmake_set PICO_PLATFORM=rp2350
#ifndef _BOARDS_AMETHYST_FPGA_H
#define _BOARDS_AMETHYST_FPGA_H
#if !PICO_RP2350
#error "Invalid PICO_PLATFORM for amethyst_fpga.h: must be rp2350 or rp2350-riscv"
#endif
// For board detection
#define RASPBERRYPI_AMETHYST_FPGA
#define PICO_NO_FPGA_CHECK 0
// --- UART ---
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 0
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 46
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 47
#endif
// Match bootrom UART baud rate of 1 Mbaud:
#ifndef PICO_DEFAULT_UART_BAUD_RATE
#define PICO_DEFAULT_UART_BAUD_RATE 1000000
#endif
// --- LED ---
#ifndef PICO_DEFAULT_LED_PIN
#define PICO_DEFAULT_LED_PIN 25
#endif
// no PICO_DEFAULT_WS2812_PIN
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 0
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 4
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 5
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 0
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 18
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 19
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 16
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 17
#endif
#define PICO_SD_CLK_PIN 18
#define PICO_SD_CMD_PIN 19
#define PICO_SD_DAT0_PIN 20
#define PICO_ON_FPGA 1
#define PICO_SCANVIDEO_COLOR_PIN_COUNT 16
#define PICO_SCANVIDEO_DPI_PIXEL_RSHIFT 0u
#define PICO_SCANVIDEO_DPI_PIXEL_GSHIFT 6u
#define PICO_SCANVIDEO_DPI_PIXEL_BSHIFT 11u
#define PICO_SCANVIDEO_48MHZ 1
#define PICO_AUDIO_I2S_DATA_PIN 29
#define PICO_AUDIO_I2S_CLOCK_PIN_BASE 30
#define PICO_AUDIO_PWM_L_PIN 28
#define PICO_AUDIO_PWM_R_PIN 27
// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
#endif

View file

@ -0,0 +1,112 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// This header may be included by other board headers as "boards/archi.h"
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_ARCHI_H
#define _BOARDS_ARCHI_H
// For board detection
#define ARCHI
// On some samples, the xosc can take longer to stabilize than is usual
#ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
#endif
// --- BOARD SPECIFIC ---
#ifndef ARCHI_BUTTON1_PIN
#define ARCHI_BUTTON1_PIN 23
#endif
#ifndef ARCHI_BUTTON2_PIN
#define ARCHI_BUTTON2_PIN 10
#endif
#ifndef ARCHI_BUTTON3_PIN
#define ARCHI_BUTTON3_PIN 25
#endif
#ifndef ARCHI_BUTTON4_PIN
#define ARCHI_BUTTON4_PIN 19
#endif
#ifndef ARCHI_BUZZER_PIN
#define ARCHI_BUZZER_PIN 22
#endif
#ifndef ARCHI_NEOPIXEL_PIN
#define ARCHI_NEOPIXEL_PIN 24
#endif
// --- UART ---
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 0
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 16
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 17
#endif
// --- LED ---
// no PICO_DEFAULT_LED_PIN
#ifndef PICO_DEFAULT_WS2812_PIN
#define PICO_DEFAULT_WS2812_PIN ARCHI_NEOPIXEL_PIN
#endif
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 1
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 14
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 15
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 0
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 2
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 3
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 4
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 5
#endif
// --- FLASH ---
// Use slower generic flash access
#define PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 4
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
#endif
#endif

View file

@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_ARDUINO_NANO_RP2040_CONNECT_H
#define _BOARDS_ARDUINO_NANO_RP2040_CONNECT_H
@ -72,10 +74,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0

View file

@ -0,0 +1,191 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_CYTRON_MAKER_PI_RP2040_H
#define _BOARDS_CYTRON_MAKER_PI_RP2040_H
// For board detection
#define CYTRON_MAKER_PI_RP2040
// --- BOARD SPECIFIC ---
// Motor driver
#ifndef MAKER_PI_RP2040_M1A_PIN
#define MAKER_PI_RP2040_M1A_PIN 8
#endif
#ifndef MAKER_PI_RP2040_M1B_PIN
#define MAKER_PI_RP2040_M1B_PIN 9
#endif
#ifndef MAKER_PI_RP2040_M2A_PIN
#define MAKER_PI_RP2040_M2A_PIN 10
#endif
#ifndef MAKER_PI_RP2040_M2B_PIN
#define MAKER_PI_RP2040_M2B_PIN 11
#endif
// Grove ports
#ifndef MAKER_PI_RP2040_GROVE1A_PIN
#define MAKER_PI_RP2040_GROVE1A_PIN 0
#endif
#ifndef MAKER_PI_RP2040_GROVE1B_PIN
#define MAKER_PI_RP2040_GROVE1B_PIN 1
#endif
#ifndef MAKER_PI_RP2040_GROVE2A_PIN
#define MAKER_PI_RP2040_GROVE2A_PIN 2
#endif
#ifndef MAKER_PI_RP2040_GROVE2B_PIN
#define MAKER_PI_RP2040_GROVE2B_PIN 3
#endif
#ifndef MAKER_PI_RP2040_GROVE3A_PIN
#define MAKER_PI_RP2040_GROVE3A_PIN 4
#endif
#ifndef MAKER_PI_RP2040_GROVE3B_PIN
#define MAKER_PI_RP2040_GROVE3B_PIN 5
#endif
#ifndef MAKER_PI_RP2040_GROVE4A_PIN
#define MAKER_PI_RP2040_GROVE4A_PIN 16
#endif
#ifndef MAKER_PI_RP2040_GROVE4B_PIN
#define MAKER_PI_RP2040_GROVE4B_PIN 17
#endif
#ifndef MAKER_PI_RP2040_GROVE5A_PIN
#define MAKER_PI_RP2040_GROVE5A_PIN 6
#endif
#ifndef MAKER_PI_RP2040_GROVE5B_PIN
#define MAKER_PI_RP2040_GROVE5B_PIN 26
#endif
#ifndef MAKER_PI_RP2040_GROVE6A_PIN
#define MAKER_PI_RP2040_GROVE6A_PIN 26
#endif
#ifndef MAKER_PI_RP2040_GROVE6B_PIN
#define MAKER_PI_RP2040_GROVE6B_PIN 27
#endif
#ifndef MAKER_PI_RP2040_GROVE7A_PIN
#define MAKER_PI_RP2040_GROVE7A_PIN 7
#endif
#ifndef MAKER_PI_RP2040_GROVE7B_PIN
#define MAKER_PI_RP2040_GROVE7B_PIN 28
#endif
// Buttons
#ifndef MAKER_PI_RP2040_BUTTON1_PIN
#define MAKER_PI_RP2040_BUTTON1_PIN 20
#endif
#ifndef MAKER_PI_RP2040_BUTTON2_PIN
#define MAKER_PI_RP2040_BUTTON2_PIN 21
#endif
// Servo headers
#ifndef MAKER_PI_RP2040_SERVO1_PIN
#define MAKER_PI_RP2040_SERVO1_PIN 12
#endif
#ifndef MAKER_PI_RP2040_SERVO2_PIN
#define MAKER_PI_RP2040_SERVO2_PIN 13
#endif
#ifndef MAKER_PI_RP2040_SERVO3_PIN
#define MAKER_PI_RP2040_SERVO3_PIN 14
#endif
#ifndef MAKER_PI_RP2040_SERVO4_PIN
#define MAKER_PI_RP2040_SERVO4_PIN 15
#endif
// --- UART ---
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 0
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 0
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 1
#endif
// --- LED ---
#ifndef PICO_DEFAULT_WS2812_PIN
#define PICO_DEFAULT_WS2812_PIN 18
#endif
// This board has two WS2812 leds in series
#ifndef PICO_DEFAULT_WS2812_NUM_PIXELS
#define PICO_DEFAULT_WS2812_NUM_PIXELS 2
#endif
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 1
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 6
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 7
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 0
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 3
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 4
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 2
#endif
// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
#endif
#endif

View file

@ -14,6 +14,8 @@
//
// This header may be included by other board headers as "boards/datanoisetv_rp2040_dsp.h"
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_DATANOISETV_RP2040_DSP_H
#define _BOARDS_DATANOISETV_RP2040_DSP_H
@ -38,10 +40,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
#endif

View file

@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
//
//------------------------------------------------------------------------------------------
// Board definition for the DatanoiseTV RP2350 DSP Board
//
// This header may be included by other board headers as "boards/datanoisetv_rp2350_dsp.h"
// pico_cmake_set PICO_PLATFORM=rp2350
#ifndef _BOARDS_DATANOISETV_RP2350_DSP_H
#define _BOARDS_DATANOISETV_RP2350_DSP_H
// For board detection
#define DATANOISETV_RP2350_DSP
// --- RP2350 VARIANT ---
#define PICO_RP2350A 1
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 0
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 24
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 25
#endif
// -- FLASH --
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
// --- I2S ---
#ifndef PICO_AUDIO_I2S_DATA_PIN
#define PICO_AUDIO_I2S_DATA_PIN 16
#endif
#ifndef PICO_AUDIO_I2S_CLOCK_PIN_BASE
#define PICO_AUDIO_I2S_CLOCK_PIN_BASE 17
#endif
#endif

View file

@ -0,0 +1,118 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2350
#ifndef _BOARDS_DEFCON32_BADGE_H
#define _BOARDS_DEFCON32_BADGE_H
// For board detection
#define DEFCON32_BADGE
// --- RP2350 VARIANT ---
#define PICO_RP2350A 1
#define DEFCON32_BADGE_SRAM_CS_PIN 0
#define DEFCON32_BADGE_TOUCH_INT_PIN 1
#define DEFCON32_BADGE_I2C_SDA_PIN 2
#define DEFCON32_BADGE_I2C_SDL_PIN 3
#define DEFCON32_BADGE_WS2812_PIN 4
#define DEFCON32_BADGE_DISPLAY_RS_PIN 5
#define DEFCON32_BADGE_DISPLAY_DO_PIN 6
#define DEFCON32_BADGE_IR_SD_PIN 7
#define DEFCON32_BADGE_DISPLAY_SCK_PIN 8
#define DEFCON32_BADGE_DISPLAY_CS_PIN 9
#define DEFCON32_BADGE_DISPLAY_BL_PIN 10
#define DEFCON32_BADGE_SYS_POWER_CONTROL_PIN 11
#define DEFCON32_BADGE_SPI_MISO_PIN 12
#define DEFCON32_BADGE_SD_CS_PIN 13
#define DEFCON32_BADGE_SPI_CK_PIN 14
#define DEFCON32_BADGE_SPI_MOSI_PIN 15
#define DEFCON32_BADGE_SW_RIGHT_PIN 16
#define DEFCON32_BADGE_SW_DOWN_PIN 17
#define DEFCON32_BADGE_SW_UP_PIN 18
#define DEFCON32_BADGE_SW_LEFT_PIN 19
#define DEFCON32_BADGE_SW_B_PIN 20
#define DEFCON32_BADGE_SW_A_PIN 21
#define DEFCON32_BADGE_SW_START_PIN 22
#define DEFCON32_BADGE_SW_SELECT_PIN 23
#define DEFCON32_BADGE_SW_FN_PIN 24
#define DEFCON32_BADGE_SPEAKER_OUT_PIN 25
#define DEFCON32_BADGE_IR_RX_PIN 27
#define DEFCON32_BADGE_IR_TX_PIN 28
// --- UART ---
// NOTE: since there is no UART on the badge, you should probably pass:
// -DPICO_BOARD=defcon32_badge -DPICO_STDIO_USB=1 -DPICO_STDIO_UART=0
// when building to set up stdio over USB CDC by default
// --- LED ---
// no PICO_DEFAULT_LED_PIN
#ifndef PICO_DEFAULT_WS2812_PIN
#define PICO_DEFAULT_WS2812_PIN DEFCON32_BADGE_WS2812_PIN
#endif
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 1
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN DEFCON32_BADGE_I2C_SDA_PIN
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN DEFCON32_BADGE_I2C_SDL_PIN
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 1
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN DEFCON32_BADGE_SPI_CK_PIN
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN DEFCON32_BADGE_SPI_MOSI_PIN
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN DEFCON32_BADGE_SPI_MISO_PIN
#endif
// multiple devices, so this doesn't make much sense
// no PICO_DEFAULT_SPI_CSN_PIN
#ifndef PICO_AUDIO_PWM_L_PIN
#define PICO_AUDIO_PWM_L_PIN DEFCON32_BADGE_SPEAKER_OUT_PIN
#endif
#ifndef PICO_AUDIO_PWM_MONO_PIN
#define PICO_AUDIO_PWM_MONO_PIN PICO_AUDIO_PWM_L_PIN
#endif
// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
#endif
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
#endif

View file

@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_EETREE_GAMEKIT_RP2040_H
#define _BOARDS_EETREE_GAMEKIT_RP2040_H
@ -67,6 +69,7 @@
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif

View file

@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_GARATRONIC_PYBSTICK26_RP2040_H
#define _BOARDS_GARATRONIC_PYBSTICK26_RP2040_H
@ -68,10 +70,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (1 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (1 * 1024 * 1024)
#endif
// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
// Linear regulator on Pybstick26
//#define PICO_SMPS_MODE_PIN 23

View file

@ -0,0 +1,119 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2350
#ifndef _BOARDS_GEN4_RP2350_24_H
#define _BOARDS_GEN4_RP2350_24_H
// For board detection
#define GEN4_RP2350_24
// --- RP2350 VARIANT ---
#define PICO_RP2350A 0
// --- UART ---
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 1
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 4
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 5
#endif
// --- LED ---
// no PICO_DEFAULT_LED_PIN
// no PICO_DEFAULT_WS2812_PIN
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 0
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 8
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 9
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 1
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 42
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 43
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 44
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 45
#endif
// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
// 4DLCD Interface
#define PORTRAIT 0
#define LANDSCAPE 1
#define PORTRAIT_R 2
#define LANDSCAPE_R 3
#define LCD_ORIENTATION PORTRAIT
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
#define LCD_BACKLIGHT 17
#define LCD_RS_PIN 18
#define LCD_WR_PIN 19
#define LCD_RD_PIN 20
#define LCD_DATA0_PIN 21
#define LCD_RESET 37
#define LCD_TOUCH_INT 38
#define LCD_TOUCH_SCL 39
#define LCD_TOUCH_SDA 46
#define LCD_TOUCH_RST 47
#define LCD_TOUCH_YD LCD_TOUCH_INT
#define LCD_TOUCH_XL LCD_TOUCH_SCL
#define LCD_TOUCH_YU LCD_TOUCH_RST
#define LCD_TOUCH_XR LCD_TOUCH_SDA
#define LCD_TOUCH_I2C i2c1
#define LCD_TOUCH_NONE
#define LCD_TOUCH_POINTS 0
#define LCD_SD_CLK 10
#define LCD_SD_CMD 11
#define LCD_SD_D0 12
#define LCD_SD_D1 13
#define LCD_SD_D2 14
#define LCD_SD_D3 15
#endif

View file

@ -0,0 +1,119 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2350
#ifndef _BOARDS_GEN4_RP2350_24CT_H
#define _BOARDS_GEN4_RP2350_24CT_H
// For board detection
#define GEN4_RP2350_24CT // CLB variants are exactly the same in operation
// --- RP2350 VARIANT ---
#define PICO_RP2350A 0
// --- UART ---
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 1
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 4
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 5
#endif
// --- LED ---
// no PICO_DEFAULT_LED_PIN
// no PICO_DEFAULT_WS2812_PIN
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 0
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 8
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 9
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 1
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 42
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 43
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 44
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 45
#endif
// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
// 4DLCD Interface
#define PORTRAIT 0
#define LANDSCAPE 1
#define PORTRAIT_R 2
#define LANDSCAPE_R 3
#define LCD_ORIENTATION PORTRAIT
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
#define LCD_BACKLIGHT 17
#define LCD_RS_PIN 18
#define LCD_WR_PIN 19
#define LCD_RD_PIN 20
#define LCD_DATA0_PIN 21
#define LCD_RESET 37
#define LCD_TOUCH_INT 38
#define LCD_TOUCH_SCL 39
#define LCD_TOUCH_SDA 46
#define LCD_TOUCH_RST 47
#define LCD_TOUCH_YD LCD_TOUCH_INT
#define LCD_TOUCH_XL LCD_TOUCH_SCL
#define LCD_TOUCH_YU LCD_TOUCH_RST
#define LCD_TOUCH_XR LCD_TOUCH_SDA
#define LCD_TOUCH_I2C i2c1
#define LCD_TOUCH_CTP_FT
#define LCD_TOUCH_POINTS 2
#define LCD_SD_CLK 10
#define LCD_SD_CMD 11
#define LCD_SD_D0 12
#define LCD_SD_D1 13
#define LCD_SD_D2 14
#define LCD_SD_D3 15
#endif

View file

@ -0,0 +1,119 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2350
#ifndef _BOARDS_GEN4_RP2350_24T_H
#define _BOARDS_GEN4_RP2350_24T_H
// For board detection
#define GEN4_RP2350_24T
// --- RP2350 VARIANT ---
#define PICO_RP2350A 0
// --- UART ---
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 1
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 4
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 5
#endif
// --- LED ---
// no PICO_DEFAULT_LED_PIN
// no PICO_DEFAULT_WS2812_PIN
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 0
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 8
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 9
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 1
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 42
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 43
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 44
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 45
#endif
// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
// 4DLCD Interface
#define PORTRAIT 0
#define LANDSCAPE 1
#define PORTRAIT_R 2
#define LANDSCAPE_R 3
#define LCD_ORIENTATION PORTRAIT
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
#define LCD_BACKLIGHT 17
#define LCD_RS_PIN 18
#define LCD_WR_PIN 19
#define LCD_RD_PIN 20
#define LCD_DATA0_PIN 21
#define LCD_RESET 37
#define LCD_TOUCH_INT 38
#define LCD_TOUCH_SCL 39
#define LCD_TOUCH_SDA 46
#define LCD_TOUCH_RST 47
#define LCD_TOUCH_YD LCD_TOUCH_INT
#define LCD_TOUCH_XL LCD_TOUCH_SCL
#define LCD_TOUCH_YU LCD_TOUCH_RST
#define LCD_TOUCH_XR LCD_TOUCH_SDA
#define LCD_TOUCH_I2C i2c1
#define LCD_TOUCH_4WIRE
#define LCD_TOUCH_POINTS 1
#define LCD_SD_CLK 10
#define LCD_SD_CMD 11
#define LCD_SD_D0 12
#define LCD_SD_D1 13
#define LCD_SD_D2 14
#define LCD_SD_D3 15
#endif

View file

@ -0,0 +1,119 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2350
#ifndef _BOARDS_GEN4_RP2350_28_H
#define _BOARDS_GEN4_RP2350_28_H
// For board detection
#define GEN4_RP2350_28
// --- RP2350 VARIANT ---
#define PICO_RP2350A 0
// --- UART ---
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 1
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 4
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 5
#endif
// --- LED ---
// no PICO_DEFAULT_LED_PIN
// no PICO_DEFAULT_WS2812_PIN
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 0
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 8
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 9
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 1
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 42
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 43
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 44
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 45
#endif
// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
// 4DLCD Interface
#define PORTRAIT 0
#define LANDSCAPE 1
#define PORTRAIT_R 2
#define LANDSCAPE_R 3
#define LCD_ORIENTATION PORTRAIT
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
#define LCD_BACKLIGHT 17
#define LCD_RS_PIN 18
#define LCD_WR_PIN 19
#define LCD_RD_PIN 20
#define LCD_DATA0_PIN 21
#define LCD_RESET 37
#define LCD_TOUCH_INT 38
#define LCD_TOUCH_SCL 39
#define LCD_TOUCH_SDA 46
#define LCD_TOUCH_RST 47
#define LCD_TOUCH_YD LCD_TOUCH_INT
#define LCD_TOUCH_XL LCD_TOUCH_SCL
#define LCD_TOUCH_YU LCD_TOUCH_RST
#define LCD_TOUCH_XR LCD_TOUCH_SDA
#define LCD_TOUCH_I2C i2c1
#define LCD_TOUCH_NONE
#define LCD_TOUCH_POINTS 0
#define LCD_SD_CLK 10
#define LCD_SD_CMD 11
#define LCD_SD_D0 12
#define LCD_SD_D1 13
#define LCD_SD_D2 14
#define LCD_SD_D3 15
#endif

View file

@ -0,0 +1,119 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
// pico_cmake_set PICO_PLATFORM=rp2350
#ifndef _BOARDS_GEN4_RP2350_28CT_H
#define _BOARDS_GEN4_RP2350_28CT_H
// For board detection
#define GEN4_RP2350_28CT // CLB variants are exactly the same in operation
// --- RP2350 VARIANT ---
#define PICO_RP2350A 0
// --- UART ---
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 1
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 4
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 5
#endif
// --- LED ---
// no PICO_DEFAULT_LED_PIN
// no PICO_DEFAULT_WS2812_PIN
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 0
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 8
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 9
#endif
// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 1
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 42
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 43
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 44
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 45
#endif
// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
// 4DLCD Interface
#define PORTRAIT 0
#define LANDSCAPE 1
#define PORTRAIT_R 2
#define LANDSCAPE_R 3
#define LCD_ORIENTATION PORTRAIT
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
#define LCD_BACKLIGHT 17
#define LCD_RS_PIN 18
#define LCD_WR_PIN 19
#define LCD_RD_PIN 20
#define LCD_DATA0_PIN 21
#define LCD_RESET 37
#define LCD_TOUCH_INT 38
#define LCD_TOUCH_SCL 39
#define LCD_TOUCH_SDA 46
#define LCD_TOUCH_RST 47
#define LCD_TOUCH_YD LCD_TOUCH_INT
#define LCD_TOUCH_XL LCD_TOUCH_SCL
#define LCD_TOUCH_YU LCD_TOUCH_RST
#define LCD_TOUCH_XR LCD_TOUCH_SDA
#define LCD_TOUCH_I2C i2c1
#define LCD_TOUCH_CTP_FT
#define LCD_TOUCH_POINTS 2
#define LCD_SD_CLK 10
#define LCD_SD_CMD 11
#define LCD_SD_D0 12
#define LCD_SD_D1 13
#define LCD_SD_D2 14
#define LCD_SD_D3 15
#endif

Some files were not shown because too many files have changed in this diff Show more