-
Notifications
You must be signed in to change notification settings - Fork 10
Description
I am trying to use Link Time Optimization (via GCC flag -flto) to reduce binary size. My sketch is too large to fit on the H7's flash otherwise. However, if I enable this then mounting a USB drive always fails.
I am using this library via Arduino_UnifiedStorage > Arduino_POSIXStorage. I don't know enough about how linking works to say whether the problem is really in this library, or one of those. However I was able to trace the issue as far as this section in Arduino_POSIXStorage.cpp.
if (false == (usbHostDevice->connected()))
{
if (false == (usbHostDevice->connect()))
{
// Only delete if the object was created by this function
if (false == hotplugKeep)
{
deleteDevice(DEV_USB, &usb);
}
return ENOTBLK;
}
}
usbHostDevice->connect() is returning false.
To try to get more info I set #define DEBUG 4 in dgb.h. Interestingly, with LTO enabled there is no debug output at all. But with LTO off I can see all the debug output over serial and the drive works correctly. This makes me think that USBHostMSD is getting optimized out completely, but I'm not sure.