B-L072Z-LRWAN1 Demo Project Build Setup

Hi, I just got this board, and it seems like it should work with Platformio, but I’m trying to just get the demo project that implements an AT command firmware to build, and I feel like I’m getting tripped up by project structure / include paths. The project I want to load from the demo zip has this folder structure:

From what I’ve gathered, EWARM, MDK-ARM, and SW4STM32 are STM32 IDEs, and those folders contained shims / projects settings files for those IDEs. The actual source code is in the LoRaWAN and Core folders respectively, but weirdly spread out with header files in inc/ folders and implementation files in src/ folders; but all include statements written as thought all the inc/ folders are on the include path (i.e. you find #include “hw.h” in main.c, but “hw.h” is located in LoRaWAN/App/inc/).

I’m using VSCode and I tried creating a new Project and selecting what I think are the appropriate options (I guess I’m not entirely sure about the Framework option):

Board: ST DISCO-L072CZ-LRWAN1
Framework: STM32Cube

But then I’m unsure how to migrate the folder structure of the demo project zip into the src/ and lib/ folder structure that Platformio expects to make build work. Can anyone help put me on the right path (pun intended).

You can put all the source files in either src/ or lib/, and header files in inc/. If you feel like the code should should be reusable, put it in lib/. You can really have any folder structure you like as long as the code finds all its include headers. If it does not find them, just add the appriopate folder path using a -I <path> build flag in the platformio.ini, e.g.

build_flags = -I src/LoRaWAN/App/inc

See docs. Include paths of library folder can be better controlled using the library.json, see docs.

And a side note: Linker scripts (.ld) and startup files (.s) are not needed, the PlatformIO will auto-include the correct one specified by your board choice.

2 Likes