Howto perform SD-Card Hotswapping?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Howto perform SD-Card Hotswapping?

Jump to solution
1,979 Views
naftalir
Contributor III

My issue is to be able to make it possible to remove and to insert the SD-Card during a runtime of the system (Hotswapping).

 

Scenario description:

1. Installation of the SD-Card (esdhc device, sdcard driver, partition manager, mfs) - All OK.

2. Writing to the SD-Card - All OK.

3. Uninstallation of the SD-Card (reverse order of installation: mfs, partition manager, sdcard driver, esdhc device) - All OK.

4. Removal of the SD-Card.

5. Insertion of the SD-Card.

6. Installation of the SD-Card (esdhc device, sdcard driver, partition manager, mfs) - Stuck at Partition manger installation and sometimes at the MFS openning.

 


The code attached here (not an executable one, but contain the exact code lines of the 1st installation, 2nd installation and the uninstallation).

 

Original Attachment has been moved to: installtion.txt.zip

Labels (1)
0 Kudos
Reply
1 Solution
1,242 Views
Martin_
NXP Employee
NXP Employee

Hopefully final reply from my side. If you need to uninstall sdcard driver, correct unistall function is _io_dev_uninstall().

Opposite for _io_sdcard_install("sdcard", ...) is _io_dev_uninstall("sdcard");

Martin

View solution in original post

0 Kudos
Reply
8 Replies
1,242 Views
naftalir
Contributor III

Martin, you did help me, but in addition to your solution, the one thing that seems to be the most important is to keep the "MFS Install" code lines and the "MFS Uninstall" code lines in the same task.

When i tried to run them in different tasks, kernel addressing issues were caused.

0 Kudos
Reply
1,243 Views
Martin_
NXP Employee
NXP Employee

Hopefully final reply from my side. If you need to uninstall sdcard driver, correct unistall function is _io_dev_uninstall().

Opposite for _io_sdcard_install("sdcard", ...) is _io_dev_uninstall("sdcard");

Martin

0 Kudos
Reply
1,242 Views
Teckna
Contributor V

Hi,

I think I've found a bug in the _io_sdcard_uninstall function (called by _io_dev_uninstall function):

I think that the line:

SDCARD_STRUCT_PTR dev_ptr = (SDCARD_STRUCT_PTR)io_dev_ptr;

should be:

SDCARD_STRUCT_PTR dev_ptr = (SDCARD_STRUCT_PTR)io_dev_ptr->DRIVER_INIT_PTR;

Am I right?

Many thanks

Teckna

0 Kudos
Reply
1,242 Views
Teckna
Contributor V

Hi,

It seems that the same bug was in the _io_mem_uninstall:

The line:

IO_MEM_STRUCT_PTR dev_ptr = (IO_MEM_STRUCT_PTR)io_dev_ptr;

should be:

IO_MEM_STRUCT_PTR dev_ptr = (IO_MEM_STRUCT_PTR)io_dev_ptr->DRIVER_INIT_PTR;

Many thanks

Teckna

0 Kudos
Reply
1,242 Views
c0170
Senior Contributor III

Hello Teckna,

good catch :smileywink:  It has been reported , will be fixed soon. Thank you for reporting !

Regards,

MartinK

0 Kudos
Reply
1,244 Views
naftalir
Contributor III

Thank you so much Martin!

I will right get to that example and will try for myself and update here for my result...


Thanks so much!

0 Kudos
Reply
1,244 Views
Martin_
NXP Employee
NXP Employee

One difference is that you call _io_sdcard_install() and _io_sdcard_uninstall() for insertion/removal. We don't do that in the mfs sdcard demo. Can you try the same approach - that means, leave the sdcard driver installed. Even the MQX MFS User's guide tells to open/close lower-layer device for hotswapping (not install/uninstall lower-layer device).

Martin

1,244 Views
Martin_
NXP Employee
NXP Employee

Our standard MQX 3.8.1 MFS demo \mfs\mfs\examples\sdcard\ implements hotswapping of SD-card. I tried to load it into twrk60f120m and seems I can insert and remove an SD card during demo runtime multiple times without an issue.

By looking into your source code, I admit I don't see obvious differences. As not being author of the code, I might have overlooked something in the pointers and #define macros. If you have a chance please have a look into "\mfs\examples\sdcard\demo.c" if you can see any differences. Could you post the partition manager install error codes that it returns ? Or the best would be if you can modify the mfs sdcard demo in such a way that it will cause the partition manager install problem on Freescale evaluation board; we could debug this and find the root cause.

Martin