RIOT-OS / RIOT

RIOT - The friendly OS for IoT
https://riot-os.org
GNU Lesser General Public License v2.1
4.92k stars 1.99k forks source link

boards/rpi-pico: add support #15822

Open tprrt opened 3 years ago

tprrt commented 3 years ago

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

aabadie commented 3 years ago

See #16609

maribu commented 3 years ago

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

maribu commented 3 years ago
krzysztof-cabaj commented 2 years ago

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.

smurfix commented 2 years ago

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

fabian18 commented 2 years ago

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?

smurfix commented 2 years ago

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

fengelhardt commented 1 year ago

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

dylad commented 1 year ago

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

dylad commented 1 year ago

periph_pwm is my next target.

MacT900 commented 1 year ago

I'm new here. Can I add i2c?

benpicco commented 1 year ago

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

maribu commented 1 year ago

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 :-)

MacT900 commented 1 year ago

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

dylad commented 1 year ago

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.

studiosoftdev commented 11 months ago

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 :)

dylad commented 11 months ago

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

MacT900 commented 8 months ago

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?

dylad commented 8 months ago

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 commented 7 months ago

periph_pwm support was just merged.

fengelhardt commented 7 months ago

I will give periph_usbus a try.

dylad commented 7 months ago

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.

fengelhardt commented 2 months ago

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:

dylad commented 2 months ago

Please go ahead. That's something I can help to polish. No promises on how fast I'll be but that's something I'd like to see merged