Skip to content
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

RASPBERRYPI: Add support for RP2040 MCU #14488

Closed
wants to merge 58 commits into from

Conversation

facchinm
Copy link
Contributor

Summary of changes

This PR introduces a new target, RaspberryPi's RP2040 microcontroller.
The technical specifications are:

  • Dual core cortex-m0+ @ 120 Mhz
  • 264KB RAM
  • External flash with XIP

Impact of changes

Supported features:

ANALOGIN
FLASH
I2C
I2CSLAVE
INTERRUPTIN
PWMOUT"
SERIAL
SERIAL_FC
SPI
USTICKER
WATCHDOG
USBDEVICE
RESET_REASON

Not yet supported:

RTC
LPTICKER
PIO (an IP specific for the chip, which require some extra tooling to be properly supported)

Migration actions required

Documentation

This porting is based on https://github.com/raspberrypi/pico-sdk with minimal patches applied (should make it easier to update to new releases)
https://datasheets.raspberrypi.org/rp2040/rp2040-datasheet.pdf


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

Will be provided soon

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@pennam @0xc0170


@mergify mergify bot added the needs: work label Mar 30, 2021
@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Mar 30, 2021
@ciarmcom
Copy link
Member

@facchinm, thank you for your changes.
@0xc0170 @ARMmbed/mbed-os-maintainers please review.

@ciarmcom ciarmcom requested review from 0xc0170 and a team March 30, 2021 11:00
@mergify mergify bot removed the needs: review label Apr 6, 2021
@WestfW
Copy link

WestfW commented Apr 12, 2021

Should the link step be using "--specs=nano.specs" as well as "--specs=nosys.specs" ? My reading indicates that they do work together, and an experiment with just that change appears to work, and cuts ~20k off the binary size.

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 21, 2021

Should the link step be using "--specs=nano.specs" as well as "--specs=nosys.specs" ? My reading indicates that they do work together, and an experiment with just that change appears to work, and cuts ~20k off the binary size.

nano lib is selected if C standard lib is set to small. nosys.specs are default linker option. This board can support small standard lib.

@ciarmcom ciarmcom added stale Stale Pull Request and removed stale Stale Pull Request labels Sep 3, 2021
@noonfom
Copy link

noonfom commented Sep 9, 2021

Are you going to add FEATURE_BLE to the NANO_RP2040_CONNECT's JSON description?

@ciarmcom ciarmcom added stale Stale Pull Request and removed stale Stale Pull Request labels Sep 10, 2021
@ciarmcom ciarmcom added stale Stale Pull Request and removed stale Stale Pull Request labels Sep 18, 2021
@ciarmcom ciarmcom added the stale Stale Pull Request label Sep 26, 2021
@0xc0170 0xc0170 removed the stale Stale Pull Request label Sep 29, 2021
@WestfW
Copy link

WestfW commented Oct 28, 2021

None of the various APIs (PWM, Serial, I2C, SPI) return the pins to GPIO mode when they are turned off. (actually, I don't see ANY code to turn off I2C or SPI.)
See https://forum.arduino.cc/t/digitalwrite-does-not-work-after-analogwrite-on-rp2040-boards/
I guess theoretically, this should be done in digitalWrite() and digitalRead() for compatibility with older boards (where that would automatically turn off PWM, for example), but that might cause problems for MBED.
It should at least be done in pinMode() and the _free() functions that exist.

@mergify
Copy link

mergify bot commented Nov 15, 2021

This PR cannot be merged due to conflicts. Please rebase to resolve them.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 16, 2022

Should this pull request still be opened?

@Arvind-Srinivasan
Copy link

So is there a plan to merge this PR in? What is left to get this target added in?

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 3, 2022

@facchinm I am closing this pull request, the best would be to open a new one with up to date information.

@0xc0170 0xc0170 closed this Aug 3, 2022
@mergify mergify bot removed needs: work release-type: patch Indentifies a PR as containing just a patch labels Aug 3, 2022
@willianpaixao
Copy link

@facchinm what's left to implement? If it's just a git conflict case I can fix them.

@facchinm
Copy link
Contributor Author

facchinm commented Aug 3, 2022

@willianpaixao There should be nothing left to implement but tests are not passing due to some cmake incompatibilities with the way we use to ignore some sdk folders.

@willianpaixao
Copy link

@facchinm could you write more about those problems? I could try to tackle them, but need some context.

@facchinm
Copy link
Contributor Author

facchinm commented Aug 3, 2022

@pennam do you still have some logs of the compliance test failures?

@pennam
Copy link
Contributor

pennam commented Aug 3, 2022

After applying this patch i recovered from my working directory:

diff --git a/targets/targets.json b/targets/targets.json
index 6985f4346f..879558d676 100644
--- a/targets/targets.json
+++ b/targets/targets.json
@@ -8363,7 +8363,12 @@
     },
     "RP2040": {
         "inherits": ["Target"],
+        "mbed_rom_start": "0x10000000",
+        "mbed_rom_size": "0x1000000",
+        "mbed_ram_start": "0x20000000",
+        "mbed_ram_size": "0x42000",
         "components_add": ["FLASHIAP"],
+        "device_name": "RP2040",
         "core": "Cortex-M0+",
         "supported_toolchains": ["GCC_ARM"],
         "extra_labels": [
@@ -8396,6 +8401,7 @@
     },
     "NANO_RP2040_CONNECT": {
         "inherits": ["RP2040"],
+        "bootloader_supported": true,
         "macros_add": [
             "PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1",
             "PICO_NO_BINARY_INFO=1",

Running mbed test gives this output:
test.log

@multiplemonomials
Copy link
Contributor

multiplemonomials commented Jul 9, 2023

Just wanted to provide an update, @JohnK1987 and I are now working on an updated version of this PR for the Mbed Community Edition project (linked above). Currently it is able to build and work for basic projects, though some Mbed tests are still not passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet