Raspberry Pi Pico (BBE)

Overview

This is a set of Bridle’s board extensions (BBE) to the original Zephyr upstream board Raspberry Pi Pico with some adaptions and improvement on Twister, Kconfig and Devicetree level.

List of extensions

Board YAML

  • add the missing features that this board supports and that Twister tests might depends on:

    • rpipico_gpio

    • rpipico_i2c

    • rpipico_spi

    • rpipico_serial

    • usbd

Kconfig

  • deactivate self powered USB explicitly and set the maximum of electrical current consumption to 500㎃:

    Raspberry Pi Pico and Pico W

    Kconfig.defconfig
    config CDC_ACM_SERIAL_SELF_POWERED
    	default n
    	depends on USB_DEVICE_STACK_NEXT && USBD_CDC_ACM_CLASS
    
    config CDC_ACM_SERIAL_MAX_POWER
    	default 250 if BOARD_RPI_PICO		# 500mA
    	depends on USB_DEVICE_STACK_NEXT && USBD_CDC_ACM_CLASS
    
  • change log level only in case of use the native USB device port raspberrypi,pico-usbd with CDC-ACM UART zephyr,cdc-acm-uart as Zephyr console:

    Raspberry Pi Pico and Pico W

    Kconfig.defconfig
    # Workaround for not being able to have commas in macro arguments
    DT_CHOSEN_Z_CONSOLE := zephyr,console
    DT_COMPAT_Z_CDC_ACM_UART := zephyr,cdc-acm-uart
    DT_COMPAT_RPIPICO_USB := raspberrypi,pico-usbd
    
    # Macros to shorten Kconfig expressions
    DT_CHOSEN_CONSOLE_NODE := $(dt_chosen_path,$(DT_CHOSEN_Z_CONSOLE))
    DT_CHOSEN_CONSOLE_PARENT := $(dt_node_parent,$(DT_CHOSEN_CONSOLE_NODE))
    
    if BOARD_RPI_PICO && \
    	$(dt_chosen_enabled,$(DT_CHOSEN_Z_CONSOLE)) && \
    	$(dt_compat_on_bus,$(DT_COMPAT_Z_CDC_ACM_UART),usb) && \
    	$(dt_node_has_compat,$(DT_CHOSEN_CONSOLE_PARENT),$(DT_COMPAT_RPIPICO_USB))
    
    # Logger cannot use itself to log
    choice USBD_CDC_ACM_LOG_LEVEL_CHOICE
    	default USBD_CDC_ACM_LOG_LEVEL_OFF
    	depends on LOG && USB_DEVICE_STACK_NEXT && USBD_CDC_ACM_CLASS
    endchoice
    
    # Set USB log level to error only
    choice USBD_LOG_LEVEL_CHOICE
    	default USBD_LOG_LEVEL_ERR
    	depends on LOG && USB_DEVICE_STACK_NEXT && USBD_CDC_ACM_CLASS
    endchoice
    
    # Set UDC driver log level to error only
    choice UDC_DRIVER_LOG_LEVEL_CHOICE
    	default UDC_DRIVER_LOG_LEVEL_ERR
    	depends on LOG && USB_DEVICE_STACK_NEXT && USBD_CDC_ACM_CLASS
    endchoice
    
    endif # zephyr,cdc-acm-uart
    

Devicetree

  • set default entries for model and compatible of the boards:

    Raspberry Pi Pico

    rpi_pico_rp2040_bbe.dts
    / {
    	model = "Raspberry Pi Pico @ UART Concole (BBE)";
    	compatible = "raspberrypi,rpi-pico",
    		     "raspberrypi,rpi-pico-bbe",
    		     "raspberrypi,rpi-pico-uartcons",
    		     "raspberrypi,rpi-pico-uartcons-bbe";
    
    };
    

    Raspberry Pi Pico - MCUboot

    rpi_pico_rp2040_mcuboot_bbe.dts
    / {
    	model = "Raspberry Pi Pico - MCUboot @ UART Concole (BBE)";
    	compatible = "raspberrypi,rpi-pico-mcuboot",
    		     "raspberrypi,rpi-pico-mcuboot-bbe",
    		     "raspberrypi,rpi-pico-mcuboot-uartcons",
    		     "raspberrypi,rpi-pico-mcuboot-uartcons-bbe";
    
    };
    

    Raspberry Pi Pico W

    rpi_pico_rp2040_w_bbe.dts
    / {
    	model = "Raspberry Pi Pico W @ UART Concole (BBE)";
    	compatible = "raspberrypi,rpi-pico-w",
    		     "raspberrypi,rpi-pico-w-bbe",
    		     "raspberrypi,rpi-pico-w-uartcons",
    		     "raspberrypi,rpi-pico-w-uartcons-bbe";
    
    };
    

    Raspberry Pi Pico W - MCUboot

    rpi_pico_rp2040_w_mcuboot_bbe.dts
    / {
    	model = "Raspberry Pi Pico W - MCUboot @ UART Concole (BBE)";
    	compatible = "raspberrypi,rpi-pico-w-mcuboot",
    		     "raspberrypi,rpi-pico-w-mcuboot-bbe",
    		     "raspberrypi,rpi-pico-w-mcuboot-uartcons",
    		     "raspberrypi,rpi-pico-w-mcuboot-uartcons-bbe";
    
    };
    
  • add the Bridle specific edge connecor binding raspberrypi,pico-header-r3

    Raspberry Pi Pico and Pico W

    rpipico_r3_connector.dtsi
    / {
    	rpipico_header: pico-connector-r3 {
    		compatible = "raspberrypi,pico-header-r3";
    		#gpio-cells = <2>;
    		gpio-map-mask = <0xffffffff 0xffffffc0>;
    		gpio-map-pass-thru = <0 0x3f>;
    		gpio-map = <RPIPICO_HEADER_R3_D0 0 &gpio0 0 0>,		/* GP0 */
    			   <RPIPICO_HEADER_R3_D1 0 &gpio0 1 0>,		/* GP1 */
    			   <RPIPICO_HEADER_R3_D2 0 &gpio0 2 0>,		/* GP2 */
    			   <RPIPICO_HEADER_R3_D3 0 &gpio0 3 0>,		/* GP3 */
    			   <RPIPICO_HEADER_R3_D4 0 &gpio0 4 0>,		/* GP4 */
    			   <RPIPICO_HEADER_R3_D5 0 &gpio0 5 0>,		/* GP5 */
    			   <RPIPICO_HEADER_R3_D6 0 &gpio0 6 0>,		/* GP6 */
    			   <RPIPICO_HEADER_R3_D7 0 &gpio0 7 0>,		/* GP7 */
    			   <RPIPICO_HEADER_R3_D8 0 &gpio0 8 0>,		/* GP8 */
    			   <RPIPICO_HEADER_R3_D9 0 &gpio0 9 0>,		/* GP9 */
    			   <RPIPICO_HEADER_R3_D10 0 &gpio0 10 0>,	/* GP10 */
    			   <RPIPICO_HEADER_R3_D11 0 &gpio0 11 0>,	/* GP11 */
    			   <RPIPICO_HEADER_R3_D12 0 &gpio0 12 0>,	/* GP12 */
    			   <RPIPICO_HEADER_R3_D13 0 &gpio0 13 0>,	/* GP13 */
    			   <RPIPICO_HEADER_R3_D14 0 &gpio0 14 0>,	/* GP14 */
    			   <RPIPICO_HEADER_R3_D15 0 &gpio0 15 0>,	/* GP15 */
    			   <RPIPICO_HEADER_R3_D16 0 &gpio0 16 0>,	/* GP16 */
    			   <RPIPICO_HEADER_R3_D17 0 &gpio0 17 0>,	/* GP17 */
    			   <RPIPICO_HEADER_R3_D18 0 &gpio0 18 0>,	/* GP18 */
    			   <RPIPICO_HEADER_R3_D19 0 &gpio0 19 0>,	/* GP19 */
    			   <RPIPICO_HEADER_R3_D20 0 &gpio0 20 0>,	/* GP20 */
    			   <RPIPICO_HEADER_R3_D21 0 &gpio0 21 0>,	/* GP21 */
    			   <RPIPICO_HEADER_R3_D22 0 &gpio0 22 0>,	/* GP22 */
    			   <RPIPICO_HEADER_R3_A0 0 &gpio0 26 0>,	/* ADC0 / GP26 */
    			   <RPIPICO_HEADER_R3_A1 0 &gpio0 27 0>,	/* ADC1 / GP27 */
    			   <RPIPICO_HEADER_R3_A2 0 &gpio0 28 0>;	/* ADC2 / GP28 */
    	};
    };
    
  • add the Bridle specific interface labels:

    • rpipico_serial: &pico_serial {};

    • rpipico_spi: &pico_spi {};

    • rpipico_spi0: &pico_spi0 {};

    • rpipico_spi1: &pico_spi1 {};

    • rpipico_i2c: &pico_i2c {};

    • rpipico_i2c0: &pico_i2c0 {};

    • rpipico_i2c1: &pico_i2c1 {};

  • enable the RP2040 SoC reset controller bindet as raspberrypi,pico-reset

    Raspberry Pi Pico and Pico W

    rpipico_r3.dtsi
    &reset {
    	status = "okay";
    };
    
  • prepare the RP2040 SoC SPI1 controller bindet as raspberrypi,pico-spi with default raspberrypi,pico-pinctrl and clock-frequency = <DT_FREQ_M(8)>; properties, but explicitly set this to disabled status

    Raspberry Pi Pico and Pico W

    rpipico_r3-spi1.dtsi
    &spi1 {
    	status = "disabled";
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-names = "default";
    	clock-frequency = <DT_FREQ_M(8)>;
    };
    
    rpipico_r3-pinctrl.dtsi
    &pinctrl {
    	spi1_default: spi1_default {
    		group1 {
    			pinmux = <SPI1_CSN_P9>, <SPI1_SCK_P10>, <SPI1_TX_P11>;
    		};
    		group2 {
    			pinmux = <SPI1_RX_P12>;
    			input-enable;
    		};
    	};
    };