nymea / berrylan

Raspberry Pi WiFi setup
http://berrylan.org
GNU General Public License v3.0
335 stars 55 forks source link

Trouble with installing on ubuntu server 22.04 on Raspberry Pi 3B #72

Closed vino-dk closed 2 years ago

vino-dk commented 2 years ago

I've followed the instructions on a clean image of ubuntu server 22.04 for Raspberry Pi 3B and I've narrowed down the problem to nymea-networkmanager failing to start:

I | Application: Using configuration file from: "/etc/nymea/nymea-networkmanager.conf"
 I | Application: =====================================
 I | Application: Starting nymea-networkmanager "1.1.0+202205050151~jammy1"
 I | Application: =====================================
 I | Application: Advertising name: "BT WLAN setup"
 I | Application: Platform name: "nymea-box"
 I | Application: Mode: Core::ModeOffline
 I | Application: Timeout: 60
 I | Application: DBus interface: "system"
 W | NymeaService: Invalid D-Bus HardwareManager interface.
 W | NymeaService: Could not init nymea D-Bus services
 W | DBus: Failed to register D-Bus service.
 I | Application: Not starting the service yet because the networkmanager is not available.
 I | Application: Networkmanager is now available.
 I | Application: Start the bluetooth service because of "offline" mode
t-mon commented 2 years ago

Looks like the daemon started, are there more logs? The NymeaService warnings are not a problem, that's an optional feature if running along nymead.

Is your bluetooth setup ok?

hciconfig -a
ttolbol commented 2 years ago

Hi, coworker here, working on the same problem. Good to know that the warnings are not the problem. Output from hciconfig -a:

hci0:   Type: Primary  Bus: UART                                                                                                                                                                                                                     
BD Address: B8:27:EB:ED:E7:C0  ACL MTU: 1021:8  SCO MTU: 64:1                                                                                                                                                                                
UP RUNNING                                                                                                                                                                                                                                   
RX bytes:1611 acl:0 sco:0 events:103 errors:0                                                                                                                                                                                                
TX bytes:1961 acl:0 sco:0 commands:103 errors:0                                                                                                                                                                                              
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87                                                                                                                                                                                            
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3                                                                                                                                                                                             
Link policy: RSWITCH SNIFF                                                                                                                                                                                                                   
Link mode: PERIPHERAL ACCEPT                                                                                                                                                                                                                 
Name: '***'                                                                                                                                                                                                                          
Class: 0x000000                                                                                                                                                                                                                              
Service Classes: Unspecified                                                                                                                                                                                                                 
Device Class: Miscellaneous,                                                                                                                                                                                                                 
HCI Version: 5.0 (0x9)  Revision: 0x156                                                                                                                                                                                                      
LMP Version: 5.0 (0x9)  Subversion: 0x6119                                                                                                                                                                                                   
Manufacturer: Cypress Semiconductor (305)

Turns out that running service nymea-networkmanager restart after booting works perfectly, so it seems that the service starts up before bluetooth is ready to use somehow.

t-mon commented 2 years ago

Sounds like a race condition or something changed in Jammy we are not aware of yet. Need to check what changed since there are other issues which might be 22.04 related.

vino-dk commented 2 years ago

I agree that it could have something to do with a race condition during boot-up. To mitigate this I added multi-user.target to the requires field in the nymea-networkmanager.service file. It seems that once the system has started the service files for this requirement, the advertisement starts and shows up in the berrylan app.

However this takes a while (~3 min), so I'll try to see if I can apply a different target or just disable some services that we won't use required by multi-user.target.

t-mon commented 2 years ago

https://github.com/nymea/nymea-networkmanager/blob/master/debian/nymea-networkmanager.service

Actually, the service is wanted by the graphical.target, and is configured to be started After the multi-user.target, since we already had once such a situation, reaching the graphical.target all required services are up and running (network-manager and bluez).

Are there more logs if you do a clean boot? Like warnings or something?

vino-dk commented 2 years ago

On a clean image of ubuntu server 22.04, we did the following steps to make it work. We added nymea to apt sources and fetched the key, then:

Install the apt packages and auxillary packages

sudo apt update
sudo apt install nymea-networkmanager dirmngr

Install Bluetooth

sudo apt install bluetooth pi-bluetooth bluez
Add "btusb" to /etc/modules-load.d/modules.conf

Following this, we edited the nymea-networkmanager.service file so it was wanted by multi-user.target. It reduced the time of device advertisement by 2 min. bringing it down to ~50s from booting up. It works fine but I will get back if we encounter any issues in this regard.