10 Default/standard mode
sys64738 edited this page 2021-09-25 12:01:28 +00:00

The default/standard mode, mode 1, exposes various interfaces.

Pinout

Raspberry Pico

Pin number Usage Usage Pin number
GP0 stdio UART TX VBUS
GP1 stdio UART RX VSYS
GND <ground> <ground> GND
GP2 SWCLK / TCK 3V3 EN
GP3 SWDIO / TMS 3V3 OUT
GP4 TDI ADC VREF
GP5 TDO / SWO GP28 / ADC2
GND <ground> <ground> GND / AGND
GP6 nTRST GP27 / ADC1
GP7 nRESET GP26 / ADC0
GP8 UART TX RUN
GP9 UART RX (1-wire, TODO) GP22
GND <ground> <ground> GND
GP10 UART CTS SCL GP21
GP11 UART RTS SDA GP20
GP12 MISO GP19
GP13 nCS GP18
GND <ground> <ground> GND
GP14 SCLK GP17
GP15 MOSI GP16
<end> <bottom> <bottom> <end>

Functions

UART

The UART interface allows one to interact with another device over a UART port, using a USB-CDC device (/dev/ttyACMx). Baudrate and other line coding settings are applied from the settings from the USB-CDC host, and thus require no special configuration tool.

It is possible to enable hardware flow control (using CTS and RTS lines), it can be enabled or disabled using dpctl uart-cts-rts.

JTAG and SWD

The device exposes CMSIS-DAP functionality over a USB HID interface, which can be used for JTAG or SWD debugging. No special configuration is required to use it.

In SWD mode, the pin mapping is entirely as with the standard Picoprobe setup, as described in Chapter 5 and Appendix A of Getting Started with Raspberry Pi Pico. It has additional experimental SWO support on the TDO/SWO pin, but has not been properly tested yet.

In JTAG mode, TCK and TMS have the same pins as SWCLK and SWDIO, respectively, TDI and TDO are on the next two consecutive free pins.

Note that, after having used JTAG mode, the device has to be power-cycled in order to use SWD mode again. This is a known bug.

In your OpenOCD flags, use -f interface/cmsis-dap.cfg. Default transport is JTAG, if OpenOCD doesn't specify a default to the probe. (OpenOCD usually defaults to SWD in most cases.)

SPI

The SPI interface can be used in two ways: using a serprog USB-CDC interface, mostly useful for interacting with SPI flash chips, and a kernel module, for generic SPI operations, though the Linux spidev interface.

For Serprog, use the following flashrom options (if /dev/ttyACM1 is the USB serial device on your machine corresponding to the Serprog CDC interface of the Pico):

flashrom -c <flashchip> -p serprog:dev=/dev/ttyACM1:115200 <rest of the read/write cmd>

Different serial speeds can be used, too. Serprog support is techincally untested, as in it does output the correct SPI commands as seen by my logic analyzer, but I don't have a SPI flash chip to test it on.

I2C

I2C is exposed only through a Linux kernel module, which can then be used by standard Linux I2C tools (such as utilities from the i2c-tools package, eg. i2cget, i2cset, i2cdetect). The i2c-dev module needs to be loaded for this to work.

Using i2cdetect -l, you should be able to see which I2C device belongs to the tool:

$ sudo i2cdetect -l
[...]
i2c-1	i2c       	i915 gmbus dpb                  	I2C adapter
i2c-8	i2c       	Radeon i2c bit bus 0x95         	I2C adapter
i2c-15	i2c       	dragonprobe-i2c-1-1:1.0             I2C adapter
i2c-6	i2c       	Radeon i2c bit bus 0x93         	I2C adapter
i2c-13	i2c       	AUX C/DDI C/PHY C               	I2C adapter

Temperature sensor

If the board/MCU has a temperature sensor, it is made available as a Linux hwmon kernel module, making the output available for use in lm_sensors output.

Additionally, it can also be configured to appear on the device's I2C bus as an emulated I2C device, pretending to be a JC42-compliant temperature sensor (more precisely, the Microchip MCP9808). This can be achieved using dpctl tempsensor (with BUSNUM the number from the above i2cdetect -l output):

$ ./dpctl.sh tempsensor --set 0x18     # need to give it an address first
$ sudo modprobe jc42
$ # now tell the jc42 module that the device can be found at this address
$ echo "jc42 0x18" | sudo tee /sys/bus/i2c/devices/i2c-BUSNUM/new_device
$ sudo sensors                               # it should show up now:
jc42-i2c-BUSNUM-18
Adapter: dragonprobe-i2c at bus 001 device 032
temp1:        +23.1°C  (low  = -20.0°C)
                       (high = +75.0°C, hyst = +75.0°C)
                       (crit = +80.0°C, hyst = +80.0°C)

Temperature readout may be a bit higher than the ambient temperature.

1-wire

This part is still TODO