Skip to content

Xtensa multicore: AtomicXX::swap() broken for atomics smaller than 32 bit #106

Description

@ivmarkov

AtomicXX::swap() does not work correctly when the atomic is smaller than 32 bit (i.e. AtomicU16, AtomicBool, possibly AtomicU8 too).

I suspect the LLVM atomic generation code is wrong, as these work just fine on riscv32imc (esp32c3) and (I would assume) single-core Xtensa (esp32s2), where atomics are lowered to libcalls using critical sections (implemented in ESP-IDF).

Here's a repo that demonstrates the problem. I've only tested it on the esp32 target, but esp32s3 might be affected as well, as it is also multicore:

  • cargo build and then flash on esp32 - the assert_eqs commented with // This breaks?! will fail
  • cargo build --target riscv32imc-esp-espidf - code should complete up to println!("All done correctly!")

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions