Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

SDK • [RP2040] sleep_us waits forever

$
0
0
Hi,
I'm seeing some very strange behavior when trying to call sleep_ms(1000): I'm getting stuck here https://github.com/raspberrypi/pico-sdk ... ime.c#L409, but only when I fetch the pico-SDK via the CMake file (set(PICO_SDK_FETCH_FROM_GIT TRUE), not when I'm debugging a project created from the vscode pico extension.

System: Ubuntu 24.04.2 LTS (Ryzen 5)
Compiler: arm-none-eabi 14.2rel1 (installed from the raspberry pi pico vscode extension)
IDE: VScode
Build system: CMake

Observation:
I'm able to build, and start the debugger. However, when I get to the sleep_ms(1000) part, it never returns, and seems to be stuck in the while loop linked above.

What works:
Building and debugging a blink program with the vscode pico extension.

What doesn't work, but I'm trying to get to work:
I clone and link the pico SDK via the CMake file (set(PICO_SDK_FETCH_FROM_GIT TRUE)). It's the same code as the vscode pico extension, and as far as I can see, I'm using the same release of the SDK (2.1.1).
The project builds and debugs, but I'm not getting past any sleep_ms() statements.

The project I'm trying out is the same as in the https://datasheets.raspberrypi.com/pico ... h-pico.pdf section "Manually Create your own Project", except I let CMake fetch the SDK, so I have not defined the PICO_SDK_PATH variable globally.

Main file:

Code:

#include <stdio.h>#include "pico/stdlib.h"#include "hardware/gpio.h"#include "pico/binary_info.h"int main() {    const uint LED_PIN = 25;    stdio_init_all();    gpio_init(LED_PIN);    gpio_set_dir(LED_PIN, GPIO_OUT);    while (1) {        gpio_put(LED_PIN, 0);        sleep_ms(250);        gpio_put(LED_PIN, 1);        sleep_ms(1000);    }}
CMakeLists.txt:

Code:

cmake_minimum_required(VERSION 3.13)set(CMAKE_C_STANDARD 11)set(CMAKE_CXX_STANDARD 17)set(PICO_SDK_FETCH_FROM_GIT TRUE)set(PICO_SDK_FETCH_FROM_GIT_TAG "2.1.1")include(pico_sdk_import.cmake)set(PICO_PLATFORM rp2040)project(test_project C CXX ASM)pico_sdk_init()add_executable(test  test.c)pico_enable_stdio_usb(test 1)pico_enable_stdio_uart(test 1)pico_add_extra_outputs(test)target_link_libraries(test pico_stdlib)
Anyone else seen this, or am I missing anything obvious here? I want to avoid relying on vscode extension as much as I can wrt building, debugging and generating code, and I have had this functionality running on another computer prior to installing it again on a new computer. I have verified that both projects use the same compiler, the same version of the SDK, and the same commands in compile_commands.json. The only difference is how I link the SDK (global via vscode vs local via CMake).
Thanks in advance,
Oskar

Statistics: Posted by oskarvh — Sun Jul 13, 2025 5:36 am — Replies 0 — Views 41



Viewing all articles
Browse latest Browse all 7503

Trending Articles