This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Mounting fatfs using mmc_spi on at91sam7sek


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]