a question about SD card rtems_blkdev_generic functions

Chan Kim ckim at etri.re.kr
Thu Aug 20 01:35:45 UTC 2015



> My real problem is , when I open a file for writing, it reads 32 consecutive
> 512-byte blocks and another block some space apart and then does nothing
> when it is supposed to do some block writing action. It used to switch to
> block writing couple of days earlier but somehow it doesn't now. I'm looking
> at what went wrong.
> Can anyone give me a clue as to what might have gone wrong?

I found fopen leads to open() and fprintf leads to write().
During fopen() sd_card_disk_ioctl is called many times for block reads and fopen() returns normal.
The write() calls handler msdos_file_write() which seems to do fat_file_write() but inside fat_file_write, sd_card_disk_ioctl is called once for "READ" operation. (not "WRITE").  I don't know what's wrong and need to look into it.
Does anybody have any guess?
Thanks!

Chan





보낸 사람 : "Chan Kim" <ckim at etri.re.kr>
보낸 날짜 : 2015-08-20 09:52:07 ( +09:00 )
받는 사람 : André Marques <andre.lousa.marques at gmail.com>
참조 : users at rtems.org <users at rtems.org>
제목 : RE: a question about SD card rtems_blkdev_generic functions

Hi André and all,

> sd_card_disk_init should be creating the disk in the system through
> rtems_disk_create_phys, which takes an IO control handler for the block
> operations. This controller is the one that should be doing your reads and
> writes.

yes, I forgot. Block read and write is through sd_card_disk_ioctl function that I connected to create_phys function.
and there was a print mistake during the debug which made me miss the rtems_blkdev_generic_ioctl calls.

My real problem is , when I open a file for writing, it reads 32 consecutive 512-byte blocks and another block some space apart and then does nothing when it is supposed to do some block writing action. It used to switch to block writing couple of days earlier but somehow it doesn't now. I'm looking at what went wrong.
Can anyone give me a clue as to what might have gone wrong?

Chan




보낸 사람 : "André Marques" 
보낸 날짜 : 2015-08-19 23:23:03 ( +09:00 )
받는 사람 : 김찬 
참조 : users at rtems.org 
제목 : Re: a question about SD card rtems_blkdev_generic functions

Hello Chan,

On 19-08-2015 13:46, Chan Kim wrote:
> Hello, rtems folks,
> I managed to write an SD card driver on our platform (it was a month ago but I was doing other things lately) and am
> tryng to test file read and write. File read is done anyway and I can print the file contents.
> Couple of days ago I saw block write starting initiated by file write operation, but somehow I don't know how to make block write start.
>
> somewhere in the driver, there are lines below.
>
> static const rtems_driver_address_table sd_card_disk_ops = {
> .initialization_entry = sd_card_disk_init,
> .open_entry = rtems_blkdev_generic_open,
> .close_entry = rtems_blkdev_generic_close,
> .read_entry = rtems_blkdev_generic_read,
> .write_entry = rtems_blkdev_generic_write,
> .control_entry = rtems_blkdev_generic_ioctl
> };
>
> sc = rtems_io_register_driver( 0, &sd_card_disk_ops, &major);
>
> but strangely, even when I read a file successfully(using fopen, fgets) and print it, only rtems_blkdev_generic_open and rtems_blkdev_generic_close function are called and rtems_blkdev_generic_read/write.functions are not called.
> Is this normal? Can someone direct me to a good document on how this works or explain it to me?
> Thanks!
> Chan

sd_card_disk_init should be creating the disk in the system through 
rtems_disk_create_phys, which takes an IO control handler for the block 
operations. This controller is the one that should be doing your reads 
and writes.

From [1] :

These primitives (except initialize) can be implemented in a generic 
fashion based upon the supplied block device driver IO control handler. 
*Every block device driver should provide an initialize entry point, 
which registers the appropriate IO control handler.*

[1] - 
https://docs.rtems.org/doxygen/cpukit/html/group__rtems__blkdev__generic.html#gab2d9149dc532657053697e5010fffa82

--André Marques

> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
_______________________________________________
users mailing list
users at rtems.org
http://lists.rtems.org/mailman/listinfo/users


More information about the users mailing list