RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

boards/rpi-pico: add support

Open tprrt opened this issue 4 years ago • 29 comments

Description

Add the support for the mcu RP2040 as weel as the Raspberry-Pi Pico board.

Raspberry Pi Pico is a low-cost, high-performance microcontroller board with flexible digital interfaces. Key features include:

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
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
26 × multi-function GPIO pins
2 × SPI, 2 × I2C, 2 × UART, 3 × 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

Useful links

https://www.raspberrypi.org/blog/raspberry-pi-silicon-pico-now-on-sale https://www.raspberrypi.org/documentation/pico/getting-started/ https://raspberrypi.github.io/pico-sdk-doxygen/index.html

tprrt avatar Jan 21 '21 08:01 tprrt

See #16609

aabadie avatar Jul 05 '21 14:07 aabadie

Maybe we can keep the issue open a bit to sync who's working on which feature

maribu avatar Jul 14 '21 17:07 maribu

  • [x] periph_timer: @fabian18 is working on this, https://github.com/RIOT-OS/RIOT/pull/16627 is already in pretty good shape
  • [x] DMA: @maribu is working on a HAL for memory to memory transfers (that should also be possible to implement for other MCUs) and some low level helper functions that should aid other RPx0xx peripheral drivers in implementing transfers from and to memory mapped I/O
  • [x] periph_uart: Basic support is upstream, @maribu is working on DMA support as a test use case
  • [x] periph_spi: See #19440 by @fengelhardt
  • [ ] `periph_i2c: ?
  • [x] periph_adc: See #19516 (@dylad)
  • [x] periph_pwm: See #20473 (@dylad)
  • [ ] periph_pm: ?
  • [ ] periph_usb: ?
  • [x] periph_pio: I think @fabian18 did take a look into it. It certainly is one of the more interesting features of the MCU, IMO.

maribu avatar Jul 14 '21 18:07 maribu

I have tried to flash RPI-pico using uf2conv programmer, using the command:

make BOARD=rpi-pico PROGRAMMER=uf2conv flash

Unfortunately, nothing happened after a successful compilation, linking, and coping UF2 file. After some inspection, I found that UF2 file generated by uf2conv program is incompatible with RPI-pico UF2 bootloader. Everything worked fine when I converted the generated elf file using elf2uf2 tool from pico-SDK and manually copied it to the flash. After some investigation, I detect minor changes in the each UF2 block header between images generated by uf2conv and elf2uf2. If details are needed, I could provide them.

Currently, after some hardcoded changes in RIOT makefiles, I could program the board using elf2uf2 conversion tool (instead of uf2conv) without any problems.

My RPI-pico is using an older RP2-B1 chip. If this problem appears in the most recent RP2-B2 chip version (unfortunately, I have no access to this version) I could add elf2uf2 tool to RIOT code.

krzysztof-cabaj avatar Dec 03 '21 15:12 krzysztof-cabaj

Is anybody working on enhancing this? there seem to be some missing peripherals …

smurfix avatar May 03 '22 06:05 smurfix

Is anybody working on enhancing this? there seem to be some missing peripherals …

Any unassigned peripheral is probably waiting to be implemented. Right now, I have more important work to do, than to continue to implement PIO support. Do you require any particular peripheral, or are you asking in general?

fabian18 avatar May 03 '22 12:05 fabian18

Besides PIO, ADC support would be nice to have, at least for my current project.

smurfix avatar May 03 '22 16:05 smurfix

I am working on SPI support right now. I can maybe add some more, it seems not that difficult.

fengelhardt avatar Mar 21 '23 09:03 fengelhardt

I've started to work on an ADC driver for this MCU.

dylad avatar Apr 22 '23 16:04 dylad

periph_pwm is my next target.

dylad avatar Apr 28 '23 19:04 dylad

I'm new here. Can I add i2c?

MacT900 avatar Sep 20 '23 14:09 MacT900

Sure, go ahead! Currently I2C is implemented via PIO, but afaik there is also a native I2C peripheral in the RP2040

benpicco avatar Sep 20 '23 14:09 benpicco

yes there is :-) And @fabian18 already has already created the stubs where it would call to either PIO or native I2C implementation.

Thanks for picking this up :-)

maribu avatar Sep 20 '23 18:09 maribu

Can I ask questions here or should I ask in forum? How and from what I create branch or pull request?

MacT900 avatar Sep 22 '23 01:09 MacT900

If you have a question about something related to RP2040 (hardware or software). You can ask it here. Otherwise, if you have questions about RIOT itself, or something else, it would be better to go to the forum. (This way this issue can focus on RP2040 only).

I strongly suggest you to have a look at a few entries in our wiki regarding RIOT development and contribution: How to make a pull request Contribution guidelines Coding Conventions

Feel free to join us on Matrix, we might also help you there.

dylad avatar Sep 22 '23 07:09 dylad

I'm currently doing a bachelors degree level project and intend to check some items off this list - looking at starting with pwm or i2c, then pm, usb and pio if there's no existing implementation for that. Posting here to ask what the current state of these features are so I don't try and do something that someone else is already doing :)

studiosoftdev avatar Oct 30 '23 09:10 studiosoftdev

I have the periph_pwm almost ready. Just need to do some testing on my side. Don't waste time on it ;)

dylad avatar Oct 31 '23 08:10 dylad

Hi, I'm back from little break. Should I add an option to use I2C as a slave and where I can find info about I2C drive strength?

MacT900 avatar Feb 17 '24 18:02 MacT900

Hi @MacT900, In the current state, RIOT doesn't support I2C slave. There is discussion about this here Regarding I2C drive strength, you could either set it to a compile-time default value in periph_cpu.h or create a special field in the I2C configuration structure defined in periph_conf.h. The current I2C API doesn't handle pull strength selection in the current state.

dylad avatar Feb 22 '24 13:02 dylad

periph_pwm support was just merged.

dylad avatar Mar 19 '24 12:03 dylad

I will give periph_usbus a try.

fengelhardt avatar Mar 23 '24 10:03 fengelhardt

I will give periph_usbus a try.

That's nice ! I have some experience with this, so don't hesitate to ask if you need help or have any questions.

dylad avatar Mar 23 '24 14:03 dylad

I have my periph_usbus code almost ready. However, I have doubts if I understood correctly what the two event handlers should do, and what should happen in the ISR and in the xmit functions.

Maybe I could push my code as a WIP Pull Request to clarify?

The code is compiling but not working at all. I just ordered a Black Magic Probe for debugging just in case :smile:

fengelhardt avatar Aug 18 '24 09:08 fengelhardt