esp: fix extended-address byte order for the hardware RX filter#84
Conversation
ivmarkov
left a comment
There was a problem hiding this comment.
Thanks for figuring out the root cause!
As discussed, instead of this change, please replace from_be_bytes with from_le_bytes at these two places (which are the buggy ones):
openthread/openthread/src/platform.rs
Line 141 in b38ad1d
openthread/openthread/src/radio.rs
Line 1267 in b38ad1d
…uning For matter-embassy-esp32c6 on esp-radio 1.0.0-beta.0: - platform.rs + radio.rs: decode the extended address little-endian (`from_le_bytes`). `otPlatRadioSetExtendedAddress` delivers it little-endian (openthread/platform/radio.h), but it was decoded big-endian, so on esp-radio (which programs its hw filter via `ext_addr.to_le_bytes()`, esp-rs/esp-hal#5314) the filter was byte-reversed -> all unicast RX dropped -> Thread never attached. (Matches the esp-rs#84 upstream fix.) - esp.rs: rx_queue_size 50 -> 200 (proven value; absorbs fragmented commissioning/interview bursts, avoids "Receive queue full"). - builder.rs: NUM_MESSAGE_BUFFERS 128 -> 256; OT_LOG_LEVEL NOTE -> CRIT (a non-CRIT C side generates a log string per MLE/MAC event, starving the radio hot path during fragmented over-Thread commissioning). - Cargo.toml: accept esp-radio 1.0.0-beta.0 (carries the AR-bit fix). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`otPlatRadioSetExtendedAddress` passes the extended address little-endian (openthread/platform/radio.h), but it was decoded with `from_be_bytes` in the platform callback, and the `MacRadio` frame parser mirrored that. So `Config.ext_addr` and the parsed `dst_ext_addr` were byte-reversed vs the on-air little-endian address. esp-radio programs its hardware filter via `ext_addr.to_le_bytes()` (esp-rs/esp-hal#5314), so the filter never matched and all unicast RX was dropped -> Thread never attached; the nRF `MacRadio` software filter was off the same way. Decode little-endian at both sites. Validated on esp32-c6 (Matter over Thread): with the fix the device attaches to Thread and operates (commission, attribute reads, reboot auto-recovery); without it, attach never completes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
d64be6d to
f14d976
Compare
|
Done — replaced Re-tested on an esp32-c6 (Matter over Thread) with this exact |
Problem
On ESP32 with
esp-radio, OpenThread never attaches to a Thread network. The node transmits Parent Requests and receives multicast traffic fine, but receives zero unicast frames — so it never gets a Parent Response, and MLE attach times out. Because TX and multicast RX work, it looks like a higher-layer problem.Root cause
An extended-address byte-order mismatch in the hardware RX address filter:
otPlatRadioSetExtendedAddressdelivers the address in little-endian order (peropenthread/platform/radio.h), andesp-radioprograms its hardware filter withext_addr.to_le_bytes()(fix: use little-endian byte order for IEEE 802.15.4 extended address esp-hal#5314, "use little-endian byte order for IEEE 802.15.4 extended address").from_be_bytes(and theMacRadioframe parser mirrored that), soConfig.ext_addr/dst_ext_addrwere byte-reversed vs the on-air little-endian address.So the filter is loaded byte-reversed; the radio drops every unicast frame addressed to the node. (This was correct before esp-rs/esp-hal#5314, when esp-radio used big-endian; that change flipped esp-radio to the spec-correct little-endian and the decode side wasn't updated to match.)
Fix
Decode the extended address little-endian at the two sites that build the
u64from the byte slice —platform.rs(otPlatRadioSetExtendedAddress) andradio.rs(theMacRadioframe parser). This makesConfig.ext_addrand the parseddst_ext_addrmatch the on-air little-endian order and esp-radio'sto_le_byteshardware-filter programming.Validation
esp32-c6, Matter over Thread: with the fix the device attaches to Thread and operates (commission, attribute reads, reboot auto-recovery); without it, attach never completes. (No nRF hardware here to exercise the
MacRadiosoftware-filter leg directly, butradio.rsis the matching counterpart so the two stay in agreement.)🤖 Generated with Claude Code