Atomic operations don't work on memory in PSRAM #2505
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#2505
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?
I unfortunately don't have any replication code to share right now, as I'm working on a project that's private for the time being.Edit: See next commentBut the short explanation is that I have some code that calls
__atomic_fetch_add(my_int, 1). Whenmy_intis in SRAM, everything works fine. Whenmy_intis in PSRAM, the system gets into an infinite loop, forever incrementingmy_int(seems like once every clock cycle).I saw this thread in which it is mentioned that atomic operations are only supported for memory <=32 bits in size (otherwise a spin lock is used), and not supported in PSRAM. That's fine, the performance hit of a spin lock is negligible for me. But seems like there's currently no check for the memory location to actually do a spin lock if the memory is in PSRAM.
Actually, I did make some replication code. It uses Arduino Pico since PSRAM support doesn't exist here yet.
Using a board with PSRAM, running as is works fine:
Swapping the comments on the top 2 lines so
my_intis in PSRAM, it freezes when__atomic_fetch_add()is called:Connecting a debugger,
my_intis just being incremented in a loop forever.Probably just going to leave this as documentation. If memory doesn't support CPU atomics, then I think that is expeted behavior; leaving open in 2.2.0 for discussion tho