-
Notifications
You must be signed in to change notification settings - Fork 8.4k
boards: waveshare: rp2040_zero: Initial support #79447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Copyright (c) 2024 Iacopo Moles | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config BOARD_RP2040_ZERO | ||
| select RP2_FLASH_W25Q080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright (c) 2024 Iacopo Moles | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| if BOARD_RP2040_ZERO | ||
|
|
||
| if I2C_DW | ||
|
|
||
| config I2C_DW_CLOCK_SPEED | ||
| default 125 | ||
|
|
||
| endif # I2C_DW | ||
|
|
||
| endif # BOARD_RP2040_ZERO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Copyright (c) 2024 Iacopo Moles | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config BOARD_RP2040_ZERO | ||
| select SOC_RP2040 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| board_runner_args(uf2 "--board-id=RPI-RP2") | ||
|
|
||
| include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| board: | ||
| name: rp2040_zero | ||
| full_name: RP2040-Zero | ||
| vendor: waveshare | ||
| socs: | ||
| - name: rp2040 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| .. zephyr:board:: rp2040_zero | ||
|
|
||
| Overview | ||
| ******** | ||
|
|
||
| RP2040-Zero, A Low-Cost, High-Performance Pico-Like MCU Board Based On Raspberry Pi Microcontroller RP2040. | ||
|
|
||
| Hardware | ||
| ******** | ||
| - RP2040 microcontroller chip designed by Raspberry Pi in the United Kingdom. | ||
| - Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz. | ||
| - 264KB of SRAM, and 2MB of on-board Flash memory. | ||
| - USB-C connector, keeps it up to date, easier to use. | ||
| - The castellated module allows soldering direct to carrier boards. | ||
| - USB 1.1 with device and host support. | ||
| - Low-power sleep and dormant modes. | ||
| - Drag-and-drop programming using mass storage over USB. | ||
| - 29 × multi-function GPIO pins (20× via edge pinout, others via solder points). | ||
| - 2 × SPI, 2 × I2C, 2 × UART, 4 × 12-bit ADC, 16 × controllable PWM channels. | ||
| - Accurate clock and timer on-chip. | ||
| - Temperature sensor. | ||
| - Accelerated floating-point libraries on-chip. | ||
| - 8 × Programmable I/O (PIO) state machines for custom peripheral support. | ||
|
|
||
| Supported Features | ||
| ================== | ||
|
|
||
| The ``rp2040_zero`` board target supports the following hardware features: | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
|
|
||
| * - Peripheral | ||
| - Kconfig option | ||
| - Devicetree compatible | ||
| * - NVIC | ||
| - N/A | ||
| - :dtcompatible:`arm,v6m-nvic` | ||
| * - UART | ||
| - :kconfig:option:`CONFIG_SERIAL` | ||
| - :dtcompatible:`raspberrypi,pico-uart` | ||
| * - GPIO | ||
| - :kconfig:option:`CONFIG_GPIO` | ||
| - :dtcompatible:`raspberrypi,pico-gpio` | ||
| * - ADC | ||
| - :kconfig:option:`CONFIG_ADC` | ||
| - :dtcompatible:`raspberrypi,pico-adc` | ||
| * - I2C | ||
| - :kconfig:option:`CONFIG_I2C` | ||
| - :dtcompatible:`snps,designware-i2c` | ||
| * - SPI | ||
| - :kconfig:option:`CONFIG_SPI` | ||
| - :dtcompatible:`raspberrypi,pico-spi` | ||
| * - USB Device | ||
| - :kconfig:option:`CONFIG_USB_DEVICE_STACK` | ||
| - :dtcompatible:`raspberrypi,pico-usbd` | ||
| * - HWINFO | ||
| - :kconfig:option:`CONFIG_HWINFO` | ||
| - N/A | ||
| * - Watchdog Timer (WDT) | ||
| - :kconfig:option:`CONFIG_WATCHDOG` | ||
| - :dtcompatible:`raspberrypi,pico-watchdog` | ||
| * - PWM | ||
| - :kconfig:option:`CONFIG_PWM` | ||
| - :dtcompatible:`raspberrypi,pico-pwm` | ||
| * - Flash | ||
| - :kconfig:option:`CONFIG_FLASH` | ||
| - :dtcompatible:`raspberrypi,pico-flash` | ||
| * - Clock controller | ||
| - :kconfig:option:`CONFIG_CLOCK_CONTROL` | ||
| - :dtcompatible:`raspberrypi,pico-clock-controller` | ||
| * - UART (PIO) | ||
| - :kconfig:option:`CONFIG_SERIAL` | ||
| - :dtcompatible:`raspberrypi,pico-uart-pio` | ||
| * - SPI (PIO) | ||
| - :kconfig:option:`CONFIG_SPI` | ||
| - :dtcompatible:`raspberrypi,pico-spi-pio` | ||
|
|
||
| Pin Mapping | ||
| =========== | ||
|
|
||
| The peripherals of the RP2040 SoC can be routed to various pins on the board. The configuration of these routes can be modified through DTS. Please refer to the datasheet to see the possible routings for each peripheral. | ||
|
|
||
| Default Zephyr Peripheral Mapping: | ||
| ---------------------------------- | ||
|
|
||
| .. rst-class:: rst-columns | ||
|
|
||
| - UART0_TX : P0 | ||
| - UART0_RX : P1 | ||
| - I2C0_SDA : P4 | ||
| - I2C0_SCL : P5 | ||
| - I2C1_SDA : P6 | ||
| - I2C1_SCL : P7 | ||
| - ADC_CH0 : P26 | ||
| - ADC_CH1 : P27 | ||
| - ADC_CH2 : P28 | ||
| - ADC_CH3 : P29 | ||
|
|
||
| Programming and Debugging | ||
| ************************* | ||
|
|
||
| Flashing | ||
| ======== | ||
|
|
||
nordicjm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Using UF2 | ||
| --------- | ||
|
|
||
| Here is an example of building the sample for driving the built-in RGB led. | ||
|
|
||
| .. zephyr-app-commands:: | ||
| :zephyr-app: samples/drivers/led/led_strip | ||
| :board: rp2040_zero | ||
| :goals: build | ||
| :compact: | ||
|
|
||
nordicjm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| You must flash the RP2040-Zero with an UF2 file. One option is to use West (Zephyr’s meta-tool). To enter the UF2 flashing mode just keep the ``BOOT`` button pressed while you connect the USB port, it will appear on the host as a mass storage device. In alternative with the board already connected via USB you can keep the ``RESET`` button pressed, press and release ``BOOT``, release ``RESET``. At this point you can flash the image file by running: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| west flash | ||
|
|
||
| In alternative you can locate the generated file at ``build/zephyr/zephyr.uf2 file`` and simply drag-and-drop to the device after entreing the UF2 flashing mode. | ||
|
|
||
| References | ||
| ********** | ||
|
|
||
| - `Official Documentation`_ | ||
| - `WS2812 datasheet`_ | ||
|
|
||
| .. _Official Documentation: https://www.waveshare.com/wiki/RP2040-Zero | ||
| .. _WS2812 datasheet: https://cdn-shop.adafruit.com/datasheets/WS2812.pdf | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Copyright (c) 2024 Iacopo Moles | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h> | ||
| #include <dt-bindings/i2c/i2c.h> | ||
|
|
||
| &pinctrl { | ||
| uart0_default: uart0_default { | ||
| status = "okay"; | ||
| group1 { | ||
| pinmux = <UART0_TX_P0>; | ||
| }; | ||
| group2 { | ||
| pinmux = <UART0_RX_P1>; | ||
| input-enable; | ||
| }; | ||
| }; | ||
|
|
||
| i2c0_default: i2c0_default { | ||
| group1 { | ||
| pinmux = <I2C0_SDA_P24>; | ||
| input-enable; | ||
| }; | ||
| group2 { | ||
| pinmux = <I2C0_SCL_P25>; | ||
| input-enable; | ||
| }; | ||
| }; | ||
|
|
||
| i2c1_default: i2c1_default { | ||
| group1 { | ||
| pinmux = <I2C1_SDA_P22>; | ||
| input-enable; | ||
| }; | ||
| group2 { | ||
| pinmux = <I2C1_SCL_P23>; | ||
| input-enable; | ||
| }; | ||
| }; | ||
|
|
||
| spi0_default: spi0_default { | ||
| group1 { | ||
| pinmux = <SPI0_TX_P3>; | ||
| }; | ||
| group2 { | ||
| pinmux = <SPI0_RX_P4>; | ||
| input-enable; | ||
| }; | ||
| group3 { | ||
| pinmux = <SPI0_SCK_P6>; | ||
| }; | ||
| }; | ||
|
|
||
| adc_default: adc_default { | ||
| group1 { | ||
| pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>; | ||
| input-enable; | ||
| }; | ||
| }; | ||
|
|
||
| ws2812_pio0_default: ws2812_pio0_default { | ||
| ws2812 { | ||
| pinmux = <PIO0_P16>; | ||
| }; | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| /* | ||
| * Copyright (c) 2024 Iacopo Moles | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /dts-v1/; | ||
|
|
||
| #include <rpi_pico/rp2040.dtsi> | ||
| #include "rp2040_zero-pinctrl.dtsi" | ||
| #include <freq.h> | ||
| #include <zephyr/dt-bindings/led/led.h> | ||
| / { | ||
| chosen { | ||
| zephyr,sram = &sram0; | ||
| zephyr,flash = &flash0; | ||
| zephyr,flash-controller = &ssi; | ||
| zephyr,console = &uart0; | ||
| zephyr,shell-uart = &uart0; | ||
| zephyr,code-partition = &code_partition; | ||
| }; | ||
|
|
||
| aliases { | ||
| rtc = &rtc; | ||
| watchdog0 = &wdt0; | ||
| led-strip = &ws2812; | ||
| }; | ||
| }; | ||
|
|
||
| &flash0 { | ||
| reg = <0x10000000 DT_SIZE_M(16)>; | ||
|
|
||
| partitions { | ||
| compatible = "fixed-partitions"; | ||
| #address-cells = <1>; | ||
| #size-cells = <1>; | ||
|
|
||
| /* Reserved memory for the second stage bootloader */ | ||
| second_stage_bootloader: partition@0 { | ||
| label = "second_stage_bootloader"; | ||
| reg = <0x00000000 0x100>; | ||
| read-only; | ||
| }; | ||
|
|
||
| /* | ||
| * Usable flash. Starts at 0x100, after the bootloader. The partition | ||
| * size is 16MB minus the 0x100 bytes taken by the bootloader. | ||
| */ | ||
| code_partition: partition@100 { | ||
| label = "code-partition"; | ||
| reg = <0x100 (DT_SIZE_M(16) - 0x100)>; | ||
| read-only; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| &uart0 { | ||
| status = "okay"; | ||
| current-speed = <115200>; | ||
| pinctrl-0 = <&uart0_default>; | ||
| pinctrl-names = "default"; | ||
| }; | ||
|
|
||
| &i2c0 { | ||
| status = "okay"; | ||
| pinctrl-0 = <&i2c0_default>; | ||
| pinctrl-names = "default"; | ||
| clock-frequency = <I2C_BITRATE_STANDARD>; | ||
| }; | ||
|
|
||
| &i2c1 { | ||
| status = "okay"; | ||
| pinctrl-0 = <&i2c1_default>; | ||
| pinctrl-names = "default"; | ||
| clock-frequency = <I2C_BITRATE_FAST>; | ||
| }; | ||
|
|
||
| &spi0 { | ||
| clock-frequency = <DT_FREQ_M(8)>; | ||
| status = "okay"; | ||
| pinctrl-0 = <&spi0_default>; | ||
| pinctrl-names = "default"; | ||
| }; | ||
|
|
||
| &timer { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| &wdt0 { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| &gpio0 { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| &rtc { | ||
| clocks = <&clocks RPI_PICO_CLKID_CLK_RTC>; | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| &adc { | ||
| status = "okay"; | ||
| pinctrl-0 = <&adc_default>; | ||
| pinctrl-names = "default"; | ||
| }; | ||
|
|
||
| &pio0 { | ||
| status = "okay"; | ||
|
|
||
| pio-ws2812 { | ||
| compatible = "worldsemi,ws2812-rpi_pico-pio"; | ||
| status = "okay"; | ||
| pinctrl-0 = <&ws2812_pio0_default>; | ||
| pinctrl-names = "default"; | ||
| bit-waveform = <3>, <3>, <4>; | ||
|
|
||
| ws2812: ws2812 { | ||
| status = "okay"; | ||
| gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; | ||
| chain-length = <1>; | ||
| color-mapping = <LED_COLOR_ID_GREEN | ||
| LED_COLOR_ID_RED | ||
| LED_COLOR_ID_BLUE>; | ||
| reset-delay = <280>; | ||
| frequency = <800000>; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| &pio1 { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| zephyr_udc0: &usbd { | ||
| status = "okay"; | ||
| }; | ||
|
|
||
| &vreg { | ||
| regulator-always-on; | ||
| regulator-allowed-modes = <REGULATOR_RPI_PICO_MODE_NORMAL>; | ||
| }; | ||
|
|
||
| pico_spi: &spi0 {}; | ||
| pico_i2c0: &i2c0 {}; | ||
| pico_i2c1: &i2c1 {}; | ||
| pico_serial: &uart0 {}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.