- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ecos community,
I have a Nios dev board (Stratix edition) running an eCos application that logs data onto a Compact Flash card. My application runs well, but I am trying to improve it in the way it deals with the Compact Flash card. I would like my application to be able to get info on the CF card, ie card size, card maker, free space etc. I suspect the CF driver does not support this at present, but if it does I would like to know how. Also, the CF driver supports interrupt driven card insertion functionality for card initialization, but on my board this does not work, as far as I can tell no interrupt is generated when a card is inserted. If anyone has experience in this area I would like to hear about it. More detail follows... From the API the following code should allow access to CF info: error = cyg_io_lookup("/dev/cfa/1",&cf_handle); // get handle to CF error = cyg_io_get_config(&cf_handle,0,xbuf,&len); but the function alt_avalon_cf_get_config in altera_avalon_cf.c is just an empty stub, however the line of execution never appears to reach this code. Is there anyone else out there using CF cards? PeterLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There was a mistake in the second line of code, the correct code is below:
error = cyg_io_lookup("/dev/cfa/1",&cf_handle); // get handle to CF error = cyg_io_get_config(cf_handle,0,xbuf,&len); // call for info, if any- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code fragments are a first attempt at providing access to CF information. The alt_avalon_cf_get_config stub is filled out and eCos cleaned and rebuilt.
// fill out stub in altera_avalon_cf.c // Altera Avalon compact flash driver alt_avalon_cf_get_config(disk_channel *chan, cyg_uint32 key, const void *xbuf, //cyg_disk_info_t; cyg_uint32 *len) { cyg_disk_info_t *info = chan->info; // info is a pointer cyg_disk_info_t *buf = (cyg_disk_info_t *) xbuf; cyg_disk_identify_t *ident = &chan->info->ident; Cyg_ErrNo res = ENOERR; D("alt_avalon_cf_get_config\n"); if (!chan->init) return -EINVAL; if (*len < sizeof(cyg_disk_info_t)) return -EINVAL; *buf = *info; *len = sizeof(cyg_disk_info_t); //D((" serial = '%s'\n", ident->serial)); //D((" firmware rev = '%s'\n", ident->firmware_rev)); D(" model num = '%s'\n", ident->model_num); D(" block_size = %d\n", info->block_size); D(" blocks_num = %d\n", info->blocks_num); return res; } Here is a code fragment to access the info. In this case the block size, number of blocks and CF model string. //------------------------------------------------------ // code to access CF info // use API call 'cyg_io_get_config' // information on the CF card cyg_disk_info_t cf_info; char cf_model[20]; // later on... { // get CF card info cyg_io_handle_t cf_handle; void *xbuf = (void *)&cf_info; //cyg_disk_info_t Cyg_ErrNo error; cyg_uint32 len = sizeof(cyg_disk_info_t); error = cyg_io_lookup("/dev/cfa/1", &cf_handle); if(error!=0) printf("lookup error:%i\n",error); else { error = cyg_io_get_config(cf_handle,0,xbuf,&len); // printf("cf get_config error: %i %i\n",error,-EINVAL); // should get -EINVAL //cf_info_ptr = *(cyg_disk_info_t *)xbuf; // get useful info block_size = cf_info.block_size; blocks_num = cf_info.blocks_num; strncpy(cf_model,cf_info.ident.model_num,16); printf("block size:%i num_blocks:%i %s\n" ,cf_info.block_size,cf_info.blocks_num,cf_model); } Looks like I get to answer my own questions.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page