PlatformIO Community

Gameduino2 and Wire errors

Hello, i am having trouble parsing some installation errors. BingUI and BingMachine are the base modules of the project. Given this is someone else’s project I had to deduce their platformio.ini file:

[env:release]
platform = atmelsam
board = due
framework = arduino
lib_ldf_mode = deep
lib_extra_dirs = ../../libs, ../../external
lib_deps = 
	greiman/SdFat @ ^1.1.4
	https://github.com/jamesbowman/gd2-lib/archive/refs/heads/master.zip
	adafruit/Adafruit DRV2605 Library@^1.2.0
	adafruit/Adafruit BusIO @ ^1.11.5
	https://github.com/adafruit/Adafruit_LED_Backpack.git
	adafruit/Adafruit GFX Library @ ^1.11.0
monitor_speed = 115200

Both get compilation error inside Adafruit and Gameduino librarys, but i don’t understand them. The Wire related errors confuse me because their supposed to be part of Arduino so there might be some serious incompatibilty issues. You may notice that SdFat version is older that latest one. That is to use the extended SdFat Class. These are the outputs i get when i try to compile in the release environment

BingUI output
BingMachine output

I see you’ve already seen the library dependency finder component of PlatformIO. Does deep+ or chain+ throw the same error? Are there then still no subdependencies of AudioI2S found in the dependency graph at the beginning of compilation?

Oh, i didn’t think about that because i added all those subdependencies manually. The only subdependency that appears in the graph for Audioi2S is SPI but it seems to be correctly installed

Changing to chain+ did remove some of the GD2 errors that showed up, but in both modules it says its missing SdFAT but i do have it installed. I’ll add new Paste bins

BingUI
BingMachine

Also this is still pointing to the original repo that doesn’t have the library.json fixes discussed in the previous topic? I hope you didn’t locally add a library.json in .pio\libdeps\ because that’s a temporary folder.

/Users/ivanmindlin/Repos/Bing-Project/libs/BingMachine/src/v3/BingMachineV3.h:4:10: fatal error: SdFat.h: No such file or directory

Hm, what are the first say 5 lines of that file? Does it do any condition #if ... including there? Does the BingMachine library folder has a library.json with some build options?

Regarding the library.json file i must admit i did put it in the .pio/libdeps folder because i understood it had to be in the library folder. But when i recompile the library.json file remains and in fact i am not getting anymore my previous error.

There wasn’t any library.json in the BingMachine folder.
This are the first few lines in SdFat (which is in a .pio folder)

#ifndef SdFat_h
#define SdFat_h
/**
* \file
* \brief SdFat class
*/
#include "SysCall.h"
#include "BlockDriver.h"
#include "FatLib/FatLib.h"
#include "SdCard/SdioCard.h"
#if INCLUDE_SDIOS
#include "sdios.h"
#endif // INCLUDE_SDIOS
/** SdFat version 1.1.2 */
#define SD_FAT_VERSION 10102

Sorry I meant the first 5 or so lines of this file ^.

To make it safer you can use my fork https://github.com/maxgerhardt/gd2-lib.git or create your own – usually the .pio folder is not pushed and to be viewed as volatile, temporary.

/Users/ivanmindlin/Repos/Bing-Project/libs/BingMachine/src/v3/BingMachineV3.h:

#ifndef __BINGMACHINEV3_HH__
#define __BINGMACHINEV3_HH__
// Audio Includes
#include <SdFat.h>
#include <AudioI2S.h>

// Touch Screen Includes
#include <GD2.h>

// Motor Includes
#include <Adafruit_DRV2605.h>

// Visual Includes
#include <Adafruit_LEDBackpack.h>

#include <DueFlashStorage.h>

Hm this looks all good and straight forward. Quite unusual that PlatformIO has problems with this. You can try and add a library.json to the BingMachine folder that declares the greiman/SdFat @ ^1.1.4 (and other) dependencies, see docs. Does that help?

So i started from scratch, made my modifications using your fork instead of in the .pio file. That didn’t work, so i made the library.json file (Adding just the names, versions and authors) for the BingMachine file. But i was getting an “undefined reference to loop and main” in this an another module. The solution was here

So i’m not so sure why defining library.json was the solution because i did not do it in another module, and i understand is optional. Does platformio need this library.json file then?

In any case, thank you for aall your help!

Indeed, when i try to start adding the other modules of the project if i run them with the Build Button in VsCode i get dependency errors, but when i run it with pio run -t clean it works. What does the Build Button run then?

No, -t clean just removes build artefacts, it does not build – It will be “successfull”, but it is the removal of old build files that is successfull, not the compilation of the firmware.

Then i am getting this

...
Building in release mode
Linking .pio/build/release/firmware.elf
.pio/build/release/libFrameworkArduino.a(main.cpp.o): In function `main':
main.cpp:(.text.startup.main+0x1a): undefined reference to `setup'
main.cpp:(.text.startup.main+0x20): undefined reference to `loop'
collect2: error: ld returned 1 exit status
*** [.pio/build/release/firmware.elf] Error 1

BingMachine does not have a loop or main functions, it its just a definition of a Class. Maybe i need i way to indicate that to pio?

The Arduino core is looking for a setup() and loop() function in the “global scope”, not inside a class. The original sketch must have had a setup and loop function somewhere. Can you locate it in a source file?

This is the project structure
Bing-Project
–>external // some external libraries
----->DueFlashStorage
----->ArduinoMD5
---->gd2
----->SdFat
–>libs // where apparently the two main modules are supposed to be plus the Audio one
----->BingMachine
----->BingUI
----->Audio
–>paradigms // where i will implement some protocols
------>GlobalLocal
–>tools // an extra tools folder that still did not come into action
-----> Bing-SdLoader
-----> Bing-SdLoaderInstaller
-----> Bing-SerialUpdater

The only one that has a setup and loop is GlobalLocal, one of the paradigms modules that calls the BingMachine and BingUI. GlobalLocal project does not compile because it says BingMachine is missing Adafruit_DRV2605 which i do have installed. GLobalLocals .ini file has libs/ and external/ folders incorporated.

This is what i get when i try to build the paradigm i get this

In file included from /Users/ivanmindlin/Repos/Boxes_project/Bing-Project/libs/BingMachine/src/BingMachine.h:11:0,
                 from src/main.cpp:3:
/Users/ivanmindlin/Repos/Boxes_project/Bing-Project/libs/BingMachine/src/v3/BingMachineV3.h:11:10: fatal error: Adafruit_DRV2605.h: No such file or directory

**************************************************************************
* Looking for Adafruit_DRV2605.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Adafruit_DRV2605.h"
* Web  > https://registry.platformio.org/search?q=header:Adafruit_DRV2605.h
*
**************************************************************************

 #include <Adafruit_DRV2605.h>
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/debug/src/main.cpp.o] Error 1
====================================================== [FAILED] Took 1.25 seconds ======================================================

Environment    Status    Duration
-------------  --------  ------------

Try creating another library.json with adafruit/Adafruit DRV2605 Library@^1.2.0 as one of its dependencies for the libs/BingMachine folder.

No use

This is the file i have in libs/BingMachine folder