horf
Posts: 6
Joined: Thu Dec 19, 2013 8:39 am

RPi crashes (sometimes) when I connect a USB peripheral

Thu Dec 19, 2013 10:40 am

Hello,

First of all, sorry for my english, I try my best.

The problem is not really clear, it does not always happen and the source of the problem is not clearly defined.
I'll explain you what we do and what happens.

We built a USB switch controlled by GPIO (Pin GPIO 17 (pin 11 in the code)) to switch a USB stick between a computer and the Raspberry Pi. When the GPIO is LOW, the USB stick is connected to the Raspberry Pi and when it's HIGH, the USB stick is connected to the other computer.

At the beginning of the script, the USB stick is connected to the RPi and then the GPIO is set to HIGH to connect the USB stick to the other computer. After that we wait a few seconds (the other computer write a file on the USB stick) and reconnect the USB stick to the Raspberry (GPIO -> LOW). It's at this moment that the problem occurs, the GPIO goes to '0' (we see it with a LED on our PCB) but the Raspberry crashes (we have to reboot it by unplugging the alimentation). This problem occurs randomly. It can works 50 times but then crash 5 times in a row...
The problem occurs exactly a the moment when the USB stick is re connected to the RPi.

We are not sure if the problem is the GPIO or the USB, but we think the problem is not in our script (neither in the RPi.GPIO library) but on the USB port. When the problem occurs, we can see the message "kernel: Disabling IRQ #32" on the console (but this message is not transmitted overs SSH, It is only visible on a screen). We saw this post with the same problem: http://www.raspberrypi.org/phpBB3/viewt ... 43#p451043

The script is written in Python 2.7.3 and uses the RPi.GPIO library. Raspbian is installed on the Raspberry and this is the output of uname -a

Code: Select all

pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.10.24+ #610 PREEMPT Thu Dec 12 13:12:09 GMT 2013 armv6l GNU/Linux
And this is the code:

Code: Select all

import RPi.GPIO as GPIO

GPIO_PIN = 11

GPIO.setmode(GPIO.BOARD)
print("setmode")
GPIO.setup(GPIO_PIN, GPIO.OUT)
print("setup")

# Switch -> Vending Machine
GPIO.output(GPIO_PIN, 1)
print("GPIO.HIGH")

# Wait until the files are on the USB stick
time.sleep(15)

print("end sleep")
# Switch -> Raspberry Pi
GPIO.output(GPIO_PIN, 0)
print("GPIO.LOW")

GPIO.cleanup()
When the problem occurs, the line "GPIO.LOW" is not displayed

After searching for hours, we don't know how to solve the problem. We need you ;)
Thank you very much for your help! :D

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12322
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: RPi crashes (sometimes) when I connect a USB peripheral

Thu Dec 19, 2013 11:40 am

That's normal, the PI's USB ports are not hot-plug-able. Meaning that if you plug in any USB device it will cause a dip in the 5V of the PI due to capacitors in the USB device, and the low capacity of the PI's power supply.

If you hot-plug into a powered USB hub it should work okay, or just avoid hot plugging if you can.

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2116
Joined: Thu Jul 11, 2013 2:37 pm

Re: RPi crashes (sometimes) when I connect a USB peripheral

Thu Dec 19, 2013 12:07 pm

Are you connecting the device to a model A or model B?

Please post full dmesg and lsusb -v output
Rockets are loud.
https://astro-pi.org

horf
Posts: 6
Joined: Thu Dec 19, 2013 8:39 am

Re: RPi crashes (sometimes) when I connect a USB peripheral

Thu Dec 19, 2013 1:16 pm

Thank you for your quick answer!

I didn't know that the RPi USB ports are not hot-plugable... I will try with a USB hub and keep you informed.

Unfortunately, I have no choice. I'm forced to do it this way because the only way to export data from the other computer is with a USB stick. First I wanted to "emulate" a USB stick with the RPi, but I saw it's not possible with the version B (which I use) and not an easy thing with the version A.
I can't change the behavior of the other computer so I will try your advice with the hub

Thank you!

The modeI use is the version B and here are the outputs of dmesg and lsusb -v.
dmesg

Code: Select all

pi@raspberrypi ~/coffeeconnect $ dmesg
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.10.24+ (dc4@dc4-arm-01) (gcc version 4.7.2 20120731 (prerelease) (crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08) ) #610 PREEMPT Thu Dec 12 13:12:09 GMT 2013
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] Machine: BCM2708
[    0.000000] cma: CMA: reserved 16 MiB at 1b000000
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] On node 0 totalpages: 114688
[    0.000000] free_area_init_node: node 0, pgdat c05c9564, node_mem_map c0675000
[    0.000000]   Normal zone: 896 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 114688 pages, LIFO batch:31
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 113792
[    0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0x338b08d2 smsc95xx.macaddr=B8:27:EB:8B:08:D2 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 448MB = 448MB total
[    0.000000] Memory: 431684k/431684k available, 27068k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     vmalloc : 0xdc800000 - 0xff000000   ( 552 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xdc000000   ( 448 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc056b420   (5518 kB)
[    0.000000]       .init : 0xc056c000 - 0xc0590134   ( 145 kB)
[    0.000000]       .data : 0xc0592000 - 0xc05ca070   ( 225 kB)
[    0.000000]        .bss : 0xc05ca070 - 0xc0674bc0   ( 683 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000] NR_IRQS:330
[    0.000000] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 4294967ms
[    0.000000] Switching to timer-based delay loop
[    0.000000] Console: colour dummy device 80x30
[    0.000000] console [tty1] enabled
[    0.001156] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=10000)
[    0.001219] pid_max: default: 32768 minimum: 301
[    0.001687] Mount-cache hash table entries: 512
[    0.002495] Initializing cgroup subsys devices
[    0.002558] Initializing cgroup subsys freezer
[    0.002594] Initializing cgroup subsys blkio
[    0.002741] CPU: Testing write buffer coherency: ok
[    0.003188] Setting up static identity map for 0xc03ff728 - 0xc03ff784
[    0.004979] devtmpfs: initialized
[    0.019153] NET: Registered protocol family 16
[    0.025073] DMA: preallocated 4096 KiB pool for atomic coherent allocations
[    0.026169] bcm2708.uart_clock = 0
[    0.027858] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[    0.027913] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.027951] mailbox: Broadcom VideoCore Mailbox driver
[    0.028048] bcm2708_vcio: mailbox at f200b880
[    0.028153] bcm_power: Broadcom power driver
[    0.028194] bcm_power_open() -> 0
[    0.028220] bcm_power_request(0, 8)
[    0.528937] bcm_mailbox_read -> 00000080, 0
[    0.528979] bcm_power_request -> 0
[    0.529204] Serial: AMBA PL011 UART driver
[    0.529366] dev:f1: ttyAMA0 at MMIO 0x20201000 (irq = 83) is a PL011 rev3
[    0.867241] console [ttyAMA0] enabled
[    0.892624] bio: create slab <bio-0> at 0
[    0.897912] SCSI subsystem initialized
[    0.901880] usbcore: registered new interface driver usbfs
[    0.907568] usbcore: registered new interface driver hub
[    0.913140] usbcore: registered new device driver usb
[    0.919684] Switching to clocksource stc
[    0.924021] FS-Cache: Loaded
[    0.927177] CacheFiles: Loaded
[    0.942805] NET: Registered protocol family 2
[    0.948211] TCP established hash table entries: 4096 (order: 3, 32768 bytes)
[    0.955475] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    0.961998] TCP: Hash tables configured (established 4096 bind 4096)
[    0.968473] TCP: reno registered
[    0.971731] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.977639] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.984372] NET: Registered protocol family 1
[    0.989293] RPC: Registered named UNIX socket transport module.
[    0.995353] RPC: Registered udp transport module.
[    1.000077] RPC: Registered tcp transport module.
[    1.004826] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    1.012177] bcm2708_dma: DMA manager at f2007000
[    1.016991] bcm2708_gpio: bcm2708_gpio_probe c059fdb0
[    1.022442] vc-mem: phys_addr:0x00000000 mem_base=0x1ec00000 mem_size:0x20000000(512 MiB)
[    1.031767] audit: initializing netlink socket (disabled)
[    1.037439] type=2000 audit(0.880:1): initialized
[    1.198778] VFS: Disk quotas dquot_6.5.2
[    1.203031] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    1.211960] FS-Cache: Netfs 'nfs' registered for caching
[    1.218683] NFS: Registering the id_resolver key type
[    1.223953] Key type id_resolver registered
[    1.228160] Key type id_legacy registered
[    1.232902] msgmni has been set to 875
[    1.238799] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    1.246642] io scheduler noop registered
[    1.250600] io scheduler deadline registered (default)
[    1.256186] io scheduler cfq registered
[    1.261436] BCM2708FB: allocated DMA memory 5b400000
[    1.266564] BCM2708FB: allocated DMA channel 0 @ f2007000
[    1.292124] Console: switching to colour frame buffer device 82x26
[    1.302305] uart-pl011 dev:f1: no DMA platform data
[    1.308734] kgdb: Registered I/O driver kgdboc.
[    1.315335] vc-cma: Videocore CMA driver
[    1.320594] vc-cma: vc_cma_base      = 0x00000000
[    1.326624] vc-cma: vc_cma_size      = 0x00000000 (0 MiB)
[    1.333272] vc-cma: vc_cma_initial   = 0x00000000 (0 MiB)
[    1.349068] brd: module loaded
[    1.358572] loop: module loaded
[    1.363209] vchiq: vchiq_init_state: slot_zero = 0xdb000000, is_master = 0
[    1.372317] Loading iSCSI transport class v2.0-870.
[    1.379669] usbcore: registered new interface driver smsc95xx
[    1.387194] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    1.594480] Core Release: 2.80a
[    1.598892] Setting default values for core params
[    1.604972] Finished setting default values for core params
[    1.811800] Using Buffer DMA mode
[    1.816385] Periodic Transfer Interrupt Enhancement - disabled
[    1.823464] Multiprocessor Interrupt Enhancement - disabled
[    1.830307] OTG VER PARAM: 0, OTG VER FLAG: 0
[    1.835964] Dedicated Tx FIFOs mode
[    1.841263] dwc_otg: Microframe scheduler enabled
[    1.841503] dwc_otg bcm2708_usb: DWC OTG Controller
[    1.847767] dwc_otg bcm2708_usb: new USB bus registered, assigned bus number 1
[    1.856381] dwc_otg bcm2708_usb: irq 32, io mem 0x00000000
[    1.863158] Init: Port Power? op_state=1
[    1.868440] Init: Power Port (0)
[    1.873075] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.881294] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.889936] usb usb1: Product: DWC OTG Controller
[    1.896048] usb usb1: Manufacturer: Linux 3.10.24+ dwc_otg_hcd
[    1.903242] usb usb1: SerialNumber: bcm2708_usb
[    1.909903] hub 1-0:1.0: USB hub found
[    1.915113] hub 1-0:1.0: 1 port detected
[    1.920692] dwc_otg: FIQ enabled
[    1.920710] dwc_otg: NAK holdoff enabled
[    1.920720] dwc_otg: FIQ split fix enabled
[    1.920739] Module dwc_common_port init
[    1.921174] usbcore: registered new interface driver usb-storage
[    1.929023] mousedev: PS/2 mouse device common for all mice
[    1.936669] bcm2835-cpufreq: min=700000 max=700000 cur=700000
[    1.943985] bcm2835-cpufreq: switching to governor powersave
[    1.950958] bcm2835-cpufreq: switching to governor powersave
[    1.957903] cpuidle: using governor ladder
[    1.963213] cpuidle: using governor menu
[    1.968408] sdhci: Secure Digital Host Controller Interface driver
[    1.975878] sdhci: Copyright(c) Pierre Ossman
[    1.981515] sdhci: Enable low-latency mode
[    2.023716] mmc0: SDHCI controller on BCM2708_Arasan [platform] using platform's DMA
[    2.034188] mmc0: BCM2708 SDHC host at 0x20300000 DMA 2 IRQ 77
[    2.041433] sdhci-pltfm: SDHCI platform and OF driver helper
[    2.048568] ledtrig-cpu: registered to indicate activity on CPUs
[    2.058151] hidraw: raw HID events driver (C) Jiri Kosina
[    2.072511] usbcore: registered new interface driver usbhid
[    2.079559] usbhid: USB HID core driver
[    2.089397] TCP: cubic registered
[    2.096153] Initializing XFRM netlink socket
[    2.103876] NET: Registered protocol family 17
[    2.109875] Key type dns_resolver registered
[    2.118848] Indeed it is in host mode hprt0 = 00021501
[    2.125832] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
[    2.154522] registered taskstats version 1
[    2.164047] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    2.184405] Waiting for root device /dev/mmcblk0p2...
[    2.205887] mmc0: read SD Status register (SSR) after 2 attempts
[    2.226799] mmc0: new high speed SDHC card at address b368
[    2.242492] mmcblk0: mmc0:b368 SDC   30.2 GiB 
[    2.249849]  mmcblk0: p1 p2
[    2.353777] usb 1-1: new high-speed USB device number 2 using dwc_otg
[    2.363074] Indeed it is in host mode hprt0 = 00001101
[    2.584453] usb 1-1: New USB device found, idVendor=0424, idProduct=9512
[    2.597133] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    2.608460] hub 1-1:1.0: USB hub found
[    2.623492] EXT4-fs (mmcblk0p2): recovery complete
[    2.630028] hub 1-1:1.0: 3 ports detected
[    2.644038] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    2.655335] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    2.665742] devtmpfs: mounted
[    2.670836] Freeing unused kernel memory: 144K (c056c000 - c0590000)
[    2.913996] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[    3.034447] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[    3.043025] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.057091] smsc95xx v1.0.4
[    3.118771] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:8b:08:d2
[    3.214051] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[    3.327968] usb 1-1.2: New USB device found, idVendor=13fe, idProduct=3100
[    3.341387] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    3.350822] usb 1-1.2: Product: Patriot Memory
[    3.357088] usb 1-1.2: Manufacturer:         
[    3.363107] usb 1-1.2: SerialNumber: 07B31E015914B1D6
[    3.378548] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[    3.395675] scsi0 : usb-storage 1-1.2:1.0
[    3.484172] usb 1-1.3: new high-speed USB device number 5 using dwc_otg
[    3.605038] usb 1-1.3: New USB device found, idVendor=0bda, idProduct=8179
[    3.613655] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    3.640648] usb 1-1.3: Product: 802.11n NIC
[    3.653942] usb 1-1.3: Manufacturer: Realtek
[    3.659865] usb 1-1.3: SerialNumber: 00E04C0001
[    4.205048] udevd[158]: starting version 175
[    4.440847] scsi 0:0:0:0: Direct-Access              Patriot Memory   PMAP PQ: 0 ANSI: 0 CCS
[    5.954851] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_A_CUT_1T1R_RomVer(0)
[    6.302757] sd 0:0:0:0: [sda] 15646720 512-byte logical blocks: (8.01 GB/7.46 GiB)
[    6.327392] sd 0:0:0:0: [sda] Write Protect is off
[    6.339213] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[    6.342852] sd 0:0:0:0: [sda] No Caching mode page found
[    6.355516] sd 0:0:0:0: [sda] Assuming drive cache: write through
[    6.385001] sd 0:0:0:0: [sda] No Caching mode page found
[    6.391918] sd 0:0:0:0: [sda] Assuming drive cache: write through
[    6.422120] bcm2708-i2s bcm2708-i2s.0: Failed to create debugfs directory
[    6.435203]  sda: sda1
[    6.453330] sd 0:0:0:0: [sda] No Caching mode page found
[    6.472407] sd 0:0:0:0: [sda] Assuming drive cache: write through
[    6.483873] sd 0:0:0:0: [sda] Attached SCSI removable disk
[    6.603484] usbcore: registered new interface driver r8188eu
[   10.511897] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[   10.974982] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[   16.649074] FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[   19.398955] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[   19.409206] R8188EU: Firmware Version 11, SubVersion 1, Signature 0x88e1
[   19.966766] MAC Address = 64:66:b3:1d:0d:c5
[   23.354659] R8188EU: ERROR assoc success
[   25.021519] Adding 102396k swap on /var/swap.  Priority:-1 extents:1 across:102396k SSFS
[  399.690367] usb 1-1.2: USB disconnect, device number 4
[  402.996816] usb 1-1.2: new high-speed USB device number 6 using dwc_otg
[  403.100615] usb 1-1.2: New USB device found, idVendor=13fe, idProduct=3100
[  403.100647] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  403.100664] usb 1-1.2: Product: Patriot Memory
[  403.100680] usb 1-1.2: Manufacturer:         
[  403.100695] usb 1-1.2: SerialNumber: 07B31E015914B1D6
[  403.106923] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[  403.116759] scsi1 : usb-storage 1-1.2:1.0
[  404.153532] scsi 1:0:0:0: Direct-Access              Patriot Memory   PMAP PQ: 0 ANSI: 0 CCS
[  405.992149] sd 1:0:0:0: [sda] 15646720 512-byte logical blocks: (8.01 GB/7.46 GiB)
[  405.995744] sd 1:0:0:0: [sda] Write Protect is off
[  405.995774] sd 1:0:0:0: [sda] Mode Sense: 23 00 00 00
[  405.999512] sd 1:0:0:0: [sda] No Caching mode page found
[  405.999548] sd 1:0:0:0: [sda] Assuming drive cache: write through
[  406.013020] sd 1:0:0:0: [sda] No Caching mode page found
[  406.013058] sd 1:0:0:0: [sda] Assuming drive cache: write through
[  406.035805]  sda: sda1
[  406.046925] sd 1:0:0:0: [sda] No Caching mode page found
[  406.046963] sd 1:0:0:0: [sda] Assuming drive cache: write through
[  406.046992] sd 1:0:0:0: [sda] Attached SCSI removable disk
[  407.883488] usb 1-1.2: USB disconnect, device number 6
[  411.187062] usb 1-1.2: new high-speed USB device number 7 using dwc_otg
[  411.290852] usb 1-1.2: New USB device found, idVendor=13fe, idProduct=3100
[  411.290885] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  411.290902] usb 1-1.2: Product: Patriot Memory
[  411.290919] usb 1-1.2: Manufacturer:         
[  411.290934] usb 1-1.2: SerialNumber: 07B31E015914B1D6
[  411.292480] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[  411.295543] scsi2 : usb-storage 1-1.2:1.0
[  412.323497] scsi 2:0:0:0: Direct-Access              Patriot Memory   PMAP PQ: 0 ANSI: 0 CCS
[  413.748416] usb 1-1.2: USB disconnect, device number 7
[  413.767466] sd 2:0:0:0: [sda] READ CAPACITY failed
[  413.767503] sd 2:0:0:0: [sda]  
[  413.767516] Result: hostbyte=0x01 driverbyte=0x00
[  413.767530] sd 2:0:0:0: [sda] Sense not available.
[  413.767671] sd 2:0:0:0: [sda] Write Protect is on
[  413.767700] sd 2:0:0:0: [sda] Mode Sense: e0 97 94 c0
[  413.767824] sd 2:0:0:0: [sda] No Caching mode page found
[  413.767848] sd 2:0:0:0: [sda] Assuming drive cache: write through
[  413.768910] sd 2:0:0:0: [sda] Attached SCSI removable disk
[  417.077511] usb 1-1.2: new high-speed USB device number 8 using dwc_otg
[  417.181154] usb 1-1.2: New USB device found, idVendor=13fe, idProduct=3100
[  417.181189] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  417.181205] usb 1-1.2: Product: Patriot Memory
[  417.181221] usb 1-1.2: Manufacturer:         
[  417.181236] usb 1-1.2: SerialNumber: 07B31E015914B1D6
[  417.182872] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[  417.185795] scsi3 : usb-storage 1-1.2:1.0
[  417.868829] usb 1-1.2: USB disconnect, device number 8
[  421.177423] usb 1-1.2: new high-speed USB device number 9 using dwc_otg
[  421.281336] usb 1-1.2: New USB device found, idVendor=13fe, idProduct=3100
[  421.281369] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  421.281386] usb 1-1.2: Product: Patriot Memory
[  421.281402] usb 1-1.2: Manufacturer:         
[  421.281416] usb 1-1.2: SerialNumber: 07B31E015914B1D6
[  421.287173] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[  421.297385] scsi4 : usb-storage 1-1.2:1.0
[  421.965399] usb 1-1.2: USB disconnect, device number 9
[  425.277612] usb 1-1.2: new high-speed USB device number 10 using dwc_otg
[  425.381391] usb 1-1.2: New USB device found, idVendor=13fe, idProduct=3100
[  425.381424] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  425.381441] usb 1-1.2: Product: Patriot Memory
[  425.381458] usb 1-1.2: Manufacturer:         
[  425.381473] usb 1-1.2: SerialNumber: 07B31E015914B1D6
[  425.387429] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[  425.397524] scsi5 : usb-storage 1-1.2:1.0
[  426.433926] scsi 5:0:0:0: Direct-Access              Patriot Memory   PMAP PQ: 0 ANSI: 0 CCS
[  428.227044] sd 5:0:0:0: [sda] 15646720 512-byte logical blocks: (8.01 GB/7.46 GiB)
[  428.230693] sd 5:0:0:0: [sda] Write Protect is off
[  428.230736] sd 5:0:0:0: [sda] Mode Sense: 23 00 00 00
[  428.234393] sd 5:0:0:0: [sda] No Caching mode page found
[  428.234419] sd 5:0:0:0: [sda] Assuming drive cache: write through
[  428.249291] sd 5:0:0:0: [sda] No Caching mode page found
[  428.249327] sd 5:0:0:0: [sda] Assuming drive cache: write through
[  428.271992]  sda: sda1
[  428.282453] sd 5:0:0:0: [sda] No Caching mode page found
[  428.282490] sd 5:0:0:0: [sda] Assuming drive cache: write through
[  428.282518] sd 5:0:0:0: [sda] Attached SCSI removable disk
lsusb -v:

Code: Select all

pi@raspberrypi ~/coffeeconnect $ lsusb -v

Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         2 TT per port
  bMaxPacketSize0        64
  idVendor           0x0424 Standard Microsystems Corp.
  idProduct          0x9512 
  bcdDevice            2.00
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      1 Single TT
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0001  1x 1 bytes
        bInterval              12
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      2 TT per port
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0001  1x 1 bytes
        bInterval              12

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         1 Single TT
  bMaxPacketSize0        64
  idVendor           0x1d6b Linux Foundation
  idProduct          0x0002 2.0 root hub
  bcdDevice            3.10
  iManufacturer           3 
  iProduct                2 
  iSerial                 1 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12

Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass         0 
  bDeviceProtocol         1 
  bMaxPacketSize0        64
  idVendor           0x0424 Standard Microsystems Corp.
  idProduct          0xec00 
  bcdDevice            2.00
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               4

Bus 001 Device 010: ID 13fe:3100 Kingston Technology Company Inc. 2/4 GB stick
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x13fe Kingston Technology Company Inc.
  idProduct          0x3100 2/4 GB stick
  bcdDevice            1.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 3 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              300mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0

Bus 001 Device 005: ID 0bda:8179 Realtek Semiconductor Corp. 
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0bda Realtek Semiconductor Corp.
  idProduct          0x8179 
  bcdDevice            0.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 3 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0

horf
Posts: 6
Joined: Thu Dec 19, 2013 8:39 am

Re: RPi crashes (sometimes) when I connect a USB peripheral

Thu Dec 19, 2013 1:55 pm

Now that I am thinking about how to use a USB hub I have a problem.
At the beginning, to simplify my post I talked about a computer on the other side of the USB switch. In fact it is the motherboard of a vending machine. And the RPi will be in the vending machine. This means I have no external power supply except the one I can get from the vending machine (24V DC). We use a transformer to go from 24V DC to 5V DC and power supply the RPi.

Now you said I need a powered USB hub. Does someone know a USB hub powered by 5V DC or 24V DC.
I found this one: https://www.modmypi.com/New-Link-4-Port ... s-Adaptor). It is cheap and has one thing I like: It can be used to power supply the RPi.
But it also have one thing I don't like: The power supply input is 220-240V AC (I don't have access to this kind of power supply in the vending machine).

I will continue my research, but I would be very happy if someone uses a USB hub like the one I need and can tell me where I can find it.

Thank you!

User avatar
DougieLawson
Posts: 36305
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RPi crashes (sometimes) when I connect a USB peripheral

Thu Dec 19, 2013 2:01 pm

USB hubs are 5V and normally 500mA per port.

So 4port is 2A.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

horf
Posts: 6
Joined: Thu Dec 19, 2013 8:39 am

Re: RPi crashes (sometimes) when I connect a USB peripheral

Thu Dec 19, 2013 4:50 pm

After some thinking I saw that I can power the USB hub directly with the power source of the vending machine (I have just to adjust it).

So just to be sure, can you tell me if my connections are correct? I will order this USB hub https://www.modmypi.com/New-Link-4-Port ... s-Adaptor).

Here is the drawing: https://www.dropbox.com/s/6x0u1emi0tyd6oa/HUB.jpg
  • - Power comes from the vending machine (voltage adjusted with a regulator)
    - The master (host - I don't know the correct name) port of the USB hub is connected to one of the USB ports of the RPi
    - The RPi is powered by a USB port of the hub
    - The switch is connected to the hub
I just want to be sure that this will solve my problem (I never used a USB hub before, I don't now exactly how it works). Can you certify this please?

Thank you for your help

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12322
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: RPi crashes (sometimes) when I connect a USB peripheral

Fri Dec 20, 2013 7:21 pm

Yes, it should work, only known issue is that when the hub also connects power to the "master" port, it means you are bypassing (back-powering) the (poly)fuse in the PI, so be careful not to short anything.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: RPi crashes (sometimes) when I connect a USB peripheral

Fri Dec 20, 2013 7:54 pm

I understand you when you say that it "should" work fine if you can use (and are using) a powered hub, but, alas, it doesn't always work.

I use a powered hub with my Pi (using one of the ports on the hub to power the Pi itself), but if I plug my WiFi dongle into the hub when the Pi is running, it always reboots the Pi.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12322
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: RPi crashes (sometimes) when I connect a USB peripheral

Fri Dec 20, 2013 8:40 pm

Yes, some hubs are also not hot-pluggable, its quite a common phenomenon I'm afraid.

horf
Posts: 6
Joined: Thu Dec 19, 2013 8:39 am

Re: RPi crashes (sometimes) when I connect a USB peripheral

Fri Dec 20, 2013 11:03 pm

Thank you very much for your time and your answers.

I have ordered the hub and I will make some tests. If a still have problems I'll try with another one...
I'll give you a feedback. By the way, the second USB port is used by the wifi dongle so it isn't a problem for me.

I wish you a merry christmas and a happy new year!

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: RPi crashes (sometimes) when I connect a USB peripheral

Sat Dec 21, 2013 12:34 am

mahjongg wrote:Yes, some hubs are also not hot-pluggable, its quite a common phenomenon I'm afraid.
I would assume you mean "not hot swappable on the Pi". Of course on normal hardware, it is hot swappable.

Heh heh...
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12322
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: RPi crashes (sometimes) when I connect a USB peripheral

Sat Dec 21, 2013 1:37 pm

Joe Schmoe wrote:
mahjongg wrote:Yes, some hubs are also not hot-pluggable, its quite a common phenomenon I'm afraid.
I would assume you mean "not hot swappable on the Pi". Of course on normal hardware, it is hot swappable.

Heh heh...
maybe.
On a PC its almost impossible to cause a drop in the 5V when connecting an empty capacitor to the 5V, as the current capacitance of the PSU is so large (over 10A) and there are masses of capacitors on the 5V that can deliver even more impulse current.
But if the hub cannot receive power from the PC, (as it should, why else would the hub need its own supply) then its up the the hubs power supply if it can survive a sudden inrush current of multiple amperes when connecting the capacitors of an USB device. If its voltage dips then its also the question how well the hubs ASIC chip can handle that.

User avatar
Tage
Posts: 287
Joined: Fri May 24, 2013 2:29 am
Location: St Thomas, Ontario Canada

Re: RPi crashes (sometimes) when I connect a USB peripheral

Sat Dec 21, 2013 3:35 pm

get a large electrolytic capacitor and connect it across the 5V and GND on the Pi, wherever you can find a suitable place to solder the wires. for example, a 10.000uF 6.3V radial aluminum electrolytic capacitor will cost you about $1. a smaller one may also work well. the main problem is the lack of decoupling capacitor. when you plug in a USB device it has its own input capacitor which is at zero volts. at plug in the small capacitor in the Pi has to deliver charge to the capacitor on the USB device, and the 5V will dip below the shutdown threshold. even if you just if you double the capacitance onboard the Pi the dip will be much smaller.

make sure the capacitor is soldered with the correct polarity so you don't apply reverse voltage, or it may leak. suddenly.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12322
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: RPi crashes (sometimes) when I connect a USB peripheral

Mon Dec 23, 2013 8:35 pm

the PI , has a 470uF bulk capacitor but its far from the USB ports, meaning the traces have some resistance. Use a small 16V 2200uF elco, and solder it directly over the USB pins, (the outer two of the four) measure which pin is GND, and which is 5V so you get the polarity right.

P.S. My 4000th post!

horf
Posts: 6
Joined: Thu Dec 19, 2013 8:39 am

Re: RPi crashes (sometimes) when I connect a USB peripheral

Thu Jan 02, 2014 11:33 am

Hi,

I wish you a happy new year and congrat's for your 4000th post ;)
If I understood correctly, I have to put a capacitor between the GND and VCC pins of the USB to replace the hub? (to protect the RPi USB supply).

I have received my USB hub (https://www.modmypi.com/New-Link-4-Port ... ns-Adaptor) but it still doesn't work. :lol: It crashes when the USB stick is disconnected from the RPi. This is printed on the screen:

Code: Select all

[161.898184] Disabling IRQ #32

Message from syslog@raspberrypi at Jan 2 11:43:32 ...
 kernel:[  161.898184] Disabling IRQ #32
But I have the feeling that it is only the USB ports which are down. The RPi seems to work correctly but I can't prove it, because I can't use the keyboard and I cannot connect by SSH because the RPi is connected to the network by a USB wifi dongle.

I have made some tests and I think I found the source of the problem. It is on the relays of my board.
My board has 2 relays to toggle the USB stick between the RPi and the vending machine. Those are controlled by GPIO.

If I insert/remove the USB stick manually (by hand = not using the relays) it works correctly. So I suppose the problem comes from the relays. Here is the link to my electronic schema: https://www.dropbox.com/s/jyhfvghc04a2y ... %201.1.PNG

Do you have idea about this problem? Do I have add an electronic component on my board?
This problem is very funny and I thank you in advance for your help :)

Return to “Troubleshooting”