Add ability to save core file to flash #1385
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 assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#1385
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?
The SDK contains many points of error checking that result in program termination, but unless the Pico is connected to a host via UART or USB, there is no record left behind. This works well for development, but for deployed products, there is no debug information saved to help solve crashes.
It would be helpful if the SDK could write a core file to the lower portion of flash memory, such that it could be downloaded to a development host system and examined using gdb "target core". This then would also require a way to locate the core file and upload it to a host. Even if only the stack is saved, it would be helpful to determining the cause.
A compile-time define switch passed through cmake would allow users to opt-out to save executable file space. The hooks include assert(), panic*(), and __breakpoint().
Yes, that would be good
In the case where the full memory image is not saved, the saved stack should include some number of stack bytes/frames above the current stack pointer. This allows the developer to see the frame(s) of call(s) made and returned prior to the crash.
I've been playing with doing this exact thing. At the moment I'm recording the state of both cores when one hits an exception, along with dumping stack for each into a 512 byte area at the top of RAM. This is (mostly) working, but there's an issue with shared IRQ use over the RP2350 doorbell interrupt, which both FreeRTOS and my "trigger NMI on the other core to capture state" use that I haven't yet been able to figure out.
I modified FreeRTOS to use
irq_add_shared_handler()instead ofirq_set_exclusive_handler()and this works fine as long as I don't add my shared handler, but as soon as I add mine (even if I never trigger my doorbell), FreeRTOS' timer tick seems to run at 1/2 to 3/8 speed and nothing works quite right. I'm pretty sure there is a bug in the way the shared interrupt code tries to be slick.I catch the exception on reboot (I use the internal watchdog to do this) and the idea is to write the crash information out to I2C or microsd (512 bytes is exactly the size of a single sector, which is why I chose it, don't need to support filesystems if you don't want to).