Am trying to understand USB PCI MMIO and am using QEMU as a playgroud.
The following devices are on my VM,
00:1d.0 USB controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 (rev 03) (prog-if 00 [UHCI])
Subsystem: Red Hat, Inc. QEMU Virtual Machine
Flags: bus master, fast devsel, latency 0, IRQ 16
I/O ports at c0a0 [size=32]
Kernel driver in use: uhci_hcd
00:1d.1 USB controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 (rev 03) (prog-if 00 [UHCI])
Subsystem: Red Hat, Inc. QEMU Virtual Machine
Flags: bus master, fast devsel, latency 0, IRQ 17
I/O ports at c0c0 [size=32]
Kernel driver in use: uhci_hcd
00:1d.2 USB controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 (rev 03) (prog-if 00 [UHCI])
Subsystem: Red Hat, Inc. QEMU Virtual Machine
Flags: bus master, fast devsel, latency 0, IRQ 18
I/O ports at c0e0 [size=32]
Kernel driver in use: uhci_hcd
00:1d.7 USB controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 (rev 03) (prog-if 20 [EHCI])
Subsystem: Red Hat, Inc. QEMU Virtual Machine
Flags: bus master, fast devsel, latency 0, IRQ 19
Memory at fc072000 (32-bit, non-prefetchable) [size=4K]
Kernel driver in use: ehci-pci
And the following code,
int fd = open("/sys/devices/pci0000:00/0000:00:1d.7/resource0", O_RDWR | O_SYNC);
int mmio = mmap(0, 0x100, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
iopl(3);
outl(0, 0xc0a0);
If I do not include outl(0, 0xc0a0); it seems that any writes to the MMIO address space will not trigger anything.
Looking to try and understand what exactly does outl(0, 0xc0a0); achieve.
outl() writes data. In your code no other function writes to I/O except outl()
https://linux.die.net/man/2/outl
If you want to know more internals about outl use gdb and disassemble it https://gist.github.com/jarun/ea47cc31f1b482d5586138472139d090
https://man7.org/linux/man-pages/man2/iopl.2.html
Related
I tried plugging two flash drives into a Raspberry Pi 4B one after another but the Pi does not seem to detect any of the drives. Here is the dmesg output
[ 177.737328] cpu cpu0: dev_pm_opp_set_rate: failed to find current OPP for freq 4294967186 (-34)
[ 180.446246] raspberrypi-clk soc:firmware:clocks: Failed to change fw-clk-arm frequency: -110
[ 181.036364] xhci_hcd 0000:01:00.0: Abort failed to stop command ring: -110
[ 181.052412] xhci_hcd 0000:01:00.0: Host halt failed, -110
[ 181.052421] xhci_hcd 0000:01:00.0: xHCI host controller not responding, assume dead
[ 181.052446] xhci_hcd 0000:01:00.0: HC died; cleaning up [ 181.052645] xhci_hcd 0000:01:00.0: Timeout while waiting for setup device command
[ 181.053349] usb 1-1: USB disconnect, device number 2
[ 181.536432] usb 1-1.3: device not accepting address 5, error -108
[ 181.536608] usb 1-1-port3: couldn't allocate usb_device
Any help is appreciated. Thanks in advance
USB problems in RPi typically happens because of a corrupted kernel, try to update it then give me a feedback.
I am trying to setup a Raspberry Pi Zero as a mass storage with dwc2 and g_mass_storage (using the last Raspbian image available).
I created the data storage file with dd, made it a FAT32 fs with mkdosfs.
I looked for a lot of things. I spent some time to understand that options should be passed in /etc/modprobe.d/g_mass_storage.conf
It is finally seen in ubuntu. My problem is : it is in read only mode.
I tried to set the ro option to y or n without any impact on the behaviour. I changed permissions on the file (777), it changed nothing.
here is the current content of my /etc/modprobe.d/g_mass_storage.conf file :
options g_mass_storage file=/piusb.bin stall=0 removable=y ro=n
here is the of dmesg from the ubuntu :
[Today and now]usb 1-1.2: new high-speed USB device number 28 using ehci-pci
[ +0,299994] usb 1-1.2: device descriptor read/64, error -71
[ +0,959969] usb 1-1.2: device descriptor read/64, error -71
[ +0,187918] usb 1-1.2: new high-speed USB device number 29 using ehci-pci
[ +0,113925] usb 1-1.2: New USB device found, idVendor=0525, idProduct=a4a5
[ +0,000007] usb 1-1.2: New USB device strings: Mfr=3, Product=4, SerialNumber=0
[ +0,000004] usb 1-1.2: Product: Mass Storage Gadget
[ +0,000003] usb 1-1.2: Manufacturer: Linux 4.19.118+ with 20980000.usb
[ +0,001467] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[ +0,000246] usb-storage 1-1.2:1.0: Quirks match for vid 0525 pid a4a5: 10000
[ +0,000283] scsi host9: usb-storage 1-1.2:1.0
[ +1,009528] scsi 9:0:0:0: Direct-Access Linux File-Stor Gadget 0419 PQ: 0 ANSI: 2
[ +0,001079] sd 9:0:0:0: Attached scsi generic sg5 type 0
[ +0,001699] sd 9:0:0:0: Power-on or device reset occurred
[ +0,001211] sd 9:0:0:0: [sde] 67108864 512-byte logical blocks: (34.4 GB/32.0 GiB)
[ +0,000672] sd 9:0:0:0: [sde] Write Protect is on
[ +0,000016] sd 9:0:0:0: [sde] Mode Sense: 0f 00 80 00
[ +0,000740] sd 9:0:0:0: [sde] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ +0,005478] sde:
[ +0,002735] sd 9:0:0:0: [sde] Attached SCSI removable disk
What to do to get a read/write mass storage ?
I reproduced your problem. I had a similar problem with the module g_acm_ms on Raspberry Pi Zero W. If you configure the module in /etc/modprobe.d/, then the system ignores the parameter ro=0. Perhaps this is due to the order of initialization of kernel modules. I got around this by adding the module to the blacklist and writing the initialization in /etc/rc.local. Thus, I managed to get an emulation of a read/write mass storage.
All steps:
Create and format the file:
# dd bs=1M if=/dev/zero of="/piusb.bin" count=2048
# mkdosfs "/piusb.bin"
Add modules-load=dwc2,g_acm_ms to end of /boot/cmdline.txt (after rootwait)
Add the string dtoverlay=dwc2 in /boot/config.txt
Prevent module initialization at startup:
$ echo "blacklist g_acm_ms" | sudo tee -a "/etc/modprobe.d/blacklist-g_acm_ms.conf"
Add initialization in /etc/rc.local above exit 0:
# nano /etc/rc.local
Add string:
/sbin/modprobe file=/piusb.bin removable=y ro=0 stall=0
Reboot system:
# reboot -h
P.S.: If you don't want to use USB for console output, you can use g_mass_storage instead of g_acm_ms.
I'm using a udev rule to automount USB flash drives on my Raspberry Pi. I found this solution few months ago and I worked very well until I start using Raspbian Stretch lite.
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="\$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/usbstick", RUN+="/bin/mount -o \$env{mount_options} /dev/%k /media/usbstick"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/usbstick", RUN+="/bin/rmdir /media/usbstick"
# Exit
LABEL="media_by_label_auto_mount_end"
And here is what I see in dmesg
[ 524.042731] usb 1-1.4: new high-speed USB device number 6 using dwc_otg
[ 524.174634] usb 1-1.4: New USB device found, idVendor=090c, idProduct=1000
[ 524.174649] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 524.174658] usb 1-1.4: Product: Flash Disk
[ 524.174666] usb 1-1.4: Manufacturer: USB
[ 524.174674] usb 1-1.4: SerialNumber: SCY0000000105542
[ 524.175515] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[ 524.175994] scsi host0: usb-storage 1-1.4:1.0
[ 525.399056] scsi 0:0:0:0: Direct-Access USB Flash Disk 1100 PQ: 0 ANSI: 4
[ 525.399986] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 525.400243] sd 0:0:0:0: [sda] 15974400 512-byte logical blocks: (8.18 GB/7.62 GiB)
[ 525.401232] sd 0:0:0:0: [sda] Write Protect is off
[ 525.401259] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[ 525.401948] sd 0:0:0:0: [sda] No Caching mode page found
[ 525.401965] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 525.415578] sda: sda1
[ 525.418642] sd 0:0:0:0: [sda] Attached SCSI removable disk
Do anybody has a similar solution that works with Raspbian Stretch lite?
abigail#abilina:~/nlp$ lspci
00:00.0 Host bridge: Intel Corporation Skylake Host Bridge/DRAM Registers (rev 07)
00:01.0 PCI bridge: Intel Corporation Skylake PCIe Controller (x16) (rev 07)
00:02.0 Display controller: Intel Corporation HD Graphics 530 (rev 06)
00:14.0 USB controller: Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller (rev 31)
00:15.0 Signal processing controller: Intel Corporation Sunrise Point-H Serial IO I2C Controller #0 (rev 31)
00:15.1 Signal processing controller: Intel Corporation Sunrise Point-H Serial IO I2C Controller #1 (rev 31)
00:16.0 Communication controller: Intel Corporation Sunrise Point-H CSME HECI #1 (rev 31)
00:17.0 RAID bus controller: Intel Corporation SATA Controller [RAID mode] (rev 31)
00:1c.0 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #2 (rev f1)
00:1c.2 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #3 (rev f1)
00:1c.3 PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #4 (rev f1)
00:1e.0 Signal processing controller: Intel Corporation Sunrise Point-H Serial IO UART #0 (rev 31)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point-H LPC Controller (rev 31)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-H PMC (rev 31)
00:1f.3 Audio device: Intel Corporation Sunrise Point-H HD Audio (rev 31)
00:1f.4 SMBus: Intel Corporation Sunrise Point-H SMBus (rev 31)
**01:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2)**
01:00.1 Audio device: NVIDIA Corporation Device 0fbc (rev a1)
02:00.0 USB controller: ASMedia Technology Inc. ASM1142 USB 3.1 Host Controller
03:00.0 Network controller: Intel Corporation Wireless 3165 (rev 79)
04:00.0 Ethernet controller: Qualcomm Atheros QCA8171 Gigabit Ethernet (rev 10)
Is the Nvidia GeForce GTX 750 Ti a GPU that can speed up deep learning?
To answer the question in the title: yes, you have a NVIDIA GPU, a GeForce GTX 750 Ti. You can use this GPU with TensorFlow if you install CUDA (see here for a full list of GPUs that can be used with CUDA: https://developer.nvidia.com/cuda-gpus). A detailed list of the prerequirements for the use of TensorFlow with GPUs can be found here:
https://www.tensorflow.org/install/install_linux
Have fun!
I finally got a USB DAC (HiFimeDIY Sabre DAC) for my Raspberry Pi (running on Raspbian Wheezy) today, but of course, just plugging it in doesn't do the trick. I've been messing around for quite some time with ALSA configuration now, but to no avail. Audio playback through the 3.5" headphone jack works just fine, but I can't seem to get the audio to play through USB. aplay -L gives
pi#raspberrypi ~ $ aplay -L
...
pulse
Playback/recording through the PulseAudio sound server
sysdefault:CARD=DAC
HiFimeDIY DAC, USB Audio
Default Audio Device
front:CARD=DAC
HiFimeDIY DAC, USB Audio
Default Audio Device
...
sysdefault:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
front:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
I wonder if both cards being marked as "Default Audio Device" is a good thing?
Anyways, testing playback via
pi#raspberrypi ~ $ aplay /usr/share/sounds/alsa/Front_Center.wav -D sysdefault:CARD=ALSA
Playback: WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate: 48000 Hz, mono
works fine, but
pi#raspberrypi ~ $ aplay /usr/share/sounds/alsa/Front_Center.wav -D sysdefault:CARD=DAC
ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params
ALSA lib pcm_dmix.c:1030:(snd_pcm_dmix_open) unable to initialize slave
aplay: main:682: Fehler beim Öffnen des Gerätes: Datenübergabe unterbrochen (broken pipe)
(Sry for german, it says something like Error while opening device: data stream interrupted)
My /etc/asound.conf looks as follows:
pcm.!default {
type hw
card 0
device 0
}
and /etc/modprobe.d/alsa-base.conf has the following entries:
# Keep snd-usb-audio from beeing loaded as first soundcard
options snd-usb-audio index=0
options snd_bcm2835 index=1
What am I doing wrong? Help would be much appreciated!
Edit:
Systemlog says the following:
Nov 7 18:30:29 raspberrypi kernel: [ 2.534311] usb 1-1: new full-speed USB device number 2 using dwc_otg
Nov 7 18:30:29 raspberrypi kernel: [ 2.546658] Indeed it is in host mode hprt0 = 00021501
Nov 7 18:30:29 raspberrypi kernel: [ 2.752653] usb 1-1: not running at top speed; connect to a high speed hub
Nov 7 18:30:29 raspberrypi kernel: [ 2.765131] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
Nov 7 18:30:29 raspberrypi kernel: [ 2.776874] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber$
Nov 7 18:30:29 raspberrypi kernel: [ 2.790194] hub 1-1:1.0: USB hub found
Nov 7 18:30:29 raspberrypi kernel: [ 2.799746] hub 1-1:1.0: 5 ports detected
Nov 7 18:30:29 raspberrypi kernel: [ 3.082453] usb 1-1.1: new full-speed USB device number 3 using dwc_otg
Nov 7 18:30:29 raspberrypi kernel: [ 3.192745] usb 1-1.1: not running at top speed; connect to a high speed hub
Nov 7 18:30:29 raspberrypi kernel: [ 3.205857] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
Nov 7 18:30:29 raspberrypi kernel: [ 3.218650] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumb$
Nov 7 18:30:29 raspberrypi kernel: [ 3.239311] smsc95xx v1.0.4
...
Nov 7 18:30:29 raspberrypi kernel: [ 3.308141] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb$
Nov 7 18:30:29 raspberrypi kernel: [ 3.432526] usb 1-1.3: new full-speed USB device number 4 using dwc_otg
Nov 7 18:30:29 raspberrypi kernel: [ 3.626813] usb 1-1.3: New USB device found, idVendor=1852, idProduct=7022
Nov 7 18:30:29 raspberrypi kernel: [ 3.647601] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumb$
Nov 7 18:30:29 raspberrypi kernel: [ 3.664695] usb 1-1.3: Product: HiFimeDIY DAC
Nov 7 18:30:29 raspberrypi kernel: [ 3.676431] usb 1-1.3: Manufacturer: HiFimeDIY Audio
Nov 7 18:30:29 raspberrypi kernel: [ 3.703597] input: HiFimeDIY Audio HiFimeDIY DAC as /devices/platform/bcm27$
Nov 7 18:30:29 raspberrypi kernel: [ 3.721606] hid-generic 0003:1852:7022.0001: input,hidraw0: USB HID v1.00 D$
Nov 7 18:30:29 raspberrypi kernel: [ 7.529882] usbcore: registered new interface driver snd-usb-audio
but as soon as the boot process is finished, I get this a jillion times in a row:
Nov 7 18:30:38 raspberrypi kernel: [ 41.221205] INFO:: schedule_periodic: Insufficient periodic bandwidth for p$
Nov 7 18:30:38 raspberrypi kernel: [ 41.221205]
Nov 7 18:30:38 raspberrypi kernel: [ 41.221261] ERROR::dwc_otg_hcd_urb_enqueue:544: DWC OTG HCD URB Enqueue fai$
Nov 7 18:30:38 raspberrypi kernel: [ 41.221261]
Nov 7 18:30:38 raspberrypi kernel: [ 41.221288] cannot submit urb 0, error -1: unknown error
Also:
Nov 7 18:45:21 raspberrypi kernel: [ 861.969647] bcm2835_audio_set_ctls:558 Controls set for stream 0
Nov 7 18:47:58 raspberrypi pulseaudio[2390]: [pulseaudio] module-always-sink.c: Unable to load module-null-sink
and
Nov 7 18:48:46 raspberrypi pulseaudio[2494]: [pulseaudio] module-udev-detect.c: Tried to configure /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0 (alsa_card.usb-HiFimeDIY_Audio_HiFimeDIY_DAC-01-DAC) more often than 5 times in 10 seconds
Edit 2:
Contents of /proc/asound/card0/stream0 are
HiFimeDIY Audio HiFimeDIY DAC at usb-bcm2708_usb-1.3, full speed : USB Audio
Playback:
Status: Stop
Interface 3
Altset 1
Format: S16_LE
Channels: 2
Endpoint: 3 OUT (ADAPTIVE)
Rates: 8000, 16000, 32000, 44100, 48000, 96000
Interface 3
Altset 2
Format: S24_3LE
Channels: 2
Endpoint: 3 OUT (ADAPTIVE)
Rates: 8000, 16000, 32000, 44100, 48000, 96000
Capture:
Status: Stop
Interface 2
Altset 1
Format: S16_LE
Channels: 2
Endpoint: 2 IN (ADAPTIVE)
Rates: 8000, 16000, 32000, 44100, 48000, 96000
Interface 2
Altset 2
Format: S24_3LE
Channels: 2
Endpoint: 2 IN (ADAPTIVE)
Rates: 8000, 16000, 32000, 44100, 48000, 96000
Every time I want to force sound through the USB card (below I set it to be the default audio device in .asoundrc)I get
pi#raspberrypi ~ $ aplay piano2.wav
Wiedergabe: WAVE 'piano2.wav' : Signed 16 bit Little Endian, Rate: 48000 Hz, stereo
aplay: set_params:1145: Fehler beim Setzen der Hardware-Parameter:
ACCESS: RW_INTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 32
CHANNELS: 2
RATE: 48000
PERIOD_TIME: 125000
PERIOD_SIZE: 6000
PERIOD_BYTES: 24000
PERIODS: 4
BUFFER_TIME: 500000
BUFFER_SIZE: 24000
BUFFER_BYTES: 96000
TICK_TIME: 0
(the german part says "aplay: set_params:1145: unable to install hw params:).
Additionally, aplay -L still gives me
Karte 0: DAC [HiFimeDIY DAC], Gerät 0: USB Audio [USB Audio]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
Karte 0: DAC [HiFimeDIY DAC], Gerät 1: USB Audio [USB Audio #1]
Sub-Geräte: 1/1
Sub-Gerät #0: subdevice #0
and when I use aplay -D hw:0,1 sound.wav, playback seems to work (no error message is thrown out), but I can't hear anything at all. Is Card 0,1 the recording device? If I use onboard sound, everything works fine. I'm not using a usb hub (DAC is plugged directly into the pi). Might this be a power issue?
lsusb has
pi#raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1852:7022 GYROCOM C&C Co., LTD
At the moment, a printer is plugged in (switched off though) and unplugging it changes nothing, lsusb still shows the same devices (I'm wondering why there are 4 and 3 of them different, while the Pi only has 2 ports, in one of which is the DAC). When the pi is starting up and the speakers are plugged into the DAC, I get a couple crackles, just like when they are plugged into the headphone jack.
Even i faced the similar issue.
Possible solution :
Check the kernel configs ( zcat /proc/config.gz | grep 'CONFIG_FW_LOADER' ). If that config is not enabled then try to build a kernel with this config enabled.
I tried similar approach across the different kernel for the same ROOT FILE SYSTEM, then checked for the configs i found out the above solution.
Thanks and Regards,
Sandesh K A
Let me know if this solution worked for you.
A while ago, I was experiencing the same issue. I've manage to fix it by double checking the config files. In my case, I've run alsa mixer after i've configured ~/.asoundrc. By running the alsa mixer / unplugging the usb, alsa automatically updates ~/.asoundrc file. Hence, overwritten my previous config.
Make sure that your changes in conf file are still in place before trying again. I hope this works on you as well.
Set up Raspberry Pi 3 USB mic ( creative sound blaster )