Skip to content

espressif/rmt: replace rmtchar with arch-specific lirc adapter#18654

Merged
acassis merged 4 commits intoapache:masterfrom
PiyushPatle26:espressif-rmt-lirc-refactor
Apr 4, 2026
Merged

espressif/rmt: replace rmtchar with arch-specific lirc adapter#18654
acassis merged 4 commits intoapache:masterfrom
PiyushPatle26:espressif-rmt-lirc-refactor

Conversation

@PiyushPatle26
Copy link
Copy Markdown
Contributor

@PiyushPatle26 PiyushPatle26 commented Mar 30, 2026

Note: Please adhere to Contributing Guidelines.

Summary

Replace the ESP-specific rmtchar upper-half with arch-local esp_lirc adapters for Xtensa and RISC-V.

This moves the RMT upper-half out of drivers/rmt, registers LIRC
devices from the ESP board bring-up paths, and removes the old common
rmtchar driver and headers.

Also update the ESP Kconfig and build wiring to build esp_lirc when
ESP_RMT and DRIVERS_RC are enabled.

Impact

  • Moves ESP-specific RMT support from common drivers/rmt into arch-local esp_lirc, aligning with NuttX layering.
  • Replaces the legacy rmtchar interface with the standard LIRC framework and removes obsolete code.
  • Registers LIRC devices from board bring-up, fixing RX/TX device conflicts and improving stability.
  • Limited to ESP targets; out-of-tree users must migrate to /dev/lircX

Testing

Tested on: ESP32-DEVKITC (Chip v1.0)
booted with CONFIG_ESP32_IGNORE_CHIP_REVISION_CHECK=y for local validation only

  • flashed and booted successfully to NSH
  • confirmed device registration:
    • /dev/lirc0
    • /dev/lirc1
    • /dev/leds0
  • confirmed the previous TX registration collision was fixed
    • before fix: board_rmt_txinitialize() failed: -17
    • after fix: both /dev/lirc0 and /dev/lirc1 register
  • confirmed the RX worker thread crash was fixed
    • before fix: opening the RX side triggered a kernel panic in esp_lirc_rx_thread
    • after fix: devices open successfully

Fixes discovered during hardware validation:

  • register TX as /dev/lirc1 so RX and TX do not collide
  • parse the RX worker thread argument from the correct argv slot
  • keep RX devices from advertising TX capability

Test logs:
image

Irtest seems struck so need guidance on what must be changed to validate completely

@github-actions github-actions bot added Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: xtensa Issues related to the Xtensa architecture Area: Drivers Drivers issues Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: risc-v Board: xtensa labels Mar 31, 2026
@acassis
Copy link
Copy Markdown
Contributor

acassis commented Mar 31, 2026

@PiyushPatle26 I liked the idea, however ESP32 RMT is use not only for RC, it is used as signal "generator" to control WS8212 RGB LEDs for example. Similar how people use I2S to emulate other protocols.

@fdcavalcanti @tmedicci @eren-terzioglu please take a look

@acassis
Copy link
Copy Markdown
Contributor

acassis commented Mar 31, 2026

@xiaoxiang781216 who from Xiaomi could help him: "Irtest seems struck so need guidance on what must be changed to validate completely" ?

Copy link
Copy Markdown
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PiyushPatle26 nice work! Kudos!!!
You didn't submit a Documentation about this driver, so searching further I noticed we even don't have basic documentation about RC: https://nuttx.apache.org/docs/latest/components/drivers/character/rc.html#remote-control-devices

Could you please help us to improve it?

@raiden00pl
Copy link
Copy Markdown
Member

related issue: #15431

@tmedicci
Copy link
Copy Markdown
Contributor

@PiyushPatle26 I liked the idea, however ESP32 RMT is use not only for RC, it is used as signal "generator" to control WS8212 RGB LEDs for example. Similar how people use I2S to emulate other protocols.

@fdcavalcanti @tmedicci @eren-terzioglu please take a look

Thanks for submitting it, @PiyushPatle26 . We are testing on our internal CI. Please don't merge it yet.

As Alan pointed, @PiyushPatle26 , the RMT driver is used to drive the WS2812 (on-board LED for some of the Espressif's boards). Did you test it?

@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 have removed the files you asked for
@acassis Added the documentation as asked
@tmedicci not yet, my ESP32-devkitc doesn't have a WS2812 on board LED , can use a external ws2812 with jumper wires for proper testing

@xiaoxiang781216
Copy link
Copy Markdown
Contributor

@xiaoxiang781216 have removed the files you asked for @acassis Added the documentation as asked @tmedicci not yet, my ESP32-devkitc doesn't have a WS2812 on board LED , can use a external ws2812 with jumper wires for proper testing

need fix:

    1: .codespellrc
Warning: /home/runner/work/nuttx/nuttx/nuttx/arch/risc-v/src/common/espressif/esp_lirc.h:26:1: warning: #include outside of 'Included Files' section
Warning: /home/runner/work/nuttx/nuttx/nuttx/arch/risc-v/src/common/espressif/esp_lirc.h:28:1: warning: #include outside of 'Included Files' section
Some checks failed. For contributing guidelines, see:

@PiyushPatle26 PiyushPatle26 force-pushed the espressif-rmt-lirc-refactor branch from a214d60 to e94f877 Compare March 31, 2026 16:08
@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216, I have made the changes you asked.

Copy link
Copy Markdown
Contributor

@linguini1 linguini1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please read the contributing guide and update the PR description to match the requirements :)

@PiyushPatle26 PiyushPatle26 force-pushed the espressif-rmt-lirc-refactor branch 2 times, most recently from 07a76b6 to f9787c9 Compare March 31, 2026 23:28
@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

@linguini1 I have made all the changes according to contributing.md

@eren-terzioglu
Copy link
Copy Markdown
Contributor

Please check CI errors

@acassis
Copy link
Copy Markdown
Contributor

acassis commented Apr 1, 2026

@PiyushPatle26 as @tmedicci you need to test it with existing usage case: i.e. to control WS8212 RGB LED matrix. Otherwise you will broke an existing feature

Hi, Tested internal RGB led using rmt defconfig with ws2812 example. C6 and S3 is working fine

So the snake and shift game still working? That is the most important thing to save! :-D

@eren-terzioglu
Copy link
Copy Markdown
Contributor

eren-terzioglu commented Apr 1, 2026

@PiyushPatle26 as @tmedicci you need to test it with existing usage case: i.e. to control WS8212 RGB LED matrix. Otherwise you will broke an existing feature

Hi, Tested internal RGB led using rmt defconfig with ws2812 example. C6 and S3 is working fine

So the snake and shift game still working? That is the most important thing to save! :-D

I have to find the demo board but even if it doesn't; it would be somehow different, no worries. :)

Replace the ESP-specific rmtchar upper-half with arch-local esp_lirc
adapters for Xtensa and RISC-V.

 This moves the RMT upper-half out of drivers/rmt, registers LIRC
 devices from the ESP board bring-up paths, and removes the old common
 rmtchar driver and headers.

 Also update the ESP Kconfig and build wiring to build esp_lirc when
 ESP_RMT and DRIVERS_RC are enabled.

 Fixes discovered during hardware validation:
  - register TX as /dev/lirc1 so RX and TX do not collide
  - parse the RX worker thread argument from the correct argv slot
  - keep RX devices from advertising TX capability

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
@PiyushPatle26 PiyushPatle26 force-pushed the espressif-rmt-lirc-refactor branch from 411e3b0 to 3acd6c5 Compare April 1, 2026 20:15
@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

Please check CI errors

Hey @eren-terzioglu, i think CI errors should be fixed now
@acassis I was not able to test as I just have a ESP32-devkitC which doesn't have WS8212, But i think @eren-terzioglu have already tested, right?

@linguini1
Copy link
Copy Markdown
Contributor

Ideally you should have a way to test your changes in some capacity. Also, the CI is failing because of config files which aren't normalized. You can use tools/refresh.sh to normalize them :)

@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

Ideally you should have a way to test your changes in some capacity. Also, the CI is failing because of config files which aren't normalized. You can use tools/refresh.sh to normalize them :)

Sorry for not being able to test properly, Thanks for helping for CI, now i have normalized the configs

@eren-terzioglu
Copy link
Copy Markdown
Contributor

eren-terzioglu commented Apr 2, 2026

Please check CI errors

Hey @eren-terzioglu, i think CI errors should be fixed now @acassis I was not able to test as I just have a ESP32-devkitC which doesn't have WS8212, But i think @eren-terzioglu have already tested, right?

I did not test for esp32, only made for esp32c6 and esp32s3 let me test and report back

Update: Seems it is fine too, fyi

@simbit18
Copy link
Copy Markdown
Contributor

simbit18 commented Apr 2, 2026

Hi @PiyushPatle26, please fix

====================================================================================
Configuration/Tool: esp32-devkitc/match4
2026-04-01 23:08:58
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
  [1/1] Normalize esp32-devkitc/match4
29d28
< CONFIG_ESP_RMT=y
31,33d29
< CONFIG_EXAMPLES_RMTCHAR=y
< CONFIG_EXAMPLES_RMTCHAR_RX=y
< CONFIG_EXAMPLES_RMTCHAR_TX=y
53,55d48
< CONFIG_RMT=y
< CONFIG_RMTCHAR=y
< CONFIG_RMT_DEFAULT_RX_BUFFER_SIZE=256
Saving the new configuration file
HEAD detached at pull/18654/merge
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   boards/xtensa/esp32/esp32-devkitc/configs/match4/defconfig

no changes added to commit (use "git add" and/or "git commit -a")
====================================================================================

acassis
acassis previously approved these changes Apr 2, 2026
Add documentation for the RC/LIRC character driver subsystem covering
device registration, the LIRC interface, and usage from user space.

Remove placeholder empty files under drivers/rmt that were left over
from the rmtchar era and are no longer referenced.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
@PiyushPatle26
Copy link
Copy Markdown
Contributor Author

tools/refresh.sh

Hi @PiyushPatle26, please fix

====================================================================================
Configuration/Tool: esp32-devkitc/match4
2026-04-01 23:08:58
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
  [1/1] Normalize esp32-devkitc/match4
29d28
< CONFIG_ESP_RMT=y
31,33d29
< CONFIG_EXAMPLES_RMTCHAR=y
< CONFIG_EXAMPLES_RMTCHAR_RX=y
< CONFIG_EXAMPLES_RMTCHAR_TX=y
53,55d48
< CONFIG_RMT=y
< CONFIG_RMTCHAR=y
< CONFIG_RMT_DEFAULT_RX_BUFFER_SIZE=256
Saving the new configuration file
HEAD detached at pull/18654/merge
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   boards/xtensa/esp32/esp32-devkitc/configs/match4/defconfig

no changes added to commit (use "git add" and/or "git commit -a")
====================================================================================

Done

The common ESP board RMT bring-up files are built whenever ESP_RMT is
enabled, but the esp_lirc declarations are only visible when DRIVERS_RC
is enabled.

Guard the esp_lirc header include and esp_lirc_rx_initialize() /
esp_lirc_tx_initialize() calls with CONFIG_DRIVERS_RC so non-RC ESP
configs continue to build while keeping the LIRC registration path for
the rmt configs.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
esp_ws2812.h exposes esp_ws2812_setup() with a struct rmt_dev_s * argument
but did not include esp_rmt.h directly.

After guarding the LIRC board registration path with CONFIG_DRIVERS_RC,
non-RC ESP configs no longer pulled in the RMT type indirectly and CI
started failing with an incomplete struct rmt_dev_s declaration.

Include esp_rmt.h in the Xtensa and RISC-V ws2812 headers.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
@PiyushPatle26 PiyushPatle26 requested a review from jerpelea April 3, 2026 16:26
@acassis
Copy link
Copy Markdown
Contributor

acassis commented Apr 3, 2026

@linguini1 PTAL, he already fixed the Summary

@linguini1 linguini1 dismissed their stale review April 3, 2026 19:02

PR fixed!

@acassis acassis merged commit 5796849 into apache:master Apr 4, 2026
42 checks passed
@PiyushPatle26 PiyushPatle26 deleted the espressif-rmt-lirc-refactor branch April 4, 2026 15:32
simbit18 added a commit to simbit18/nuttx that referenced this pull request Apr 6, 2026
Add:
- replace rmtchar with arch-specific lirc adapter apache#18654

Signed-off-by: simbit18 <simbit18@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: xtensa Issues related to the Xtensa architecture Area: Drivers Drivers issues Board: risc-v Board: xtensa Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants