Todd Peterson(deleted)
|
SD card driver - mount problems
|
Todd Peterson(deleted)
07/24/2009 1:44 PM
post34541
|
SD card driver - mount problems
I have implemented an SD card driver for Phytec (NXP) LPC3180, starting with driver in Atmel AT91SAM BSP. Implemented
low-level functions for read, write, get cid/csd, etc. and verify that they work. Hooked up to the sim system and
initialization seems to complete ok. But, when I try to mount the device I get the message below, I can't locate
mount_dos cmd, which it complains about. Any ideas? Thanks. Todd
when i start the driver:
Path=0 -
target=0 lun=0 Direct-Access(0) - SD:#3 SU01G Rev: 8.0
when i try to mount:
# mount -vvvvv -t dos /dev/hd0 /mnt/usb
Parsed: mount from [/dev/hd0] mount on [/mnt/usb] type [dos]
exec: mount_dos /dev/hd0 /mnt/usb
Using internal mount (mount_dos not found)
Type [dos] Flags 0x00000000
Device [/dev/hd0] Directory [/mnt/usb]
Options []
mount: Can't mount /mnt/usb (type dos)
mount: Possible reason: Resource busy
|
|
|
Kevin Stallard(deleted)
|
Re: SD card driver - mount problems
|
Kevin Stallard(deleted)
07/24/2009 1:50 PM
post34543
|
Re: SD card driver - mount problems
Are cam-disk.so, io-blk.so and fs-dos.so all available?
|
|
|
Todd Peterson(deleted)
|
Re: SD card driver - mount problems
|
Todd Peterson(deleted)
07/24/2009 2:00 PM
post34544
|
Re: SD card driver - mount problems
|
|
|
Kevin Stallard(deleted)
|
Re: SD card driver - mount problems
|
Kevin Stallard(deleted)
07/24/2009 2:08 PM
post34545
|
Re: SD card driver - mount problems
You may have done all this already but...
Have you tried to exercise the read capability of your driver:
i.e.
cat /mnt/usb >somefile.bin
1. Check to see the file continue to grow (i.e. your driver doesn't stall)
2. Open it in a hex edit and and see if it looks okay?
Secondly, most SD cards are like hard disks. Have you done a:
mount -e /mnt/usb
It may need to read partition tables first
It should enumerate the device to something like:
/mnt/usbt6
Then try to mount that
Kevin
|
|
|
Todd Peterson(deleted)
|
Re: SD card driver - mount problems
|
Todd Peterson(deleted)
07/24/2009 4:35 PM
post34563
|
Re: SD card driver - mount problems
You may have done all this already but...
Have you tried to exercise the read capability of your driver:
i.e.
cat /mnt/usb >somefile.bin
don't you mean cat /dev/hd0 > somefile.bin ???
1. Check to see the file continue to grow (i.e. your driver doesn't stall)
2. Open it in a hex edit and and see if it looks okay?
what would it look like?
Secondly, most SD cards are like hard disks. Have you done a:
mount -e /mnt/usb
I get nothing when I do this, I do mount -e /dev/hd0.
From your next post, I tried the following:
# ls /dev
console mem ptyp2 sem ttyp0 ttyp6
dbgmem null ptyp3 shmem ttyp1 ttyp7
hd0 pipe ptyp4 slog ttyp2 tymem
hd0t11 profiler ptyp5 socket ttyp3 zero
io-net ptyp0 ptyp6 text ttyp4
io-usb ptyp1 ptyp7 tty ttyp5
Process 204815 (ls) exited status=0.
# umount /dev/hd0t11
Process 213007 (umount) exited status=0.
# ls /dev
console null ptyp3 shmem ttyp1 ttyp7
dbgmem pipe ptyp4 slog ttyp2 tymem
hd0 profiler ptyp5 socket ttyp3 zero
io-net ptyp0 ptyp6 text ttyp4
io-usb ptyp1 ptyp7 tty ttyp5
mem ptyp2 sem ttyp0 ttyp6
Process 221199 (ls) exited status=0.
# mount -vvvv -t dos /dev/hd0 /mnt/usb
Parsed: mount from [/dev/hd0] mount on [/mnt/usb] type [dos]
exec: mount_dos /dev/hd0 /mnt/usb
Using internal mount (mount_dos not found)
Type [dos] Flags 0x00000000
Device [/dev/hd0] Directory [/mnt/usb]
Options []
mount: Can't mount /mnt/usb (type dos)
mount: Possible reason: Corrupted file system detected
|
|
|
Kevin Stallard(deleted)
|
Re: SD card driver - mount problems
|
Kevin Stallard(deleted)
07/24/2009 4:48 PM
post34566
|
Re: SD card driver - mount problems
Sorry Todd, I sometimes read a little too fast for my own good.
Yes...
cat /dev/hd0 >somefile.bin
...is correct.
> Process 221199 (ls) exited status=0.
> # mount -vvvv -t dos /dev/hd0 /mnt/usb
> Parsed: mount from [/dev/hd0] mount on [/mnt/usb] type [dos]
> exec: mount_dos /dev/hd0 /mnt/usb
> Using internal mount (mount_dos not found)
> Type [dos] Flags 0x00000000
> Device [/dev/hd0] Directory [/mnt/usb]
> Options []
> mount: Can't mount /mnt/usb (type dos)
> mount: Possible reason: Corrupted file system detected
I copied the above from your last email...it is almost correct...except that you need one more step in there.
You want to do the following:
mount -e /dev/hd0
THEN
mount -t dos /dev/hd0t6 /mnt/usb
^^^^^^^
The first one enumerates the partition tables, the second will then take the specified partition (hd0t6) and mount a dos
partition to /mnt/usb
See how that works
Kevin
|
|
|
Kevin Stallard(deleted)
|
Re: SD card driver - mount problems
|
Kevin Stallard(deleted)
07/24/2009 2:20 PM
post34548
|
Re: SD card driver - mount problems
Hey Todd,
So I went and did some simple mounting of my sd driver and captured the attached screen shot.
Bottom line is that it should mount the root device as you specify, its just that if you try to read it it will complain
about a corrupted file system.
It is possible that you may have a problem with reading from your device. Getting all the SIM/CAM stuff right can be
tricky.
I debugged my driver using the cat utility as I mentioned in my earlier post. Once you get this right, then it should
mount.
Kevin
|
|
|
Todd Peterson(deleted)
|
Re: SD card driver - mount problems
|
Todd Peterson(deleted)
07/24/2009 4:59 PM
post34568
|
Re: SD card driver - mount problems
The cat command does give me back what looks like the FAT structure in block 249 and another block which looks like a
file system information sector, but the file does not continue to grow, cat returns almost immediately.
|
|
|
Kevin Stallard(deleted)
|
Re: SD card driver - mount problems
|
Kevin Stallard(deleted)
07/24/2009 5:07 PM
post34570
|
Re: SD card driver - mount problems
Hmmm...the file should equal the size of the SD card you have in the slot when cat returns.
If this isn't happening, then you may have problems with the reading part of your driver.
Kevin
|
|
|
John Garvey
|
Re: SD card driver - mount problems
|
John Garvey
07/24/2009 5:43 PM
post34571
|
Re: SD card driver - mount problems
Todd Peterson wrote:
> I have implemented an SD card driver for Phytec (NXP) LPC3180, starting with driver in Atmel AT91SAM BSP. Implemented
low-level functions for read, write, get cid/csd, etc. and verify that they work. Hooked up to the sim system and
initialization seems to complete ok. But, when I try to mount the device I get the message below, I can't locate
mount_dos cmd, which it complains about. Any ideas? Thanks. Todd
>
> when i start the driver:
>
> Path=0 -
> target=0 lun=0 Direct-Access(0) - SD:#3 SU01G Rev: 8.0
>
> when i try to mount:
>
> # mount -vvvvv -t dos /dev/hd0 /mnt/usb
> Parsed: mount from [/dev/hd0] mount on [/mnt/usb] type [dos]
> exec: mount_dos /dev/hd0 /mnt/usb
> Using internal mount (mount_dos not found)
> Type [dos] Flags 0x00000000
> Device [/dev/hd0] Directory [/mnt/usb]
> Options []
> mount: Can't mount /mnt/usb (type dos)
> mount: Possible reason: Resource busy
Don't worry about mount_dos, that is a mount extension that first tries
to launch a fs-specific mount helper function, in case processing is not
in the usual manner. Failing that it will handle it internally via a
standard mount() libc call.
The EBUSY typically means you already have a fsys of type dos mounted
on the partition (or raw device in your case apparently). This might
be from a previous try or an automount or an enumerator etc. "df"
would probably indicate this (mountpt shown in brackets).
Because you most likely report your SD device as being removable, io-blk
will remember the mount even if it cannot be actioned, as it might
become possible to perform on media insertion/change. This feature for
example allows always mounting of a CD/ISO fsys at boot even though you
would seldom have a CD installed at that point; user access to the
pathname will cause a soft-remount attempt using the remembered
parameters; it also allows you to eject/change media without having
to explicitly remount (internally it will notice a new media and
perform an automatic remount). You can disable this using the 'normv'
parameter (eg 'mount -o normv', or 'blk normv' to apply permanently),
in which case a EIO/ENXIO/EBADFSYS error is reported immediately.
Or slaying your driver should drop the mounts, or umounting the raw
device ('umount /dev/hd0') will also.
Try enabling 'blk verbose' on the driver, and check in sloginfo that
the device is attached as expected, and partitions are enumerated
(or at least attempt to read blk 0). Check reported size is correct
(eg 'ls -s' or 'fdisk info'). Perhaps "spatch -b" it to examine the raw
data and see it looks as expected. Does it 'dcheck'? I am presuming
you expect it to be DOS-formatted? Are you expecting it to be
partitioned? Note that some factory-formatted SD and USB devices are
actually invalid (too big for the partition), but recent io-blk should
allow this in the special case of DOS, just forced to read-only (will
be told in sloginfo).
|
|
|
Kevin Stallard(deleted)
|
Re: SD card driver - mount problems
|
Kevin Stallard(deleted)
07/24/2009 6:11 PM
post34572
|
Re: SD card driver - mount problems
>
> Because you most likely report your SD device as being removable, io-blk
> will remember the mount even if it cannot be actioned, as it might
> become possible to perform on media insertion/change. This feature for
> example allows always mounting of a CD/ISO fsys at boot even though you
> would seldom have a CD installed at that point; user access to the
> pathname will cause a soft-remount attempt using the remembered
> parameters; it also allows you to eject/change media without having
> to explicitly remount (internally it will notice a new media and
> perform an automatic remount). You can disable this using the 'normv'
> parameter (eg 'mount -o normv', or 'blk normv' to apply permanently),
> in which case a EIO/ENXIO/EBADFSYS error is reported immediately.
> Or slaying your driver should drop the mounts, or umounting the raw
> device ('umount /dev/hd0') will also.
>
Hey John,
So one question, how is the recommended way for a driver to notify io-blk that the media has changed? I have some
requirements that specify that as soon as the media is removed, the mount point goes away. I can detect the removal of
the SD card via interrupt, and I've settled on using xpt_async() to notify io-blk. Is this the recommended way or is
there a better way?
Thanks
Kevin
|
|
|
John Garvey
|
Re: SD card driver - mount problems
|
John Garvey
07/24/2009 6:24 PM
post34573
|
Re: SD card driver - mount problems
Kevin Stallard wrote:
> So one question, how is the recommended way for a driver to notify io-blk that the media has changed? I have some
requirements that specify that as soon as the media is removed, the mount point goes away. I can detect the removal of
the SD card via interrupt, and I've settled on using xpt_async() to notify io-blk. Is this the recommended way or is
there a better way?
To cause the mountpoint to be removed, you must detach it (eg
devb-umass USB), whatever that means at the driver level to get
blkdev_detach() called. Changed media by istelf is usually reported
via SK_UNIT_ATN sense codes (eg devb-eide ATAPI CD-ROM), which will
be translated into an internal io-blk/libcam protocol exchange
(possibly blkdev_event() and/or DCMD_CAM_VERIFY_MEDIA handshake).
But io-blk is on the top side of libcam, I think you are asking
about the driver side of the interface? So the devb disk driver people
would be the correct people to ask, but they do not monitor this forum;
you could try somewhere over in the BSP ones perhaps? Ditto other SD
driver questions that have recently been raised, this is not the forum
that will likely obtain precise (if any) driver-side answers.
|
|
|
Todd Peterson(deleted)
|
Re: SD card driver - mount problems
|
Todd Peterson(deleted)
07/24/2009 7:45 PM
post34574
|
Re: SD card driver - mount problems
OK...got it working. Had a problem with my implementations of READ_MULTIPLE and WRITE_MULTIPLE. Once I fixed that, a
mount worked and I can do ls, cp, etc. and files look ok. Thanks for the help!
Todd
|
|
|
Todd Peterson(deleted)
|
Re: SD card driver - mount problems
|
Todd Peterson(deleted)
07/24/2009 7:52 PM
post34575
|
Re: SD card driver - mount problems
Now that it's working, I'm seeing heap usage of 5M. Is that normal? Or controllable?
Todd
|
|
|
Kevin Stallard(deleted)
|
Re: SD card driver - mount problems
|
Kevin Stallard(deleted)
07/24/2009 9:08 PM
post34577
|
Re: SD card driver - mount problems
Hey Todd, congrats
I think it is, io-blk by default takes a percentage of the available RAM and allocates it as stack. Take a look at io-
blk.so in the utilities reference, you can specify this on the command line.
Kevin
|
|
|
Daniel Lee
|
Re: SD card driver - mount problems
|
Daniel Lee
08/09/2012 2:46 AM
post94706
|
Re: SD card driver - mount problems
Hello todd,
I'm also porting SD card filesystem on QNX. I write low level driver for SDHC card and test read() write() etc.
ok, and I want to kown how to hook on the sim system? Is there some document about that? Thank you.
|
|
|
Todd Peterson(deleted)
|
Re: SD card driver - mount problems
|
Todd Peterson(deleted)
08/09/2012 12:06 PM
post94721
|
Re: SD card driver - mount problems
Just look at an existing implementation. For example, I used the Atmel AT91SAM BSP. Then, I used the existing Linux code
for my board to see how to implement the low-level code and glued all together. Wasn't fun, but got there eventually.
> Hello todd,
> I'm also porting SD card filesystem on QNX. I write low level driver
> for SDHC card and test read() write() etc. ok, and I want to kown how to hook
> on the sim system? Is there some document about that? Thank you.
|
|
|
|