disk_initialize(SD) hangs when using MQX

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

disk_initialize(SD) hangs when using MQX

跳至解决方案
1,684 次查看
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

标签 (1)
标记 (4)
0 项奖励
回复
1 解答
1,459 次查看
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 项奖励
回复
1 回复
1,460 次查看
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 项奖励
回复