This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to debug fopen() returning NULL?

I have an eMMC connected to an STM32H7 via the SDMMC1 interface and am using the File System component provided by Keil.

The eMMC registers as M0:. In the debugger, the File System window shows everything looks good.

finit() and fmount() both return fsOK.

However, after these, when I use fopen("Test.txt", "w") the result is always NULL. 

I do not have access to the source code and there are no events generated when this call fails.

How can I debug this?

Parents
  • The eMMC registers as M0:. In the debugger, the File System window shows everything looks good.

    When did you take this picture? It shows that the driver M0 as well as the drivers are not initialized.

    When you used the Event Recorder, you should have seen the events and API calls of the previous finit() and fmount() calls as well as the fopen call in the Event Recorder window. Usually, you see error messages from the driver layers below.

    Only some ideas:

    - Did you format the drive?
    - Can you connect the eMMC module to PC to format and write a few files on it (some eMMCs are soldered, others are modules that can be removed)? If yes, can you read these files in your microcontroller application?
    - do you see some activity on the eMMC signals when you initialize, mount and write to the file system? 

Reply
  • The eMMC registers as M0:. In the debugger, the File System window shows everything looks good.

    When did you take this picture? It shows that the driver M0 as well as the drivers are not initialized.

    When you used the Event Recorder, you should have seen the events and API calls of the previous finit() and fmount() calls as well as the fopen call in the Event Recorder window. Usually, you see error messages from the driver layers below.

    Only some ideas:

    - Did you format the drive?
    - Can you connect the eMMC module to PC to format and write a few files on it (some eMMCs are soldered, others are modules that can be removed)? If yes, can you read these files in your microcontroller application?
    - do you see some activity on the eMMC signals when you initialize, mount and write to the file system? 

Children