BlueZ: No default controller available - embedded-linux

I'm setting up Linux device to act as BLE host, and ESP32 to work as a BLE controller over UART.
I'm using BlueZ v5.55, with btattach and bluetoothctl utilities, and bluetoothd running in the background. However, after finishing the setup bluetoothctl still says No default controller available.
# /usr/bin/btattach -B /dev/ttymxc1 -S 921600 --protocol h4 &
# Attaching Primary controller to /dev/ttymxc1
Switched line discipline from 0 to 15
Device index 0 attached
# /usr/libexec/bluetooth/bluetoothd
# bluetoothctl
Agent registered
[bluetooth]# power on
No default controller available
Output of btmon:
# btmon
Bluetooth monitor ver 5.55
= Note: Linux version 5.4.8 (armv7l) 0.258161
= Note: Bluetooth subsystem version 2.22 0.258269
= New Index: 00:00:00:00:00:00 (Primary,UART,hci0) [hci0] 0.258314
# MGMT Open: bluetoothd (privileged) version 1.14 {0x0001} 0.258357
Output of dmesg during kernel start:
# dmesg | grep Blu
[ 0.643821] Bluetooth: Core ver 2.22
[ 0.644222] Bluetooth: HCI device and connection manager initialized
[ 0.644528] Bluetooth: HCI socket layer initialized
[ 0.644622] Bluetooth: L2CAP socket layer initialized
[ 0.645069] Bluetooth: SCO socket layer initialized
[ 4.678559] Bluetooth: HCI UART driver ver 2.3
[ 4.683346] Bluetooth: HCI UART protocol H4 registered
[ 4.688821] Bluetooth: HCI UART protocol LL registered
The ESP32 is running UART HCI controller firmware: https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/hci/controller_hci_uart
The host is running a Buildroot-created Linux with BR2_PACKAGE_BLUEZ_TOOLS=y and a kernel with CONFIG_BT=y, CONFIG_BT_LE=y, CONFIG_BT_HCIUART=y, CONFIG_BT_HCIUART_H4=y.
I have 4 UART lines connected TX->RX, RX->TX, RTS->CTS and CTS->RTS.
I have checked the UART communication with the same HW setup - I can exchange data over UART with the ESP32 (in both directions).
The commands are run as root.
What am I missing here?
If you have any decent documentation on BlueZ HCI setup, I'll be happy to see it.
EDIT: I also installed hcidump and hciconfig (normally deprecated in BLueZ v5.55). Here is a log from hcidump:
# hcidump
HCI sniffer - Bluetooth packet analyzer ver 5.55
device: hci0 snap_len: 1500 filter: 0xffffffff
< HCI Command: Read Local Supported Features (0x04|0x0003) plen 0
< HCI Command: Read Local Version Information (0x04|0x0001) plen 0
< HCI Command: Read BD ADDR (0x04|0x0009) plen 0
(in 2nd terminal)
# hciconfig hci0 up
Can't init device hci0: Connection timed out (110)

After a few days, I have found a solution of this problem.
I have also used nRF52 DK as an alternative to better understand if the problem lies on the side of ESP32 controller, or on the side of Linux host. Because the nRF HCI UART worked on Ubuntu 20.04, but didn't work on my embedded Linux, I looked deeper on the Linux host side.
After starting BlueZ daemon with
bluetoothd -n
it showed more details:
bluetoothd[593]: src/adapter.c:get_static_addr() Failed to open crypto
bluetoothd[593]: No Bluetooth address for index 0
Which led me to this topic: https://github.com/raspberrypi/linux/issues/3628
It turns out, when attaching the UART HCI controller with btattach, BlueZ was not able to create a static address, because of missing Linux kernel crypto interface in user-space.
I compiled the kernel with additional configs:
CONFIG_CRYPTO_USER
CONFIG_CRYPTO_USER_API
CONFIG_CRYPTO_USER_API_AEAD
CONFIG_CRYPTO_USER_API_HASH
CONFIG_CRYPTO_AES
CONFIG_CRYPTO_CCM
CONFIG_CRYPTO_AEAD
CONFIG_CRYPTO_CMAC
After that change, I was able to attach the Bluetooth controller to my Embedded Linux host.

Related

Webcam in Lenovo Ideapad 3 horrible resolution in Ubuntu 20.04

Got Lenovo Ideapad 3 at end of year. Installed ubuntu 20.04 on it. Webcam "works" but the image is undistinguishable (basically an indescript blob and I don't look that bad). Can run hand in front of webcam and see some change to blob, but nothing recognizable. Can turn camera on and off. Not a pro, so I've been searching and gathered the following data:
uname -a
Linux mjcasile-IdeaPad-3-15IIL05 5.8.0-44-generic #50~20.04.1-Ubuntu SMP Wed Feb 10 21:07:30 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Many refs to fix in 5.4.0-37-generic ... but figuring I'm at 5.8.0-44-generic would include it. Should I research backing off to 5.4.0-37-generic ? Not sure kernel level is the issue
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
sudo lshw
output includes this:
*-usb:0
description: Video
product: Integrated Camera
vendor: Chicony Electronics Co.,Ltd.
physical id: 5
bus info: usb#1:5
version: 27.11
serial: 0001
capabilities: usb-2.01
configuration: driver=uvcvideo maxpower=500mA speed=480Mbit/s
lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 2386:4339 Raydium Corporation Raydium Touch System
Bus 001 Device 002: ID 04f2:b6d9 Chicony Electronics Co., Ltd Integrated Camera
Bus 001 Device 004: ID 8087:0aaa Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
ls -l /dev/video*
crw-rw----+ 1 root video 81, 0 Mar 14 20:13 /dev/video0
crw-rw----+ 1 root video 81, 1 Mar 14 20:13 /dev/video1
dmesg
Pertinent info (per my untrained eye)
[ 2.151466] usb 1-5: New USB device found, idVendor=04f2, idProduct=b6d9, bcdDevice=27.11
[ 2.151467] usb 1-5: New USB device strings: Mfr=3, Product=1, SerialNumber=2
[ 2.151468] usb 1-5: Product: Integrated Camera
[ 2.151469] usb 1-5: Manufacturer: Chicony Electronics Co.,Ltd.
[ 2.151470] usb 1-5: SerialNumber: 0001
...
[ 2.810480] uvcvideo: Found UVC 1.10 device Integrated Camera (04f2:b6d9)
...
[ 2.797385] videodev: Linux video capture interface: v2.00
[ 2.807515] intel_rapl_common: Found RAPL domain package
[ 2.807517] intel_rapl_common: Found RAPL domain core
[ 2.807518] intel_rapl_common: Found RAPL domain uncore
[ 2.807867] mei_hdcp 0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04: bound 0000:00:02.0 (ops i915_hdcp_component_ops [i915])
[ 2.810480] uvcvideo: Found UVC 1.10 device Integrated Camera (04f2:b6d9)
[ 2.811987] input: Raydium Corporation Raydium Touch System as /devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6:1.0/0003:2386:4339.0002/input/input12
[ 2.812088] hid-multitouch 0003:2386:4339.0002: input,hiddev0,hidraw1: USB HID v1.10 Device [Raydium Corporation Raydium Touch System] on usb-0000:00:14.0-6/input0
[ 2.812132] usbcore: registered new interface driver usbhid
[ 2.812133] usbhid: USB HID core driver
[ 2.816014] input: Integrated Camera: Integrated C as /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5:1.0/input/input13
[ 2.816062] usbcore: registered new interface driver uvcvideo
[ 2.816063] USB Video Class driver (1.1.1)
...
[ 3.814863] ACPI: Video Device [GFX0] (multi-head: yes rom: no post: no)
[ 3.815098] input: Video Bus as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/LNXVIDEO:00/input/input14
[ 3.815322] snd_hda_intel 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
[ 3.816277] fbcon: i915drmfb (fb0) is primary device
[ 3.816318] Console: switching to colour frame buffer device 170x48
(on a prior run I also saw:
[ 0.168948] ACPI: Added _OSI(Linux-Dell-Video))
When I bring up VLC and Open Capture Device ... I get error:
Your input can't be opened: VLC is unable to open the MRL 'v4l2:///dev/video0'. Check the log for details.
Any idea where to begin on this? Thanks,
OK, clearly an embarrassing answer. The little label telling one how to turn the webcam on and off was actually covering the camera. Take off the label, and voila. All is good. I guess that qualifies as a "hardware" problem. More of a DFU though (Dumb darn user).

I2C driver changes to recognize multiple buses

We have defined the analog videoIn adv7180 metadata hardware definition in the i2c2 node in one iMX device tree file. The ultimate aim is to recognize adv7180 driver from the i2c2 bus.
During the boot process of the processor using the linux image made with defconfig changes for I2C, the second I2C bus is not getting recognized.
Given below are the serial console print statements:
U-Boot 2015.10+fslc+g1b6aee7 (Jan 16 2018 - 14:57:01 +0530)
CPU: Freescale i.MX6Q rev1.2 996 MHz (running at 792 MHz)
CPU: Automotive temperature grade (-40C to 125C) at 26C
Reset cause: POR
Board: MX6-SabreSD
I2C: ready
Line 129: i2c i2c-1: IMX I2C adapter registered //i2c-2 not registered??
Line 272 onwards: i2c /dev entries driver
IR NEC protocol handler initialized
IR RC5(x) protocol handler initialized
IR RC6 protocol handler initialized
IR JVC protocol handler initialized
IR Sony protocol handler initialized
IR RC5 (streamzap) protocol handler initialized
IR SANYO protocol handler initialized
IR MCE Keyboard/mouse protocol handler initialized
mxc_v4l2_output v4l2_out.28: V4L2 device registered as video16
mxc_v4l2_output v4l2_out.28: V4L2 device registered as video17
i2c-core: driver [mag3110] using legacy suspend method
i2c-core: driver [mag3110] using legacy resume method
I have written these extra lines in defconfig files in the source directory of my Yocto Built.
CONFIG_IMX_HAVE_PLATFORM_IMX_I2C=y
# CONFIG_I2C_COMPAT is not set
CONFIG_I2C_CHARDEV=y
# CONFIG_I2C_HELPER_AUTO is not set
CONFIG_I2C_ALGOPCF=m
CONFIG_I2C_ALGOPCA=m
CONFIG_I2C_ALGOBIT=y
CONFIG_I2C_IMX=y
CONFIG_I2C_MUX=y
CONFIG_I2C_MUX=y
I have also check Kconfig files and seen that i2c driver is passed from the kernel-source directory in the built.
Do I have to make modifications to the C-files (driver files) made in the path /home/fsl-community-bsp-myproject/build/tmp/work-shared/imx6qonlinepdd/kernel-source/drivers/i2c of my yocto built?
There is even a C file for adv7180 in the sub-directory /drivers/media , can it be modified?
you should look in the device tree you're using if i2c bus 2 is enabled.
You need to add the folowing line in your dts :
&i2c2 { // Change the name as needed
status = "okay";
pinctrl-names = "default";
}
You've probably status = "disabled"; in the i2c node you're seeking.
EDIT:
At first glance provided dts (https://pastebin.com/Y0esXmaX) seems ok. In order to debug further, one shall look into /dev/ directory in order to find the i2c bus.
As an example :
root#pico-imx8mq:~# ls /dev/*i2c*
/dev/i2c-0 /dev/i2c-1 /dev/i2c-2
This means I have 3 i2c bus and I can find them all on my dts. If you don't have the bus there you probably do have a dts problem.
dmesg | grep i2c might also give some hints.
You can also use i2cdetect from i2ctools package :
root#pico-imx8mq:~# i2cdetect -y 0 ## that will detect devices on first i2c bus
root#pico-imx8mq:~# i2cdetect -y 1 ## that will detect devices on second i2c bus
root#pico-imx8mq:~# i2cdetect -y 2 ## that will detect devices on third i2c bus

Allwinner A13 hang on boot and return "SPL:Unsupported Boot Device!" error

I am new in here and I am sorry my bad English.
I have OLinuXino A13 board. I endeavor kernel and boot events. So I try boot OLinuxino-A13 via spiflash(in FEL mode). I connected board to my PC(USB OTG). I Sending commands from my computer for writing to spiflash. And differently I build second connect with usb-ttl. So I can see opening writing of board with CuteCom program from my PC. And I use sunxi-tools for write to spiflash of my board.
And I did this:
I compiled kernel and I created u-boot-sunxi-with-spl.bin file. After I entered FEL mode and I wrote this file to on my board with ./sunxi-fel spiflash-write 0 /path/u-boot-sunxi-with-spl.bin. When I use boot my board from PC with ./sunxi-fel uboot /path/u-boot-sunxi-with-spl.bin, my board start and it work for find to sd card. Result this:
U-Boot SPL 2019.04-rc1-00141-g63f7e3fca3 (Feb 19 2019 - 17:23:48 +0300)
DRAM: 512 MiB
CPU: 1008000000Hz, AXI/AHB/APB: 3/2/2
Trying to boot from FEL
U-Boot 2019.04-rc1-00141-g63f7e3fca3 (Feb 19 2019 - 17:23:48 +0300) Allwinner Technology
CPU: Allwinner A13 (SUN5I)
Model: Olimex A13-Olinuxino
I2C: ready
DRAM: 512 MiB
MMC: mmc#1c0f000: 0
Loading Environment from FAT... MMC: no card present
Setting up a 1024x768 vga console (overscan 0x0)
In: serial
Out: vga
Err: vga
Allwinner mUSB OTG (Peripheral)
Net:
Warning: usb_ether using MAC address from ROM
eth0: usb_ether
starting USB...
USB0: USB EHCI 1.00
USB1: USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
scanning bus 1 for devices... 1 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 2 <0x08><0x08><0x08> 1 <0x08><0x08><0x08> 0
MMC: no card present
Device 0: unknown device
But differently if I restart my board after(card is out of fel mode) ./sunxi-fel spiflash-write 0 /path/u-boot-sunxi-with-spl.bin command. Result this:
U-Boot SPL 2019.04-rc1-00141-g63f7e3fca3 (Feb 19 2019 - 17:23:48 +0300)
DRAM: 512 MiB
CPU: 1008000000Hz, AXI/AHB/APB: 3/2/2
SPL: Unsupported Boot Device!
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
A13-OLinuxino_defconfig file:
CONFIG_ARM=y
CONFIG_ARCH_SUNXI=y
CONFIG_SPL=y
CONFIG_MACH_SUN5I=y
CONFIG_DRAM_CLK=408
CONFIG_DRAM_EMR1=0
CONFIG_MMC0_CD_PIN="PG0"
CONFIG_USB0_VBUS_DET="PG1"
CONFIG_USB1_VBUS_PIN="PG11"
CONFIG_AXP_GPIO=y
# CONFIG_VIDEO_HDMI is not set
CONFIG_VIDEO_VGA_VIA_LCD=y
CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH=y
CONFIG_VIDEO_LCD_POWER="AXP0-0"
CONFIG_VIDEO_LCD_BL_PWM="PB2"
CONFIG_NR_DRAM_BANKS=1
# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
CONFIG_SPL_I2C_SUPPORT=y
CONFIG_CMD_DFU=y
# CONFIG_CMD_FLASH is not set
CONFIG_CMD_USB_MASS_STORAGE=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_PARTITION_UUIDS is not set
CONFIG_DEFAULT_DEVICE_TREE="sun5i-a13-olinuxino"
CONFIG_DFU_RAM=y
CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
CONFIG_AXP_ALDO3_VOLT=3300
CONFIG_CONS_INDEX=2
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_MUSB_GADGET=y
CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=yONFIG_AXP_ALDO3_VOLT=3300
CONFIG_CONS_INDEX=2
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_MUSB_GADGET=y
CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
I struggle for exceed this error and want to see result like on above. How can I fix this error?

AT91SAM9263ek booting Linux with Device Tree failed

I have problem booting Linux 3.16.1. I have compiled sources from http://www.kernel.org with at91sam9263_defconfig.
I have added Flattened Device Tree support in Boot options.
Followin tips suggested in this (https://www.slideshare.net/softpapa/device-tree-support-on-arm-linux-8930303) presentation to turn on Support device tree in /proc but i don't have that option in menuconfig.
I have U-Boot bootloader version 2014.10rc2 which supports device tree.
I have generated dtb from script shipped with kernel:
make at91sam9263ek.dtb
And now i'm getting this error:
Welcome to minicom 2.5
OPTIONS: I18n
Compiled on Feb 9 2011, 14:45:00.
Port /dev/ttyS0
Press CTRL-A Z for help on special keys
RomBOOT
>
U-Boot 2014.10-rc2-00200-g9170818-dirty (Sep 23 2014 - 15:16:39)
CPU: AT91SAM9263
Crystal frequency: 16.368 MHz
CPU clock : 199.919 MHz
Master clock : 99.960 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
NAND: 256 MiB
MMC: mci: 0
In: serial
Out: serial
Err: serial
Net: macb0
Warning: Your board does not use generic board. Please read
doc/README.generic-board and take action. Boards not
upgraded by the late 2014 may break or be removed.
Hit any key to stop autoboot: 0
U-Boot> tftp uImage
macb0: Starting autonegotiation...
macb0: Autonegotiation complete
macb0: link up, 100Mbps full-duplex (lpa: 0xcde1)
Using macb0 device
TFTP from server 192.168.1.247; our IP address is 192.168.1.240
Filename 'uImage'.
Load address: 0x22000000
Loading: #################################################################
#################################################################
#################################################################
##############
1.2 MiB/s
done
Bytes transferred = 3068016 (2ed070 hex)
U-Boot> tftp 20000000 dt
macb0: link up, 100Mbps full-duplex (lpa: 0xcde1)
Using macb0 device
TFTP from server 192.168.1.247; our IP address is 192.168.1.240
Filename 'dt'.
Load address: 0x20000000
Loading: #
340.8 KiB/s
done
Bytes transferred = 13279 (33df hex)
U-Boot> bootm 22000000 - 20000000
## Booting kernel from Legacy Image at 22000000 ...
Image Name: Linux-3.16.1
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3067952 Bytes = 2.9 MiB
Load Address: 20008000
Entry Point: 20008000
Verifying Checksum ... OK
## Flattened Device Tree blob at 20000000
Booting using the fdt blob at 0x20000000
Loading Kernel Image ... OK
Loading Device Tree to 23ea3000, end 23ea93de ... OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Error: unrecognized/unsupported device tree compatible list:
[ 'atmel,at91sam9263ek' 'atmel,at91sam9263' 'atmel,at91sam9' ]
Available machine support:
ID (hex) NAME
000004b2 Atmel AT91SAM9263-EK
Please check your kernel config and/or bootloader.
Solution:
Add this line to .config:
CONFIG_MACH_AT91SAM9_DT=y
The correct configuration for this board when using device tree is at91_dt_defconfig.
However, I am quite surprised to see someone trying to use such an old kernel. This board is fully supported upstream. Why don't you use v5.3? If this doesn't work, please report any bug, we will be happy to help correct them.

I got a error putting mode monitor airmon-ng start eth1

Well friend
i can't put my eth1 at mode monitor...
Interface Chipset Driver
eth1 Unknown wl - [phy0]mon0: ERROR mientras se obtenían las banderas de interfaz: No existe el dispositivo
(monitor mode enabled on mon0)
and when run the monitor appear:
sudo airodump-ng mon0Interface mon0:
ioctl(SIOCGIFINDEX) failed: No such device
Anyone can helpme?
Few things I can think of, 1st is unsupported chipset! which if you provide info for would be helpful. 2nd is missing libraries or unpatched driver!
Tested and working cards
AWUS036H (rtl8187, r8187) - both mac80211 and IEEE drivers - passed
AWUS036NH (Ralink RT2870/3070) - using the mac80211 rt2x00usb drivers - passed
BCM4312 802.11b/g LP-PHY (rev 01) - using the mac80211 b43, works well - passed
Rockland N3 - (Ralink RT2870/3070) - using the mac80211 rt2x00usb drivers -passed
Edimax EW-7318USG USB - (Ralink RT2501/RT2573) - using the mac80211 rt2500usb/rt73usb drivers -passed
ASUSTek Computer, Inc. RT2573 - using the mac80211 rt2500usb/rt73usb drivers -passed
Linksys WUSB54GC ver 3 - using the mac80211 rt2800usb drivers -passed
Ubiquiti SRC - using the mac80211 ath9k drivers-passed
Internal Intel Corporation PRO/Wireless 3945ABG - using the mac80211 iwl3945 drivers-passed
Dlink WNA-2330 PCMCIA - using the mac80211 ath5k drivers-passed
Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) (rev 01) - using the mac80211 ath9k drivers-passed
Netgear wg111v2 - using the mac80211 rtl8187 drivers-passed
ZyXEL AG-225H v2 - using the mac80211 zd1211 drivers - passed
Intel 4956/5xxx - using the iwlagn drivers - passed
Working, without injection
Broadcom Corporation BCM4321 802.11a/b/g/n (rev 03)
Broadcom Corporation BCM4322 802.11a/b/g/n Wireless LAN Controller (rev 01)
NON working cards
D-Link DWL-122 - using the mac80211 prism2_usb drivers - fail
Linksys WUSB600N v2 - using the mac80211 rt2800usb drivers - fail
AWUS051NH - fail
Your chipset does not support the injection.
try with kali linux http://www.kali.org

Resources