earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 and RP2350 boards
GNU Lesser General Public License v2.1
2.02k stars 419 forks source link

Low Power Modes #345

Closed CyberCityCircuits closed 2 years ago

CyberCityCircuits commented 2 years ago

Do you have any plans on implementing the native low power modes that the RP2040?  This would be deeply appreciated.

earlephilhower commented 2 years ago

In the short term I'm unfortunately occupied with other things, but to access the pico-extra sleep functions should be possible with some simple modifications to the core. (This is also for #344)

Basically, you will need to rebuild libpico.a to include the pico_sleep directory and add the proper include path to platform_inc to let the IDE fine the proper headers.

  1. Add the pico_sleep line to the Cmakefile.txt: https://github.com/earlephilhower/arduino-pico/blob/master/tools/libpico/CMakeLists.txt
  2. Rebuild libpico.a by running make-libpico.sh https://github.com/earlephilhower/arduino-pico/blob/master/tools/libpico/make-libpico.sh
  3. Add the pico-extras/pico_sleep path to pl;atform_inc.txt: https://github.com/earlephilhower/arduino-pico/blob/master/lib/platform_inc.txt (the format is a little off but should be obvious)

Restarting the IDE should then give the ability to #include <pico/sleep.h> and call the functions exported there. Note that I have not looked deeply at this and it is in the extras repo so it may not be 100% working from the RPi folks,yet. I have a feeling you'll need to do things like save/restore all active clocks, set which clocks to disable in sleep mode, and make sure I/Os are set to appropriate drive strengths/inputs.

WildkatzGithub commented 2 years ago

Hello, I tried to run make-libpico.sh with GitBash, but don't work. I want to access pico sleep functions, too.

$ ./make-libpico.sh ./make-libpico.sh: line 6: cd: ../../system/arm-none-eabi/bin: No such file or directory ./make-libpico.sh: line 11: cmake: command not found

earlephilhower commented 2 years ago

You'll need to clone the git repo, run the get.py script to fetch the toolchain (your 1st missing exe), and also of course have cmake installed(the 2nd one). It uses the pico-sdk build process, so all the pico-sdk prerequisites are needed.

For cmake, your distro's package manager should have it (apt install cmake or yum install cmake as the case may be...)

WildkatzGithub commented 2 years ago

Thx for help! I have cloned the git repo, ran get.py and installed cmake. & cmake was found by GitBash, but now it hangs around line 12:

./make-libpico.sh: line 12: make: command not found

I can't install the apt or yum package manager as I'm currently using only Windows 10.

Would it be better to use Linux for this?

earlephilhower commented 2 years ago

Would it be better to use Linux for this?

Short answer is, "Yes." Long answer is, "Yeeeeeees." :) WSL will work fine too.

Alternatively, you can see how they build the Pico SDK under Windows. There is a readme in their project, but I never looked at it since I didn't have the need. The build prerequisites they need are what the makelibpico.sh script requires, too.

WildkatzGithub commented 2 years ago

Thank you for showing me these possibilities :) At https://github.com/raspberrypi/pico-playground I read that the use of pico_sleep is not yet stable.

I took current measurements on the Pico yesterday. The Pico needs 15 mA in a simple while loop at 125 MHz and only one core. Without external components and peripherals, of course. If I now set the system clock to 10 MHz, it only needs 1 to 2 mA in the same loop. That is sufficient for my application.

With this I avoid the use of pico_sleep and the known problems like "frozen pico" or "printf () / puts () - not possible" after sleep / dormant.

alfonsoletizia1 commented 2 years ago

@WildkatzGithub how did you succeded in setting the clock to 10 MHz? I tried using platform io, but then it's unusable

WildkatzGithub commented 2 years ago

Hello, you can set the clock to 10 MHz with this code in the Arduino IDE:

include "pico/stdlib.h"

set_sys_clock_khz(10000, true); // Set System clock to 10000 kHz

I've already tried lower clocks, but 10 MHz was the lowest clock speed so far without the Pico getting stuck. Please let me know if you can find a lower clock.

By the way, if the clock is currently set to 10 MHz, the Pico can only be programmed using the button at this point.

sail81 commented 2 years ago

@WildkatzGithub thank you so much for your 10 MHz power saving hint. A great idea indeed. In my application I do some outdoor measurement every minute and send it via LoRa. In between I have 59s delay. The pico is driven by 3 rechargeable AA NiMH batteries. After I saw your post I created this function:

void power_save(uint16_t psinterval){ LoRa.sleep(); delay(2); set_sys_clock_khz(10000, false); // Set System clock to 10 MHz, sys_clock_khz(10000, true); did not work for me delay(2); vreg_set_voltage(VREG_VOLTAGE_0_95); // 0.85V did not work, 0.95V seems pretty stable delay(psinterval); vreg_set_voltage(VREG_VOLTAGE_DEFAULT); // corresponds to 1.10V, not sure if that is really required for 48 MHz delay(2); set_sys_clock_48mhz(); // Set System clock back to 48 MHz to make LoRa work delay(2); LoRa.idle(); }

Now I am testing it since 3 days and it runs stably. I can already tell that the battery voltage drops much slower that before. I should have measured the power consumption before. I will do that once my test is completed. One could play with the voltages, too. Though, I have not yet an idea how much power saving would benefit from that. Let's see.

When checking lower clocks than 10 Mhz did you run more that a delay()?

earlephilhower commented 2 years ago

Looks like this is closed. Unfortunately the Pico SDK sleep modes are unstable per above, but setting a low system clock seems to help at the cost of peripheral(USB) issues.

JudgeBeeb commented 2 years ago

Has anyone managed to get sleep_pico working in the Arduino IDE yet? whenever I try to build libpico.a I get the following errors: ar: stdio.c.obj: not found in archive ar: stdio_usb.c.obj: not found in archive ar: stdio_usb_descriptors.c.obj: not found in archive

DansDesigns commented 1 year ago

Hello, you can set the clock to 10 MHz with this code in the Arduino IDE:

include "pico/stdlib.h"

set_sys_clock_khz(10000, true); // Set System clock to 10000 kHz

I've already tried lower clocks, but 10 MHz was the lowest clock speed so far without the Pico getting stuck. Please let me know if you can find a lower clock.

By the way, if the clock is currently set to 10 MHz, the Pico can only be programmed using the button at this point.

sorry for reviving an old threat but I am wondering if the Pico/rp2040 would stay in the 10Mhz setting after a power cycling or would it revert to the original set frequency in the sketch settings upon reboot?

earlephilhower commented 1 year ago

On reboot the rom and app will set the core to 133mhz until your app changes it again. So you could set the frequency in your setup() if desired and only a short period would be at the higher frequency.

NuclearPhoenixx commented 1 year ago

Looks like this is closed. Unfortunately the Pico SDK sleep modes are unstable per above, but setting a low system clock seems to help at the cost of peripheral(USB) issues.

Is this still the case today? Are there any alternatives to using the native Pico SDK sleep functions that you know of? Like for example the Adafruit SleepyDog lib: https://github.com/adafruit/Adafruit_SleepyDog

ninjampa commented 1 year ago

Hello guys, sorry for bringing up this issue again. I tried to follow the steps that @earlephilhower provided:

In the short term I'm unfortunately occupied with other things, but to access the pico-extra sleep functions should be possible with some simple modifications to the core. (This is also for #344)

Basically, you will need to rebuild libpico.a to include the pico_sleep directory and add the proper include path to platform_inc to let the IDE fine the proper headers.

  1. Add the pico_sleep line to the Cmakefile.txt: https://github.com/earlephilhower/arduino-pico/blob/master/tools/libpico/CMakeLists.txt
  2. Rebuild libpico.a by running make-libpico.sh https://github.com/earlephilhower/arduino-pico/blob/master/tools/libpico/make-libpico.sh
  3. Add the pico-extras/pico_sleep path to pl;atform_inc.txt: https://github.com/earlephilhower/arduino-pico/blob/master/lib/platform_inc.txt (the format is a little off but should be obvious)

Restarting the IDE should then give the ability to #include <pico/sleep.h> and call the functions exported there. Note that I have not looked deeply at this and it is in the extras repo so it may not be 100% working from the RPi folks,yet. I have a feeling you'll need to do things like save/restore all active clocks, set which clocks to disable in sleep mode, and make sure I/Os are set to appropriate drive strengths/inputs.

But, unfortunaly I'm getting this error when I try to compile:

c:/arduino15/packages/rp2040/tools/pqt-gcc/1.4.0-c-0196c06/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe:C:\arduino-sketch-BD4F72D8F8EE93E9B2F4A5F1CE012847\sketch\SLEEP.ino.cpp.o: in functionsleep_run_from_xosc': c:\arduino15\packages\rp2040\hardware\rp2040\2.6.2\pico-extras-master\src\rp2_common\pico_sleep\include\pico/sleep.h:50:undefined reference tosleep_run_from_dormant_source' collect2.exe: error: ld returned 1 exit status Compilation error: Error: 2 UNKNOWN: exit status 1

Looks like it is importing the library (at least this alone does not result in an error anymore) but it is not importing the functions as it should. Testing the solution proposed from step 3 I can succesfully cmake and make the project but there is anything that I should be doing after that? Replacing a CMakeFile in the library with the generated one perhaps?

NuclearPhoenixx commented 1 year ago

@ninjampa The Adafruit SleepyDog Arduino Library now also supports the RP2040 architecture. You can try it if that's what you're looking for.

ninjampa commented 1 year ago

Thank you for the support @Phoenix1747, but the Adafruit SleepyDog Arduino Library currently just perform a sleep_ms, as you can check here. The problem with this solution is that RP2040's sleep_ms executes a NOP in the processor, as you can check in this video, it does not shutdown any peripherals.

NuclearPhoenixx commented 1 year ago

Alright, I see no worries!

metrafonic commented 1 year ago

@ninjampa did you find any solution for getting pico-extras sleep.h functionality or similar?

Dj-EKI commented 1 year ago

In the short term I'm unfortunately occupied with other things, but to access the pico-extra sleep functions should be possible with some simple modifications to the core. (This is also for #344)

Basically, you will need to rebuild libpico.a to include the pico_sleep directory and add the proper include path to platform_inc to let the IDE fine the proper headers.

  1. Add the pico_sleep line to the Cmakefile.txt: https://github.com/earlephilhower/arduino-pico/blob/master/tools/libpico/CMakeLists.txt
  2. Rebuild libpico.a by running make-libpico.sh https://github.com/earlephilhower/arduino-pico/blob/master/tools/libpico/make-libpico.sh
  3. Add the pico-extras/pico_sleep path to pl;atform_inc.txt: https://github.com/earlephilhower/arduino-pico/blob/master/lib/platform_inc.txt (the format is a little off but should be obvious)

Restarting the IDE should then give the ability to #include <pico/sleep.h> and call the functions exported there. Note that I have not looked deeply at this and it is in the extras repo so it may not be 100% working from the RPi folks,yet. I have a feeling you'll need to do things like save/restore all active clocks, set which clocks to disable in sleep mode, and make sure I/Os are set to appropriate drive strengths/inputs.

I have successfully completed all 3 points, but get this error message when compiling. I downloaded pico-extras from Github and copied it to the Arduino15\packages\rp2040\hardware\rp2040\2.7.3\pico-sdk. I copied -iwithprefixbefore/pico-sdk/pico-extras/src/rp2_common/pico_sleep/include to Platform_inc.txt. Did I do something wrong?

c:/users/reder/appdata/local/arduino15/packages/rp2040/tools/pqt-gcc/1.5.0-b-c7bab52/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe: C:\Users\reder\AppData\Local\Temp\arduino-sketch-0DC35D2694194C1647C2F116391771FB\sketch\Pico_HelloWorld.ino.cpp.o: in function `loop':
C:\Users\reder\Documents\Arduino\Pico_HelloWorld/Pico_HelloWorld.ino:124: undefined reference to `sleep_goto_dormant_until_pin'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1
earlephilhower commented 1 year ago

Did you recompile the libpico.a using the make-libpico.sh script before building? The addition of the pico-sleep target in the CMakefile should cause it to include the new source. If that did not work properly, then I'd suggest just cut-n-pasting the function in question to your own code and working from there.

Dj-EKI commented 1 year ago

I ran make-libpico.sh. But what do you mean by building? Should I edit another CMake file? If so, which ones and what do I have to do? As I said, I only did the 3 steps you described. Since it didn't work, I finally ran make-libpico.sh again.

ninjampa commented 1 year ago

@ninjampa did you find any solution for getting pico-extras sleep.h functionality or similar?

Hello @metrafonic,

Well, there is not a supported way of entering a real (regarding power saving) sleep mode. My application at the time was an embedded battery-solar solution (something around uA), so I had to drop the RP2040 in the design.

I just noticed that @Phoenix1747 updated the Adafruit SleepyDog Arduino Library that had a delay function and now has a proper sleep_ms, but I didn't use it, can you test it and put the results in here?

If the RP is mandatory in low power mode in your project, I suggest looking for a solution like this one.

ninjampa commented 1 year ago

I ran make-libpico.sh. But what do you mean by building? Should I edit another CMake file? If so, which ones and what do I have to do? As I said, I only did the 3 steps you described. Since it didn't work, I finally ran make-libpico.sh again.

@Dj-EKI, do you have the logs from make-libpico.sh? Back in the day I had the same problem, and the reason was because make-libpico.sh was not compiling as it should.

NuclearPhoenixx commented 1 year ago

@ninjampa Relating to the Adafruit SleepyDog Arduino Library, the lib doesn't actually enable any deep sleep modes as you might have already read here:

https://github.com/earlephilhower/arduino-pico/issues/345#issuecomment-1320010455

That's good, but it doesn't actually shut down anything. It's still consuming a whole lot of power (relatively) in this mode.

ninjampa commented 1 year ago

@Phoenix1747 Thank you, it was my own comment and I forgot about it.

NuclearPhoenixx commented 1 year ago

Oh yeah, true. Didn't even notice that 😄

Dj-EKI commented 1 year ago

@ninjampa I don't know where the log files are, but I found them here. http://dj-eki.de/Dateien/CMakeFiles.7z

Dj-EKI commented 1 year ago

I managed to implement pico-extras in arduino. I didn't know that I also had to enter something in the cmake file.

  1. Copy pico-extras into the hardware folder of rp2040. %USERPROFILE%\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.0.0
  2. Copy these commands into platform_inc.txt. (Arduino15\packages\rp2040\hardware\rp2040\3.0.0\lib\platform_inc.txt)
    -iwithprefixbefore/pico-extras/src/rp2_common/pico_sleep/include
    -iwithprefixbefore/pico-extras/src/rp2_common/hardware_rosc/include
  3. Enter the following codes in CMakeLists.txt. (Arduino15\packages\rp2040\hardware\rp2040\3.0.0\tools\libpico\CMakeLists.txt) Do not enter twice what is already available.
    
    cmake_minimum_required(VERSION 3.12)

set(PICO_EXTRAS_PATH ../../../pico-extras)

include(pico_sdk_import.cmake) include($ENV{PICO_EXTRAS_PATH}../../pico-extras/external/pico_extras_import.cmake)

in target_link_libraries:

hardware_xosc hardware_rosc hardware_sleep pico_sleep

4. setup_default_uart() does not work with Arduino. That has something to do with "Serial". That's why it has to be commented out.
Arduino15\packages\rp2040\hardware\rp2040\3.0.0\pico-extras\src\rp2_common\pico_sleep\sleep.c

... // Assuming both xosc and rosc are running at the moment if (dormant_source == DORMANT_SOURCE_XOSC) { // Can disable rosc rosc_disable(); } else { // Can disable xosc xosc_disable(); }

// Reconfigure uart with new clocks
//setup_default_uart();

}


5. Run make-libpico.sh. Can also be done with Linux.  (Arduino15\packages\rp2040\hardware\rp2040\3.0.0\tools\libpico\make-libpico.sh)
6. Enter dormant mode with this command.

sleep_run_from_xosc(); sleep_goto_dormant_until_pin(21,1,0);


There are other commands too. See playground.
But sleep_run_from_xosc(); is very important to reduce the current.
After waking up you have to adjust the clock rate again.
SIeeepy commented 1 year ago
  1. Run make-libpico.sh. Can also be done with Linux.

I really want to use the rp2040 low power modes but I don't understand this step. Can someone explain how I can run the make-libpico.sh file on windows?

earlephilhower commented 1 year ago

Does the Windows install of the Pico SDK still install a full MiinGW? If so, then I think you can just run the bash script there. Make sure you're using a full git clone of the tree, and use python3 tools/get.py to install the binaries so the build script can find them.

SIeeepy commented 1 year ago

Thanks. I'm familiar with Arduino but I struggle with Raspi/Linux/Python subjects and terminology.

I've learned now that sh files are Linux related and also managed to install Git Bash and Python3 and to finally run the make-libpico.sh. But now I've reached the hurdle that already stopped @WildkatzGithub, the error message "./make-libpico.sh: line 12: make: command not found".

@Dj-EKI's wording "Run make-libpico.sh. Can also be done with Linux" gave me hope that there was a way in windows but maybe I misunderstood.

Dj-EKI commented 1 year ago

It is not easy to equip Windows with Linux components. Install Chocolatey. And use this command choco install make it is an important component for Linux. but you will be missing more, so I would recommend you to download Ubuntu from Windows Store. In Ubuntu U can use this command to get all components.

sudo apt update
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential libstdc++-arm-none-eabi-newlib
earlephilhower commented 1 year ago

You can also use MinGW which is what I think the RPI team originally had folks do. But running it all under WSL is probably easier at @Dj-EKI says.

SIeeepy commented 1 year ago

Now it works!! The RP2040 is sleeping peacefully. Thanks @earlephilhower & @Dj-EKI !

If someone has the same issues:

  1. Install a Linux distribution like Ubuntu via Microsoft Store (e.g. Ubuntu 22.04.02)

  2. Open Ubuntu in admin mode and setup user name and a password

  3. Run a command to install cmake, python3 and gcc-arm-none-eabi

    sudo apt update && sudo apt install gcc-arm-none-eabi cmake python3 -y

  4. Guide Ubuntu to the libpico folder an run the make-libpico.sh file

    cd /mnt/c/Users/[YOUR USERNAME]/AppData/Local/Arduino15/packages/rp2040/hardware/rp2040/3.0.0/tools/libpico && ./make-libpico.sh

(edit your directory and user name)

On a side note I'm still not getting near the low sleep power consumption of 180µA promised in the RP2040 datasheet (p. 622). I measured 1.2mA during dormant sleep. It's 20x better then the aktive 23mA consumption before, but why is it still 7x higher than spec? Is this a hardware issue or could I switch off more software-wise?

Hardware: I'm using the tiny Waveshare RP2040 Zero. The schematics don't indicate power hungry components, the rt9013-33 linear regulator seems fine.

Here's my test code, maybe I'm missing something (a button press wakes the rp2040 up for 1 sec)

#include <pico/stdlib.h>
#include <pico/sleep.h>
#include <hardware/rosc.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(0, 1); // RX, TX

int Button_Pin = 8;
bool awake = false;

void setup()
{
  pinMode(Button_Pin, INPUT_PULLUP);
  mySerial.begin(9600);
  delay(1000);
  mySerial.println("Start...");
  delay(1000);
}

void loop()
{
  if (!awake)
  {
    sleep_run_from_xosc();
    sleep_goto_dormant_until_pin(Button_Pin, false, false); // Pin, Edge, HIGH
    awake = true;
  }

  else if (awake)
  {
    Get_Up();
    mySerial.println("I have things to do and I will never slee...");
    delay(1000);
    awake = false;
  }
}

void Get_Up()
{
  rosc_write(&rosc_hw->ctrl, ROSC_CTRL_ENABLE_BITS);
  clocks_init();
  set_sys_clock_khz(133000, true);
}
julianatgit commented 1 year ago

Is there any way to check weather the "make-libpico.sh" bash ran successfully or not?

I followed the instructions (from Dj-EKI ) and the sleep.h is found, but the functions (sleep.c) are not. With my very limited knowledge i think that something went wrong during the execution of the "make-libpico.sh" bash, but i have no idea how to figure that out.

Im using the Pico setup for Windows (https://github.com/raspberrypi/pico-setup-windows/releases) and executed everything in the "Pico - Developer Command Prompt".

c:/users/WIN_USER/appdata/local/arduino15/packages/rp2040/tools/pqt-gcc/1.5.0-b-c7bab52/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe: C:\Users\WIN_USER\AppData\Local\Temp\arduino\sketches\90E80519620805E9FF0E2CC4AAE29730\sketch\SleepTest.ino.cpp.o: in function `_Z18recover_from_sleepjjj':
C:\Users\WIN_USER\Desktop\gsm-car-control\ArduinoIDE\SleepTest/SleepTest.ino:56: undefined reference to `stdio_init_all'
c:/users/WIN_USER/appdata/local/arduino15/packages/rp2040/tools/pqt-gcc/1.5.0-b-c7bab52/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe: C:\Users\WIN_USER\AppData\Local\Temp\arduino\sketches\90E80519620805E9FF0E2CC4AAE29730\sketch\SleepTest.ino.cpp.o: in function `sleep_run_from_xosc':
c:\users\WIN_USER\appdata\local\arduino15\packages\rp2040\hardware\rp2040\3.1.0\pico-extras\src\rp2_common\pico_sleep\include\pico/sleep.h:50: undefined reference to `sleep_run_from_dormant_source'
c:/users/WIN_USER/appdata/local/arduino15/packages/rp2040/tools/pqt-gcc/1.5.0-b-c7bab52/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld.exe: C:\Users\WIN_USER\AppData\Local\Temp\arduino\sketches\90E80519620805E9FF0E2CC4AAE29730\sketch\SleepTest.ino.cpp.o: in function `rtc_sleep':
C:\Users\WIN_USER\Desktop\gsm-car-control\ArduinoIDE\SleepTest/SleepTest.ino:40: undefined reference to `sleep_goto_sleep_until'
collect2.exe: error: ld returned 1 exit status
earlephilhower commented 1 year ago

Make sure you're running your git copy, not the Boards Manager install.

The script assumes you're running from the git version of the core and installs the rebuilt libraries into that path, not the path that the Arduino IDE uses for Boards Manager.

I believe CMake will give very clear error messages and the script will abort if there is a compile error.

Also, stdio_init_all is not legal but being called in your sketch, so drop that too.

viduq commented 1 year ago

Is it planned to implement this to the upstream arduino-pico? If yes, when approximately?

yaswanthsk04 commented 1 year ago

Is this feature already implemented? if no, when will be available?

viduq commented 1 year ago

Maybe open a new issue. Don't think we'll get an answer here, since this is closed.

NuclearPhoenixx commented 1 year ago

Is this feature already implemented? if no, when will be available?

https://github.com/earlephilhower/arduino-pico/discussions/1544#discussioncomment-6205182

viduq commented 1 year ago

Thank you, didn't see this comment until now.

therman89 commented 1 year ago

Hi, I ran the get.py script from the git repo which downloaded and according to the output, it extracted the files. Then I tried to run the make-libpico.sh script, but it throws an error that the Pi Pico SDK is missing from arduino-pico/pico-sdk folder. Did I miss something with the install? I'm using Linux Mint.

tibi@tibi-VivoBook:~/arduino-pico/tools/libpico$ bash make-libpico.sh 
Using PICO_SDK_PATH from environment ('/home/tibi/arduino-pico/pico-sdk')
CMake Error at pico_sdk_import.cmake:57 (message):
  Directory '/home/tibi/arduino-pico/pico-sdk' does not appear to contain the
  Raspberry Pi Pico SDK
Call Stack (most recent call first):
  CMakeLists.txt:3 (include)

-- Configuring incomplete, errors occurred!
earlephilhower commented 1 year ago

Make sure you've followed the whole set of instructions here: https://github.com/earlephilhower/arduino-pico#installing-via-git

You might just need to do a couple git submodule update --inits to get the sdk set up properly.

Sokoloft commented 11 months ago

Been messing with this all day with no success. I keep getting the undefined reference error and cant fix it. I've built it on my linux laptop using the make-libpico.sh script and it ran without error. Moved it back over to my windows desktop and I still have this undefined reference error.

xrevert commented 4 months ago

It took me so many days to get it to compile. Finally worked with Ming64. but I am getting this error now:

c:/users/myuser/appdata/local/arduino15/packages/rp2040/tools/pqt-gcc/2.2.0-d04e724/bin/../lib/gcc/arm-none-eabi/12.3.0/../../../../arm-none-eabi/bin/ld.exe: C:\Users\myuser\AppData\Local\Temp\arduino\sketches\6A7C4EDC103DDEFA1BCC2E875EAC0882\sketch\RP2040_story.ino.ino.cpp.o: in functionloop': c:\users\myuser\appdata\local\arduino15\packages\rp2040\hardware\rp2040\3.9.2\pico-extras\src\rp2_common\pico_sleep\include\pico/sleep.h:50: undefined reference to sleep_run_from_dormant_source' c:/users/myuser/appdata/local/arduino15/packages/rp2040/tools/pqt-gcc/2.2.0-d04e724/bin/../lib/gcc/arm-none-eabi/12.3.0/../../../../arm-none-eabi/bin/ld.exe: c:\users\myuser\appdata\local\arduino15\packages\rp2040\hardware\rp2040\3.9.2\pico-extras\src\rp2_common\pico_sleep\include\pico/sleep.h:89: undefined reference tosleep_goto_dormant_until_pin' collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1`

Does this mean my build was not successful?

toseef-ahmd commented 2 months ago

Hi. Is there anyone who has solved the RP2040 not waking up from dormant mode? I'm trying to get it back on key interrupt, but it doesn't wake up.

I have pico-sdk and pico-extras installed, as this thread suggests. I am able to use sleep.h functionality.

But the mcu does not want to wake up once it goes to dormant mode.

Anyone? please!

DerJantob commented 2 months ago

Had the same issue, but it worked with this:

#include <pico/stdlib.h>
#include <pico/sleep.h>
#include <hardware/rosc.h>
sleep_run_from_xosc();
sleep_goto_dormant_until_pin(15, true, true);  // Pin, Edge, HIGH
rosc_write(&rosc_hw->ctrl, ROSC_CTRL_ENABLE_BITS);
clocks_init();
set_sys_clock_khz(133000, true);
Humancell commented 3 weeks ago

Hello,

I apologize if this is beating a dead horse however I am unclear about the status of this topic. With the recent RP2350 introduction I'm curious if it still the case that the "standard" board support does not support Deep Sleep?

This is such a critical feature for so many low power/battery applications. We're working on several solar powered remote applications, and have had to move to the ESP32 for these.

It seems from this thread there is a well known solution to manually add Deep Sleep, but it has not yet been rolled into the "standard" library, and that a custom build must be created? Is that accurate?

Will this same manual process work for the new RP2350?

What contribution is being looked for to make this already included?

Thank you for any insights in advance!

NuclearPhoenixx commented 3 weeks ago

I apologize if this is beating a dead horse however I am unclear about the status of this topic. With the recent RP2350 introduction I'm curious if it still the case that the "standard" board support does not support Deep Sleep?

Especially regarding the RP2350, IIRC there are also additional low-power/sleep modes available now. So that would make that even more interesting!