RP2350: `rom_reboot` fails if `delay_ms` is set to 0
It seems like there is a bug when calling `rom_reboot` with `delay_ms` set to 0. If called with `delay_ms = 0` the function returns with `BOOTROM_OK` and does not reboot at all. Any value greater than 0 for `delay_ms` seems to work and the watchdog reset happens.
Following code is expected to enter `BOOTSEL` mode after calling `rom_reboot`, however this does not happen. Instead, the LED flashes at 1/2 Hz and some text is printed to the console:
```c
#include <stdint.h>
#include <stdio.h>
#include <pico/stdlib.h>
#include <pico/bootrom.h>
#include <boot/picoboot_constants.h>
#include <hardware/gpio.h>
#define GPIO_LED 25
int main(void)
{
stdio_init_all();
gpio_init( GPIO_LED);
gpio_put( GPIO_LED, true);
gpio_set_dir( GPIO_LED, true);
// Wait for USB
sleep_ms(2000);
printf("rom_reboot: test bug\n");
// == 0 -> no reboot
// != 0 -> reboot after delay_ms
uint32_t delay_ms = 0;
int rom_reboot_ret = rom_reboot(REBOOT2_FLAG_REBOOT_TYPE_BOOTSEL, delay_ms, 0, 0);
// reports BOOTROM_OK
printf("rom_reboot: %u\n", rom_reboot_ret);
while (true)
{
sleep_ms(1000);
gpio_xor_mask(1 << GPIO_LED);
printf("This should not be output to the console\n");
}
}
```
1 条评论