usb Mass Storage driver for am335x - linux-kernel

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

Related

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?

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.

Install grub on a disk drive by UUID

There is a way to indicate to grub to install on a device MBR by UUID instead of using /dev/sdX ? I'm setting a external eSATA hard disk with NixOS, and obviusly, the hard disk not would be always the same /dev/sdX device ?
I see that I can config it with boot.loader.grub.device = "/dev/sdX", but could set it to something like "/dev/disk/by-uuid/...." ??
currently there is no support for what you want in nixos.
see the respective source code here:
https://github.com/NixOS/nixpkgs/blob/release-15.09/nixos/modules/system/boot/loader/grub/grub.nix
however, you should be able to use:
boot.loader.grub.device = "/dev/mydisk"
but you will need a udev-ruleset like this:
services.udev.extraRules = ''
#Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", MODE="666", SYMLINK+="ttyUSB-odroid-u3-1"
#Bus 003 Device 055: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE="666", SYMLINK+="ttyUSB-odroid-u3-2"
# Bus 003 Device 057: ID 054c:0268 Sony Corp. Batoh Device / PlayStation 3 Controller
ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0268", SUBSYSTEMS=="usb", ACTION=="add", MODE="0660", GROUP="users"
'';
but for your external harddrive of course. just by using the symlink feature.

Yocto Boot Partition error (Intel Edison)

I was trying to resize partitions of Intel Edison which runs on Yocto system. I destroyed partition 1 somehow. So when I reboot system it loops forever to boot the system correctly. So, interrupted boot sequence and checked for partitions to see what is wrong. As you can see down below partitions start from number two not one! According to error from bootloader it searches for part 1 but cannot find . So how can I add/ create/ repair manually partition 1 to recover system?
boot > printenv partitions
partitions=uuid_disk=${uuid_disk};name=u-boot0,start=1MiB,size=2MiB,uuid=${uuid_uboot0};name=u-boot-env0,size=1MiB,uuid=${uuid_uboot_env0};name=u-boot1,size=2MiB,uuid=${uuid_uboot1};name=u-boot-env1,size=1MiB,uuid=${uuid_uboot_env1};name=factory,size=1MiB,uuid=${uuid_factory};name=panic,size=24MiB,uuid=${uuid_panic};name=boot,size=32MiB,uuid=${uuid_boot};name=rootfs,size=512MiB,uuid=${uuid_rootfs};name=update,size=768MiB,uuid=${uuid_update};name=home,size=-,uuid=${uuid_home};
boot > mmc part
Partition Map for MMC device 0 -- Partition Type: DOS
Part Start Sector Num Sectors UUID Type
2 16 7634928 00000000-02 83
Boot Sequence
******************************
PSH KERNEL VERSION: b0182727
WR: 20104000
******************************
SCU IPC: 0x800000d0 0xfffce92c
PSH miaHOB version: TNG.B0.VVBD.0000000c
microkernel built 23:15:13 Apr 24 2014
******* PSH loader *******
PCM page cache size = 192 KB
Cache Constraint = 0 Pages
Arming IPC driver ..
Adding page store pool ..
PagestoreAddr(IMR Start Address) = 0x04899000
pageStoreSize(IMR Size) = 0x00080000
*** Ready to receive application ***
U-Boot 2014.04 (Oct 14 2014 - 15:19:04)
Watchdog enabled
DRAM: 980.6 MiB
MMC: tangier_sdhci: 0
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
Target:blank
Partitioning already done...
Flashing already done...
**dfu_fill_entity_mmc: could not find partition #1 on mmc device #0!
ERROR: DFU entities configuration failed!**
at drivers/dfu/dfu.c:71/dfu_init_env_entities()
dfu - Device Firmware Upgrade
Usage:
dfu <USB_controller> <interface> <dev> [list|timeout]
- device firmware upgrade via <USB_controller>
on device <dev>, attached to interface
<interface>
[list] - list available alt settings
[timeout] - specify inactivity timeout in sec, doesn't work whit list
** Invalid partition 7 **
Error: Invalid Boot Flag (found 0xffef, expected 0xaa55)
## Kernel loading failed ...
zboot - Boot bzImage
Usage:
zboot [addr] [size] [initrd addr] [initrd size]
addr - The optional starting address of the bzimage.
If not set it defaults to the environment
variable "fileaddr".
size - The optional size of the bzimage. Defaults to
zero.
initrd addr - The address of the initrd image to use, if any.
initrd size - The size of the initrd image to use, if any.
Unknown boot mode: boot
Saving Environment to MMC...
Writing to MMC(0)... done
Resetting to default boot mode and reboot...
resetting ...
I solved that problem myself. After interrupting boot sequence use gpt command to add new partition to mmc. Then, system boots correctly.

Resources