Description
The esp32c3
is a riscv based cpu, without the atomic extension. Unlike the arm thumbv6
target, it does not have atomic load/stores for the following types u8
, u16
, u32
, which means we cannot use defmt
(and other rtt based crates) as it stands.
I recently landed a PR in atomic-polyfill
that adds load/store for those types mentioned above, implemented using critical sections. I have a PR in rtt-target
to use that, but it has not yet been accepted.
In theory for better performance, we could ditch the critical section and implement our own atomic operation that use fences to ensure atomicity (this is what is done in llvm for thumbv6
) - however this can cause UB when mixed with lock based CAS atomics (see: here, here, and here ) therefore is not suitable to add to atomic-polyfill
as it stands.
I would like the esp32c3 to be able to support the c3, and I am sure there are other riscv, non-a targets too.
What do you think the best idea is going forward?