raspberrypi / pico-playground

BSD 3-Clause "New" or "Revised" License
440 stars 93 forks source link

Confusion re building examples in `pico-playground` #50

Open seamusdemora opened 1 day ago

seamusdemora commented 1 day ago

Sorry to have to ask, but I've got some doubts about my approach:

I need to use the sleep and/or dormant mode for an off-grid Pico project. I plan to use a RV-3028 as the RTC/interrupt source due to its accuracy and low power consumption.

I planned on using the examples in pico-playground to get me started, but I may have "missed a beat" somewhere along the line:

   $ cd ~/pico/pico-playground
   $  mkdir build 
   $ cd build
   $ export PICO_SDK_PATH=../../pico-sdk              # don't know if this was needed or not 
   $ cmake .. 
   $ cd sleep/hello_sleep
   $ make -j2 
    . . .
   [100%] Built target hello_sleep 
   $ 

So here's where I'm confused. I had to descend two levels below ./build - into sleep/hello_sleep to get things to work. This doesn't feel right...

Should I be copying hello_sleep into /home/pi/pico/examples/build?? - instead of trying to set up pico-playground as a stand-alone set of examples??

TIA!

lurch commented 1 day ago

So here's where I'm confused. I had to descend two levels below ./build - into sleep/hello_sleep to get things to work. This doesn't feel right...

IIRC this is exactly the same way that pico-examples works. Note that the examples in pico-examples need pico-sdk to be present (specified with PICO_SDK_PATH=...), but the examples in pico-playground may also need pico-extras to be present (specified with PICO_EXTRAS_PATH=...)

Should I be copying hello_sleep into /home/pi/pico/examples/build?? - instead of trying to set up pico-playground as a stand-alone set of examples??

You shouldn't be using the CMakeLists.txt from a pico-examples or pico-playground example for your own projects, as these are all tightly integrated with the top-level CMakeLists.txt in those repos.

To create your own project (independent from the pico-playground repo), see the "Manually Create your own Project" section in https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf

$ export PICO_SDK_PATH=../../pico-sdk # don't know if this was needed or not

If you're jumping around between different build directories, it's probably safer to set this to an absolute path, rather than a relative path.

kilograham commented 21 hours ago

So here's where I'm confused. I had to descend two levels below ./build - into sleep/hello_sleep to get things to work. This doesn't feel right... $ make -j2

Make from the top-level builds everything in pico-playground by default

you could do

make -j2 hello_sleep

instead.