RP2: Overclock or CPU_MHZ as a board config option
For PicoSystem we shipped a port of MicroPython that clocks the RP2040 to 250MHz at 1.2v (up from the stock 133MHz 1.1v settings) and have (short of needing to apply the slight overvolt in response to some units not being stable) generally seen these settings to be stable and safe. I accomplished this by maintaining a fork full of hacks where I've modified main.c :grimacing:
Many RP2040-based projects leveraging MicroPython could probably benefit from this same overclock, particularly if the manufacturers are happy to support boards at these speeds.
As such I'd like to propose a board config approach to setting CPU frequency and overvolt, with a view to supporting this in the RP2 port at first and perhaps expanding to other boards (we've encountered MCUs that are ostensibly one speed, but get a manufacturer certified OC frequency later).
This is part of a multi-step process to untie all the hacks I needed to implement for PicoSystem, justify their existence and bring them upstream for the benefit of everyone.
It also seems a shame to leave that 2x+ speedup on the table.
- What settings are common across MCUs for achieving overclock? I guess CPU_FREQ and VOLTAGE perhaps, but the latter could be derived from the former in most cases
- Is there anywhere in the MicroPython codebase where assumptions are made about CPU frequency that this would horribly break?
- Would it be appropriate to configure an "Overclocked Pico" board variant, for those who want to opt in to more performance?
Raspberry Pi Pico2 W - Wifi fails to start if CPU is overclocked
Port, board and/or hardware
RPI_PICO_2_W
MicroPython version
MicroPython v1.25.0-preview.307.g4364d9411 on 2025-02-23; Raspberry Pi Pico 2 W with RP2350
Reproduction
Save the following code onto the Pico 2 W and run it with either CPU_FREQ = 300_000_000 or CPU_FREQ = 150_000_000 uncommented.
When using the overclocked frequency, the following error is printed and the access point is not available to connect to: [CYW43] Failed to start CYW43
When using the default frequency the access point can be connected to and no errors are printed
import machine
import network
"""
When overclocked we get
[CYW43] Failed to start CYW43
When using default CPU frequency
the wifi starts fine
"""
CPU_FREQ = 300_000_000 # overclocked
#CPU_FREQ = 150_000_000 # default
machine.freq(CPU_FREQ)
wifi = network.WLAN(network.WLAN.IF_AP)
wifi.config(
ssid="pico2w_ap",
channel=10,
security=network.WLAN.SEC_OPEN,
)
wifi.active(True)
Expected behaviour
WiFi should work if the CPU is overclocked
Observed behaviour
When the CPU is overclocked, the wireless card firmware does not appear to initialize correctly:
[CYW43] Failed to start CYW43
Additional Information
My testing setup has 2 I2C devices connected: an OLED display GP0 & GP1 and a battery-backed realtime clock on GP2 & GP3. The code above does not initialize these devices, so I don't think their presence should have any impact; it looks like simply changing the CPU frequency is enough.
Doing a little trial-and-error changing the frequencies in the script above it looks like 270MHz is the upper limit of what the wifi can handle. Is this a known limitation of the firmware?
Code of Conduct
Yes, I agree