I’m new to the mbed platform and I was hoping to use Visual Studio for coding rather than the online IDE / EmBitz
I found PlatformIO which appears to be a collection of Python scripts which can be used for building programs for various microcontrollers. It was fairly easy to install using these instructions once you have Python 2.7 installed.
I was able to set up a blank Visual Studio project by running this script:
Which appears to copy the Pokitto lib into C:\Users<username>.platformio\lib\Pokitto
I added the Hello World example main.cpp to my project root and attempted to build. It looks like it managed to find the Pokitto lib correctly (from the #include “Pokitto.h”) but fails to build the library. It appears to be a problem with include paths when trying to find the headers.
C:\Users\James.platformio\lib\Pokitto\POKITTO_CORE\FONTS\TIC806x6.cpp:15:10: fatal error: PokittoFonts.h: No such file or directory
PokittoFonts.h is actually in the parent directory so it makes sense that it fails without setting up explicit include paths. How is this handled in mbed / EmBitz build scripts? Does anyone else have experience building with PlatformIO that can lend a hand?
In file included from /home/dreamer/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/dirent.h:7:0,
from lib/PokittoLib/Pokitto/POKITTO_SIM/tinydir/tinydir.h:54,
from lib/PokittoLib/Pokitto/POKITTO_LIBS/FileIO/FileIO_SIM.cpp:42:
/home/dreamer/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/sys/dirent.h:10:2: error: #error "<dirent.h> not supported"
#error "<dirent.h> not supported"
^~~~~
Compiling .pioenvs/lpc11u68/lib/PokittoLib/Pokitto/POKITTO_LIBS/ImageFormat/BmpImage.o
In file included from lib/PokittoLib/Pokitto/POKITTO_LIBS/FileIO/FileIO_SIM.cpp:42:0:
lib/PokittoLib/Pokitto/POKITTO_SIM/tinydir/tinydir.h:159:22: error: 'DIR' does not name a type
#define _TINYDIR_DIR DIR
^
lib/PokittoLib/Pokitto/POKITTO_SIM/tinydir/tinydir.h:207:2: note: in expansion of macro '_TINYDIR_DIR'
_TINYDIR_DIR *_d;
^~~~~~~~~~~~
lib/PokittoLib/Pokitto/POKITTO_SIM/tinydir/tinydir.h: In function 'int tinydir_open(tinydir_dir*, const char*)':
lib/PokittoLib/Pokitto/POKITTO_SIM/tinydir/tinydir.h:279:7: error: 'tinydir_dir {aka struct tinydir_dir}' has no member named '_d'; did you mean '_e'?
dir->_d = NULL;
^~
_e
lib/PokittoLib/Pokitto/POKITTO_SIM/tinydir/tinydir.h:302:7: error: 'tinydir_dir {aka struct tinydir_dir}' has no member named '_d'; did you mean '_e'?
dir->_d = _tinydir_opendir(path);
^~
_e
lib/PokittoLib/Pokitto/POKITTO_SIM/tinydir/tinydir.h:161:26: error: 'opendir' was not declared in this scope
#define _tinydir_opendir opendir
^
... etc.
lib/PokittoLib/Pokitto/POKITTO_LIBS/FileIO/FileIO_SIM.cpp:42:10: fatal error: tinydir.h: No such file or directory
#include "tinydir.h"
^~~~~~~~~~~
compilation terminated.
I think the problem here is that the compiler is trying to compile FileIO_SIM.cpp when it shouldn’t be.
/PokittoLib/Pokitto/POKITTO_LIBS/FileIO/ has both FileIO_HW.cpp and FileIO_SIM.cpp.
The former is the hardware implementation, the latter is the simulator implementation.
PlatformIO needs to be instructed to ignore FileIO_SIM.cpp
Otherwise FileIO_SIM.cpp will need some conditional compilation,
i.e. #if defined(POK_SIM) to the top of FileIO_SIM.cpp and #endif at the bottom.
That might be a mistake in the library.
Includes are case sensitive depending on the compiler,
and Pokittodisplay.h doesn’t exist, but PokittoDisplay.h does.
lib/PokittoLib/Pokitto/POKITTO_LIBS/ImageFormat/BmpImage.cpp: In function 'int openImageFileFromSD(char*, uint16_t**, uint8_t**)':
lib/PokittoLib/Pokitto/POKITTO_LIBS/ImageFormat/BmpImage.cpp:66:5: error: 'BITMAPFILEHEADER' was not declared in this scope
BITMAPFILEHEADER bf;
^~~~~~~~~~~~~~~~
lib/PokittoLib/Pokitto/POKITTO_LIBS/ImageFormat/BmpImage.cpp:67:5: error: 'BITMAPINFO' was not declared in this scope
BITMAPINFO bmi;
^~~~~~~~~~
whole lot more like these.
Further down the line I also still see that Physics is still included somehow.
Open up a project “HelloWorld” in EmBitz, go to project options and see which files are included. BmpImage for example, is @Hanski’s RLE encoded bitmap optional library.
AFAIremember, Only POKITTO_CORE, POKITTO_HW and POKITTO_LIBS/Synth are actually needed for compilation
Yes somehow pio goes through everything in the lib-directory and tries to link it.
It seems the dependency-graph is not correctly calculated starting from the HelloWorld main.cpp
I will investigate further when I have the time. Thnx for the help
ps; EmBitz is windows only? I just want a sane command-line workflow that I can integrate with any editor easily (hence PlatformIO)
Also a better way to integrate the mbed lib via a library.json is probably the way to go here.
I think it’s because it’s trying to precompile it and tries to use all the available .cpp files.
To be honest I’m not entirely sure what dictates which .cpp files get used but EmBitz doesn’t seem to have a problem.
I can’t find anything that says conclusively either way, but I would assume it’s Windows only.
A contradiction in terms? :P
You probably should have waited until it’s all up and running 100% first.
I think it might be possible to get Visual Studio or VS Code compiling without PlatformIO, but you’d have to get them using gcc first and then make sure all the project settings are correct, which can be a bit of a pain.
Yeah I know, but already looking at how the mbed libraries are included is much different than just git-pulling into a lib/ directory. I’m kind of hoping this will save some headaches somehow :#