Using Compact Flash with Ubuntu

Some notes about using SanDisk Extreme III 4GB 30MB/s CF card on Ubuntu.

Actually I was using lighter Lubuntu 10.4 with openbox windowmanager since my system is underpowered VIA C3 Nehemiah 665MHz:

root@ismo:~# dmesg |grep Nehe
[    0.446812] longhaul: VIA C3 'Nehemiah B' [C5XLOH] CPU detected.  Powersaver supported.
root@ismo:~#

root@ismo:~# lscpu
Architecture:          i686
CPU(s):                1
Thread(s) per core:    1
Core(s) per socket:    1
CPU socket(s):         1
Vendor ID:             CentaurHauls
CPU family:            6
Model:                 9
Stepping:              3
CPU MHz:               665.000

root@ismo:~# lspci
00:00.0 Host bridge: VIA Technologies, Inc. VT8623 [Apollo CLE266]
00:01.0 PCI bridge: VIA Technologies, Inc. VT8633 [Apollo Pro266 AGP]
00:0d.0 FireWire (IEEE 1394): VIA Technologies, Inc. VT6306/7/8 [Fire II(M)] IEEE 1394 OHCI Controller (rev 80)
00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.3 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 82)
00:11.0 ISA bridge: VIA Technologies, Inc. VT8235 ISA Bridge
00:11.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 06)
00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 50)
00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 74)
01:00.0 VGA compatible controller: VIA Technologies, Inc. VT8623 [Apollo CLE266] integrated CastleRock graphics (rev 03)
root@ismo:~#

root@ismo:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 10.04.1 LTS
Release:        10.04
Codename:       lucid
root@ismo:~#


root@ismo:~# uname -a
Linux ismo 2.6.32-25-generic #44-Ubuntu SMP Fri Sep 17 20:26:08 UTC 2010 i686 GNU/Linux
root@ismo:~#

SanDisk detected in boot:

root@ismo:~# dmesg |grep SanDisk
[    3.292664] ata1.00: CFA: SanDisk SDCFX3-004G, HDX 4.32, max UDMA/66
[    3.293754] scsi 0:0:0:0: Direct-Access     ATA      SanDisk SDCFX3-0 HDX  PQ: 0 ANSI: 5

Note UDMA/66. But according to this link:

http://kb.sandisk.com/app/answers/detail/a_id/262

my card does not support DMA.

So first go here:

http://www.mjmwired.net/kernel/Documentation/kernel-parameters.txt

search for “CF”. And disable DMA altogether like this:

Add libata.dama=0 in this file:

root@ismo:~# cat /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
libata.dma=0
root@ismo:~#

and reboot:

root@ismo:~# dmesg |grep command
[    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-2.6.32-25-generic root=UUID=b59249ce-9490-400d-a435-4c6669cb53ed ro splash libata.dma=0

hdparm test gives me this:

root@ismo:~# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   194 MB in  2.00 seconds =  96.90 MB/sec
 Timing buffered disk reads:   12 MB in  3.53 seconds =   3.40 MB/sec
root@ismo:~#

If you dont have DMA disabled with this CF card you’ll get very slow boot up times since Linux kernel keeps probing CF card for DMA quite some time:

root@ismo:/var/log# grep  -i UDMA messages
Oct  7 12:06:05 ismo kernel: [    3.252649] ata1.00: CFA: SanDisk SDCFX3-004G, HDX 4.32, max UDMA/66
Oct  7 12:06:05 ismo kernel: [    3.253244] ata1.00: configured for UDMA/66
Oct  7 12:06:05 ismo kernel: [   34.021251] ata1.00: configured for UDMA/66
Oct  7 12:06:05 ismo kernel: [   64.867333] ata1.00: limiting speed to UDMA/44:PIO4
Oct  7 12:06:05 ismo kernel: [   65.021184] ata1.00: configured for UDMA/44
Oct  7 12:06:05 ismo kernel: [   95.867339] ata1.00: limiting speed to UDMA/33:PIO4
Oct  7 12:06:05 ismo kernel: [   96.021202] ata1.00: configured for UDMA/33
root@ismo:/var/log#

From /var/log/kern.log:

Oct  7 11:05:10 ismo kernel: [    3.273619] scsi 0:0:0:0: Direct-Access     ATA      SanDisk SDCFX3-0 HDX  PQ: 0 ANSI: 5
Oct  7 11:05:10 ismo kernel: [    3.274175] sd 0:0:0:0: Attached scsi generic sg0 type 0
Oct  7 11:05:10 ismo kernel: [    3.275210] sd 0:0:0:0: [sda] 8027712 512-byte logical blocks: (4.11 GB/3.82 GiB)
Oct  7 11:05:10 ismo kernel: [    3.275338] sd 0:0:0:0: [sda] Write Protect is off
Oct  7 11:05:10 ismo kernel: [    3.275350] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
Oct  7 11:05:10 ismo kernel: [    3.275413] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Oct  7 11:05:10 ismo kernel: [    3.276307]  sda:
Oct  7 11:05:10 ismo kernel: [    4.480411] ieee1394: Host added: ID:BUS[0-00:1023]  GUID[004063f000000481]
Oct  7 11:05:10 ismo kernel: [   33.816090] ata1: lost interrupt (Status 0x58)
Oct  7 11:05:10 ismo kernel: [   33.820019] ata1: drained 32768 bytes to clear DRQ.
Oct  7 11:05:10 ismo kernel: [   33.867340] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
Oct  7 11:05:10 ismo kernel: [   33.867356] ata1.00: failed command: READ DMA
Oct  7 11:05:10 ismo kernel: [   33.867381] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
Oct  7 11:05:10 ismo kernel: [   33.867387]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
Oct  7 11:05:10 ismo kernel: [   33.867400] ata1.00: status: { DRDY }
Oct  7 11:05:10 ismo kernel: [   33.867443] ata1: soft resetting link
Oct  7 11:05:10 ismo kernel: [   34.021243] ata1.00: configured for UDMA/66
Oct  7 11:05:10 ismo kernel: [   34.021260] ata1.00: device reported invalid CHS sector 0
Oct  7 11:05:10 ismo kernel: [   34.021285] ata1: EH complete
Oct  7 11:05:10 ismo kernel: [   64.816089] ata1: lost interrupt (Status 0x58)
Oct  7 11:05:10 ismo kernel: [   64.820020] ata1: drained 32768 bytes to clear DRQ.
Oct  7 11:05:10 ismo kernel: [   64.867335] ata1.00: limiting speed to UDMA/44:PIO4
Oct  7 11:05:10 ismo kernel: [   64.867349] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
Oct  7 11:05:10 ismo kernel: [   64.867364] ata1.00: failed command: READ DMA
Oct  7 11:05:10 ismo kernel: [   64.867390] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
Oct  7 11:05:10 ismo kernel: [   64.867396]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
Oct  7 11:05:10 ismo kernel: [   64.867408] ata1.00: status: { DRDY }
Oct  7 11:05:10 ismo kernel: [   64.867450] ata1: soft resetting link
Oct  7 11:05:10 ismo kernel: [   65.021184] ata1.00: configured for UDMA/44
Oct  7 11:05:10 ismo kernel: [   65.021200] ata1.00: device reported invalid CHS sector 0
Oct  7 11:05:10 ismo kernel: [   65.021232] ata1: EH complete
Oct  7 11:05:10 ismo kernel: [   95.816093] ata1: lost interrupt (Status 0x58)
Oct  7 11:05:10 ismo kernel: [   95.820019] ata1: drained 32768 bytes to clear DRQ.
Oct  7 11:05:10 ismo kernel: [   95.867333] ata1.00: limiting speed to UDMA/33:PIO4
Oct  7 11:05:10 ismo kernel: [   95.867346] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
Oct  7 11:05:10 ismo kernel: [   95.867361] ata1.00: failed command: READ DMA
Oct  7 11:05:10 ismo kernel: [   95.867386] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
Oct  7 11:05:10 ismo kernel: [   95.867392]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
Oct  7 11:05:10 ismo kernel: [   95.867404] ata1.00: status: { DRDY }
Oct  7 11:05:10 ismo kernel: [   95.867444] ata1: soft resetting link
Oct  7 11:05:10 ismo kernel: [   96.021187] ata1.00: configured for UDMA/33
Oct  7 11:05:10 ismo kernel: [   96.021202] ata1.00: device reported invalid CHS sector 0
Oct  7 11:05:10 ismo kernel: [   96.021232] ata1: EH complete
Oct  7 11:05:10 ismo kernel: [  126.816088] ata1: lost interrupt (Status 0x58)
Oct  7 11:05:10 ismo kernel: [  126.820019] ata1: drained 32768 bytes to clear DRQ.
Oct  7 11:05:10 ismo kernel: [  126.867334] ata1.00: limiting speed to PIO4
Oct  7 11:05:10 ismo kernel: [  126.867347] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
Oct  7 11:05:10 ismo kernel: [  126.867362] ata1.00: failed command: READ DMA
Oct  7 11:05:10 ismo kernel: [  126.867387] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
Oct  7 11:05:10 ismo kernel: [  126.867394]          res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
Oct  7 11:05:10 ismo kernel: [  126.867406] ata1.00: status: { DRDY }

 

 

 

 

Tags: , , ,

2 Responses to “Using Compact Flash with Ubuntu”

  1. Bill Birch Says:

    Hi, I have a similar settup. Via C3, but with Squeeze Debian. I will follow your instructions and report back. Bill

  2. Bill Birch Says:

    Hi, The above did not work for me. However I got it to work by editting
    # vi /etc/default/grub.
    GRUB_CMDLINE_LINUX=”libata.dma=3″
    then
    # update grub
    Cheers,
    Bill

Leave a comment