alexreinert / piVCCU

piVCCU is a project to install the original Homematic CCU3 firmware inside a virtualized container (lxc) on ARM based single board computers.
Apache License 2.0
302 stars 64 forks source link

Can't get piVCCU working for RPI-RF-MOD #329

Closed DennisGaida closed 3 years ago

DennisGaida commented 3 years ago

I do know piVCCU should be working with HMRPI-RF-MOD, so I must be doing something wrong. I just got a fresh HMRPI-RF-MOD delivered and wanted to tinker with it and my RPi 3B.

I have followed the steps outlined at https://github.com/alexreinert/piVCCU/blob/master/docs/setup/raspberrypi.md. The problem is that piVCCU just doesn't start and doesn't recognize the hardware. I do see the AMA0 device though - should I somehow test a raw serial connection?

Before playing around with a million things I got an installation error on a subroutine with status code 255. pivccu-info showed "lxc doesn't exist" and no HMRF hardware. I now played around some more (see bottom for things I have tried) and have a weird /dev/raw_uart5 for "connected via" which looks wrong.

ls -l /dev/ttyAMA0 crw--w---- 1 root tty 204, 64 Nov 30 23:22 /dev/ttyAMA0

**ls -l /dev/serial***

lrwxrwxrwx 1 root root  7 Nov 30 23:22 /dev/serial0 -> ttyAMA0
lrwxrwxrwx 1 root root  5 Nov 30 23:22 /dev/serial1 -> ttyS0

pivccu-info

piVCCU version: 3.53.34-49
Kernel modules: Available
Raw UART dev:   Available
Rasp.Pi UART:   Assigned to GPIO pins
HMRF Hardware:  unknown
 Connected via:  (/dev/raw-uart5)
 Board serial:  unknown
 Radio MAC:     unknown
HMIP Hardware:  unknown
 SGTIN:         unknown
 Radio MAC:     unknown
State:          STOPPED

/boot/cmdline.txt dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=53e33d80-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

more /boot/config.txt | grep -Ev "^([#\s])"

 hdmi_force_hotplug=1

 dtoverlay=pi3-disable-wifi

 dtparam=eth_led0=14
 dtparam=eth_led1=14

 dtparam=pwr_led_trigger=none
 dtparam=pwr_led_activelow=off

 dtparam=act_led_trigger=none
 dtparam=act_led_activelow=off

 enable_uart=1
 core_freq=250
 dtoverlay=pi3-miniuart-bt

 dtoverlay=pivccu-raspberrypi

sudo dpkg --get-selections | grep pivccu

pivccu-modules-dkms                             install
pivccu-modules-raspberrypi                      install
pivccu3                                         install

systemctl status pivccu.service

● pivccu.service - piVCCU
   Loaded: loaded (/lib/systemd/system/pivccu.service; enabled; vendor preset: enabled)
   Active: failed (Result: resources) since Mon 2020-11-30 23:09:01 CET; 2min 41s ago
  Process: 782 ExecStart=/var/lib/piVCCU3/start_container.sh (code=exited, status=0/SUCCESS)
      CPU: 531ms

Nov 30 23:08:25 raspberrypi start_container.sh[782]: <12>Nov 30 23:08:25 piVCCU3: HMIP hardware was not detected
Nov 30 23:08:26 raspberrypi start_container.sh[782]: kernel.sched_rt_runtime_us = -1
Nov 30 23:08:31 raspberrypi start_container.sh[782]: lxc-start: tools/lxc_start.c: main: 366 The container failed to start.
Nov 30 23:08:31 raspberrypi start_container.sh[782]: lxc-start: tools/lxc_start.c: main: 368 To get more details, run the container in foregro
Nov 30 23:08:31 raspberrypi start_container.sh[782]: lxc-start: tools/lxc_start.c: main: 370 Additional information can be obtained by setting
Nov 30 23:08:31 raspberrypi systemd[1]: pivccu.service: PID file /var/run/pivccu3.pid not readable (yet?) after start: No such file or directo
Nov 30 23:09:01 raspberrypi systemd[1]: pivccu.service: Daemon never wrote its PID file. Failing.
Nov 30 23:09:01 raspberrypi systemd[1]: Failed to start piVCCU.
Nov 30 23:09:01 raspberrypi systemd[1]: pivccu.service: Unit entered failed state.
Nov 30 23:09:01 raspberrypi systemd[1]: pivccu.service: Failed with result 'resources'.

brctl show

bridge name     bridge id               STP enabled     interfaces
br0             8000.b827eb7ba851       no              eth0
docker0         8000.0242ea3ede4d       no

I have already tried the following to no avail:

 sudo apt-get install --reinstall raspberrypi-bootloader raspberrypi-kernel
 sudo apt install lxc bridge-utils systemd
 <reboot>
 sudo apt-get install --reinstall pivccu-modules-raspberrypi
 <reboot>
 sudo apt-get install --reinstall pivccu3

I have tried force_turbo and core_freq in the boot config.

alexreinert commented 3 years ago

I don't know a HM-RF-MOD. Possible you mean RPI-RF-MOD or HM-MOD-RPI-PCB?

DennisGaida commented 3 years ago

Sorry, I meant RPI-RF-MOD. I can't get over all the weird names in the HM universe.

alexreinert commented 3 years ago

Can you please provide images how the radio module is connected to your Pi?

DennisGaida commented 3 years ago

Just sitting on the GPIO headers like shown here (including the case): https://de.elv.com/elv-komplettbausatz-funk-modulplatine-fuer-raspberry-pi-3-b-rpi-rf-mod-fuer-homematic-und-homematic-ip-152941

Besides that nothing "fancy" for the RPi. I'm using all 4 USB ports for a ConBee stick, a CUL, a 433MHz-Antenna and a LED. The CUL I want to replace with the RPI-RF-MOD in the long run.

alexreinert commented 3 years ago

Please provide output of following commands:

ls -la /dev/raw-uar*
dmesg | grep raw
detect-raw-uart /dev/raw-uart
alexreinert commented 3 years ago
dmesg | grep rtc
DennisGaida commented 3 years ago
 $ ls -la /dev/raw-uar*
ls: cannot access '/dev/raw-uar*': No such file or directory
 $ ls -la /dev/raw-*
ls: cannot access '/dev/raw-*': No such file or directory

then I did a pivccu-info and still got that reference to raw-uar:

 $ pivccu-info
piVCCU version: 3.53.34-49
Kernel modules: Available
Raw UART dev:   Not available
Rasp.Pi UART:   Assigned to GPIO pins
HMRF Hardware:  unknown
 Connected via:  (/dev/raw-uart5)
 Board serial:  unknown
 Radio MAC:     unknown
HMIP Hardware:  unknown
 SGTIN:         unknown
 Radio MAC:     unknown
State:          STOPPED
 $ dmesg | grep raw
[    0.879130] hidraw: raw HID events driver (C) Jiri Kosina
[    3.926835] hid-led 0003:27B8:01ED.0001: hidraw0: USB HID v1.01 Device [ThingM blink(1) mk2] on usb-3f980000.usb-1.1.3/input0
# that's the USB LED I previously mentioned.

dmesg | grep rtc doesn't return anything, detect-raw-uart isn't a command on my system, neither is detect.

Before fiddling around pivccu still didn't say anything was connected, but "connected via" reported "(/dev)" which also seemed weird (which is why I reinstalled and tried things).

alexreinert commented 3 years ago

There is a gap between the output of the first and the second pivccu-info. Did you uninstall the package pivccu-modules-raspberrypi or did you change the /boot/config.txt and removed the pivccu-raspberrypi device tree overlay?

Please run

sudo apt install --reinstall pivccu-modules-raspberrypi

and the reboot the system.

Afterwards, please run these commands:

ls -la /dev/raw-uar*
dmesg | grep raw
dmesg | grep rtc
detect_raw_uart /dev/raw-uart
DennisGaida commented 3 years ago

"Did you uninstall the package" - no only ever reinstall did not uninstall yet "change boot config" - well yes I did that some time ago, see the output above but I didn't change it recently. more /boot/config.txt | grep -Ev "^([#\s])" still returns the same data as in the OP "remove device tree overlay" - I suppose that is the dtoverlay setting. It's still there

I reinstalled the pivccu modules and following is the output of all commands (nice. different than before!):

 $ ls -la /dev/raw-uar*
crw------- 1 root root 241, 0 Dec  1 13:26 /dev/raw-uart
 $ dmesg | grep raw
[    0.879293] hidraw: raw HID events driver (C) Jiri Kosina
[    4.258643] hid-led 0003:27B8:01ED.0001: hidraw0: USB HID v1.01 Device [ThingM blink(1) mk2] on usb-3f980000.usb-1.1.3/input0
[    4.700362] generic_raw_uart: loading out-of-tree module taints kernel.
[    4.922358] pl011_raw_uart 3f201000.serial: Initialized pl011 device; mapbase=0x3f201000; irq=81; clockrate=47999625
[   13.678576] raw-uart raw-uart: Reset radio module
 $ dmesg | grep rtc
[    4.888193] rtc-rx8130 1-0032: Enabling charging of external capacitor
[    4.889439] rtc-rx8130 1-0032: Update timer was detected
[    4.895674] rtc-rx8130 1-0032: rtc core: registered rx8130-legacy as rtc0
$ detect_raw_uart /dev/raw-uart
-su: detect_raw_uart: command not found

I did find the command detect_radio_module now, but not detect_raw_uart. For completeness sake:

 $ pivccu-info
piVCCU version: 3.53.34-49
Kernel modules: Available
Raw UART dev:   Available
Rasp.Pi UART:   Assigned to GPIO pins
HMRF Hardware:  unknown
 Connected via:  (/dev/raw-uart5)
 Board serial:  unknown
 Radio MAC:     unknown
HMIP Hardware:  unknown
 SGTIN:         unknown
 Radio MAC:     unknown
State:          STOPPED
alexreinert commented 3 years ago

My bad, it should be

sudo detect_radio_module /dev/raw-uart
DennisGaida commented 3 years ago

:-(

$ detect_radio_module /dev/raw-uart
Error: Radio module was not detected
alexreinert commented 3 years ago

The three lines

Kernel modules: Available
Raw UART dev:   Available
Rasp.Pi UART:   Assigned to GPIO pins

together with the messages from dmesg are indicating, that all of the kernel stuff is working well.

Even though, no communication with the radio module is possible.

The last thing, you could try is a full power cycle of the Pi with at least 5 minutes without power for the entire system. If that isn't working, I would guess a hardware issue.

DennisGaida commented 3 years ago

I reassembled the RPI-RF-MOD to the RPi and also restarted - no luck. I then tried to just use another solution: RaspberryMatic on another SD card. Everything works without me making any changes. I could make RaspberryMatic talk to a new HM device right out of the box. But I don't want to use RaspberryMatic of course 😉

It must be the RPi installation I am using and some settings (and not a hardware fault) since there aren't any hardware changes I made. I would love to reset things or know where things are going wrong. I have also tried to disconnect all other USB devices which didn't help.

alexreinert commented 3 years ago

Far-fetched idea: Do you have anything that accesses the GPIOs? Can you provide the output of

sudo cat /sys/kernel/debug/gpio
DennisGaida commented 3 years ago

not that I would know

$ sudo cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-53, parent: platform/3f200000.gpio, pinctrl-bcm2835:
 gpio-16  (                    |rpi_rf_mod:red      ) out lo
 gpio-18  (                    |pivccu:reset        ) in  lo
 gpio-20  (                    |rpi_rf_mod:green    ) out lo
 gpio-21  (                    |rpi_rf_mod:blue     ) out hi
 gpio-29  (                    |led0                ) out lo

gpiochip1: GPIOs 504-511, parent: platform/soc:firmware:expgpio, raspberrypi-exp-gpio, can sleep:
 gpio-506 (                    |led1                ) out hi

I'm already planning just redoing the whole pi. Somehow feels like this is necessary just like you reinstall Windows every few years. Though I have no other problems than accessing this new RPI-RF-MOD.

DennisGaida commented 3 years ago

Alright I did some "things". As always I did many things and have yet to figure out which fixed it:

I'm pointing my finger at either the reinstall of pivccu3 or the Udev rules. I'll try reactivating things and see what comes out of it. Following some beautiful output:

 $ pivccu-info
piVCCU version: 3.53.34-49
Kernel modules: Available
Raw UART dev:   Available
Rasp.Pi UART:   Assigned to GPIO pins
HMRF Hardware:  RPI-RF-MOD
 Board serial:  5A4994028F
 Radio MAC:     0xFF028F
HMIP Hardware:  RPI-RF-MOD
 SGTIN:         3014F711A0001F5A4994028F
 Radio MAC:     0xB1E88F
State:          RUNNING
PID:            1112
CPU use:        1.62 seconds
BlkIO use:      18.64 MiB
Memory use:     21.82 MiB
KMem use:       1.96 MiB
Link:           vethpivccu
 TX bytes:      9.51 KiB
 RX bytes:      84.60 KiB
 Total bytes:   94.11 KiB
 $ detect_radio_module /dev/raw-uart
RPI-RF-MOD 5A4994028F 3014F711A0001F5A4994028F 0xFF028F 0xB1E88F 4.2.6

Is it correct that the RPI-RF-MOD is still "mounted" (whatever the word) to /dev/raw-uart? I always see it mounted to ttyAMA0?

alexreinert commented 3 years ago

/dev/raw-uart is correct as the communication needs to be done with a low level kernel module because the normal tty* is much too slow.

DennisGaida commented 3 years ago

Sorry for spamming you here - I just hope that my quest for a solution might help other users in the future.

pivccu-info can connect to the module

 $ pivccu-info
piVCCU version: 3.53.34-49
Kernel modules: Available
Raw UART dev:   Available
Rasp.Pi UART:   Assigned to GPIO pins
HMRF Hardware:  RPI-RF-MOD
 Board serial:  5A4994028F
 Radio MAC:     0xFF028F
HMIP Hardware:  RPI-RF-MOD
 SGTIN:         3014F711A0001F5A4994028F
 Radio MAC:     0xB1E88F
State:          RUNNING
PID:            1190
CPU use:        1.67 seconds
BlkIO use:      18.64 MiB
Memory use:     21.83 MiB
KMem use:       1.97 MiB
Link:           vethpivccu
 TX bytes:      22.65 KiB
 RX bytes:      130.35 KiB
 Total bytes:   153.00 KiB

but can't get a network connection (yellow blinking LED on the module after a while):

 $ sudo pivccu-attach cat /var/log/messages
Dec  3 09:37:09 piVCCU syslog.info syslogd started: BusyBox v1.29.2
Dec  3 09:37:09 piVCCU user.notice kernel: klogd started: BusyBox v1.29.2 (2020-10-13 10:15:05 CEST)
Dec  3 09:37:14 piVCCU user.notice kernel: [   27.785557] Bridge firewalling registered
Dec  3 09:37:16 piVCCU user.info kernel: [   29.085611] docker0: port 1(vetha4232ce) entered disabled state
Dec  3 09:37:16 piVCCU user.info kernel: [   29.086130] IPv6: ADDRCONF(NETDEV_UP): vetha4232ce: link is not ready
Dec  3 09:37:16 piVCCU user.info kernel: [   29.086147] docker0: port 1(vetha4232ce) entered forwarding state
Dec  3 09:37:17 piVCCU syslog.info syslogd exiting
Dec  3 09:37:17 ccu3-webui syslog.info syslogd started: BusyBox v1.29.2
Dec  3 09:37:17 ccu3-webui user.notice kernel: klogd started: BusyBox v1.29.2 (2020-10-13 10:15:05 CEST)
Dec  3 09:37:17 ccu3-webui daemon.err udhcpc[170]: started, v1.29.2
Dec  3 09:37:17 ccu3-webui daemon.err udhcpc[170]: sending discover
Dec  3 09:37:20 ccu3-webui daemon.err udhcpc[170]: sending discover
[...]
 $ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.b827eb7ba851       no              eth0
                                                        vethpivccu
docker0         8000.0242f5016136       no
 $ pivccu-attach ping www.heise.de
ping: bad address 'www.heise.de'

maybe of note: detect_radio_module again doesn't detect, but pivccu-info returns state "running":

 $ detect_radio_module /dev/raw-uart
Error: Radio module was not detected

after a while pivccu-info does return an IP, but the module's LED is still blinking yellow:

 $ pivccu-info
piVCCU version: 3.53.34-49
Kernel modules: Available
Raw UART dev:   Available
Rasp.Pi UART:   Assigned to GPIO pins
HMRF Hardware:  RPI-RF-MOD
 Board serial:  5A4994028F
 Radio MAC:     0xFF028F
HMIP Hardware:  RPI-RF-MOD
 SGTIN:         3014F711A0001F5A4994028F
 Radio MAC:     0xB1E88F
State:          RUNNING
PID:            1190
IP:             169.254.7.40
CPU use:        31.73 seconds
BlkIO use:      61.82 MiB
Memory use:     153.01 MiB
KMem use:       4.79 MiB
Link:           vethpivccu
 TX bytes:      125.17 KiB
 RX bytes:      623.07 KiB
 Total bytes:   748.24 KiB

I can't connect to this IP 169.254.7.40 in any way. Neither externally via ping/browser nor internally on the RPi host via ping/curl.

alexreinert commented 3 years ago

Known issue of Docker: Docker adds some iptables rules, which prevent DHCP packages pass on all bridges, not only on the docker0 bridge.

DennisGaida commented 3 years ago

Great pointer! I have a piVCCU UI accessible via browser 😊

https://github.com/docker/for-linux/issues/103 helped solved this issue: sudo -I DOCKER-USER -i br0 -o br0 -j ACCEPT

and add to the iptables-persistent rules (/etc/iptables/rules.v4`)

I would think this issue can be closed. Thank you Alex!