DavidAntliff / esp32-owb

Maxim One Wire Bus driver for ESP32.
MIT License
158 stars 52 forks source link

Fix crash on RMT driver initialization #29

Closed dmitrymu closed 2 years ago

dmitrymu commented 2 years ago

I'm sorry, David, created PR by mistake (instead of creating in in my own fork).

The crash is still real, I observe it when compiled with IDF SDK 4.1.3

DavidAntliff commented 2 years ago

Hi @dmitrymu, no problem, thank you for the PR.

How reproducible is the crash? Does it happen 100% of the time with SDK 4.1.3? I suspect that Espressif have moved their initialisation sequence around a bit, perhaps.

dmitrymu commented 2 years ago

For me it was stable under 4.1.3, and rmt.c, which is crashing (https://github.com/espressif/esp-idf/blob/release/v4.1/components/driver/rmt.c) did not change much in 4.4.2.

It crashes because rmt_set_source_clk() internally uses a structure which is initialized by rmt_driver_install(). Calling them in reverse order causes null pointer dereference.

DavidAntliff commented 2 years ago

Thank you!