# Raspberry Pi B and bad SD card IO performance



## gustopn (Jun 13, 2015)

So! I am here again, LOL!

```
KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2015 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
   The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 11.0-CURRENT #0 r283577: Wed May 27 01:17:31 UTC 2015
  root@releng2.nyi.freebsd.org:/usr/obj/arm.armv6/usr/src/sys/RPI-B arm
FreeBSD clang version 3.6.1 (tags/RELEASE_361/final 237755) 20150525
VT: init without driver.
sema_sysinit
CPU: ARM1176JZ-S rev 7 (ARM11J core)
 Supported features: ARM_ISA THUMB2 JAZELLE ARMv4 Security_Ext
 WB enabled LABT branch prediction enabled
  16KB/32B 4-way instruction cache
  16KB/32B 4-way write-back-locking-C data cache
real memory  = 503312384 (479 MB)
avail memory = 482803712 (460 MB)
random: entropy device infrastructure driver
random: selecting highest priority adaptor <Dummy>
random: SOFT: yarrow init()
random: selecting highest priority adaptor <Yarrow>
kbd0 at kbdmux0
ofwbus0: <Open Firmware Device Tree>
simplebus0: <Flattened device tree simple bus> mem 0x20000000-0x20ffffff on ofwbus0
cpulist0: <Open Firmware CPU Group> on ofwbus0
cpu0: <Open Firmware CPU> on cpulist0
bcm2835_cpufreq0: <CPU Frequency Control> on cpu0
intc0: <BCM2835 Interrupt Controller> mem 0xb200-0xb3ff on simplebus0
systimer0: <BCM2835 System Timer> mem 0x3000-0x3fff irq 8,9,10,11 on simplebus0
Event timer "BCM2835 Event Timer 3" frequency 1000000 Hz quality 1000
Timecounter "BCM2835 Timecounter" frequency 1000000 Hz quality 1000
bcmwd0: <BCM2708/2835 Watchdog> mem 0x10001c-0x100027 on simplebus0
gpio0: <BCM2708/2835 GPIO controller> mem 0x200000-0x2000af irq 57,59,58,60 on simplebus0
gpio0: read-only pins: 46-53.
gpio0: reserved pins: 48-53.
gpiobus0: <OFW GPIO bus> on gpio0
gpioled0: <GPIO led> at pin(s) 16 on gpiobus0
gpioc0: <GPIO controller> on gpio0
iichb0: <BCM2708/2835 BSC controller> mem 0x205000-0x20501f irq 61 on simplebus0
iicbus0: <OFW I2C bus> on iichb0
iic0: <I2C generic I/O> on iicbus0
iichb1: <BCM2708/2835 BSC controller> mem 0x804000-0x80401f irq 61 on simplebus0
iicbus1: <OFW I2C bus> on iichb1
iic1: <I2C generic I/O> on iicbus1
spi0: <BCM2708/2835 SPI controller> mem 0x204000-0x20401f irq 62 on simplebus0
spibus0: <OFW SPI bus> on spi0
bcm_dma0: <BCM2835 DMA Controller> mem 0x7000-0x7fff,0xe05000-0xe05fff irq 24,25,26,27,28,29,30,31,32,33,34,35,36 on simplebus0
mbox0: <BCM2835 VideoCore Mailbox> mem 0xb880-0xb8bf irq 1 on simplebus0
sdhci_bcm0: <Broadcom 2708 SDHCI controller> mem 0x300000-0x3000ff irq 70 on simplebus0
mmc0: <MMC/SD bus> on sdhci_bcm0
uart0: <PrimeCell UART (PL011)> mem 0x201000-0x201fff irq 65 on simplebus0
uart0: console (115200,n,8,1)
vchiq0: <BCM2835 VCHIQ> mem 0xb800-0xb84f irq 2 on simplebus0
vchiq0: [GIANT-LOCKED]
vchiq: local ver 6 (min 3), remote ver 6.
pcm0: <VCHQI audio> on vchiq0
bcm283x_dwcotg0: <DWC OTG 2.0 integrated USB controller (bcm283x)> mem 0x980000-0x99ffff irq 17 on simplebus0
usbus0 on bcm283x_dwcotg0
fb0: <BCM2835 VT framebuffer driver> on ofwbus0
fbd0 on fb0
VT: initialize with new VT driver "fb".
fb0: 656x416(656x416@0,0) 24bpp
fb0: fbswap: 0, pitch 1968, base 0x1e08c000, screen_size 818688
Timecounters tick every 10.000 msec
usbus0: 480Mbps High Speed USB v2.0
bcm2835_cpufreq0: ARM 700MHz, Core 250MHz, SDRAM 400MHz, Turbo OFF
ugen0.1: <DWCOTG> at usbus0
uhub0: <DWCOTG OTG Root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus0
sdhci_bcm0-slot0: Got data interrupt 0x00000002, but there is no active command.
sdhci_bcm0-slot0: ============== REGISTER DUMP ==============
sdhci_bcm0-slot0: Sys addr: 0x00000000 | Version:  0x00009902
sdhci_bcm0-slot0: Blk size: 0x00000040 | Blk cnt:  0x00000001
sdhci_bcm0-slot0: Argument: 0xe6240000 | Trn mode: 0x0000071b
sdhci_bcm0-slot0: Present:  0x01ff0000 | Host ctl: 0x00000001
sdhci_bcm0-slot0: Power:  0x0000000f | Blk gap:  0x00000000
sdhci_bcm0-slot0: Wake-up:  0x00000000 | Clock:  0x00003947
sdhci_bcm0-slot0: Timeout:  0x0000000e | Int stat: 0x00000000
sdhci_bcm0-slot0: Int enab: 0x01ff00fb | Sig enab: 0x01ff00fb
sdhci_bcm0-slot0: AC12 err: 0x00000000 | Slot int: 0x00000000
sdhci_bcm0-slot0: Caps:  0x00000000 | Max curr: 0x00000001
sdhci_bcm0-slot0: ===========================================
sdhci_bcm0-slot0: Got data interrupt 0x00000002, but there is no active command.
sdhci_bcm0-slot0: ============== REGISTER DUMP ==============
sdhci_bcm0-slot0: Sys addr: 0x00000000 | Version:  0x00009902
sdhci_bcm0-slot0: Blk size: 0x00000040 | Blk cnt:  0x00000001
sdhci_bcm0-slot0: Argument: 0xe6240000 | Trn mode: 0x0000071b
sdhci_bcm0-slot0: Present:  0x01ff0000 | Host ctl: 0x00000001
sdhci_bcm0-slot0: Power:  0x0000000f | Blk gap:  0x00000000
sdhci_bcm0-slot0: Wake-up:  0x00000000 | Clock:  0x00003947
sdhci_bcm0-slot0: Timeout:  0x0000000e | Int stat: 0x00000000
sdhci_bcm0-slot0: Int enab: 0x01ff00fb | Sig enab: 0x01ff00fb
sdhci_bcm0-slot0: AC12 err: 0x00000000 | Slot int: 0x00000000
sdhci_bcm0-slot0: Caps:  0x00000000 | Max curr: 0x00000001
sdhci_bcm0-slot0: ===========================================
sdhci_bcm0-slot0: Got data interrupt 0x00000002, but there is no active command.
sdhci_bcm0-slot0: ============== REGISTER DUMP ==============
sdhci_bcm0-slot0: Sys addr: 0x00000000 | Version:  0x00009902
sdhci_bcm0-slot0: Blk size: 0x00000040 | Blk cnt:  0x00000001
sdhci_bcm0-slot0: Argument: 0xe6240000 | Trn mode: 0x0000071b
sdhci_bcm0-slot0: Present:  0x01ff0000 | Host ctl: 0x00000001
sdhci_bcm0-slot0: Power:  0x0000000f | Blk gap:  0x00000000
sdhci_bcm0-slot0: Wake-up:  0x00000000 | Clock:  0x00003947
sdhci_bcm0-slot0: Timeout:  0x0000000e | Int stat: 0x00000000
sdhci_bcm0-slot0: Int enab: 0x01ff00fb | Sig enab: 0x01ff00fb
sdhci_bcm0-slot0: AC12 err: 0x00000000 | Slot int: 0x00000000
sdhci_bcm0-slot0: Caps:  0x00000000 | Max curr: 0x00000001
sdhci_bcm0-slot0: ===========================================
uhub0: 1 port with 1 removable, self powered
sdhci_bcm0-slot0: Got data interrupt 0x00000002, but there is no active command.
sdhci_bcm0-slot0: ============== REGISTER DUMP ==============
sdhci_bcm0-slot0: Sys addr: 0x00000000 | Version:  0x00009902
sdhci_bcm0-slot0: Blk size: 0x00000040 | Blk cnt:  0x00000001
sdhci_bcm0-slot0: Argument: 0xe6240000 | Trn mode: 0x0000071b
sdhci_bcm0-slot0: Present:  0x01ff0000 | Host ctl: 0x00000001
sdhci_bcm0-slot0: Power:  0x0000000f | Blk gap:  0x00000000
sdhci_bcm0-slot0: Wake-up:  0x00000000 | Clock:  0x00003947
sdhci_bcm0-slot0: Timeout:  0x0000000e | Int stat: 0x00000000
sdhci_bcm0-slot0: Int enab: 0x01ff00fb | Sig enab: 0x01ff00fb
sdhci_bcm0-slot0: AC12 err: 0x00000000 | Slot int: 0x00000000
sdhci_bcm0-slot0: Caps:  0x00000000 | Max curr: 0x00000001
sdhci_bcm0-slot0: ===========================================
mmc0: CMD7 failed, RESULT: 1
mmcsd0: 16GB <SDHC SD16G 8.0 SN 18DC8D0A MFG 04/2012 by 3 SD> at mmc0 25.0MHz/4bit/65535-block
random: unblocking device.
Root mount waiting for: usbus0
ugen0.2: <vendor 0x0424> at usbus0
uhub1: <vendor 0x0424 product 0x9512, class 9/0, rev 2.00/2.00, addr 2> on usbus0
uhub1: MTT enabled
uhub1: 3 ports with 2 removable, self powered
Root mount waiting for: usbus0
ugen0.3: <vendor 0x0424> at usbus0
smsc0: <vendor 0x0424 product 0xec00, rev 2.00/2.00, addr 3> on usbus0
Trying to mount root from ufs:/dev/ufs/rootfs [rw]...
smsc0: chip 0xec00, rev. 0002
miibus0: <MII bus> on smsc0
ukphy0: <Generic IEEE 802.3u media interface> PHY 1 on miibus0
ukphy0:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
ue0: <USB Ethernet> on smsc0
ue0: Ethernet address: b8:27:eb:fc:5e:20
warning: no time-of-day clock registered, system time will not be set accurately
smsc0: chip 0xec00, rev. 0002
ue0: link state changed to DOWN
ue0: link state changed to UP
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 1219, size: 4096
swap_pager: indefinite wait buffer: bufobj: 0, blkno: 1219, size: 4096
```
Whatever, the problem seems to reside at sdhci_bcm because on my Beagle Bone Black with sdhci_ti the performance is "normal". here on Raspberry Pi B it looks like 200 KB/s which is too low. The card as it is can do up to 7 MB/s writing (using a cardreader from laptop).


----------



## tingo (Jun 15, 2015)

Why do you compare performance of the RaspBerry Pi to performance of the BeagleBone Black?
The two boxes are *very* different.


----------



## gustopn (Jun 15, 2015)

bthomson said:


> Not sure if it's related to your issue, but there's a setting I usually add: `hw.bcm2835.sdhci.hs="0"` in /boot/loader.conf. Apparently that disables "high speed" access for the SD card and often helps prevent filesystem corruption, or at least it did last year when I looked into the issue because my Pi was always screwing up.


Yes, it seemed to helped a lot, I am now running a littler bit faster, however, I need to test it further, but it looks like a step into the right direction. I did not know that there was a parameter like this, because in sysctl it did not show up.
UPDATE: OK, I can confirm write data rates up to 7200 kB/s which is about 20x faster than before, after disabeling that hs mode.


----------



## gustopn (Jun 15, 2015)

tingo said:


> Why do you compare performance of the RaspBerry Pi to performance of the BeagleBone Black?
> The two boxes are *very* different.


Difference only in Raspberry Pi being Broadcom and Beagle Bone Black being Texas Instruments. But it works as a comparison, when Raspberry Pi works fine writing on card, then it is the Broadcom (or its driver) where to look for the problem. Like we just found out, it was the case.


----------

