Skip to content

lora sx126x silently returns crc failed packets as valid #1112

@maholli

Description

@maholli

The lora/lora-sx1262 driver is structured to check the chip-level crc of received packets, but is missing the bit flag to make that possible.

I've confirmed that, without including the _IRQ_CRC_ERR when configuring the IRQ bit mask, the GetIrqStatus bytes from _get_irq() will never have their _IRQ_CRC_ERR bit set.

Test1 methodology:

Four radios transmitting repeatedly (with small jitter) at same freq, same lora params, and at low power. The purpose was to have them occasionally talking over themselves enough to induce demodulation errors on the receiver. The transmitted packets were unique (and changing) payloads of 60 bytes with the last byte containing a manually calculated crc of the payload data. A fifth radio was used to receive and log packets during the test. Also logged alongside each packet was the IRQ status byte from _get_irq(). After a few minutes, received packets were analyzed and their manually-calculated crc values compared against byte 60 of the packet, as well as the bit flags for each corresponding IRQ status byte. Test was repeated using hardware DIO0 and software IRQ polling.

Result1:

200 packets received, only IRQ bit set is RxDone on every packet, yet 15 packets fail their manual crc check.

Test2 (with patch):

_IRQ_CRC_ERR was added to the IRQ mask on this line and the test above repeated

Result2:

119 packets received, all pass manual crc check. In addition to the valid packets, an additional 13 RxDone IRQs were triggered and their _IRQ_CRC_ERR flag set in the IRQ status byte. During normal usage, the library driver does not return a packet in the crc err case, which is the expected behavior.

PR to follow with this proposed fix. Fix is intentionally minimal so as to not impact other driver behavior.

If memory serves, this bit masking behavior differs from other semtech chips (or maybe it's the way the irq status byte is presented). Either way, combine that with the difficulty to induce crc packet errors and it's very understandable this was missed! Thank you, micropython devs for all your hard work!

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