Rtems_fsmount dosfs hanging

Ritesh Harjani ritesh.harjani at gmail.com
Tue Aug 26 08:20:49 UTC 2014


Thanks Andre,

This will be really a big help. Also, I am sure it will help anyone who
will be working over SD card/MMC interface in Raspberry pi for RTEMS.

Currently, since I don't have enough knowledge on SD spec. I am going
through the pdf that you have sent and trying to just initialize SD card on
raspberry pi.
Later I will try to read the block/sectors on SD card.


Thanks & Regards
Ritesh




On Tue, Aug 26, 2014 at 1:34 PM, Andre Marques <
andre.lousa.marques at gmail.com> wrote:

>  Hello Ritesh,
>
> My progress on the SD card support can be found on
>
> https://bitbucket.org/asuol/rtems-graduation-project/src/
>
> It contains the sources and a test case (it reads a file and write another
> on the card), as well as patches so you can easily test that code.
>
> It was based on
>
> https://github.com/jncronin/rpi-boot/blob/master/emmc.c
>
> and right now it may or may not work with your SD card. I got it working
> with the SD card I have used during development (4GB class 4 SanDisk SD
> card), but it does not work with the card I have now (Kingston 8GB microSD
> card on a SD adapter). I suspect this is related with the timeout the
> driver gives for each command to complete in, as it is an hard coded value
> which should be calculated by parsing the card's CSD register. Also the
> code needs some major cleanup, and some features were overlooked such as
> memory barriers.
>
> As for SD card documentation I have used the v3 simplified specifications
>
> SD host controller -
> https://www.sdcard.org/downloads/pls/simplified_specs/archive/partA2_300.pdf
>
> SD physical layer -
> https://www.sdcard.org/downloads/pls/simplified_specs/archive/part1_301.pdf
>
> Besides the broadcom datasheet.
>
> By the way, since you replied to this thread I am not sure if I ever
> shared why it was hanging. Turns out that there was/is a conflict between
> my emmc driver and the raspberry pi clock driver. All I had to do was to
> disable the clock driver for it to work.
>
> --André Marques.
>
>
> On 08/26/14 06:38, Ritesh Harjani wrote:
>
> Hi Andre,
>
>  I am too trying to understand SD card/MMC protocol on Raspberry pi for
> RTEMS. You said in your last mail that you have already done some progress
> on this.
> Could you please share your code at some place, so that others can get a
> help from your code in case anybody else too is trying to
> understand/develop SD card support for Raspberry pi.
>
>
>  Thanks for the help!!
> Ritesh
>
>
> On Wed, May 14, 2014 at 12:30 AM, Andre Marques <
> andre.lousa.marques at gmail.com> wrote:
>
>>  On 05/13/14 12:15, Andrey Mozzhuhin wrote:
>>
>>  Do you not forget to call rtems_blkdev_request_done in read routine of
>> block device driver?
>>  Also try to increase CONFIGURE_MAXIMUM_TASKS - bdbuf need some worker
>> tasks.
>>
>>
>>  I call rtems_blkdev_request_done after each read request, and changing
>> CONFIGURE_MAXIMUM_TASKS to 20 (instead of 2) did not had any impact.
>>
>>
>>
>> >> https://github.com/jncronin/rpi-boot/blob/master/emmc.c
>>
>>  Hmm. Implementation specific to Raspberry Pi is not good idea. It is
>> better to separate MMC/SD protocol implementation and hardware support like
>> in FreeBSD or Linux.
>>
>>
>>  Yes, the point in the end is probably to have the MMC/SD protocol
>> somewhere else, just like the spi-sd-card driver (SD card access through
>> SPI interface protocol, at c/src/libchip/i2c/spi-sd-card*).
>>
>>
>>
>> >> Not sure how to approach this problem, as the logic seems right. Will
>> do more testing in the meanwhile.
>>
>>
>>  Today I have re-formated the card (under Linux), and the block data read
>> on RPi checks with the card hexdump on Linux.
>>
>> So far I tested:
>>
>> - The block data that is being read, and compared with the same block
>> data read on Linux (small mismatch (4 bits) at the middle of a 512 byte
>> block before, no mismatch now)
>>
>> - The request buffer contents (
>> http://www.rtems.org/onlinedocs/doxygen/cpukit/html/structrtems__blkdev__sg__buffer.html).
>> Looking at this I don't know what the User pointer is. I'm using the buffer
>> pointer to store my readings.
>>
>> - Reading the partition table from the first block. I can read the first
>> block and register the card partition as a logical disk, so reading and
>> registering the partition table is no problem.
>>
>> - Tried also a busy wait between block readings.
>>
>> The result is always the same: when mounting the card partition, it reads
>> the first two partition blocks and then hangs.
>>
>>
>>  If you get stuck share your sources and let me know.
>>
>>
>>  Will try to get the code to github soon.
>>
>>
>>
>>
>> 2014-05-13 14:03 GMT+04:00 Andre Marques <andre.lousa.marques at gmail.com>:
>>
>>>  On 05/12/14 19:25, Andrey Mozzhuhin wrote:
>>>
>>>  I think you need start with simple tests without file systems and
>>> block device driver.
>>>  Try read and write blocks with known patterns and check it on PC and
>>> Raspberry Pi.
>>>
>>>
>>>  I have checked the data read by my emmc driver from the first two
>>> blocks (the ones it reads) on the RPi, and compared with an hexdump of
>>> those same two blocks on Linux, and there is a small mismatch at the middle
>>> of the first block.
>>>
>>> Not sure how to approach this problem, as the logic seems right. Will do
>>> more testing in the meanwhile.
>>>
>>>
>>>   What are you use for MMC/SD protocol? Can I see it and block device
>>> driver somewhere?
>>>
>>>
>>>  I'm porting the following code
>>>
>>> https://github.com/jncronin/rpi-boot/blob/master/emmc.c
>>>
>>> and using the following SD card documentation
>>>
>>> Physical Layer Simplified Specification (3.01)  -
>>> https://www.sdcard.org/downloads/pls/simplified_specs/archive/part1_301.pdf
>>>
>>> Host Controller Simplified Specification (2.00) -
>>> https://www.sdcard.org/downloads/pls/simplified_specs/archive/partA2_200.pdf
>>>
>>> and the raspberry soc datasheet: Broadcom BCM2835 Peripherals Guide
>>> (Chapter 5 - EMMC)
>>>
>>>
>>>
>>> 2014-05-12 20:23 GMT+04:00 Andre Marques <andre.lousa.marques at gmail.com>
>>> :
>>>
>>>>  Hello,
>>>>
>>>> I have used the pc386 BSP to mount the card (before your suggestions)
>>>> using the fileio sample and it could read the card contents perfectly.
>>>>
>>>> Then I filled the card with zeros using dd on Linux, modified the
>>>> fileio sample to format the card with msdos_format(dev, NULL) and then
>>>> mounted it on the pc 386 BSP fileio sample and I could write and read the
>>>> card.
>>>>
>>>> On Linux I set the card with the necessary files for Raspberry, and
>>>> when my driver tries to mount the card on the Raspberry Pi it reads the
>>>> first 2 blocks (now 0 and 1, because the card has no partition table) and
>>>> hangs, just as before.
>>>>
>>>> I guess my driver is having some reading problems.
>>>>
>>>>
>>>> On 05/05/14 19:30, Andrey Mozzhuhin wrote:
>>>>
>>>> You can try to use SD Card in opposite direction:
>>>> 0) fill SD Card with zeroes;
>>>>  1) format partition under RTEMS with msdos_format() function;
>>>> 2) check that PC can read/write this SD Card;
>>>> 3) if PC fails to mount this partition - dump SD Card and check that
>>>> all data is on right sectors.
>>>>
>>>>
>>>>
>>>> 2014-05-05 22:28 GMT+04:00 Andrey Mozzhuhin <nopscmn at gmail.com>:
>>>>
>>>>>   Hi, Andre
>>>>>
>>>>>  You can try to use SD Card in opposite direction:
>>>>>  0) fill SD Card with zeroes;
>>>>>  1) format partition under RTEMS with msdos_format() function;
>>>>>  2) check that PC can read/write this SD Card;
>>>>>  3) if PC fails to mount this partition - dump SD Card and check that
>>>>> all data is on right sectors.
>>>>>
>>>>>
>>>>>
>>>>> 2014-05-05 13:52 GMT+04:00 Andre Marques <
>>>>> andre.lousa.marques at gmail.com>:
>>>>>
>>>>> Hello,
>>>>>>
>>>>>> Following the problem in
>>>>>>
>>>>>> http://www.rtems.org/pipermail/rtems-devel/2014-April/006585.html
>>>>>>
>>>>>> I am now trying to mount the SD card partitions on RTEMS.
>>>>>>
>>>>>> Summarizing the process:
>>>>>>
>>>>>> 1. rtems_io_register_driver (by calling my driver with
>>>>>> CONFIGURE_APPLICATION_EXTRA_DRIVERS on hello sample)
>>>>>>
>>>>>> 2. rtems_filesystem_make_dev_t (to get the device file)
>>>>>>
>>>>>> 3.  rtems_disk_io_initialize
>>>>>>
>>>>>> 4. rtems_disk_create_phys (to create the disk, at /dev/sdc0)
>>>>>>
>>>>>> 5. rtems_bdpart_register_from_disk (to read and register the
>>>>>> partitions)
>>>>>>
>>>>>> 6. rtems_fsmount (to mount the partitions)
>>>>>>
>>>>>> For rtems_fsmount I am providing the following fs_table:
>>>>>>
>>>>>> rtems_fstab_entry fs_table [] = {
>>>>>>    {
>>>>>>      .source = "/dev/sdc0",
>>>>>>      .target = "/mnt/p1",
>>>>>>      .type = "dosfs",
>>>>>>      .options = RTEMS_FILESYSTEM_READ_WRITE,
>>>>>>      .report_reasons =  RTEMS_FSTAB_ANY,
>>>>>>      .abort_reasons = RTEMS_FSTAB_OK
>>>>>>    },{
>>>>>>      .source = "/dev/sdc01",
>>>>>>      .target = "/mnt/p2",
>>>>>>      .type = "dosfs",
>>>>>>      .options = RTEMS_FILESYSTEM_READ_WRITE,
>>>>>>      .report_reasons = RTEMS_FSTAB_ANY,
>>>>>>      .abort_reasons = RTEMS_FSTAB_NONE
>>>>>>    }
>>>>>>  };
>>>>>>
>>>>>> The SD card has only one partition starting at block number 8192.
>>>>>>
>>>>>> After I call rtems_fsmount it calls my driver to read block 8192 and
>>>>>> 8193 and then hangs.
>>>>>>
>>>>>> I have tested the driver and It seems to have no problem reading
>>>>>> single or multiple blocks.
>>>>>>
>>>>>> Any tips?
>>>>>>
>>>>>> Also I am using the following confdefs configuration (some values are
>>>>>> exaggerated):
>>>>>>
>>>>>> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
>>>>>> #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
>>>>>> #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
>>>>>>
>>>>>> #define CONFIGURE_FILESYSTEM_DOSFS
>>>>>> #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
>>>>>>
>>>>>> #define CONFIGURE_APPLICATION_EXTRA_DRIVERS SD_CARD_DRIVER_TABLE_ENTRY
>>>>>>
>>>>>> #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
>>>>>>
>>>>>> #define CONFIGURE_MAXIMUM_TASKS 2
>>>>>> #define CONFIGURE_MAXIMUM_DRIVERS 10
>>>>>>
>>>>>> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
>>>>>>
>>>>>>  #define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
>>>>>>
>>>>>> #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
>>>>>>
>>>>>> #define CONFIGURE_INIT
>>>>>>
>>>>>> --André Marques
>>>>>>
>>>>>> _______________________________________________
>>>>>> rtems-devel mailing list
>>>>>> rtems-devel at rtems.org
>>>>>> http://www.rtems.org/mailman/listinfo/rtems-devel
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> rtems-devel mailing listrtems-devel at rtems.orghttp://www.rtems.org/mailman/listinfo/rtems-devel
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>> _______________________________________________
>> rtems-devel mailing list
>> rtems-devel at rtems.org
>> http://www.rtems.org/mailman/listinfo/rtems-devel
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20140826/5da06bad/attachment-0001.html>


More information about the devel mailing list