world leader in high performance signal processing
Trace: » pata_bf54x

Blackfin On-Chip ATAPI Controller

This driver is used to control the Blackfin On-Chip ATAPI controller that exists in some parts (like the BF54x). It is not used for any other device.

Kernel configuration

Driver

You will need to enable the SCSI layer as well as the Blackfin-specific driver. You should enable disk/cdrom support depending on what devices you will be connecting.

Device Drivers  --->

  SCSI device support  --->
    <*> SCSI device support
    <*> SCSI disk support
    <*> SCSI CDROM support

  Serial ATA (prod) and Parallel ATA (experimental) drivers  --->
    [*] ATA SFF support
    <*>   Blackfin 54x ATAPI support

File systems

You should enable whatever file systems you will be placing onto the hard drive. If you want the drive to be readable by both Windows and Linux, then you should pick VFAT. If you want the drive to only be usable by Linux, then you should pick EXT3.

File systems  --->
  <*> Ext3 journalling file system support

  DOS/FAT/NT Filesystems  --->
    <*> VFAT (Windows-95) fs support
    (437) Default codepage for FAT
    (iso8859-1) Default iocharset for FAT

NLS Support

Depending on the codepages used in the filesystem, you might have to enable additional NLS options. You might also want to change the default codepages to UTF-8 if you want to support extended characters.

File systems  --->
  <*> Native language support  --->
  (iso8859-1) Default NLS Option
  <*>   Codepage 437 (United States, Canada)

Userspace Utilities

You should enable the userspace utility to create/check the filesystem(s) you intend to support. These are found under the user/vendor settings.

Filesystem Applications  --->
  [*] fdisk
  [*] e2fsck
  [*] mke2fs
  [*] mkdosfs
  [*] dosfsck

Testing

  1. A configured kernel should print messages as following when start up. You should find your hard disk name “TOSHIBA MK4032GAX”, capacitor “78140160 sectors”, working mode “configured for UDMA/100”, partiton name “sda: sda1 sda2”, etc.
    register bfin atapi driver
    ata1: PATA max UDMA/133 cmd 0x00000000 ctl 0xffc03800 bmdma 0x00000000 irq 68
    scsi0 : bf54x-atapi
    ata1.00: ATA-6: TOSHIBA MK4032GAX, AD101A, max UDMA/100
    ata1.00: 78140160 sectors, multi 16: LBA48
    ata1.00: configured for UDMA/100
    blk_queue_max_hw_segments: set to minimum 1
    scsi 0:0:0:0: Direct-Access     ATA      TOSHIBA MK4032GA AD10 PQ: 0 ANSI: 5
    SCSI device sda: 78140160 512-byte hdwr sectors (40008 MB)
    sda: Write Protect is off
    SCSI device sda: write cache: enabled, read cache: enabled, doesn't support DPO or FUA
    SCSI device sda: 78140160 512-byte hdwr sectors (40008 MB)
    sda: Write Protect is off
    SCSI device sda: write cache: enabled, read cache: enabled, doesn't support DPO or FUA
     sda: sda1 sda2
    sd 0:0:0:0: Attached scsi disk sda                                                                     
  2. Libata interrupt should be hit if you check in proc file.
    root:~> cat /proc/interrupts
      6:     243210   BFIN Timer Tick
     48:        209   BFIN_UART_RX
     49:       1406   BFIN_UART_TX
     68:          3   pata-bf54x
     74:          0   BF54X NFC driver
    175:          0   smsc911x
    Err:          0
  3. Libata block device “sd” can be found in proc file.
    root:~> cat /proc/devices
    Character devices:
      1 mem
      5 /dev/tty
      5 /dev/console
      5 /dev/ptmx
     10 misc
     13 input
    128 ptm
    136 pts
    204 ttyBF
    254 rtc
    
    Block devices:
      1 ramdisk
      8 sd
     31 mtdblock
     65 sd
     66 sd
     67 sd
     68 sd
     69 sd
     70 sd
     71 sd
    128 sd
    129 sd
    130 sd
    131 sd
    132 sd
    133 sd
    134 sd
    135 sd
  4. harddisk information can be found under sys filesystem.
    root:~> ls /sys/block/
    mtdblock0  ram10      ram13      ram2       ram5       ram8
    ram0       ram11      ram14      ram3       ram6       ram9
    ram1       ram12      ram15      ram4       ram7       sda
    root:~> ls /sys/block/sda/
    dev        holders    range      sda1       size       stat       uevent
    device     queue      removable  sda2       slaves     subsystem
    root:~> ls /sys/block/sda/stat
    /sys/block/sda/stat
    root:~> cat /sys/block/sda/size
    78140160
  5. scsi disk device nodes are created dynamically under dev folder.
    root:~> ls /dev/
    console   log       pts       ram12     ram3      ram8      sda0    ttyBF0
    dpmc      mem       ram0      ram13     ram4      ram9      sda1    urandom
    full      null      ram1      ram14     ram5      random    sport0  watchdog
    kmem      port      ram10     ram15     ram6      rtc0      sport1  zero
    kmsg      ptmx      ram11     ram2      ram7      sda       tty
  6. Parition the drive:
    1. Start fdisk:
      root:~> fdisk /dev/sda
      
      The number of cylinders for this disk is set to 4864.
      There is nothing wrong with that, but this is larger than 1024,
      and could in certain setups cause problems with:
      1) software that runs at boot time (e.g., old versions of LILO)
      2) booting and partitioning software from other OSs
         (e.g., DOS FDISK, OS/2 FDISK)
      
      Command (m for help): 
    2. Delete the existing FAT like partition:
      Command (m for help): d
      Selected partition 1
    3. Create a new primary partition:
       Command (m for help): n
      Command action
         e   extended
         p   primary partition (1-4)
      p
      Partition number (1-4): 1
      First cylinder (1-4864, default 1): 1
      Last cylinder or +size or +sizeM or +sizeK (1-4864, default 4864):
      Using default value 4864
    4. Create additional partitions if necessary
    5. Activate the first partition:
      Command (m for help): a
      Partition number (1-4): 1
      
      Command (m for help):
    6. Set the partition type to ext2:
      Command (m for help): t
      Partition number (1-4): 1
      Hex code (type L to list codes): 82
    7. write out the partition table:
      Command (m for help): w
      The partition table has been altered!
      
      Calling ioctl() to re-read partition table
      sd 0:0:0:0: [sda] 78140160 512-byte hardware sectors (40008 MB)
      sd 0:0:0:0: [sda] Write Protect is off
      sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
       sda: sda1
      root:~>
  7. Format the disk
    root:~> mkfs.ext2 /dev/sda1
    mke2fs 1.39 (29-May-2006)
    Filesystem label=
    OS type: Linux
    Block size=1024 (log=0)
    Fragment size=1024 (log=0)
    4884480 inodes, 39070048 blocks
    1953502 blocks (4%) reserved for the super user
    First data block=1
    4770 block groups
    8192 blocks per group, 8192 fragments per group
    1024 inodes per group
    Superblock backups stored on blocks:
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, 663553,
            1024001, 1990657, 2809857, 5120001, 5971969, 17915905, 19668993,
            25600001
    
    Writing inode tables:  116/4770 
  8. Mount the disk device
    root:~> mount /dev/sda1 /mnt/
  9. Display drive content
    root:~> ls /mnt/
    busybox     lost+found  test
  10. Simple read/write test
    root:~> cp /bin/busybox /mnt/abc
    root:~> ls -l /mnt/
    -rwxr-xr-x    1 root     root       454020 Feb 22 17:19 abc
    -rwxr-xr-x    1 root     root       454020 Feb 22 15:45 busybox
    drwx------    2 root     root        12288 Feb 22 12:04 lost+found
    drwxr-xr-x    2 root     root         1024 Feb 22 12:07 test
    root:~> rm -rf /mnt/abc
    root:~> ls /mnt/
    busybox     lost+found  test
    root:~> cat proc/interrupts
      6:      30524   BFIN Timer Tick
     48:        202   BFIN_UART_RX
     49:       3386   BFIN_UART_TX
     68:         55   libata
    Err:          0
  11. Throughput test show that the average read byte rate in UDMA mode is about 10MB/s. In PIO mode, this data is about 4MB/s
    root:~> time cat /mnt/ffmpeg.opt.tar > /dev/null
    real    0m 2.76s
    user    0m 0.00s
    sys     0m 2.71s
  12. If you want to be able to use the drive as a rootfs:
    1. create the initial dev directory:
      root:/mnt/dev> mknod -m 600 console c 5 1
      root:/mnt/dev> mknod -m 666 zero c 1 5
      root:/mnt/dev> mknod -m 666 null c 1 3
      root:/mnt/dev> mkdir pts
      root:/mnt/dev> ls -l
      crw-------    1 root     root       5,   1 Jan  1 01:37 console
      crw-rw-rw-    1 root     root       1,   3 Jan  1 01:45 null
      drwxr-xr-x    2 root     root         1024 Jan  1 01:42 pts
      crw-rw-rw-    1 root     root       1,   5 Jan  1 01:45 zero
  13. Unmount disk
    root:~> umount /mnt/

Performance Test

We run bonnie++ and dd to test performance of BF54x PATA driver.

  • System Setting
Board Version CCLK SCLK Kernel Version Toolchain Version Hard disk Type
BF548Ezkit-1.4 - Rev 0.1 525MHz 131MHz 2.6.28-rc2-ADI-2009R1-pre-svn5908 gcc 4.1.2 (svn) TOSHIBA MK4032GA 40GB
  • Kernel Configuration
BF54x ATAPI DMA Mode
on
Test Case 1: Write Speed on Ext2
root:/> mkfs.ext2 /dev/sda1 
root:/> mount /dev/sda1 /mnt/
root:/> time dd conv=fsync if=/dev/zero of=/mnt/100m.bin bs=1M count=100
100+0 records in
100+0 records out
real    0m 11.22s
user    0m 0.00s
sys     0m 9.40s
  • Result: Write speed 8.9 MB/s
Test Case 2: Read Speed on Ext2
    time cat /mnt/100m.bin > /dev/null                                      
    real    0m 9.58s                                                                
    user    0m 0.10s                                                                
    sys     0m 6.87s    
  • Result: Read speed 10.4 MB/s
Test Case 3: Bonnie++ on Ext2
root:/> mkfs.ext2 /dev/sda1 
root:/> mount /dev/sda1 /mnt/
root:/> bonnie++ -u root -d /mnt/ 
  • Result:
Version  1.94       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
blackfin       300M    41  99  8258  43  4974  70    80  99  9425  88 108.2   5
Latency               271ms     260ms     300ms     115ms     652ms     888ms
Version  1.94       ------Sequential Create------ --------Random Create--------
blackfin            -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16   185  99  2579 100  2049  97   186  99  2680  99   632  98
Latency             96000us    4000us    4000us     103ms    4000us    8000us