How to link Luos with Platformio

WARNING: This post replaces the post How to link Luos and Robus to Platformio which is deprecated.

The aim of this post is to show you how works the link between Luos and PlatformIO. This connection is very important, thanks to it Luos’s github pages have been reorganized in order to make the download easier and multiplatform available for users. Indeed, once you have download a container (for example button_container) you just have to start the PlatformIO project and compile it.

All the necessary libraries will be found without any configuration on your part, and if you want to add another container to your project you just have to drag and drop the container of your choice and add it to the lib folder of PlatformIO. If you want that your project supports other boards, you just have to add a new env in your platformio.ini file.

PlatformIO documentation

To do the link between Luos and PlatformIO we followed the instructions of the PlatformIO documentation:

This documentation explains that we have to create a python script and a .json file for each library in order to select the right board according to the value of the board in platformio.ini. To select the board we want, we simply add a define to build_flags in platformio.ini.

Platformio.ini

[env:eval_f072vb]

platform = ststm32

board = eval_f072vb

framework = stm32cube

build_flags = 

    -D USE_FULL_LL_DRIVER

    -D USE_HAL_DRIVER

    -I Inc

    -DLUOSHAL=STM32F0

lib_extra_dirs = 
    C:\Workspace\Luos

This file is use to configure the platformIO project. We can see that we are using an stm32 platform which is the eval_f072vb board. Then we have build_flags, very important fields which are in charge of the preprocessing, compilation, assembly and linking processes for C code. In our case, we use it for three reasons:

1) Make preprocessor define:

        -D USE_FULL_LL_DRIVER

        -D USE_HAL_DRIVER

2) Include header file generate by CubeMX:

        -I Inc

3) Select our board

        -DLUOSHAL=STM32F0 

Thanks to -DLUOSHAL=STM32F0 line, we indicate to our scripts what board it must choose in the LuosHAL folder.

We also have the lib_extra_dirs field to specify to the compilator where are Luos and LuosHAL librairies folder.

library.json (Luos)


{

    "name": "Luos",

    "keywords": "robus,network",

    "description": "distributing operating system",

    "version": "0.6.0",

    "frameworks": "stm32cube",

    "platforms": "ststm32",

    "authors": {

        "name": "Luos",

        "url": "https://luos.io"

    },

    "licence": "MIT",

    "build" : {

        "flags": [

            "-I Inc",

            "-I OD"

        ],

        "extraScript": "select_board_script.py"

    },

    "dependencies":

    [

        {

        "name": "LuosHAL"

        }

    ]

}

This .json file is related to the Luos library as we can see in the name field.

This file has 2 goals:

1- Include the header file useful to Luos and execute the python script to use the board reference in platformio.ini :


    "build" : {

        "flags": [

            "-I Inc",

            "-I OD"

        ],

        "extraScript": "select_board_script.py"

    },


2- Make a dependence to LuosHAL because we need the LuosHAL to make Luos works:


    "dependencies":

    [

        {

        "name": "LuosHAL"

        }

    ]

select_board_script.py (Luos)


Import('env')
from os.path import join, realpath

# private library flags

for item in env.get("CPPDEFINES", []):

    if isinstance(item, tuple) and item[0] == "LUOSHAL":
        env.Append(CPPPATH=[realpath(item[1])])
        env.Replace(SRC_FILTER=[ "+<%s>" % item[1]])
        break

This python script will specify which source files should be include from build process in function of the selected board. In our case, STM32F0 source file place in the LuosHAL folder STM32F0.

Luos folder structure


  Luos
    │   library.json
    │   select_board_script.py
    │
    ├───LuosHAL
    │   └───lSTM32F0
    │                luosHAL.c
    │                luosHAL.h
    │                luosHAL_Config.h
    │
    ├───Inc
    │       
    ├───OD
    │     
    └───src

Hi Thomas,

I am basically trying to use your post to set the environment in Platform IO for a STM32 F030 board

  • I basically updated the platformio.ini file to reference my board F030 instead of the F072 used in your Luos post

  • then I understood the the lib_extra_dirs specified folder should be filled with the LuosHAL related to my board:
    https://github.com/Luos-io/LuosHAL/tree/master/STM32F0

  • and the files select_board_script.py and library.json have to be created based on the content explained in you post too

Questions :

  • did I miss something here ?
  • what are the content of the 3 additional folders show in the Tree :
    ├───Inc -> I guess the include files for my Luos application ?

    ├───OD -> ???

    └───src -> I guess the source files for my Luos application ?

Thanks!
Alexis

Hi Alexis,

I don’t think you miss something. Just remeber you will have to adapt pinout to your design. You can find the basic luos configuration in luosHAL_config and modifiy what you want in your application.

inc -> this is the include files of luos Library in .h files you will find the API function that you can use in you application
src -> this is source files for luos library that you can consulte to understand how library work
OD -> this is the Object Dictionnary. Object dictionnary allow you to create standart object container to faciliate communication between containers and make them re usable by other dev

thanks you to use Luos

regards

Thomas

Hi Thomas, thanks!
My question was more : where can I download the content of the src / inc OD etc… folders could you maybe send me a link ?

Hi alex,

You will find all the files relative to Luos library in the github folder:

best regards

perfect thanks Thomas !