Palatis / Arduino-Lufa

LUFA (Lightweight USB For AVRs) on the Arduino!
MIT License
100 stars 26 forks source link

Build with LUFA and SD/SdFat libraries fail #24

Closed Ogekuri closed 1 year ago

Ogekuri commented 1 year ago

Hi!, I'm trying to include SD or SdFat library on a LUFA project but I get build errors.

The project corretly build with "Arduino Leonardo" board, but fail with the "Arduino Leonardo (LUFA)" board: In file included from C:\Program Files (x86)\Arduino\libraries\SD\src/SD.h:21:0, from C:\Users\frolando.DLC0YLZW2\Desktop\SD-1.2.4\examples\Files\Files.ino:3: C:\Program Files (x86)\Arduino\libraries\SD\src/utility/SdFatUtil.h: In function 'void SerialPrint_P(const char*)': C:\Program Files (x86)\Arduino\libraries\SD\src/utility/SdFatUtil.h:63:5: error: 'Serial' was not declared in this scope Serial.write(c); ^~~~~~

Here a project created for the tests:

include

include

include

include

File myFile;

void setup() { if (!SD.begin(4)) { while (1); }

// open a new file and immediately close it: myFile = SD.open("example.txt", FILE_WRITE); myFile.close(); }

void loop() { // nothing happens after setup finishes. }

I've attached both logs.

Do you have any suggestions?

Thanks!

build_log_Arduino-Leonardo.txt build_log_Arduino-Leonardo-(LUFA).txt

Ogekuri commented 1 year ago

After a more deep analysis it seem caused by the "USBAPI.h" where the Serial is disabled by LUFA.

Do you think that I can try to re-enable the Serial object in the "USBAPI.h"?

There is any other workaround?

Ogekuri commented 1 year ago

I've definitely fixed and tested on my Badusb USB (and Arduino Leonardo with SD card reader) replacing the arduino-LUFA files with the original ones from ardunio dir.

In detail I've recover the following 2 files into hardware\arduino\avr\cores\arduino-LUFA:

hardware\arduino\avr\cores\arduino\Arduino.h
hardware\arduino\avr\cores\arduino\USBAPI.h

The fist one has the USBAPI.h include and the second one is API it'self.

The SD and the USB work's well togeder on my setup, but I don't kow it can work for other boards, so you can just close the issue.

Thanks.