2009-12-06 20:51:48     How to add a driver for the SD card?

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2009-12-06 20:51:48     How to add a driver for the SD card?

zhang zhihua (CHINA)

Message: 83126   

 

Hi,

  I want to add a driver for my SD card,the board is BF518F-EZBRD,the kernel is 2009R1,frist I set the kernel like

 

this:

SPI support  --->

    *** SPI Master Controller Drivers ***

    {*}   SPI controller driver for ADI Blackfin5xx

MMC/SD/SDIO card support  --->

    <*>   MMC block device driver (NEW)

    [*]     Use bounce buffer for simple hosts (NEW)

    <*>   MMC/SD/SDIO over SPI

SPI support  --->

    [ ] SPI support

then make and loaded it to the board,but I can't find the mmc device in the dev folder!

I also set like this:

Enable File System in kernel:

        File systems  --->

            <*> Second extended fs support

            [ ]   Ext2 extended attributes

                DOS/FAT/NT Filesystems  --->

                       <*> MSDOS fs support

                       <*> VFAT (Windows-95) fs support

                       (437) Default codepage for FAT

                       (iso8859-1) Default iocharset for FAT

                Native Language Support  --->

                       --- Base native language support

                       (iso8859-1) Default NLS Option

                       <*>   Codepage 437 (United States, Canada)

                       <*>   NLS ISO 8859-1  (Latin 1; Western European Languages)

Configure uclinux-dist to add the FS applications:

        Filesystem Applications  --->

                [*] fdisk

                [*] e2fsck

                [*] mke2fs

                [*] mkdosfs

How to solve this problem?

when I read the docs,I find that:Add SPI device configure in bfin_spi_board_info[] structure in board file (e.g,

 

arch/blackfin/mach-bf537/boards/stamp.c)

 

static struct spi_board_info bfin_spi_board_info[] __initdata = {

[snip]

#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)

        {

                .modalias = "mmc_spi",

                .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */

                .bus_num = 0,

                .chip_select = 4,

                .platform_data = &bfin_mmc_spi_pdata,

                .controller_data = &mmc_spi_chip_info,

                .mode = SPI_MODE_3,

        },

#endif

[snip]

}

 

Also:

 

#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)

#define MMC_SPI_CARD_DETECT_INT IRQ_PF5

 

static int bfin_mmc_spi_init(struct device *dev,

        irqreturn_t (*detect_int)(int, void *), void *data)

{

        return request_irq(MMC_SPI_CARD_DETECT_INT, detect_int,

                IRQF_TRIGGER_FALLING, "mmc-spi-detect", data);

}

 

static void bfin_mmc_spi_exit(struct device *dev, void *data)

{

        free_irq(MMC_SPI_CARD_DETECT_INT, data);

}

 

static struct mmc_spi_platform_data bfin_mmc_spi_pdata = {

        .init = bfin_mmc_spi_init,

        .exit = bfin_mmc_spi_exit,

        .detect_delay = 100, /* msecs */

};

 

static struct bfin5xx_spi_chip  mmc_spi_chip_info = {

        .enable_dma = 0,

        .bits_per_word = 8,

};

#endif

what's mean?I must to delete the codes like this?

[snip]

#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)

        {

                .modalias = "mmc_spi",

                .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */

                .bus_num = 0,

                .chip_select = 4,

                .platform_data = &bfin_mmc_spi_pdata,

                .controller_data = &mmc_spi_chip_info,

                .mode = SPI_MODE_3,

        },

#endif

[snip]

TranslateQuoteReplyEditDelete

 

 

2009-12-06 21:22:54     Re: How to add a driver for the SD card?

Yi Li (CHINA)

Message: 83128   

 

Zhihua,

 

BF518F support SD host, why do you want to use mmc over spi? Please review:   docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:bfin_sdh

 

-Yi

QuoteReplyEditDelete

 

 

2009-12-06 21:25:16     Re: How to add a driver for the SD card?

zhang zhihua (CHINA)

Message: 83129   

 

我想给我的SD卡添加一个驱动,我按照  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:spi_mmc&s[]=sd&s[]=card这个网址上的说明文档对内核进行了相关配置,但是我编译下装后在dev目录还是没有SD卡的相关设备,好像是没添加成功,而且有几个疑问想请教一下大家,

 

第一就是:我看到上面有这么一句话:The SDH driver doesn't support automatic card detection currently. So card scanning must be triggered manually by doing: echo 0 > /proc/driver/sdh ,我必须运行:root:> echo 0 > /proc/driver/sdh 吗?

 

第二就是:说需要修改stamp.c文件,在我的内核上是uClinux-dist/linux-2.6.x/arch/blackfin/mach-bf518/boards/目录下的ezbrd.c文件,但是我修改之后就无法编译!怎么办?

 

谢谢...

TranslateQuoteReplyEditDelete

 

 

2009-12-06 21:30:04     Re: How to add a driver for the SD card?

zhang zhihua (CHINA)

Message: 83132   

 

Li Yi ,thank you!

 

I will see it again!

TranslateQuoteReplyEditDelete

 

 

2009-12-06 22:07:19     Re: How to add a driver for the SD card?

zhang zhihua (CHINA)

Message: 83134   

 

Hi,Li Yi,

   frist I run like this :

   root:>echo 0 > /proc/driver/sdh

   root:>root:/> mkfs.ext2 /dev/mmcblk0p1

but it appears that:

   mkfs.ext2:not found

I also can't find the mmcblk0p1 in my dev folder!

 

help me ...

TranslateQuoteReplyEditDelete

 

 

2009-12-07 01:11:09     Re: How to add a driver for the SD card?

zhang zhihua (CHINA)

Message: 83139   

 

when I reboot the system,it note that:

 

mmc0: error -84 whilst initialising SD card

TranslateQuoteReplyEditDelete

 

 

2009-12-07 01:12:02     Re: How to add a driver for the SD card?

Mike Frysinger (UNITED STATES)

Message: 83140   

 

if you dont enable the ext2 tools in your configuration system, then they wont be built

QuoteReplyEditDelete

 

 

2009-12-07 01:12:40     Re: How to add a driver for the SD card?

Mike Frysinger (UNITED STATES)

Message: 83141   

 

you need to post the entire kernel boot output, not just one line

QuoteReplyEditDelete

 

 

2009-12-07 01:20:41     Re: How to add a driver for the SD card?

zhang zhihua (CHINA)

Message: 83142   

 

U-Boot 2008.10 (ADI-2009R1-rc3) (Nov 11 2009 - 22:17:35)

 

CPU:   ADSP bf518-0.0 (Detected Rev: 0.0) (spi flash boot)

Board: ADI BF518F EZ-Board board

       Support:   blackfin.uclinux.org/

Clock: VCO: 400 MHz, Core: 400 MHz, System: 80 MHz

RAM:   32 MB

Flash:  4 MB

SF: Got idcode 20 20 15

In:    serial

Out:   serial

Err:   serial

Net:   Blackfin EMAC

MAC:   B6:6B:66:3C:19:05

Hit any key to stop autoboot:  0

SF: Got idcode 20 20 15

2048 KiB M25P16 at 0:2 is now current device

## Booting kernel from Legacy Image at 01000000 ...

   Image Name:   Linux-2.6.28.10-ADI-2009R1

   Created:      2009-12-07   5:25:28 UTC

   Image Type:   Blackfin Linux Kernel Image (gzip compressed)

   Data Size:    1153688 Bytes =  1.1 MB

   Load Address: 00001000

   Entry Point:  00216bac

   Verifying Checksum ... OK

   Uncompressing Kernel Image ... OK

Starting Kernel at = 00216bac

Linux version 2.6.28.10-ADI-2009R1 (root@ubuntu) (gcc version 4.1.2 (ADI svn)) #

39 Sun Dec 6 21:25:15 PST 2009

bootconsole [early_shadow0] enabled

bootconsole [early_BFuart0] enabled

early printk enabled on early_BFuart0

Board Memory: 32MB

Kernel Managed Memory: 32MB

Memory map:

  fixedcode = 0x00000400-0x00000490

  text      = 0x00001000-0x001655d0

  rodata    = 0x001655d0-0x001cc178

  bss       = 0x001cd000-0x001f362c

  data      = 0x001f362c-0x0020a000

    stack   = 0x00208000-0x0020a000

  init      = 0x0020a000-0x00228000

  available = 0x00228000-0x01eff000

  DMA Zone  = 0x01f00000-0x02000000

Hardware Trace Active and Enabled

Boot Mode: 3

Reset caused by Software reset

Blackfin support (C) 2004-2009 Analog Devices, Inc.

Compiled for ADSP-BF518 Rev 0.0

Blackfin Linux support by   blackfin.uclinux.org/

Processor Speed: 400 MHz core clock and 80 MHz System Clock

NOMPU: setting up cplb tables

Instruction Cache Enabled for CPU0

Data Cache Enabled for CPU0 (write-back)

Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 7873

Kernel command line: root=/dev/mtdblock0 rw rootfstype=jffs2 clkin_hz=25000000 e

arlyprintk=serial,uart0,57600 console=ttyBF0,57600

Configuring Blackfin Priority Driven Interrupts

PID hash table entries: 128 (order: 7, 512 bytes)

I-pipe 1.10-00: pipeline enabled.

Console: colour dummy device 80x25

console [ttyBF0] enabled, bootconsole disabled

console [ttyBF0] enabled, bootconsole disabled

Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)

Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)

Memory available: 29240k/32768k RAM, (120k init code, 1425k kernel code, 659k da

ta, 1024k dma, 296k reserved)

Calibrating delay loop... 794.62 BogoMIPS (lpj=1589248)

Security Framework initialized

Mount-cache hash table entries: 512

Blackfin Scratchpad data SRAM: 4 KB

Blackfin L1 Data A SRAM: 16 KB (15 KB free)

Blackfin L1 Data B SRAM: 16 KB (16 KB free)

Blackfin L1 Instruction SRAM: 48 KB (42 KB free)

net_namespace: 288 bytes

NET: Registered protocol family 16

Blackfin DMA Controller

ezbrd_init(): registering device resources

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 1024 (order: 1, 8192 bytes)

TCP bind hash table entries: 1024 (order: 0, 4096 bytes)

TCP: Hash tables configured (established 1024 bind 1024)

TCP reno registered

NET: Registered protocol family 1

I-pipe: Domain Xenomai registered.

Xenomai: hal/blackfin started.

Xenomai: real-time nucleus v2.4.7 (Andalusia) loaded.

Xenomai: starting native API services.

Xenomai: starting POSIX services.

Xenomai: starting RTDM services.

JFFS2 version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.

msgmni has been set to 57

io scheduler noop registered (default)

Serial: Blackfin serial driver

bfin-uart.1: ttyBF0 at MMIO 0xffc00400 (irq = 29) is a BFIN-UART

bfin-uart.1: ttyBF1 at MMIO 0xffc02000 (irq = 31) is a BFIN-UART

brd: module loaded

bfin_mii_bus: probed

bfin_mac: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:03, irq=-1, mdc_

clk=2500000Hz(mdc_div=15)@sclk=80MHz)

bfin_mac bfin_mac.0: Blackfin on-chip Ethernet MAC driver, Version 1.1

physmap platform flash device: 00300000 at 20000000

physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank

NOR chip too large to fit in mapping. Attempting to cope...

Amd/Fujitsu Extended Query Table at 0x0040

number of CFI chips: 1

cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.

Reducing visibility of 4096KiB chip to 3072KiB

cmdlinepart partition parsing not available

RedBoot partition parsing not available

Using physmap partition information

Creating 1 MTD partitions on "physmap-flash.0":

0x00000000-0x00300000 : "file system(nor)"

m25p80 spi0.2: m25p16 (2048 Kbytes)

Creating 2 MTD partitions on "m25p80":

0x00000000-0x00040000 : "bootloader(spi)"

0x00040000-0x00200000 : "linux kernel(spi)"

bfin-spi bfin-spi.0: Blackfin on-chip SPI Controller Driver, Version 1.0, regs_b

ase@ffc00500, dma channel@7

bfin-spi bfin-spi.1: Blackfin on-chip SPI Controller Driver, Version 1.0, regs_b

ase@ffc03400, dma channel@5

rtc-bfin rtc-bfin: rtc core: registered rtc-bfin as rtc0

bfin-wdt: initialized: timeout=20 sec (nowayout=0)

dma_alloc_init: dma_page @ 0x002ed000 - 256 pages at 0x01f00000

TCP cubic registered

NET: Registered protocol family 17

Distributed Switch Architecture driver version 0.1

eth0: detected a KSZ8893M switch

dsa slave smi: probed

rtc-bfin rtc-bfin: setting system clock to 1997-06-21 09:44:23 UTC (866886263)

VFS: Mounted root (jffs2 filesystem).

Freeing unused kernel memory: 120k freed

mmc0: error -84 whilst initialising SD card

   *************************************************************

  *       check the username and passwords successful!          *

   *************************************************************

  *            _   _     _                                      *

  *          / _| | |   |_|            __  __ (TM)              *

  *   _   _ | |   | |    _ ____  _   _ \ \/ /                   *

TranslateQuoteReplyEditDelete

 

 

2009-12-07 01:30:03     Re: How to add a driver for the SD card?

zhang zhihua (CHINA)

Message: 83144   

 

yes,Mike,

 

    I dont enable the ext2 tools ,but now the problem is that there are no mmcblk0p1 device in my dev floder!

TranslateQuoteReplyEditDelete

 

 

2009-12-07 02:37:33     Re: How to add a driver for the SD card?

Mike Frysinger (UNITED STATES)

Message: 83145   

 

if the kernel cant find the card, then there's no way it can find partitions

QuoteReplyEditDelete

 

 

2009-12-07 03:14:15     Re: How to add a driver for the SD card?

zhang zhihua (CHINA)

Message: 83149   

 

but if I use the instruction 'mmcinit 'to initialize the mmc/sdio subsystem,it can detect the SD card,like this:

bfin> mmcinit

'CID information:

Manufacturer ID:       03

OEM/Application ID:    5344

Product name:          SD256

Product Revision:      8.0

Product Serial Number: 6027901

Manufacturing Date:    02/12

SD Card detected (RCA 32970)

CSD information:

CSD structure version:   1.0

Card command classes:    5f5

Max trans speed: 25MHz

Read block length:       512

Write block length:      16

Card capacity:          252968960 bytes'

 

 

there are also have a sdh in dir /proc/driver,but if I run 'echo 0 > /proc/driver/sdh'

it appears:mmc0: error -84 whilst initialising SD card

TranslateQuoteReplyEditDelete

 

 

2009-12-07 05:59:35     Re: How to add a driver for the SD card?

Wolfgang Muees (GERMANY)

Message: 83168   

 

If you use SPI mode 3, you have to add some pullup resistors on the data and clock lines.

Attachments

    Outcomes