2008-02-10 15:06:16 Difficulties seeing SD card using SVN trunk
Frank Van Hooft (CANADA)
Message: 50892 Hello,
I've been struggling to get the SD/MMC driver stuff working for several days now, and figure it's time to ask for help and advice. I'm using the SVN trunk code, with the SD card plugged into a BF537-STAMP board, it being the only device on the SPI bus, and what follows is consistent with two different SD cards (a Sandisk & a Kingston).
I'm trying to follow the instructions at:
http://docs.blackfin.uclinux.org/doku.php?id=mmc_driver
This page seems to say that after booting ucLinux, I should be able to do a "cat /proc/spi_mmc" and see info on the inserted card. However, no matter which SPI driver I use (the SPI Framework driver, or the PIO driver), immediately after boot I always get "no card found". For example, using the SPI Framework Driver:
bf537> bootelf 0x01000000
Loading .text @ 0x00001000 (1070032 bytes)
Loading .rodata @ 0x001063d0 (243400 bytes)
Loading __ksymtab @ 0x00141a98 (14528 bytes)
Loading __ksymtab_gpl @ 0x00145358 (4160 bytes)
Loading __ksymtab_strings @ 0x00146398 (44696 bytes)
Loading __param @ 0x00151230 (300 bytes)
Clearing .bss @ 0x00151360 (61584 bytes)
Loading .data @ 0x001603f0 (72720 bytes)
Loading .init.text @ 0x00172000 (95524 bytes)
Loading .init.data @ 0x00189524 (13092 bytes)
Loading .init.setup @ 0x0018c848 (596 bytes)
Loading .initcall.init @ 0x0018ca9c (456 bytes)
Loading .con_initcall.init @ 0x0018cc64 (4 bytes)
Loading .init.ramfs @ 0x0018cc68 (3053682 bytes)
Loading .text_l1 @ 0xffa00000 (8236 bytes)
sh_addr: FFA00000, p_paddr: 004764DA
Loading from: 01468000 to 004764DA, size: 8236
Loading .data_l1 @ 0xff800000 (192 bytes)
sh_addr: FF800000, p_paddr: 00478506
Loading from: 0146B000 to 00478506, size: 192
## Starting application at 0x00172000 ...
Linux version 2.6.22.16-ADI-2008R2-pre-svn4232 (frank@DownstairsLinux) (gcc version 4.1.2 (ADI svn)) #14 Sun Feb 10 11:16:26 PST 2008
Warning: limiting memory to 56MB due to hardware anomaly 05000263
Board Memory: 64MB
Kernel Managed Memory: 64MB
Memory map:
text = 0x00001000-0x001063d0
rodata = 0x001063d0-0x0015135c
bss = 0x00151360-0x001603f0
data = 0x001603f0-0x00172000
stack = 0x00170000-0x00172000
init = 0x00172000-0x00479000
available = 0x00479000-0x037ff000
DMA Zone = 0x03f00000-0x04000000
Hardware Trace Active and Enabled
Blackfin support (C) 2004-2008 Analog Devices, Inc.
Compiled for ADSP-BF537 Rev 0.2
Blackfin Linux support by http://blackfin.uclinux.org/
Processor Speed: 500 MHz core clock and 100 MHz System Clock
Instruction Cache Enabled
Data Cache Enabled (write-through)
Built 1 zonelists. Total pages: 14224
Kernel command line: root=/dev/mtdblock0 rw console=ttyBF0,115200
Configuring Blackfin Priority Driven Interrupts
PID hash table entries: 256 (order: 8, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory available: 52180k/65536k RAM, (3100k init code, 1044k kernel code, 432k data, 1024k dma, 7756k reserved)
Blackfin Scratchpad data SRAM: 4 KB
Blackfin Data A SRAM: 16 KB (15 KB free)
Blackfin Data B SRAM: 16 KB (16 KB free)
Blackfin Instruction SRAM: 48 KB (39 KB free)
Security Framework v1.0.0 initialized
Mount-cache hash table entries: 512
NET: Registered protocol family 16
Blackfin GPIO Controller
Blackfin DMA Controller
stamp_init(): registering device resources
Generic PHY: Registered new driver
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
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)
TCP reno registered
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler cfq registered
Dynamic Power Management Controller Driver v0.1: major=10, minor = 254
bfin-wdt: initialized: timeout=20 sec (nowayout=0)
Serial: Blackfin serial driver
bfin-uart.1: ttyBF0 at MMIO 0xffc00400 (irq = 18) is a BFIN-UART
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
SMSC LAN83C185: Registered new driver
bfin_mac_mdio: probed
bfin_mac: attached PHY driver [SMSC LAN83C185] (mii_bus:phy_addr=0:01, irq=-1, mdc_clk=2500000Hz(mdc_div=19)@sclk=100MHz)
bfin_mac: Version 1.1, Blackfin BF53[67] BF527 on-chip Ethernet MAC driver
bfin-spi bfin-spi.0: Blackfin BF5xx on-chip SPI Contoller Driver, Version 1.0, regs_base@ffc00500, dma channel@7
rtc-bfin rtc-bfin: rtc core: registered rtc-bfin as rtc0
4294892686, spi_mmc_init(): 1308 Registering spi_mmc_dummy...
4294892688, spi_mmc_init(): 1312 Registering spi_mmc...
4294892689, spi_mmc_probe(): 1248
4294892690, spi_mmc_dev_setup(): 1110 Major number 36 was ok
4294892691, spi_mmc_block_setup(): 1209 on version > 2.6.19
4294892693, spi_mmc_init(): 1316 init ok!
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
rtc-bfin rtc-bfin: setting the system clock to 1970-01-01 09:41:57 (34917)
Freeing unused kernel memory: 3100k freed
dma_alloc_init: dma_page @ 0x00475000 - 256 pages at 0x03f00000
_____________________________________
a8888b. / Welcome to the uClinux distribution \
d888888b. / _ _ \
8P"YP"Y88 / | | |_| __ __ (TM) |
8|o||o|88 _____/ | | _ ____ _ _ \ \/ / |
8' .88 \ | | | | _ \| | | | \ / |
8`._.' Y8. \ | |__ | | | | | |_| | / \ |
d/ `8b. \ \____||_|_| |_|\____|/_/\_\ |
dP . Y8b. \ For embedded processors including |
d8:' " `::88b \ the Analog Devices Blackfin /
d8" 'Y88b \___________________________________/
:8P ' :888
8a. : _a88P For further information, check out:
._/"Yaa_: .| 88P| - http://blackfin.uclinux.org/
\ YP" `| 8P `. - http://docs.blackfin.uclinux.org/
/ \.___.d| .' - http://www.uclinux.org/
`--..__)8888P`._.' jgs/a:f - http://www.analog.com/blackfin
Have a lot of fun...
BusyBox v1.9.0 (2008-02-10 11:15:27 PST) built-in shell (msh)
Enter 'help' for a list of built-in commands.
root:/> cat /proc/spi_mmc
Driver build date: Feb 10 2008
SCLK: 20000 KHz
SPISEL6 as chip select
Driver: SPI Framework master
No MMC/SD card found.
Not too surprisingly, if I hope against hope & try to mount this, I get:
root:/> mount /dev/spi_mmc /mnt/ -o sync
4294907738, mmc_spi_init_card(): 767 1
4294907739, mmc_spi_init_card(): 777 2
4294907740, spi_mmc_open(): 934
4294907741, mmc_spi_init_card(): 767 1
4294907742, mmc_spi_init_card(): 777 2
4294907743, spi_mmc_open(): 934
4294907745, mmc_spi_init_card(): 767 1
4294907746, mmc_spi_init_card(): 777 2
4294907747, spi_mmc_open(): 934
4294907748, mmc_spi_init_card(): 767 1
4294907749, mmc_spi_init_card(): 777 2
4294907750, spi_mmc_open(): 934
mount: mounting /dev/spi_mmc on /mnt/ failed: No such device
But if I rebuild, reload & reboot using the SPI PIO driver instead of the SPI Framework driver, things get different. After boot:
root:/> cat /proc/spi_mmc
Driver build date: Feb 10 2008
SCLK: 20000 KHz
SPISEL6 as chip select
Driver: Blackfin PIO SPI directly
No MMC/SD card found.
So far the same. But if I try to mount this (so-called non-existent) card, I get:
root:/> mount /dev/spi_mmc /mnt/ -o sync
4294934255, mmc_spi_init_card(): 767 1
4294934256, mmc_spi_init_card(): 777 2
4294934256, mmc_spi_init_card(): 784 3
4294934259, mmc_spi_init_card(): 816 SD card found!
New MMC/SD card found: 976 MB(1023410176 bytes)
4294934261, spi_mmc_open(): 934
4294934261, mmc_spi_init_card(): 767 1
4294934262, mmc_spi_init_card(): 777 2
4294934263, mmc_spi_init_card(): 784 3
4294934265, mmc_spi_init_card(): 816 SD card found!
spi_mmc: spi_mmc1
4294934274, spi_mmc_release(): 953
4294934275, mmc_spi_init_card(): 767 1
4294934276, mmc_spi_init_card(): 777 2
4294934277, mmc_spi_init_card(): 784 3
4294934279, mmc_spi_init_card(): 816 SD card found!
4294934280, spi_mmc_open(): 934
4294934281, spi_mmc_release(): 953
4294934282, mmc_spi_init_card(): 767 1
4294934283, mmc_spi_init_card(): 777 2
4294934284, mmc_spi_init_card(): 784 3
4294934286, mmc_spi_init_card(): 816 SD card found!
4294934287, spi_mmc_open(): 934
4294934288, spi_mmc_release(): 953
4294934289, mmc_spi_init_card(): 767 1
4294934290, mmc_spi_init_card(): 777 2
4294934291, mmc_spi_init_card(): 784 3
4294934293, mmc_spi_init_card(): 816 SD card found!
4294934294, spi_mmc_open(): 934
4294934295, spi_mmc_release(): 953
mount: mounting /dev/spi_mmc on /mnt/ failed: Invalid argument
Which is actually a good sign in a way, as it shows a card is present. Then, doing the "cat /proc/spi_mmc" a second time now yields:
root:/> cat /proc/spi_mmc
Driver build date: Feb 10 2008
SCLK: 20000 KHz
SPISEL6 as chip select
Driver: Blackfin PIO SPI directly
Total errors: 0
SD card :
Capacity: 1023410176 B
Name: AF SD
Rev: 0.2
Date: 2009/5
Serial: 0x34f4fa (3470586)
CSD ver.: 0
CCC supported: 1f5
Mult. block writes works: YES
last block: 0
users: 0
Performance for last 100 transfers
Mean read throughput: 10 kB/s
Mean write throughput: 0 kB/s
(If you've read down this far, thank you.) This all leaves me with about a dozen questions in my tiny confused brain. Like:
- Why does the PIO Driver require a "mount" before a "cat /proc/spi_mmc" even recognises the card? Is there some initialisation supposed to be taking place before the "cat", which isn't actually happening?
- Why does the SPI Framework Driver not recognise the card at all, no matter what I try?
- What am I missing, or not understanding, or simply not doing?
Thanks!
QuoteReplyEditDelete
2008-02-13 02:03:57 Re: Difficulties seeing SD card using SVN trunk
Yi Li (CHINA)
Message: 50971 Frank,
Could you double check your kernel setting for SPI chip select pin and the board switch setting, also your card detect PF pin setting. If possible, please post your SPI related configuration here. We cannot reproduce your problem, the spi-mmc driver works well here using the SPI framework. Here is sample output:
"root:/> cat /proc/spi_mmc^M
Driver build date: Feb 8 2008^M
SCLK: 20000 KHz^M
SPISEL4 as chip select^M
Driver: SPI Framework master^M
Total errors: 0^M
^M
MMC :^M
Capacity: 519569408 B^M
Name: AF HMB^P ^M
Rev: 1.0 ^M
Date: 2006/6 ^M
Serial: 0x2e2561aa (774201770)^M
CSD ver.: 4^M
CCC supported: 1f5^M
Mult. block writes works: YES^M
last block: 0^M
users: 0^M
Performance for last 100 transfers^M
Mean read throughput: 0 kB/s^M
Mean write throughput: 0 kB/s^M
"
-Yi
QuoteReplyEditDelete
2008-02-14 15:51:20 Re: Difficulties seeing SD card using SVN trunk
Frank Van Hooft (CANADA)
Message: 51068 Hi Yi,
I think I'll close this particular question because it's possible my problem was caused by using SVN trunk kernel code with an older version of the tools (2007R1). During the last couple of days I've upgraded everything to SVN trunk, including the tools (building the tools as per http://docs.blackfin.uclinux.org/doku.php?id=developing_with_blackfin_live_sources )
Now I have a whole different issue. I can build the tools OK, and I can use those tools to build the kernel (BF537-STAMP) OK when selecting the "Default all settings" in menuconfig. But if I enable the MMC/SD device driver (as per http://docs.blackfin.uclinux.org/doku.php?id=mmc_driver ) I get build errors. These errors happen whether I select the SPI Framework Driver or the SPI Driver (Blackfin Bus Directly). Here's an example of the build error:
<snip>
LD drivers/mmc/built-in.o
CC lib/reciprocal_div.o
CC lib/rwsem-spinlock.o
CC [M] fs/jffs2/debug.o
CC drivers/mmc/spi_mmc/spi_mmc_core.o
CC lib/semaphore-sleepers.o
CC [M] fs/jffs2/wbuf.o
drivers/mmc/spi_mmc/spi_mmc_core.c: In function ‘spi_mmc_make_request’:
drivers/mmc/spi_mmc/spi_mmc_core.c:513: error: too many arguments to function ‘bio_endio’
drivers/mmc/spi_mmc/spi_mmc_core.c: In function ‘spi_mmc_getgeo’:
drivers/mmc/spi_mmc/spi_mmc_core.c:907: warning: format ‘%u’ expects type ‘unsigned int’, but argument 2 has type ‘sector_t’
make[3]: *** [drivers/mmc/spi_mmc/spi_mmc_core.o] Error 1
make[2]: *** [drivers/mmc/spi_mmc] Error 2
make[1]: *** [drivers] Error 2
make[1]: *** Waiting for unfinished jobs....
CC [M] fs/jffs2/compr_rtime.o
CC fs/msdos/namei.o
CC lib/sha1.o
CC lib/string.o
LD fs/msdos/msdos.o
<snip>
Any thoughts? Should I pose this question in a new thread?
Thanks.
QuoteReplyEditDelete
2008-02-14 21:49:08 Re: Difficulties seeing SD card using SVN trunk
Yi Li (CHINA)
Message: 51078 Frank,
This is a bug (may be due to kernel upgrading). I will log this in the bug tracker. Also, I think you may try to use the svn 2008R1 branch - it should be much stable.
-Yi
QuoteReplyEditDelete
2008-02-16 18:27:22 Re: Difficulties seeing SD card using SVN trunk
Frank Van Hooft (CANADA)
Message: 51158 Hi Yi,
Thanks very much for the suggestion to try the 2008R1 branch. I had pretty much convinced myself that the problem was on my end; your suggestion saved me a lot of work. I switched over to 2008R1 (tools, u-boot & uclinux) and all my building problems went away.
Even with 2008R1 I still find that I have to run something like "fdisk - l /dev/spi_mmc" before a "cat /proc/spi_mmc" will recognise the SD card. Don't know why, and right now I'm not too worried about it to be quite honest. Once I've done that, the SD card works well - I can mount it, write files to it, etc. Life is good.
Thanks again.
QuoteReplyEditDelete
2008-03-26 08:15:45 Re: Difficulties seeing SD card using SVN trunk
Hans Eklund (SWEDEN)
Message: 53049 To celar things up: reading /proc/spi_mmc does nothing with the actual card. It is just a simple way of getting information from the driver. You need to init the card by open it. Fdisk, mke2fs or mount will open the card kick it to life. I should have written "no card detected(yet)" in the /proc/spi_mmc entry. Or better still, not made and /proc/spi_mmc entry at all:) It seem to confuse users. /Hans
QuoteReplyEditDelete
2008-03-26 14:43:10 Re: Difficulties seeing SD card using SVN trunk
Frank Van Hooft (CANADA)
Message: 53071 Thanks very much for the clarification Hans - I'm happy to hear this is expected behaviour.