• Posts

  • Joined

  • Last visited

m9aertner's Achievements

  1. TL;DR *Works* with a minor amendment to the DTS overlay pin reference. $ uname -a Linux nanopineo 5.10.13-sunxi #trunk SMP Mon Feb 8 21:56:43 CET 2021 armv7l armv7l armv7l GNU/Linux $ dmesg | grep Machine [ 0.000000] OF: fdt: Machine model: FriendlyARM NanoPi NEO # Baked current kernel. Configuration ... CIR module appears to NOT be enabled by default for NanoPI NEO. $ grep -iE "^CONFIG_IR_.*(CIR|SUN)" /boot/config-5.10.13-sunxi CONFIG_IR_GPIO_CIR=m CONFIG_IR_SUNXI=m # Connected Vishay TSOP4838 IR Receiver to 3V3 (via 100R, with C100nF to GND), GND, OUT -> PL11 # +----------+ # 1 --- OUT ---! /--\ ! # 2 --- GND ---! | | ! # 3 --- 3V3 ---! \__/ ! # +----------+ # Get DTS and install as user overlay (commit 0ff3217) $ wget -O sun8i-h3-cir.dts https://raw.githubusercontent.com/armbian/sunxi-DT-overlays/master/sun8i-h3/sun8i-h3-cir.dts # Fix pin reference # from ir_pins_a (from DTS file) # to r_ir_rx_pin (from dtc -I fs -O dts /proc/device-tree) $ sed -e "s/ir_pins_a/r_ir_rx_pin/" sun8i-h3-cir.dts > sun8i-h3-cir-nanopineo.dts $ cat sun8i-h3-cir-nanopineo.dts /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&ir>; __overlay__ { pinctrl-names = "default"; pinctrl-0 = <&r_ir_rx_pin>; status = "okay"; }; }; }; $ armbian-add-overlay sun8i-h3-cir-nanopineo.dts Compiling the overlay Copying the compiled overlay file to /boot/overlay-user/ Reboot is required to apply the changes $ shutdown -r now $ dmesg | grep sunxi-ir [ 10.653323] rc rc0: sunxi-ir as /devices/platform/soc/1f02000.ir/rc/rc0 [ 10.653692] rc rc0: lirc_dev: driver sunxi-ir registered at minor = 0, raw IR receiver, no transmitter [ 10.653883] input: sunxi-ir as /devices/platform/soc/1f02000.ir/rc/rc0/input3 [ 10.665297] sunxi-ir 1f02000.ir: initialized sunXi IR driver # Protocols file is there == driver present and overlay loaded OK. $ cat /sys/class/rc/rc0/protocols rc-5 nec rc-6 jvc sony rc-5-sz sanyo sharp mce_kbd xmp imon rc-mm [lirc] # Enable "nec" protocol. # I tried them all to find out what encoding is used by the remote that I happened to have here. # There may be a smarter way where the IR subsystem tells you what encoding an incoming signal has. $ echo "+nec" > /sys/class/rc/rc0/protocols # The bracketed items appear to be [enabled] $ cat /sys/class/rc/rc0/protocols rc-5 [nec] rc-6 jvc sony rc-5-sz sanyo sharp mce_kbd xmp imon rc-mm [lirc] # Test: $ apt-get install ir-keytable $ ir-keytable Found /sys/class/rc/rc0/ with: Name: sunxi-ir Driver: sunxi-ir Default keymap: rc-empty Input device: /dev/input/event3 LIRC device: /dev/lirc0 Attached BPF protocols: Operation not supported Supported kernel protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp imon rc-mm Enabled kernel protocols: lirc nec bus: 25, vendor/product: 0001:0001, version: 0x0100 Repeat delay = 500 ms, repeat period = 125 ms $ ir-keytable -t Testing events. Please, press CTRL-C to abort. 147.355171: lirc protocol(necx): scancode = 0xe31947 147.355225: event type EV_MSC(0x04): scancode = 0xe31947 147.355225: event type EV_SYN(0x00). ^C # Test using event system (adjust Input device, cf. above): $ evtest /dev/input/event3 Input driver version is 1.0.1 Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100 Input device name: "sunxi-ir" Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 152 (KEY_SCREENLOCK) Event type 2 (EV_REL) Event code 0 (REL_X) Event code 1 (REL_Y) Event type 4 (EV_MSC) Event code 4 (MSC_SCAN) Key repeat handling: Repeat type 20 (EV_REP) Repeat code 0 (REP_DELAY) Value 500 Repeat code 1 (REP_PERIOD) Value 125 Properties: Property type 5 (INPUT_PROP_POINTING_STICK) Testing ... (interrupt to exit) Event: time 1612923728.916182, type 4 (EV_MSC), code 4 (MSC_SCAN), value e31948 Event: time 1612923728.916182, -------------- SYN_REPORT ------------ Event: time 1612923728.967737, type 4 (EV_MSC), code 4 (MSC_SCAN), value e31948 Event: time 1612923728.967737, -------------- SYN_REPORT ------------ ^C # From here on, use LIRC and/or adjust /etc/rc_maps.cfg et al. to map scan # codes to key codes. This makes the IR receiver compatible with media player # software. For the IoT device that I am building currently the scan codes # suffice, so I won't describe this here. (I am not really sure if that name change is a bug in the DTS repository, or if that name "ir_pins_a" refers to an older kernel, or if one is supposed to have another DT fragment somewhere that maps "ir_pins_a" to "r_ir_rx_pin", please comment if above is not the _right solution_.)