Szabolcs Diós Posted February 21, 2020 Posted February 21, 2020 (edited) Dear friends! I have a project, where I needed to use 4 infrared receivers and 2 transmitters connected to GPIO. After a lot of research I realized how to cook all stuffs together: So I have Pine64 A64 512MB cards (not the plus model), running Armbian 20.05.0-trunk.038 nightly, (uname -r: 5.4.18-sunxi64). I needed to freeze upgrades for two reasons: Boot hangs up: The armbian thinks that I have the plus model: on every upgrade I need to replace the "sun50i-a64-pine64-plus.dtb" file with "sun50i-a64-pine64.dtb" at /boot/dtb/allwinner because the non-plus model (512MB) has different ethernet hardware. Missing gpio-ir-recv kernel module from stock Armbian: For transmitting IR signals via GPIO we are using gpio-ir-tx kernel module already located in stock armbian, but for receiving IR signals via GPIO we need the gpio-ir-recv kernel module. So I have downloaded this file from the official armbian source at github and recompiled all kernel modules to get only this gpio-ir-recv.ko kernel module file.... (it took a while) So to activate those kernel modules I needed to create a Custom Device Tree Overlay (here is how to activate it). Here is the content of my custom dt overlay, but if you want to modify GPIO pin numbers, you need to experiment which pin is interrupt enabled and not used for other stuff... +1 good advice ---> If you want to send and receive custom IR protocol, it's better to use the ir-ctl program than lirc. /dts-v1/; /plugin/; / { compatible = "allwinner,sun50i-a64"; fragment@0 { target = <&pio>; __overlay__ { ir_rx1_pins: ir-rx1-pins { pins = "PH6"; function = "gpio_in"; }; ir_rx2_pins: ir-rx2-pins { pins = "PH7"; function = "gpio_in"; }; ir_rx3_pins: ir-rx3-pins { pins = "PH8"; function = "gpio_in"; }; ir_rx4_pins: ir-rx4-pins { pins = "PH9"; function = "gpio_in"; }; ir_tx1_pins: ir-tx1-pins { pins = "PH5"; function = "gpio_out"; }; ir_tx2_pins: ir-tx2-pins { pins = "PD0"; function = "gpio_out"; }; }; }; fragment@1 { target-path = "/"; __overlay__ { gpio_ir_rx1: gpio-ir-receiver-1 { compatible = "gpio-ir-receiver"; pinctrl-names = "default"; pinctrl-0 = <&ir_rx1_pins>; gpios = <&pio 7 6 1>; /* PH6 */ status = "okay"; }; gpio_ir_rx2: gpio-ir-receiver-2 { compatible = "gpio-ir-receiver"; pinctrl-names = "default"; pinctrl-0 = <&ir_rx2_pins>; gpios = <&pio 7 7 1>; /* PH7 */ status = "okay"; }; gpio_ir_rx3: gpio-ir-receiver-3 { compatible = "gpio-ir-receiver"; pinctrl-names = "default"; pinctrl-0 = <&ir_rx3_pins>; gpios = <&pio 7 8 1>; /* PH8 */ status = "okay"; }; gpio_ir_rx4: gpio-ir-receiver-4 { compatible = "gpio-ir-receiver"; pinctrl-names = "default"; pinctrl-0 = <&ir_rx4_pins>; gpios = <&pio 7 9 1>; /* PH9 */ status = "okay"; }; gpio_ir_tx1: gpio-ir-transmitter-1 { compatible = "gpio-ir-tx"; pinctrl-names = "default"; pinctrl-0 = <&ir_tx1_pins>; gpios = <&pio 7 5 0>; /* PH5 */ status = "okay"; }; gpio_ir_tx2: gpio-ir-transmitter-2 { compatible = "gpio-ir-tx"; pinctrl-names = "default"; pinctrl-0 = <&ir_tx2_pins>; gpios = <&pio 3 0 0>; /* PD0 */ status = "okay"; }; }; }; }; Edited February 21, 2020 by Szabolcs Diós Was a typo in the provided code at comment section 0 Quote
vr1152 Posted July 16, 2021 Posted July 16, 2021 Very interesting, thanks for You post. I am trying to add only one IR transmitter to Orange Pi PC. And all this time without success. Can You help and explain more detailed, how to create dtoverlay correctly? Now i can't understand how to calculate pin numbers that write in gpios = <&pio 7 8 1>; /* PH8 */ (for examle) For example, i have a physical pin 16, which named PC4 and what i need to write in "gpios"? Pin number for manual control is 68, according to this https://linux-sunxi.org/GPIO But what "gpios" to write in the dts file? I would really appreciate, if somebody say something 0 Quote
vr1152 Posted August 12, 2021 Posted August 12, 2021 Would like to answer to myself )) Seems to be i made it )) in my case i use 2 4 0 and all line is gpios = <&pio 2 4 0>; /* PC4 */ My pin is PC4 If i understand correctly, so the "P" doesn't count, the C is the 3rd letter, -1, so it would be 2, and the number 4 I don't know exactly what is the last number, seems to be an output polarity, maybe it could be 0 or 1. And yes, Szabolcs Diós, thank You very much for Your post and especially for Your the dt overalay file, it help me very much. If not You, i might be stop my project, because it was too hard for me and i can't understand in what direction i need to go. 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.