world leader in high performance signal processing
Trace: » using_cf_flash_card_disk_with_u-boot_and_linux_kernel

Introduction

U-Boot provides only basic functionality to access CF Card based “disks”: you can print the partition table and read and write blocks (addressed by absolute block number), but there is no support to create new partitions or to read files from any type of filesystem. U-Boot support three partition type: CONFIG_MAC_PARTITION and/or CONFIG_DOS_PARTITION and/or CONFIG_ISO_PARTITION. Before you use CF flash card with Blackfin uboot and linux kernel, you need to do the partition of the CF flash card on your linux host.

Enable the IDE driver in the Blackfin uClinux kernel

The CF card is working in the TRUE IDE mode. Follow the instruction to enable the driver in the kernel:

cf-ide-nand

Enable the CF card support in the Uboot

Add or uncomment one line in the configuration header file of the BF537 STAMP board

Uncomment this line to add support for CF-Cards

#define CONFIG_BFIN_CF_IDE /* Add CF flash card support */

Uncomment this line to add support for IDE HDD drives

#define CONFIG_BFIN_HDD_IDE /* Add IDE Disk Drive (HDD) support */  

Uncommenting is EXCLUSIVE OR - don't define both !

Using a MS-DOS Partition Table

The MS-DOS partition table is especially common on PC type computers, which these days means nearly everywhere. You will prefer this format if you want to exchange your “disk” media with any PC type host system.

The fdisk command is used to create MS-DOS type partition tables; to create the same partitioning scheme as above you would use the following commands:

Linux:~ # fdisk /dev/sdd

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p

Disk /dev/sdd: 512 MB, 512483328 bytes
16 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 992 * 512 = 507904 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1009, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1009, default 1009): +10M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (22-1009, default 22): 
Using default value 22
Last cylinder or +size or +sizeM or +sizeK (22-1009, default 1009): +10M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (43-1009, default 43): 
Using default value 43
Last cylinder or +size or +sizeM or +sizeK (43-1009, default 1009): +400M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (832-1009, default 832): 
Using default value 832
Last cylinder or +size or +sizeM or +sizeK (832-1009, default 1009): 
Using default value 1009

Command (m for help): p

Disk /dev/sdd: 512 MB, 512483328 bytes
16 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 992 * 512 = 507904 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1          21       10385   83  Linux
/dev/sdd2              22          42       10416   83  Linux
/dev/sdd3              43         831      391344   83  Linux
/dev/sdd4             832        1009       88288   83  Linux

Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 82
Changed system type of partition 4 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sdd: 512 MB, 512483328 bytes
16 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 992 * 512 = 507904 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1          21       10385   83  Linux
/dev/sdd2              22          42       10416   83  Linux
/dev/sdd3              43         831      391344   83  Linux
/dev/sdd4             832        1009       88288   82  Linux swap / Solaris

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
Linux:~ # mkswap /dev/sdd4
Setting up swapspace version 1, size = 90402 kB
Linux:~ # mke2fs /dev/sdd3
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
97920 inodes, 391344 blocks
19567 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
48 block groups
8192 blocks per group, 8192 fragments per group
2040 inodes per group
Superblock backups stored on blocks: 
        8193, 24577, 40961, 57345, 73729, 204801, 221185

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
Linux:~ # 

Booting Blackfin uClinux kernel from the U-Boot

U-Boot-1.1.3-ADI-2005R4 (Jan 26 2006 - 11:44:43)

CPU:  ADSP BF537 Rev.: 0.2
Board: ADI BF537 stamp board
      Support: http://blackfin.uclinux.org/
Clock: VCO: 500 MHz, Core: 500 MHz, System: 62 MHz
SDRAM: 64 MB
FLASH:  4 MB
In:    serial
Out:  serial
Err:  serial
Bus 0: OK
  Device 0: Model: Hitachi XX.V.3.5.0.0  Firm: Rev 0.00 Ser#:
            Type: Removable Hard Disk
            Capacity: 488.7 MB = 0.4 GB (1000944 x 512)
Net:    ADI BF537 EMAC
I2C:  ready
Hit any key to stop autoboot:  0
bf537> help ide
ide reset - reset IDE controller
ide info  - show available IDE devices
ide device [dev] - show or set current device
ide part [dev] - print partition table of one or all IDE devices
ide read  addr blk# cnt
ide write addr blk# cnt - read/write `cnt' blocks starting at block `blk#'
    to/from memory address `addr'
bf537> ide part

Partition Map for IDE device 0  --  Partition Type: DOS

Partition    Start Sector    Num Sectors    Type
    1                  63          20097      83
    2                20160          20160      83
    3                40320          782208      83
    4              822528          178416      82
bf537> tftpboot 0x1000000 uImage
Using MAC Address 00:E0:22:FE:42:84
TFTP from server 192.168.0.2; our IP address is 192.168.0.15
Filename 'uImage'.
Load address: 0x1000000
Loading: #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        ##################
done
Bytes transferred = 2085133 (1fd10d hex)
bf537> ide write 0x1000000 0x3F 0x1000

IDE write: device 0 block # 63, count 4096 ... 4096 blocks written: OK
bf537> tftpboot 0x1000000 rootfs.img
Using MAC Address 00:E0:22:FE:42:84
TFTP from server 192.168.0.2; our IP address is 192.168.0.15
Filename 'rootfs.img'.
Load address: 0x1000000
Loading: #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        #################################################################
        ##############
done
Bytes transferred = 8388608 (800000 hex)
bf537> ide write 0x1000000 0x9D80 0x4000

IDE write: device 0 block # 40320, count 16384 ... 16384 blocks written: OK

bf537> setenv bootargs root=/dev/hda3 rw
bf537> help diskboot
diskboot loadAddr dev:part

bf537> diskboot 0x1000000 0:1

Loading from IDE device 0, partition 1: Name: hda1
  Type: U-Boot
  Image Name:  uClinux Kernel and Filesystem
  Created:      2006-01-25  9:11:39 UTC
  Image Type:  Blackfin Linux Kernel Image (gzip compressed)
  Data Size:    2085069 Bytes =  2 MB
  Load Address: 00001000
  Entry Point:  00001000
bf537> bootm 0x1000000
## Booting image at 01000000 ...
  Image Name:  uClinux Kernel and Filesystem
  Created:      2006-01-25  9:11:39 UTC
  Image Type:  Blackfin Linux Kernel Image (gzip compressed)
  Data Size:    2085069 Bytes =  2 MB
  Load Address: 00001000
  Entry Point:  00001000
  Verifying Checksum ... OK
  Uncompressing Kernel Image ... OK
Starting Kernel at = 1000
Linux version 2.6.12.1 (aubrey@linux) (gcc version 3.4.4) #10 Wed Jan 25 17:11:22 CST 2006
Blackfin support (C) 2004 Analog Devices, Inc.
ADSP-BF537 Rev. 0.2
uClinux/BF537
Blackfin uClinux support by blackfin.uclinux.org
Processor Speed: 500 MHz core clock and 62 Mhz System Clock
Board Memory: 64MB
Memory map:
  text = 0x001000-0x0dc6fc
  data = 0x0ea208-0x10ff3c
  bss  = 0x10ff40-0x11e3d0
  rootfs = 0x3700000-0x3f00000
  stack = 0x0ec000-0x0ee000
Command line: 'root=/dev/hda3'
Instruction Cache Enabled
Data Cache Enabled (write-through)
Hardware Trace Enabled
Built 1 zonelists
Kernel command line: root=/dev/hda3
Configuring Blackfin Priority Driven Interrupts
PID hash table entries: 256 (order: 8, 4096 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Physical pages: 3700
Memory available: 54656k/64599k RAM, (52k init code, 877k kernel code, 208k data, 9216k dma)
Blackfin Scratchpad data SRAM: 4 KB
Blackfin DATA_A SRAM: 16 KB
Blackfin DATA_B SRAM: 16 KB
Security Framework v1.0.0 initialized
Capability LSM initialized
Mount-cache hash table entries: 512
NET: Registered protocol family 16
Blackfin DMA Controller for BF533
stamp_init(): registering device resources
Real Time Clock Driver v1.10e
BlackFin BF533 serial driver version 2.00 With DMA Support
io scheduler noop registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Blackfin 537 mac net device registered.
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
Blackfin IDE interrupt setup: flag PF4, irq 34
ide0: Blackfin generic IDE interface
hda: probing with STATUS(0x50) instead of ALTSTATUS(0x00)
hda: Hitachi XX.V.3.5.0.0, CFA DISK drive
ide0 at 0x2030c020-0x2030c027,0x2030c01c on irq 34
hda: max request size: 128KiB
hda: 1000944 sectors (512 MB) w/1KiB Cache, CHS=993/16/63
hda: cache flushes not supported
hda: hda1 hda2 hda3 hda4
uclinux[mtd]: RAM probe address=0x3700000 size=0x800000
Creating 1 MTD partitions on "RAM":
0x00000000-0x00800000 : "EXT2fs"
uclinux[mtd0]: set EXT2fs to be root filesystem
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
NET: Registered protocol family 1
NET: Registered protocol family 17
hda: hda1 hda2 hda3 hda4
VFS: Mounted root (ext2 filesystem)
Freeing unused kernel memory: 52k freed (0xdd000 - 0xe9000)
ttyS0 at irq = 18 is a builtin BlackFin UART
dma_alloc_init: dma_page @ 0x000e6000 - 256 pages at 0x03f00000
bfin_change_speed: baud = 57600, cval = 0x13

Welcome to:
      ____ _  _
      /  __| ||_|            _  _
_  _| |  | | _ ____  _  _ \ \/ /
| | | | |  | || |  _ \| | | | \  /
| |_| | |__| || | | | | |_| | /  \
|  ___\____|_||_|_| |_|\____|/_/\_\
|_|

For further information see:
http://www.uclinux.org/
http://blackfin.uclinux.org/



BusyBox v1.00 (2006.01.20-06:56+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.

root:~> cat /proc/cmdline
root=/dev/hda3 rw

Complete Table of Contents/Topics