arduino / arduino/ArduinoCore-mbed
[RP2040] Missing time.c and stdio.h files
- Dominant language
- C
- Stars
- 411
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying this simple timer-related code, which is simplified from [RPI pico SDK **hardware_timer**](https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__timer.html)
```
//#include "pico/stdlib.h"
#include "pico/time.h"
volatile bool timer_fired = false;
int64_t alarm_callback(alarm_id_t id, void *user_data)
{
Serial.print("Fired. Timer");
Serial.println((int) id);
timer_fired = true;
// Can return a value here in us to fire in the future
return 0;
}
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println("TimerTest");
// Call alarm_callback in 2 seconds
add_alarm_in_ms(2000, alarm_callback, NULL, false);
// Wait for alarm callback to set timer_fired
while (!timer_fired)
{
tight_loop_contents();
}
Serial.println("Done");
}
void loop()
{
}
```
This code compiles OK using SDK or [**RP2040 arduino-pico core**](https://github.com/earlephilhower/arduino-pico)
But there are some issues with this core
1. Missing `stdio.h`
In [stdlib.h#L10-L12](https://github.com/arduino/ArduinoCore-mbed/blob/master/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/common/pico_stdlib/include/pico/stdlib.h#L10-L12)
```
#include "pico.h"
#include "pico/stdio.h"
#include "pico/time.h"
```
but compiler finds no `pico/stdio.h` in the core
```
In file included from /tmp/arduino_modified_sketch_904848/sketch_jun02d.ino:1:0:
/home/kh/.arduino15/packages/arduino/hardware/mbed_rp2040/2.1.0/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/common/pico_stdlib/include/pico/stdlib.h:11:10: fatal error: pico/stdio.h: No such file or directory
#include "pico/stdio.h"
^~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Raspberry Pi Pico.
```
2. Missing `time.c`
Comment out
```
#include "pico/stdlib.h"
```
The compiler also generates error with this core, possibly no `time.c` was included in the core
```
/home/kh/Arduino/Testing/RPi_Pico/Testing/Mbed_TimerInterrupt/Stdio_Issue/Stdio_Issue.ino: In function 'void setup()':
Stdio_Issue:24:3: error: 'add_alarm_in_ms' was not declared in this scope
add_alarm_in_ms(2000, alarm_callback, NULL, false);
^~~~~~~~~~~~~~~
/home/kh/Arduino/Testing/RPi_Pico/Testing/Mbed_TimerInterrupt/Stdio_Issue/Stdio_Issue.ino:24:3: note: suggested alternative: 'alarm_id_t'
add_alarm_in_ms(2000, alarm_callback, NULL, false);
^~~~~~~~~~~~~~~
alarm_id_t
exit status 1
'add_alarm_in_ms' was not declared in this scope
```
In [time.h#L548-L549](https://github.com/arduino/ArduinoCore-mbed/blob/master/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/common/pico_time/include/pico/time.h#L548-L549), the function `add_alarm_in_ms` is declared as
```
static inline alarm_id_t add_alarm_in_ms(uint32_t ms, alarm_callback_t callback, void *user_data, bool fire_if_past) {
return alarm_pool_add_alarm_in_ms(alarm_pool_get_default(), ms, callback, user_data, fire_if_past);}
```
Regards,
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by inspecting the RP2040 pico-sdk paths for pico/stdlib.h, pico/stdio.h, and pico/time.h referenced in the issue, then trace how these files are included by the ArduinoCore-mbed core. Verify the reported sketch and compiler errors; done means the timer example can include the expected headers and resolve add_alarm_in_ms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100