When using flash_safe_execute, if the victim core does not respond within the timeout, it will be locked out forever #2454
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#2454
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
My Pico program uses two cores. Here is a sequence of events leading to the bug
flash_safe_execute_core_initflash_safe_executewith short timeout parametermulticore_lockout_start_block_untilLOCKOUT_MAGIC_STARTand wait for an acknowledgmentmulticore_lockout_handlerreturnsPICO_ERROR_TIMEOUTis returnedmulticore_lockout_handlerObserved behaviour:
multicore_lockout_handlerforever, in the following loop:multicore_lockout_end_block_untilto be called.Expected behaviour:
multicore_lockout_handlerexits quickly as the lockout request has been abandonedAnalysis:
The timeout caused
flash_safe_executeto abandon the attempt to lock out core 0, soLOCKOUT_MAGIC_ENDis never sent. Core 0 is not aware that the lockout request was abandoned and waits forever.Workarounds:
Core 0 can be recovered by a second attempt to use
flash_safe_execute. Alternatively, using a very long timeout will avoid the problem.Steps to reproduce
The attached project flash-lockout-timeout-bug.tar.gz contains a small program which reproduces the problem.
The two cores run in loops, with cycle counts in global variables for easier debugging. One core runs
flash_safe_executeperiodically, while the other disables interrupts periodically. When a call toflash_safe_executeon core Y coincides with disabled interrupts on core X,flash_safe_executereturnsPICO_ERROR_TIMEOUT(-2). Unfortunately this also causes core X to get stuck inmulticore_lockout_handler. If core X = core 1, then USB continues to work, and the status can be seen on the serial line (the cycle count for core X stops, while the cycle count for core Y continues to increment). If core X = core 0, then USB stops working (no interrupts) but a hardware debugger can still be used to observe the cycle counts and see where core 0 has become stuck.merged into develop