Problem with SD card unmount with rtems 4.10.99

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Apr 7 11:11:50 UTC 2014


Hello Ali,

the differences between 4.10 and 4.11 are quite huge in this area.  In RTEMS 
4.11 the rtems_disk_obtain()/release() is deprecated.  You should use 
rtems_blkdev_create() to create disks:

http://www.rtems.org/onlinedocs/doxygen/cpukit/html/group__rtems__blkdev.html#gae2fe7e8c05fa9db0fa7c0ec4e8e4967d

Use unlink() to delete disks (this will sync and purge automatically).

Register partitions via:

http://www.rtems.org/onlinedocs/doxygen/cpukit/html/group__rtems__bdpart.html

For the media manger please have a look at:

http://git.rtems.org/rtems-libbsd/tree/rtemsbsd/rtems/rtems-bsd-cam.c

On 2014-04-07 12:48, ali nasir wrote:
> Hi,
> By only calling the unmount and the rmdir, the SD card does not get mount
> successfully the next time i.e. if i insert another SD card, after unmounting
> the previous one, then the scond SD card mount fails in the
> rtems_disk_create_phys. It returns RTEMS_RESOURCE_IN_USE (12). I remember we
> had this problem with the 4.10 also. In 4.10, we had to call the below sequence
> to have a clean unmount
> unmount(mount_path)
> rmdir(mount_path)
> sync_dev(dev)    //dev = /dev/sdc01
> purge_dev(dev)
> disk_delete(dev)
> sync_dev(dev)    //dev = /dev/sdc0
> purge_dev(dev)
> disk_delete(dev)
> io_unregister_driver(major)
> with the RTEMS 4.11, the sync_dev and purge_dev needs a pointer of type
> rtems_disk_device.
> I get this pointer with a call to the rtems_disk_obtain(dev). I get the dev
> from a call to rtems_media_get_device_identifier("/dev/sdc01", &dev);
> But when i pass the dev returned from rtems_media_get_device_identifier to the
> rtems_disk_obtain, i get a NULL pointer.
> Regards,
> Ali
> *From:* Sebastian Huber <sebastian.huber at embedded-brains.de>
> *To:* rtems-users at rtems.org
> *Sent:* Monday, April 7, 2014 2:56 PM
> *Subject:* Re: Problem with SD card unmount with rtems 4.10.99
>
> Hello Ali,
>
> On 2014-04-07 05:15, ali nasir wrote:
>  > Hi,
>  >
>  > I am facing a problem during the SDcard unmount with the rtems 4.10.99 (GIT
>  > HEAD). Following sequence is performed during the mount:
>  > 1. rtems_io_register_driver .This returns the major number of the device
>  > 2. Then create a device (dev) using the call to rtems_filesystem_make_dev_t
>  > 3. rtems_disk_io_initialize
>  > 4. rtems_disk_create_phys is then called with the device (dev) returned from
>  > above call to rtems_filesystem_make_dev_t and the name as /dev/sdc0
>  > 5. rtems_bdpart_register_from_disk("/dev/sdc0")
>  > 6. rtems_fsmount. The rtems_fstab_entry has two entries. one for the partition
>  > (/dev/sdc01) and the other as /dev/sdc0
>  > The above sequence is succesfull.
>  > The unmount sequence is as follows:
>  > 1. unmount("/mnt/sdcard")
>  > 2. rmdir("/mnt/sdcard")
>  > 3. Call the rtems_media_get_device_identifier("/dev/sdc01", &dev) to get the
>  > dev. Note that here we start with the first partition
>  > 4. Call rtems_disk_obtain(dev) to get the disk_device pointer.
>  > 5. rtems_bdbuf_syncdev is then called. The pointer returned by disk_obtain is
>  > passed here.
>  > But at this point, i notice that the rtems_disk_obtain returns a NULL pointer
>  > and the syncdev crashes. I also see that the dev returned from the call to
>  > rtems_media_get_device_identifier does not seem to be correct. It does not give
>  > me the correct major number.
>  > This sequence used to work with the rtems4.10.2. The only difference was that
>  > in 4.10.2, the syncdev used to take the 'dev' itself as the argument. In
>  > 4.10.2, if this partition was not correctly removed, then all further SD card
>  > mount failed and needed a system reset for further mounts.
>  >
>  > What is the correct sequence to unmount an existing single partition SDcard
>  > with the latest RTEMS?Note that it used to work correct with the 4.10.2
>  > I see that there is a media manager also in place? Any example on how to use
>  > the media manager?
>
>
> on RTEMS 4.11 it is enough to call unmount(mount_path) and optionally the
> rmdir(mount_path).
>
> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone  : +49 89 189 47 41-16
> Fax    : +49 89 189 47 41-09
> E-Mail  : sebastian.huber at embedded-brains.de
> <mailto:sebastian.huber at embedded-brains.de>
> PGP    : Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org <mailto:rtems-users at rtems.org>
> http://www.rtems.org/mailman/listinfo/rtems-users
>


-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the users mailing list