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

200MHz Clock Support for RP2040 #2814

Open
technoblogy opened this issue Feb 20, 2025 · 9 comments · May be fixed by #2815
Open

200MHz Clock Support for RP2040 #2814

technoblogy opened this issue Feb 20, 2025 · 9 comments · May be fixed by #2815
Labels
enhancement New feature or request

Comments

@technoblogy
Copy link

I see that the latest release of the pico-sdk released yesterday includes the change:

RP2040 has now been certified to run at a system clock of 200Mhz when using a regulator voltage of at least 1.15 volts.

For more details see: pico-sdk 2.1.1

Do you think the next version of your core should make 200MHz the default clock frequency, or remove (Overclocked) from frequencies up to and including 200MHz in the CPU Speed menu?

@technoblogy technoblogy changed the title 200Mhz Clock Support for RP2040 200MHz Clock Support for RP2040 Feb 20, 2025
earlephilhower added a commit that referenced this issue Feb 20, 2025
Fixes #2814

Biggest difference should be default 200MHz clock (133 still available
through the menus) on the RP2040.
@earlephilhower earlephilhower linked a pull request Feb 20, 2025 that will close this issue
@earlephilhower
Copy link
Owner

I wonder if there are any concerns with the flash SPI interface. On the RP2040 it's a function of the SYSCLK AIUI, so bumping SYSCLK up by 50% would speed up the QSPI the same amount. In any case we'll see if it passes CI and some testing locally.

@earlephilhower
Copy link
Owner

....and it doesn't because there is a logic/compile error in SYNC.H. 😭

/home/runner/arduino_ide/hardware/pico/rp2040//pico-sdk/src/rp2_common/hardware_sync/include/hardware/sync.h: In function 'uint32_t disable_interrupts()':
/home/runner/arduino_ide/hardware/pico/rp2040//pico-sdk/src/rp2_common/hardware_sync/include/hardware/sync.h:212:1: error: no return statement in function returning non-void [-Werror=return-type]
  212 | }
      | ^

The function is defined to return a uint32_t but doesn't. It will crash hard on later GCCs (like this one)...

@earlephilhower
Copy link
Owner

Probably going to need to wait for a 2.1.2 to bump, but it is being tracked. raspberrypi/pico-sdk#2309

FWIW 200MHz is in the menus already for folks who want to use it, so no real rush.

@earlephilhower earlephilhower added the enhancement New feature or request label Feb 21, 2025
@dan2wik
Copy link

dan2wik commented Feb 22, 2025

Does setting 200MHz in menus actually bump up the core voltage to the officially verified one?
I noticed overclock voltage mapping was done in #2274
But I looked for the relevant code in main.cpp and also searched the whole repo for 'vreg_set_voltage' but I cannot find where the voltage setting actually occurs.

Have I missed something or is something missing?

@earlephilhower
Copy link
Owner

Good catch. It's kind of a mess in the SDK and I thought it was auto-adjusting, but we need to define SYS_CLK_VREG_VOLTAGE_AUTO_ADJUST in the configuration to get it enabled. runtime_init_clocks

Actually seems just defining the new PICO_USE_FASTEST_SUPPORTED_CLOCK=1 will take care of this and default to 200mhz.

But because we build only a single SDK library for every different F_CPU and use the set_sys_clk() call to set the over/underclock from the app that higher V would still be there even in the nominal 133MHz case.

So it's probably best to move that logic into the core and keep the SDK @ 133MHz and nominal V.

@magy00
Copy link
Contributor

magy00 commented Feb 23, 2025

Maybe also make sure that when the frequency is changed to 153.6/135.6 MHz for I²S that the voltage is always the same (either 1.10 V or 1.15 V)?

@earlephilhower
Copy link
Owner

The SDK logic is only clk==200mhz (i.e. won't touch anything if you run at 180mhz or 201mhz) but the PR I've done will bump things up for any overclock over 133. That should be safe in any case...

#if defined(PICO_RP2040)
// From runtime_init_clocks() to bump up RP2040 V for 200Mhz+ operation
if ((F_CPU > 133000000) && (vreg_get_voltage() < VREG_VOLTAGE_1_15)) {
vreg_set_voltage(VREG_VOLTAGE_1_15);
// wait for voltage to settle; must use CPU cycles as TIMER is not yet clocked correctly
busy_wait_at_least_cycles((uint32_t)((SYS_CLK_VREG_VOLTAGE_AUTO_ADJUST_DELAY_US * (uint64_t)XOSC_HZ) / 1000000));
}
#endif

@earlephilhower
Copy link
Owner

If you want to give #2815 a try, it's at the stage where everything seems to build OK. I've not done much testing other than very basic ones at this point. You'll need to update the pico-sdk repo to point to my fork until the upstream pico-sdk develop branch gets that PR merged.

@magy00
Copy link
Contributor

magy00 commented Feb 25, 2025

It looks to me like I2S::setSysClk() doesn't adjust the voltage according to the frequency (which may be fine, but it may be necessary to document that compiling with 200 MHz uses 1.15 V compared to default 1.10 V for 125 MHz, even though 153.6 MHz or 135.6 MHz will potentially be used).

#if (defined(PICO_RP2040) && (F_CPU != 125000000)) || (defined(PICO_RP2350) && (F_CPU != 150000000))

bool I2S::setSysClk(int samplerate) { // optimise sys_clk for desired samplerate
if (samplerate % 11025 == 0) {
return set_sys_clock_khz(I2SSYSCLK_44_1, false);
}
if (samplerate % 8000 == 0) {
return set_sys_clock_khz(I2SSYSCLK_8, false);
}
return false;
}

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

Successfully merging a pull request may close this issue.

4 participants