I2C driver changes to recognize multiple buses - linux-kernel

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

Related

BlueZ: No default controller available

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.

usb Mass Storage driver for am335x

i want to loard a usb drive storage module so i make when i load usb mass storage module the usb drive detect in /media or /dev/sda1
I have one customized bord using an am335x processor and this board has one USB port(for USB drive connector) and one micro USB port. and also have kernel source code and version is 4.4.16 now i follow the command to compile kernel source code
make distclean CROSS_COMPILE=arm-linux-gnueabihf-
make am335x_fujitel_defconfig CROSS_COMPILE=arm-linux-gnueabihf-
note= am335x_fujitel_defconfig is my edited defconfig file according to my bord and after that type
make menuconfig
The reason is I want to make module of USB storage driver so i can install module first to connect my usb drive to the device
so i follow this link https://processors.wiki.ti.com/index.php/Usbgeneralpage#Mass_Storage_Gadget as reference
and changes some driver configurations.
I found that when i uncheck
< > Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...)
MUSB Mode Selection (Dual Role mode) --->
my usb drive not work on my device so I make module 'm' for Inventra Highspeed Dual Role Controller and generate musb-hdrc.ko file
I load new zImage and /lib/module/4/4/16 to my board and found .ko file in /lib... directory
root#arm:~# ls /lib/modules/4.4.16/kernel/drivers/usb/musb/musb_hdrc.ko
Now run "modprobe musb-hdrc" command and write "musb_hdrc" vi /etc/modules-load.d/modules.conf
above command run successfully and not see any error
after that reboot, the board run "lsmod" command to the sure module is load or not
root#arm:~# lsmod
Module Size Used by Not tainted
bridge 87777 0
stp 2111 1 bridge
llc 5184 2 bridge,stp
usb_f_rndis 21887 2
usb_f_ecm 9211 2
u_ether 11816 2 usb_f_rndis,usb_f_ecm
libcomposite 42715 16 usb_f_rndis,usb_f_ecm
omap_sham 22202 0
omap_aes_driver 19511 0
omap_rng 4212 0
rng_core 7198 1 omap_rng
musb_hdrc 78777 0
musb_hdrc load is successful.BUT when I connect my USB drive to USB port my USB drive not mount in /media also not show me at /dev why ?? am I missing something ?? also i check Kconfig file
config USB_MUSB_HDRC
tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...)'
depends on (USB || USB_GADGET)
help
Say Y here if your system has a dual role high speed USB
controller based on the Mentor Graphics silicon IP. Then
configure options to match your silicon and the board
it's being used with, including the USB peripheral role,
or the USB host role, or both.
Texas Instruments families using this IP include DaVinci
(35x, 644x ...), OMAP 243x, OMAP 3, and TUSB 6010.
Analog Devices parts using this IP include Blackfin BF54x,
BF525 and BF527.
Allwinner SoCs using this IP include A10, A13, A20, ...
If you do not know what this is, please say N.
To compile this driver as a module, choose M here; the
module will be called "musb-hdrc".
So after exploring many things, I found that when I mark 'm' in Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...) there are two another support which automatically goes to < > like
<M> Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...)
MUSB Mode Selection (Dual Role mode) --->
*** Platform Glue Layer ***
< > OMAP2430 and onwards
< > AM35x
< > TI DSPS platforms
*** MUSB DMA mode ***
[ ] Disable DMA (always use PIO)
Here I forgot to notice that TI DSPS platforms and Disable DMA also goes to empty(< >) automatically when I select Inventra Highspeed Dual Role Controller. so I also check TI DSPS platforms and <*> for Disable DMA and then cross compile kernel and modules again
Now after when my board boot up successfully I see 3 new modules
root#arm:~# ls /lib/modules/4.4.16/kernel/drivers/usb/musb/musb_
musb_am335x.ko musb_dsps.ko musb_hdrc.ko
Then type lsmod command
root#arm:~# lsmod
Module Size Used by Not tainted
bridge 87777 0
stp 2111 1 bridge
llc 5184 2 bridge,stp
usb_f_rndis 21887 2
usb_f_ecm 9211 2
u_ether 11816 2 usb_f_rndis,usb_f_ecm
libcomposite 42715 16 usb_f_rndis,usb_f_ecm
musb_dsps 9418 0
musb_hdrc 72752 1 musb_dsps
omap_aes_driver 19511 0
omap_sham 22202 0
omap_rng 4212 0
rng_core 7198 1 omap_rng
musb_am335x 1547 0 [permanent]
and I successfully connect my USB drive to device which detect in /media location
But I am surprised here how to Musb_* module load automatically? I can't understand also when i remove am335x from /lib directory, all musb* module remove automatically
So how do I solve this automatically load module issue? anyone help me

udevadm to retrieve device attribute

OS: Ubuntu 16.04
Ethernet chip: Intel I210
Ethernet driver: igb
I've looked into my etherent device attribute.
By typing the command
udevadm info -p -a /sys/class/net/eth0
I got the following information:
looking at device '/devices/pci0000:00/0000:00:1c.2/0000:02:00.0/net/eth0':
KERNEL=="eth0"
SUBSYSTEM=="net"
DRIVER==""
ATTR{mtu}=="1500"
ATTR{type}=="1"
ATTR{netdev_group}=="0"
ATTR{flags}=="0x1003"
ATTR{speed}=="1000"
ATTR{dormant}=="0"
ATTR{addr_assign_type}=="0"
ATTR{dev_id}=="0x0"
ATTR{duplex}=="full"
ATTR{gro_flush_timeout}=="0"
ATTR{iflink}=="2"
ATTR{addr_len}=="6"
ATTR{address}=="0c:c4:7a:12:b4:e4"
ATTR{operstate}=="up"
ATTR{carrier_changes}=="2"
ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"
ATTR{tx_queue_len}=="1000"
ATTR{dev_port}=="0"
ATTR{ifalias}==""
ATTR{ifindex}=="2"
ATTR{link_mode}=="0"
ATTR{carrier}=="1"
looking at parent device '/devices/pci0000:00/0000:00:1c.2/0000:02:00.0':
KERNELS=="0000:02:00.0"
SUBSYSTEMS=="pci"
DRIVERS=="igb"
ATTRS{irq}=="18"
ATTRS{subsystem_vendor}=="0x15d9"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x020000"
ATTRS{index}=="1"
ATTRS{label}==" Intel Ethernet controller#1 i210"
ATTRS{driver_override}=="(null)"
ATTRS{consistent_dma_mask_bits}=="64"
ATTRS{dma_mask_bits}=="64"
ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f"
ATTRS{device}=="0x1533"
ATTRS{enable}=="1"
ATTRS{msi_bus}=="1"
ATTRS{local_cpulist}=="0-3"
ATTRS{vendor}=="0x8086"
ATTRS{subsystem_device}=="0x1533"
ATTRS{numa_node}=="-1"
ATTRS{d3cold_allowed}=="1"
Some questions below:
what is the relationship between "device" and "parent device"
Are these attributes retrieved from firmware ( on device ) or BIOS or driver ?
Is it possible to modify the attribute value ?
I ask this is because as you may know, Ubuntu 15.10 and newer version has taken the rule of predictable network interface names. For the onboard device, it will be recognized as "enox" and x means its index.
Unfortunately, on my host, my two ethernets have the same index and this causes the race condition. If I did not revert back to the original network interface naming rule, the boot is gonna take about 4 mins.
I suspect it's the firmware issue.

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.

Falied to register i2c-dev module

I'm trying to run some i2c testcases for ltp-ddt on arm board.
I installed i2c-tools, i checked i2c devices in /dev folder,
$ls /dev/i2c-*
/dev/i2c-0 /dev/i2c-1 /dev/i2c-2 /dev/i2c-3.
But, when i try to detect i2c devices by running
$i2cdetect -a 0
its throwing error as,
Error: Could not open file `/dev/i2c-0': No such device or address
Please let me know the valid solution ASAP.

Resources