-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
rp2: Add new port to Raspberry Pi's RP2040 microcontroller #6791
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
Conversation
Can't build it: Error
It's the include path to lib/tinyusb/src, which is missing. Where to add? |
OK. Adding that path as a hot fix to flags.make, the next build error comes up:
|
I was able to build this -- all I did was run:
You can probably avoid the full recursive clone (also note that lib/pico-sdk itself has tinyusb as a submodule) but that's the easiest thing that works. |
Fails: I can update the submodules w/o the --recursive option. |
It looks like the pico-sdk has the tinyusb submodule set to use an ssh (rather than http) URL. They just fixed this a couple of hours ago upstream. raspberrypi/pico-sdk@493ed00 As a temporary workaround (until this PR is updated to change the revision for the pico-sdk submodule), you can do
(Or set up ssh auth for github) |
No joy. I wait until this PR has been fixed (and the boards arrive). |
The rp2 port now builds under CI. If you look at the Hopefully we can eventually use the local tinyusb (ie |
Thanks. Now building works. And yes - ssh auth for github is just another PITA to come. |
Works and builds run on the target. Very fine port! Which options are required for mpy-cross? I can embed files as frozen bytecode, but for manually compiled files the device complains about an incompatible version. |
Ah, it's because |
Thanks. Now it works. |
ret = i2c_read_blocking(self->i2c_inst, addr, buf, len, nostop); | ||
} else { | ||
if (len <= 2) { | ||
// Workaround issue with hardware I2C not accepting short writes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an rp2040 errata or pico-sdk bug for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure... I got this from inspecting the SDK's behaviour. I don't think it's a bug, just a limitation of the hardware.
The CMake build system added for this port isn't quite at feature parity with the Makefile approach used elsewhere- As near as I can tell, the fixes here are missing - https://github.com/raspberrypi/micropython/pull/3 - and user C/C++ module support in general is lacking. IE I cannot:
With the fixes in my PR, and the additions to the CMake build system in the feature branch that it's targeting... I can. And, in fact, do: Edit: In fact, porting MicroPython to CMake seems like rather a more elaborate exercise than simply including the relevant Pico SDK files into a regular MicroPython Makefile so that there remains only one way of including/building USER_C_MODULES (which is already a documented process). Am I missing something here? CircuitPython seem to be taking this approach - https://github.com/adafruit/circuitpython/blob/45b3c9ae4213008da092d5bb35e8602e1e90bca2/ports/raspberrypi/Makefile#L159-L184 |
Referring to raspberrypi/micropython/issues/9 - the API for the machine.Pin class is different in this port than in the standard API. Given the API at https://docs.micropython.org/en/latest/library/machine.Pin.html (specifically the methods
Presumably this is deliberate - what's the rationale? Will this change be documented somewhere? As of this moment the only way to realize this change has occurred is to stumble into it and then read the source code trying to find out why the API functions are missing, unless I'm missing something obvious (always a possibility) |
pull() and mode() are supported in the stm32 port (only). They return the respective pull and mode setting. Setting of pull and mode had to be done with init() or as part of the object construction. |
Fair enough. It sounds like this might be a documentation/consistency issue - why doesn't the website list that those functions are only for STM32? (Also, I note that it doesn't appear that it's only the ST family that use these, the ESP chips also appear to use |
More undocumented incompatibilities in the machine module doesn't sound good :-( |
Port specific variation is a can of worms for those of us who try to write cross-platform code. The purpose of the machine module (as I understand it) was to facilitate port-independence. |
Another hiccups I ran into: |
I don’t know how useful or widespread things like ure or ujson are in the micro world, but I’m including them both in our build at the request of a user. It looks like there’s a fair amount of headroom and that module choice is pretty conservative. From a vendor perspective the 2MB flash on Pico is already very conservative and I don’t see many RP2040-based boards shipping with less. Indeed they seem to be targeting 16MB and at least some of these (probably ours) will be compatible with an unmodified MicroPython binary. |
Very (IMO). For object serialisation ujson uses less RAM and is more efficient than pickle. From forum posts I would say that ure is also widely used. |
2b4a099
to
c696876
Compare
Signed-off-by: Damien George <damien@micropython.org>
This returns a reference to the globals dict associated with the function, ie the global scope that the function was defined in. This attribute is read-only but the dict itself is modifiable, per CPython behaviour. Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Adds a new compile-time option MICROPY_EMIT_THUMB_ARMV7M which is enabled by default (to get existing behaviour) and which should be disabled (set to 0) when building native emitter support (@micropython.native) on ARMv6M targets.
Based on change made by Graham Sanderson. Signed-off-by: Damien George <damien@micropython.org>
Hmm... not at the moment, I'd have to set something up. It would be good for it to point to a truly stable release version, eg the upcoming v1.14 release, rather than daily (unstable) builds. Would you agree? |
Ping @aivarannamaa also, as he might find a stable link useful for Thonny too? |
Agreed. |
See #6822 for docs clarification of |
I'd rather avoid adding another dependency. Also, I chose to introduce my own web resource for directing Thonny to the recommended MicroPython for Pico (which would be the latest stable unless it is known to have problems in Thonny). |
@aivarannamaa Cool, I didn't realise you already had your own system in place 🙂 (but FYI you'll want to update that to use https://github.com/micropython/micropython/releases instead of https://github.com/raspberrypi/micropython/releases once Damien has released v1.14) |
@dpgeorge While I'm waiting for this — since the nightly with the V1.0.1 SDK should fix the GP19 problem — should I pull in today's nightly build and link to this from the Getting Started page, rather than the UF2 that was build for release day? |
Yes. There's now a v1.14 stable release available which you can link to: https://micropython.org/resources/firmware/rp2-pico-20210202-v1.14.uf2 Did you want that to be a permanent version-agnostic link that automatically pointed to the latest stable, something like micropython.org/resources/firmware/rp2-pico/latest.uf2 ? |
Yes please, that would be optimal. Then I can link to it directly from the "Download UF2" button on the Getting Started page. |
|
Maybe it's even better to set up a redirect or |
Yes that could work. I can do:
|
Yup. That'd work for me I think. |
Ok, the redirect is here: https://micropython.org/download/rp2-pico/rp2-pico-latest.uf2 |
Cool, in Chromium on my Ubuntu laptop that link gives me a |
Thanks @dpgeorge. I've swapped out the link on the Getting Started page and other places to point to that URL. |
The RP2040 is a new microcontroller from Raspberry Pi. See https://www.raspberrypi.org/blog/raspberry-pi-silicon-pico-now-on-sale/ for more information.
This PR adds support for this class of MCUs.
Currently supported features are:
utime
module with sleep, time and ticks functions.uos
module with VFS support.machine
module with the following classes:Pin
,ADC
,PWM
,I2C
,SPI
,SoftI2C
,SoftSPI
,Timer
,UART
,WDT
.rp2
module with programmable IO (PIO) support.See the
ports/rp2/examples/
directory for some example code.The code here appears also at https://github.com/raspberrypi/micropython