[En-Nut-Discussion] NutRegisterDevice().....

PragmaLab info at pragmalab.nl
Wed Apr 9 09:14:15 CEST 2008


Hello all,

I'm currently busy implementing the NutOS phat-filesystem in our streaming
audio application. Since we don't use the Ethernut 3 platform but some
platform that comes close to Ethernut 1, I created a new blockdevice that
deals with the AVR-SPI iso the nplmmc blockdevice driver. It seems to do the
job (although I have to solve a speed issue). We need the filesystem to read
and write songs from a SD/MMC card.

My question is about the way to register the 2 devices that are involved
when using the filesystem and the blockdevice driver. 
When starting the application, I will:

1) register devPhat0 (filesystem)
2) register devAvrMmc0 (block device driver)
3) mount the volume (first partition)

That works OK and I can read and write from/to the card. But now if I remove
the card and put it back, then what should I do? I cannot register the same
device twice, so NutRegisterDevice will fail. Ofcourse I need to mount the
card again since it might be a new or modified card. I would expect in that
case only to do

3) mount the volume

again. But that always fails. I do call "_close(g_hVolume)" when the card is
removed (unmount). 

In general, since there is no NutUnregisterDevice(), I would expect that
registering device drivers indeed only needs to be done once. But that
implies that the initialisation function of the device driver is not allowed
to read the fysical device and/or store info related to the device.
Otherwise the initialisation needs to be done each time a new device is
present (eg a new card is inserted), which (like I said) is not possible
when using NutRegisterDevice.

The reason that mounting the volume fails when called without registering
the devices first, is probably because the SD-card is not reset/initialised
again. This low level reset/initialisation is done in MmCardInit() but that
one is in the device-init function.

Anyone got an idea how to deal with cards that are re-insterted? Should I
just call '(*dev->dev_init)(dev) ' ?

thanks.

Best regards,

Rob van Lieshout

 




More information about the En-Nut-Discussion mailing list