Rtems_fsmount dosfs hanging

Ric Claus claus at slac.stanford.edu
Tue May 13 16:43:12 UTC 2014


I did this same kind of thing almost a year ago (for a Zynq project), but starting from the U-Boot sources.  (I understand there are licensing issues that prevent it from being included in RTEMS.)  In the process of debugging it, I found that one pattern that would periodically mess me (and the SD card) up was to reset the system (usually in order to load a new version of the code) without having first unmounted the device or otherwise flushing the file system.  Remember that the block device driver caches, so if the cache doesn't get flushed you can end up with partially written blocks, or an inconsistent set of blocks, on the SD card.

My driver doesn't (yet) support SD card removal and insertion on a live system (I think this would be difficult to get right).  If you're doing this, then, for the same caching reason, it might be a place where you're getting tripped up.

	Ric


On May 13, 2014, at 3:03 AM, Andre Marques wrote:

> 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 list
>>> 
>>> rtems-devel at rtems.org
>>> http://www.rtems.org/mailman/listinfo/rtems-devel
>> 
>> 
> 
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel





More information about the devel mailing list