disk_initialize(SD) hangs when using MQX

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

disk_initialize(SD) hangs when using MQX

Jump to solution
902 Views
barrymcnamara
Contributor II

I have a project which reads data from an SD card. It was written using bare metal and works fine. I would now like to transition the project to use MQX.

 

However, once I add "FSL_RTOS_MQX" to my defines, the disk_initialize(SD) function hangs.

I have not changed anything besides adding that define and including the MQX files in the SDK needed to compile the project.

 

I have used the debugger and traced the hanging to the OSA_SemaWait call in fsl_sdhc_driver.c, which I have determined is implemented slightly differently for MQX than it is for bare metal. I, however, cannot determine why the function is hanging.

 

Can anybody point me in the right direction to fix this?

 

Thanks

Labels (1)
0 Kudos
1 Solution
677 Views
barrymcnamara
Contributor II

I eventually got past the disk_initialize(SD) call by adding the following line at the start of my main task:

OSA_InstallIntHandler(SDHC_IRQn, MQX_SDHC_IRQHandler);

I had to import fsl_sdhc_irq.c for this to work, which isn't ideal since you generally shouldn't import .c files, but this was the only file in the SDK that had the right IRQ handler.

However, I then encountered another problem. I set the current drive with f_chdrive(SD) and call f_mount(SD), but the current drive would not remain set when I called f_opendir, returning the FR_NOT_ENABLED status. I managed to fix this by changing ff.h so that CurrVol is initialized to 1 (SD) instead of 0 (USB) which is also an ugly hack, but this was the only thing that seemed to work.

If anybody has a more elegant solution, I would love to hear it.

View solution in original post

0 Kudos
1 Reply
678 Views
barrymcnamara
Contributor II

I eventually got past the disk_initialize(SD) call by adding the following line at the start of my main task:

OSA_InstallIntHandler(SDHC_IRQn, MQX_SDHC_IRQHandler);

I had to import fsl_sdhc_irq.c for this to work, which isn't ideal since you generally shouldn't import .c files, but this was the only file in the SDK that had the right IRQ handler.

However, I then encountered another problem. I set the current drive with f_chdrive(SD) and call f_mount(SD), but the current drive would not remain set when I called f_opendir, returning the FR_NOT_ENABLED status. I managed to fix this by changing ff.h so that CurrVol is initialized to 1 (SD) instead of 0 (USB) which is also an ugly hack, but this was the only thing that seemed to work.

If anybody has a more elegant solution, I would love to hear it.

0 Kudos