bluetoothd error: adapter_ops_setup failed - bluetooth

I am trying to create a GATT Service with BLE in Raspberry pi 2 (Kernel Version: Linux raspberrypi 4.1.7-v7+ and Bluez version: 5.11). I have connected leoxsys BLE adapter with the pi. I am able to advertise as iBeacon and the advertising signal is detected in "Beacon Bits" iOS App. Based on this tutorial I ran the command sudo /usr/sbin/bluetoothd --plugin=time -n to start the example GATT service. It returned the following:
bluetoothd[4818]: Bluetooth daemon 4.99
bluetoothd[4818]: Starting SDP server
bluetoothd[4818]: Ignoring (cli) pnat
bluetoothd[4818]: Ignoring (cli) audio
bluetoothd[4818]: Ignoring (cli) sap
bluetoothd[4818]: Ignoring (cli) input
bluetoothd[4818]: Ignoring (cli) serial
bluetoothd[4818]: Ignoring (cli) network
bluetoothd[4818]: Ignoring (cli) proximity
bluetoothd[4818]: Ignoring (cli) service
bluetoothd[4818]: Ignoring (cli) gatt_example
bluetoothd[4818]: Ignoring (cli) alert
bluetoothd[4818]: Ignoring (cli) health
bluetoothd[4818]: Ignoring (cli) thermometer
bluetoothd[4818]: Ignoring (cli) hciops
bluetoothd[4818]: Ignoring (cli) mgmtops
bluetoothd[4818]: Ignoring (cli) formfactor
bluetoothd[4818]: Ignoring (cli) storage
bluetoothd[4818]: Ignoring (cli) adaptername
bluetoothd[4818]: Ignoring (cli) wiimote
bluetoothd[4818]: Ignoring (cli) dbusoob
bluetoothd[4818]: Failed to init time plugin
bluetoothd[4818]: adapter_ops_setup failed
How to resolve the following error:
bluetoothd[4818]: Failed to init time plugin
bluetoothd[4818]: adapter_ops_setup failed

Related

Cannot start J-Link GDB Server on Ubuntu

I am currently working on the ARM Cortex-M4 inside the NXP i.MX8M Mini.
I am able to compile a project for M4 on Eclipse IDE on an Ubuntu VM.
I would now like to debug on the M4 via a SEGGER Flasher ARM probe, still from Ubuntu.
My probe is well recognized by Ubuntu, and I can launch the J-Link GDB server by simply typing the command :
$ sudo ./JLinkGDBServerCLExe
However, if I type the same command without sudo, I get :
$ ./JLinkGDBServerCLExe
SEGGER J-Link GDB Server V7.58b Command Line Version
JLinkARM.dll V7.58b (DLL compiled Nov 16 2021 15:04:27)
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: Unspecified
Target interface: JTAG
Target interface speed: 4000kHz
Target endian: little
Connecting to J-Link...
Connecting to J-Link failed. Connected correctly?
GDBServer will be closed...
Shutting down...
Could not connect to J-Link.
Please check power, connection and settings.
My problem is that when I start eclipse, I get the same result as starting the GDB server without sudo.
It seems that this is a rights issue, how can I solve it?
As #KamilCuk said, the problem came from the udev rules.
So you just have to copy the rules provided by Segger with J-Link Software on the system:
$ sudo cp 99-jlink.rules /etc/udev/rules.d
Then you have to reboot the system:
$ reboot

Bluetooth module not loaded sometimes on reboot in Raspbian Buster, Raspberry Pi 4

I have written a bluez application on Raspbian Buster, Raspberry Pi 4. In some reboots, the bluetooth module and service are not loaded.
On checking the bluetooth.service with command: $ sudo systemctl status bluetooth.service,
I see, Condition check resulted in Bluetooth service being skipped.
I checked $ lsmod and $ dmesg logs for both issue and non-issue conditions.
The difference I find in the lsmod is shown below:
The difference I find in the dmesg log is shown below:
The left side is the issue case and the right side is non issue case.
How can I fix the issue so that the bluetooth works consistently?
I am using Raspbian Lite OS 2020-02-14.
Update 1 [03 Feb 2021]: I checked the journalctl log for the issue case and found this:
Feb 03 11:52:18 pi btuart[373]: Failed to reset chip, invalid HCI event
Feb 03 11:52:18 pi btuart[373]: Can't initialize device: Success
Feb 03 11:52:18 pi btuart[373]: bcm43xx_init
Feb 03 11:52:18 pi systemd[1]: hciuart.service: Control process exited, code=exited, status=1/FAILURE
Feb 03 11:52:18 pi systemd[1]: hciuart.service: Failed with result 'exit-code'.
Feb 03 11:52:18 pi systemd[1]: Failed to start Configure Bluetooth Modems connected by UART.
Update 2 [03 Feb 2021]: My /boot/config.txt contents:
dtparam=i2c_arm=on
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25
dtoverlay=spi1-1cs
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
[all]
dtoverlay=vc4-fkms-v3d
disable_splash=1
enable_uart=1
max_usb_current=1
dtoverlay=uart2
dtoverlay=i2c-rtc,ds3231
gpu_mem=256
My cmdline.txt contents:
console=tty1 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait logo.nologo vt.global_cursor_default=0 consoleblank=1 loglevel=1 quiet
My orientation sensor was interfaced to UART2 of Raspberry Pi 4. On getting suggestion from #svin83 , I disabled UART2. After that I rebooted the Pi 4 10 times and the bluetooth worked correctly all the times.
I moved the sensor to I2C-3 bus in Raspberry Pi 4.
As per the documentation, UART Configuration, the UART2 should not have interfered with bluetooth functionality, but it turns out it does.

Xlib.error.DisplayConnectionError when running my python program on os startup using systemd

Basic background info:
I'm trying to run my program on os startup (my current OS is Debian 9
latest stable release)
my project is listening to the keyboard using Xlib library and I'm also
using Tkinter to pop up some UI windows.
this is /etc/system/system/my_project.service
[Unit]
Description=Daemon tool that opens the required environment given a
certain shortcut key
[Service]
Environment="DISPLAY=:0"
ExecStart=/usr/local/bin/keyboard_listener.py
[Install]
WantedBy=multi-user.target
after reboot I run:
sudo systemctl status my_project.service
and I get the following error
May 08 11:49:43 debian keyboard_listener.py[303]: File
"/usr/local/lib/python3.5/dist-packages/Xlib/protocol/display.py",
line 90, in init
May 08 11:49:43 debian keyboard_listener.py[303]: self.socket =
connect.get_socket(name, protocol, host, displayno)
May 08 11:49:43 debian keyboard_listener.py[303]: File
"/usr/local/lib/python3.5/dist-packages/Xlib/support/connect.py", line
87, in get_socket
May 08 11:49:43 debian keyboard_listener.py[303]: return
mod.get_socket(dname, protocol, host, dno)
May 08 11:49:43 debian keyboard_listener.py[303]: File
"/usr/local/lib/python3.5/dist-packages/Xlib/support/unix_connect.py",
line 113, in get_socket
May 08 11:49:43 debian keyboard_listener.py[303]: raise
error.DisplayConnectionError(dname, str(val))
May 08 11:49:43 debian keyboard_listener.py[303]:
Xlib.error.DisplayConnectionError: Can't connect to display ":0":
[Errno 111] Connection refused
May 08 11:49:43 debian systemd[1]: my_project.service: Main
process exited, code=exited, status=1/FAILURE
May 08 11:49:43 debian systemd[1]: my_project.service: Unit
entered failed state.
May 08 11:49:43 debian systemd[1]: my_project.service: Failed
with result 'exit-code'.
how can I solve this issue(Erron 111)? should I add something to my_project.service
and how can I make my project to run on startup?
tl;dr: systemd won't work
In absence of explicit ordering dependencies, systemd processes all units in a transaction simultaneously. That means it does not and will not wait for X server to become available on display :0 before starting your .service unit.
In modern GNU/Linux distributions, X server is not started directly by any systemd unit, so you cannot specify a systemd ordering dependency on X server. Hence systemd is not suitable for whatever you are trying to accomplish, at least not until more fine-grained dependency mechanisms are implemented in systemd.
suggested workarounds
As a workaround, you may try /etc/xdg/autostart, ~/.config/autostart or ~/.xinitrc (whatever is applicable for your X.org setup). These scripts are guaranteed to be run from inside a graphical user session.
If status monitoring is desired, you can combine both methods and start a transient systemd unit with systemd-run(1) or equivalent from inside one of those scripts.

Unable to launch weston on linux yocto from ssh

I have the error "no drm device found" as shown below.
I thinks the mail error is fatal: failed to create compoitor backend.
I have the following in my lib
desktop-shell.so drm-backend.so fbdev-backend.so fullscreen-shell.so gl-renderer.so hmi-controller.so ivi-shell.so wayland-backend.so x11-backend.so
root#salvator-x:/etc/systemd/system/multi-user.target.wants# /usr/bin/weston-launch \
-u root -- --idle-time=0 --config=/etc/xdg/weston/weston-drm-hdmi.ini $OPTARGS
Date: 2018-02-26 UTC
[21:29:08.949] weston 1.11.0
http://wayland.freedesktop.org
Bug reports to: https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland&component=weston&version=1.11.0
Build: a9df8430-dirty v4l2-renderer: Fix calcluation of clip region (2017-04-13 18:25:00 +0900)
[21:29:08.949] OS: Linux, 4.9.0-yocto-standard, #1 SMP PREEMPT Mon Feb 26 17:46:03 EST 2018, aarch64
[21:29:08.949] Using config file '/etc/xdg/weston/weston-drm-hdmi.ini'
[21:29:08.950] Output repaint window is 34 ms maximum.
[21:29:08.950] Loading module '/usr/lib/weston/drm-backend.so'
[21:29:08.954] initializing drm backend
[21:29:08.954] logind: failed to get session seat
[21:29:08.954] logind: cannot setup systemd-logind helper (-61), using legacy fallback
[21:29:08.955] no drm device found
[21:29:08.955] fatal: failed to create compositor backend
failed to restore keyboard mode: Bad file descriptor
failed to set KD_TEXT mode on tty: Bad file descriptor
could not reset vt handling
How do I launch weston on linux yocto?
Here is the image:
So.. I found the answer to my question
it has three errors logind (systemd) was having trouble access the input keyboard type
second one is drm device is not found which implies that you have trouble accesing your output port. try to troubleshoot the port make it accessible to the board and then try to launch weston with correct config.
NOTE: Weston wayland wont launch if you dont have keyboard or a mouse connected preferably a usb

Bluetooth LE on Raspbian does not bond with nRF

I have an Rpi3 and I want to bond it with nRF which is connected to my laptop via UART. This nRF-laptop connection shows me whether Rpi3 is connected and/or paired with nRF. I am able to connect to the nRF device by running:
gatttool -t random -b XX:XX:XX:XX:XX:XX -I
I found that to be able to pair it, all I need to do is run the following command after I connected using gattool:
sec-level medium
However, nRF device only showed "Connected".
Then I tried using bluetoothctl command. I made sure the power is on, agent is on, it's discoverable and etc. After I ran the command pair XX:XX:XX:XX:XX:XX, it said it was successful. This was also confirmed after running info XX:XX:XX:XX:XX:XX. Yet nRF device did not react to the pairing. If I connect to nRF device through my phone using "nRF Connect" app, then nRF shows that my phone is paired.
I am running:
Linux 4.9.13-v7+ #974 SMP Wed Mar 1 20:09:48 GMT 2017 armv7l GNU/Linux
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
Bluez-5.44
I followed tutorials from adafruit and stackoverflow. I read that for Bluez-5.44 I do not need to run bluetooth in the experimental mode.
What am I missing? I would appreciate any help.
To any lost souls who might have also been stuck in this situation, here is how I solved it (you need to run sudo for the following commands):
$ service bluetooth stop
$ /etc/init.d/bluetooth start
If the nRF device has been paired once and then restarted, that means the pairing key is still on Pi's side which needs to be removed and can be done by:
$ bluetoothctl
$ remove XX:XX:XX:XX:XX:XX
$ exit
After this you need to start bluetooth device:
$ hciconfig hci0 up

Resources