* [ECOS] Mounting fatfs using mmc_spi on at91sam7sek
@ 2007-08-09 14:15 Rune Sørensen
2007-08-09 14:28 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Rune Sørensen @ 2007-08-09 14:15 UTC (permalink / raw)
To: ecos-discuss
Dear all,
I'm new to eCos (as well as this mailing list) so I hope my issue is
pretty basic.
I am trying to mount fatfs on a sdcard connected using spi, but the
mount() call never returns. More specific, it seems that a mutex lock
in mmc_spi_send_init() never becomes locked:
spi.c :
cyg_spi_transaction_begin(cyg_spi_device* device){
.
.
while (!cyg_drv_mutex_lock(&(bus->spi_lock))); <------ Does not return
.
}
I am wondering if I am using the spi implementation correctly. This is
my testcode:
-------------------------------------------------------------
cyg_spi_device *cyg_spi_mmc_dev0;
cyg_spi_at91_device_t spi_at91_mmc_dev0 CYG_SPI_DEVICE_ON_BUS(0);
void test_main(CYG_ADDRESS id)
{
int err = -1;
cyg_spi_mmc_dev0 = &spi_at91_mmc_dev0.spi_device;
spi_at91_mmc_dev0.spi_device.spi_bus = &cyg_spi_at91_bus0.spi_bus;
spi_at91_mmc_dev0.dev_num = 0; // Device number
spi_at91_mmc_dev0.cl_pol = 0; // Clock polarity (0 or 1)
spi_at91_mmc_dev0.cl_pha = 1; // Clock phase (0 or 1)
spi_at91_mmc_dev0.cl_brate = 5000000; // Clock baud rate
spi_at91_mmc_dev0.cs_up_udly = 0; // Delay in usec between CS up and
transfer start
spi_at91_mmc_dev0.cs_dw_udly = 0; // Delay in usec between transfer
end and CS down
spi_at91_mmc_dev0.tr_bt_udly = 0; // Delay in usec between two transfers
spi_at91_mmc_dev0.init = false; // Trigger initialization
// Test if spi is working - output ok on the oscilloscope!
cyg_uint8 Test[] = { 0xAA, 0xAB, 0xFF };
cyg_spi_transaction_begin(cyg_spi_mmc_dev0);
cyg_spi_transaction_transfer(cyg_spi_mmc_dev0, 0, sizeof(Test), Test, NULL, 0);
cyg_spi_transaction_end(cyg_spi_mmc_dev0);
diag_printf("trying to mount sdcard...");
err = mount("/dev/sdcard/1", "/sdcard", "fatfs"); //<----- Does not return
if (err < 0)
{
diag_printf("mount() unsuccessfully completed\n");
}
}
static cyg_handle_t thread_handle;
static cyg_thread thread;
static char stack[CYGNUM_HAL_STACK_SIZE_TYPICAL+1024];
externC void cyg_start( void )
{
cyg_thread_create(1,test_main,0,0 &stack[0], sizeof(stack),
&thread_handle, &thread);
cyg_thread_resume(thread_handle);
cyg_scheduler_start();
}
-------------------------------------------------------------
Does anyone have any examples regarding the use fatfs on sdcard/mmc?
Best regards,
Rune Aa. L. Sørensen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ECOS] Mounting fatfs using mmc_spi on at91sam7sek
2007-08-09 14:15 [ECOS] Mounting fatfs using mmc_spi on at91sam7sek Rune Sørensen
@ 2007-08-09 14:28 ` Andrew Lunn
2007-08-21 12:51 ` Rune Sørensen
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2007-08-09 14:28 UTC (permalink / raw)
To: Rune S??rensen; +Cc: ecos-discuss
On Thu, Aug 09, 2007 at 04:15:36PM +0200, Rune S??rensen wrote:
> Dear all,
>
> I'm new to eCos (as well as this mailing list) so I hope my issue is
> pretty basic.
> I am trying to mount fatfs on a sdcard connected using spi, but the
> mount() call never returns. More specific, it seems that a mutex lock
> in mmc_spi_send_init() never becomes locked:
>
> spi.c :
>
> cyg_spi_transaction_begin(cyg_spi_device* device){
> .
> .
> while (!cyg_drv_mutex_lock(&(bus->spi_lock))); <------ Does not return
> .
> }
If you define DEBUG in
packages/devs/disk/generic/mmc/current/src/mmc_spi.c what do you see?
Does it find the MMC card? Does it read the partition table?
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ECOS] Mounting fatfs using mmc_spi on at91sam7sek
2007-08-09 14:28 ` Andrew Lunn
@ 2007-08-21 12:51 ` Rune Sørensen
0 siblings, 0 replies; 3+ messages in thread
From: Rune Sørensen @ 2007-08-21 12:51 UTC (permalink / raw)
To: ecos-discuss
On 8/9/07, Andrew Lunn <andrew@lunn.ch> wrote:
> On Thu, Aug 09, 2007 at 04:15:36PM +0200, Rune S??rensen wrote:
> > Dear all,
> >
> > I'm new to eCos (as well as this mailing list) so I hope my issue is
> > pretty basic.
> > I am trying to mount fatfs on a sdcard connected using spi, but the
> > mount() call never returns. More specific, it seems that a mutex lock
> > in mmc_spi_send_init() never becomes locked:
> >
> > spi.c :
> >
> > cyg_spi_transaction_begin(cyg_spi_device* device){
> > .
> > .
> > while (!cyg_drv_mutex_lock(&(bus->spi_lock))); <------ Does not return
> > .
> > }
>
> If you define DEBUG in
> packages/devs/disk/generic/mmc/current/src/mmc_spi.c what do you see?
> Does it find the MMC card? Does it read the partition table?
>
> Andrew
>
This is the debug output:
SPI: spi_at91_init_bus[170]: bus base fffe0000
Entering cyg_user_start() function
test() trying to mount sdcard...
mmc_spi_send_init(): dev pointer 0x0x00201d80, 0
: begin pointer 0x00000000
Taking a look at the pointer to the spi structure used in
mmc_spi_send_init() it seems that the pointer does not point to a
valid structure (e.g. begin pointer is zero, the value of the spi_lock
mentioned earlier is bogus). So no, it does not find the MMC card or
the partition table since the spi communication has not been
established.
No one have a working example I can take a look at?
Best regards,
Rune
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-08-21 12:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-09 14:15 [ECOS] Mounting fatfs using mmc_spi on at91sam7sek Rune Sørensen
2007-08-09 14:28 ` Andrew Lunn
2007-08-21 12:51 ` Rune Sørensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).