Skip to content

RPI RP 2040 support #144

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

Open
wants to merge 6 commits into
base: arduino
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
variant: add rpi_pico_rp2040
  • Loading branch information
pennam committed Jun 17, 2025
commit 8e635289324a36397609f6dac5c6311c9644611a
64 changes: 64 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -564,3 +564,67 @@ opta.debug.cortex-debug.custom.request=attach
opta.debug.svd_file={runtime.platform.path}/svd/STM32H747_CM7.svd

##############################################################################################################

rpi_pico.name=Raspberry Pi Pico
rpi_pico.build.core=arduino
rpi_pico.build.crossprefix=arm-zephyr-eabi-
rpi_pico.build.compiler_path={runtime.tools.arm-zephyr-eabi-0.16.8.path}/bin/

rpi_pico.menu.debug.false=Standard
rpi_pico.menu.debug.true=Debug

rpi_pico.menu.debug.false.postbuild_debug=
rpi_pico.menu.debug.true.postbuild_debug=-debug

rpi_pico.build.zephyr_target=rpi_pico
rpi_pico.build.zephyr_args=
rpi_pico.build.zephyr_hals=hal_rpi_pico
rpi_pico.build.variant=rpi_pico_rp2040
rpi_pico.build.mcu=cortex-m0plus
rpi_pico.build.fpu=
rpi_pico.build.architecture=cortex-m0plus
rpi_pico.compiler.zephyr.arch.define=

rpi_pico.build.float-abi=-mfloat-abi=soft
rpi_pico.build.extra_flags=
rpi_pico.build.postbuild.cmd="{tools.imgtool.path}/{tools.imgtool.cmd}" exit
rpi_pico.recipe.hooks.objcopy.postobjcopy.3.pattern="{runtime.platform.path}/extra/bin2uf2/bin2uf2" "{build.path}/{build.project_name}.elf-zsk.bin" "{build.path}/{build.project_name}.uf2"
rpi_pico.build.architecture=cortex-m0plus
rpi_pico.build.board=RASPBERRY_PI_PICO
rpi_pico.compiler.zephyr=
rpi_pico.vid.0=0x2e8a
rpi_pico.pid.0=0x00C0
rpi_pico.upload_port.0.vid=0x2e8a
rpi_pico.upload_port.0.pid=0x00C0

rpi_pico.upload.tool=picotool
rpi_pico.upload.tool.default=picotool
rpi_pico.upload.protocol=
rpi_pico.upload.transport=
rpi_pico.upload.vid=0x2e8a
rpi_pico.upload.pid=0x00C0
rpi_pico.upload.interface=0
rpi_pico.upload.use_1200bps_touch=true
rpi_pico.upload.wait_for_upload_port=false
rpi_pico.upload.native_usb=true
rpi_pico.upload.maximum_size=2097152
rpi_pico.upload.maximum_data_size=270336

rpi_pico.upload.address=0x100E0000

rpi_pico.bootloader.tool=picotool
rpi_pico.bootloader.tool.default=picotool
rpi_pico.bootloader.vid=0x2e8a
rpi_pico.bootloader.pid=0x00C0
rpi_pico.bootloader.interface=0
rpi_pico.bootloader.file=zephyr-{build.variant}


rpi_pico.debug.tool=gdb
rpi_pico.debug.server.openocd.scripts.0=interface/{programmer.protocol}.cfg
rpi_pico.debug.server.openocd.scripts.1={programmer.transport_script}
rpi_pico.debug.server.openocd.scripts.2=target/rp2040-core0.cfg
rpi_pico.debug.cortex-debug.custom.request=attach
rpi_pico.debug.svd_file={runtime.platform.path}/svd/rp2040.svd

##############################################################################################################
Empty file.
208 changes: 208 additions & 0 deletions variants/rpi_pico_rp2040/rpi_pico_rp2040.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/adc/adc.h>

/ {
zephyr,user {
digital-pin-gpios = <&pico_header 0 0>,
<&pico_header 1 0>,
<&pico_header 2 0>,
<&pico_header 3 0>,
<&pico_header 4 0>,
<&pico_header 5 0>,
<&pico_header 6 0>,
<&pico_header 7 0>,
<&pico_header 8 0>,
<&pico_header 9 0>,
<&pico_header 10 0>,
<&pico_header 11 0>,
<&pico_header 12 0>,
<&pico_header 13 0>,
<&pico_header 14 0>,
<&pico_header 15 0>,
<&pico_header 16 0>,
<&pico_header 17 0>,
<&pico_header 18 0>,
<&pico_header 19 0>,
<&pico_header 20 0>,
<&pico_header 21 0>,
<&pico_header 22 0>,
<&gpio0 23 0>,
<&gpio0 24 0>,
<&gpio0 25 0>,
<&pico_header 26 0>,
<&pico_header 27 0>,
<&pico_header 28 0>;

builtin-led-gpios = <&gpio0 25 0>;

pwm-pin-gpios = <&pico_header 2 0>,
<&pico_header 3 0>,
<&pico_header 7 0>,
<&pico_header 8 0>,
<&pico_header 10 0>,
<&pico_header 11 0>,
<&pico_header 12 0>,
<&pico_header 13 0>,
<&pico_header 14 0>,
<&pico_header 15 0>,
<&pico_header 20 0>,
<&pico_header 21 0>,
<&pico_header 22 0>,
<&gpio0 25 0>;

adc-pin-gpios = <&pico_header 26 0>,
<&pico_header 27 0>,
<&pico_header 28 0>;

pwms = <&pwm 2 255 PWM_POLARITY_NORMAL>,
<&pwm 3 255 PWM_POLARITY_NORMAL>,
<&pwm 7 255 PWM_POLARITY_NORMAL>,
<&pwm 8 255 PWM_POLARITY_NORMAL>,
<&pwm 10 255 PWM_POLARITY_NORMAL>,
<&pwm 11 255 PWM_POLARITY_NORMAL>,
<&pwm 12 255 PWM_POLARITY_NORMAL>,
<&pwm 13 255 PWM_POLARITY_NORMAL>,
<&pwm 14 255 PWM_POLARITY_NORMAL>,
<&pwm 15 255 PWM_POLARITY_NORMAL>,
<&pwm 4 255 PWM_POLARITY_NORMAL>,
<&pwm 5 255 PWM_POLARITY_NORMAL>,
<&pwm 6 255 PWM_POLARITY_NORMAL>,
<&pwm 9 255 PWM_POLARITY_NORMAL>;

io-channels = <&adc 0>,
<&adc 1>,
<&adc 2>;

serials = <&pico_serial>;
i2cs = <&pico_i2c0>;
spis = <&pico_spi>;
};
};

&pinctrl {
pwm_ch1a_default: pwm_ch1a_default {
group1 {
pinmux = <PWM_1A_P2>;
};
};

pwm_ch1b_default: pwm_ch1b_default {
group1 {
pinmux = <PWM_1B_P3>;
};
};

pwm_ch2a_default: pwm_ch2a_default {
group1 {
pinmux = <PWM_2A_P20>;
};
};

pwm_ch2b_default: pwm_ch2b_default {
group1 {
pinmux = <PWM_2B_P21>;
};
};

pwm_ch3a_default: pwm_ch3a_default {
group1 {
pinmux = <PWM_3A_P22>;
};
};

pwm_ch3b_default: pwm_ch3b_default {
group1 {
pinmux = <PWM_3B_P7>;
};
};

pwm_ch4a_default: pwm_ch4a_default {
group1 {
pinmux = <PWM_4A_P8>;
};
};

pwm_ch5a_default: pwm_ch5a_default {
group1 {
pinmux = <PWM_5A_P10>;
};
};

pwm_ch5b_default: pwm_ch5b_default {
group1 {
pinmux = <PWM_5B_P11>;
};
};

pwm_ch6a_default: pwm_ch6a_default {
group1 {
pinmux = <PWM_6A_P12>;
};
};

pwm_ch6b_default: pwm_ch6b_default {
group1 {
pinmux = <PWM_6B_P13>;
};
};

pwm_ch7a_default: pwm_ch7a_default {
group1 {
pinmux = <PWM_7A_P14>;
};
};

pwm_ch7b_default: pwm_ch7b_default {
group1 {
pinmux = <PWM_7B_P15>;
};
};
};

&pwm {
status = "okay";
divider-frac-4 = <15>;
divider-int-4 = <255>;
};

&adc {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};

channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};

channel@2 {
reg = <2>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
};
};

&flash0 {
partitions {
user_sketch: partition@e0000 {
reg = <0x0E0000 0x20000>;
};
};
};
5 changes: 5 additions & 0 deletions variants/rpi_pico_rp2040/variant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi
*
* SPDX-License-Identifier: Apache-2.0
*/