Clocks_init() disappeared

I have some code, largely based on routines from the Pi Playground, that sends an RP2040 to sleep until an event wakes it. This needs to stop most of the processor's clocks and restart them later. A year ago my code was working, now it won't compile. After investigation I find that clocks_init() is missing from version 4.0.0 onwards of the board manager 'Raspberry Pi Pico/RP2040/RP2350 by Earle F. Philhower, III'. To demonstrate this, I have made a stub:

void setup() {
  // put your setup code here, to run once:

  //reset clocks
  clocks_init();
}

void loop() {
  // put your main code here, to run repeatedly:
}

This compiles under versions up to 3.9.5 but from 4.0.0 onwards it fails with

C:\Users\Admin\Documents\Arduino\testclock\testclock.ino: In function 'void setup()':
C:\Users\Admin\Documents\Arduino\testclock\testclock.ino:5:5: error: 'clocks_init' was not declared in this scope; did you mean 'lock_init'?
5 |
| ^
| lock_init

exit status 1

Compilation error: 'clocks_init' was not declared in this scope; did you mean 'lock_init'?

How can I fix this?

Install an older version of the board definition. Or find the function code and add it to your project.

Well yes, that's what I'm doing. But it's not a solution, is it? The functionality cannot have disappeared, the author must have provided an alternative.

Why? The author is under no obligation. Some study of the code should show whether the function has been renamed or the code moved into some other function.

You can log an issue here: GitHub · Where software is built.

There might be an explanation if you dig through the releases (and read the release notes). There is mention of a new SDK (whatever that means in this context) with the transition to 4.0.0 and your issue might be a result of that.

Since I have no idea what clocks_init does or what it is part of it is impossible to track down. I did a quick search of the releases docs and had only one hit to do with ADC, does that ring a bell.
Maybe if you posted ALL your code we could refine our searches.

That call was removed from the RPI Pico-SDK in the latest release. There's a header-only shim which your code could manually include to define it, but the best thing for current SDKs is to call runtime_init_clocks().

1 Like

Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.