SD Library unaligned pointer error - Nrf52832

I'm using the SD library with a Adafruit Feather nRF52832 Bluefruit. When I run the example sketches such as "CardInfo" or "Files" I sometimes get this warning as the sketch is compiling

C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp: In member function 'uint8_t SdFile::open(SdFile*, const char*, uint8_t)':
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:532:15: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
  532 |     dateTime_(&p->creationDate, &p->creationTime);
      |               ^~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:532:15: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:532:33: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
  532 |     dateTime_(&p->creationDate, &p->creationTime);
      |                                 ^~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:532:33: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp: In member function 'uint8_t SdFile::sync(uint8_t)':
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:1155:17: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
 1155 |       dateTime_(&d->lastWriteDate, &d->lastWriteTime);
      |                 ^~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:1155:17: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:1155:36: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
 1155 |       dateTime_(&d->lastWriteDate, &d->lastWriteTime);
      |                                    ^~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:1155:36: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]

I only get this warning sometimes. But every time I do get the warning, the SD card reader fails to initialize. I'm stumped as to what is causing this, since I never get this warning when I run the same sketches on the UNO R3. Any ideas on what might be causing the issue and how to fix it?

Same issue here! Any fix for this?

EDIT: It looks like the error occurs when the sd card is not properly seated.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.