Skip to content

esp32c3: fast_isr.S uses RISC-V atomic ops (lr.w/sc.w) but C3 lacks the A extension #2576

Closed

Description

@zackees

Symptom

Every esp32c3 example build on master fails:

fast_isr.S:150: Error: unrecognized opcode `lr.w t0,(t4)', extension `zalrsc' required
fast_isr.S:160: Error: unrecognized opcode `sc.w t5,t1,(t4)', extension `zalrsc' required
FAILED: AnalogOutput

Reproducible run: https://github.com/FastLED/FastLED/actions/runs/26677701936 — every example fails identically.

Root cause

src/platforms/esp/32/drivers/gpio_isr_rx/fast_isr.S is gated only by #ifdef __riscv (line 49). That matches every Espressif RISC-V chip, including:

Chip ISA Atomic (A) ext?
ESP32-C3 RV32IMC no
ESP32-C2 RV32IMC no
ESP32-C6 RV32IMAC yes
ESP32-H2 RV32IMAC yes
ESP32-C5 RV32IMAC yes
ESP32-P4 RV32IMAFC yes

The ISR body uses RV32A load-reserved / store-conditional (lr.w / sc.w) at lines 150 and 160 — those opcodes need the A extension. On ESP32-C3 the assembler rejects them.

The accompanying C++ file gpio_isr_rx_mcpwm.cpp.hpp is properly gated:

#if defined(SOC_MCPWM_SUPPORTED) && SOC_MCPWM_SUPPORTED

ESP32-C3/C2 do not have MCPWM, so the C++ glue is correctly skipped — only the .S is the outlier.

The file's own header comment explicitly says the target is ESP32-C6 (RV32IMAC), so the C3 inclusion is purely incidental from the loose preprocessor gate.

Affected jobs

  • Every esp32c3 workflow (every example).
  • Any future RV32IMC Espressif chip will hit the same.

Proposed fix

Tighten the gate in fast_isr.S to require the atomic extension. GCC predefines __riscv_atomic (and __riscv_a) when the A extension is enabled by -march= flags. RV32IMC chips never define it.

- #ifdef __riscv  // Only compile for RISC-V platforms (ESP32-C6)
+ // The fast ISR uses RV32A lr.w/sc.w atomics for the circular-buffer
+ // index update. Only compile on RISC-V cores that ship the A extension
+ // (ESP32-C6/H2/C5/P4 — RV32IMAC+). ESP32-C3/C2 are RV32IMC and would
+ // fail the assembler with "extension `zalrsc' required". The companion
+ // C++ glue in gpio_isr_rx_mcpwm.cpp.hpp already guards on
+ // SOC_MCPWM_SUPPORTED, which excludes C3/C2 anyway — this aligns the
+ // assembly with that gate.
+ #if defined(__riscv) && defined(__riscv_atomic)

(Symmetric #endif comment update.)

Repro

bash compile esp32c3 --examples Blink


Filed automatically while triaging broken builds; intent is to open a PR immediately.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions