Under Code Generator tab, select the âCopy only the necessary library filesâ and âGenerate peripheral initialization as a pair of .c / .h files per peripheralâ
Apply the settings, customize the pinouts, peripherals as per your need. When you are done initializing the MCU, click on the âGenerate Codeâ option.
This is how the project output looks like. A bunch of headers and C files under the âIncâ and âSrcâ folders.
Now copy the headers and source files under the âsrcâ folder in the Platformio IDE and compile.
Thats all! It should compile without any errors or issues.
(Well, atleast it did so for me)
Hope this helps for anyone else looking for a guide.
Thank you for the hint about the âincâ folder @ivankravets. PIO has been incredibly intuitive and easy to use. Most of the time I dont read the documentation unless I have a specific need or purpose.
( I really should take the time and read it⌠)
Iâve one additional question regarding the project folders generated by STM32CubeMX. For some platforms like STM32 F7x, enabling LwIP and FreeRTOS generates their sources under Middlewares/ and are not in a flat-directory structure. A part of that directory tree for LwIP library is attached below.
I felt that converting them into a flat-directory i.e. placing all of their headers/source files inside lib/ to be a tedious task since that would involve changing their source filesâ include statements too. Is there any better way to include/configure such libraries using platformio.ini commands? lib_extra_dirs kind of statements didnât help much.
Hi @krishna_chaitanya, thanks for your reply. I meant lib_extra_dirs in my previous comment.
Following was my configuration and error received while building. Would I need any additional configuration file, like package.json?
Can you post a complete directory tree structure of your entire project.
From what I am able to see and understand, your errors are because of improper paths in the include directives and the lib_extra_dirs directives.
As you say, I understand that the headers/sources from third-party libraries are not included/linked during compilation. Would like to see how lib_extra_dirs directives may solve for that. More like a CPPPATH inclusion issue.
Not sure whether I understood it right, correct me if Iâve understood it wrong. I set
lib_extra_dirs = âŚ/Middlewares/Third_Party/LwIP, âŚ/Middlewares/Third_Party/FreeRTOS
which is relative to Inc/ folder. Didnât work as well.
Actually from your earlier posts, you referenced the extra libs search path to your home directory, not the inc folder, not even wrt your project folder.
the â~â in your lib_extra_dirs path references wrt your user home folder.
Secondly, I meant when you include the freertos.h and the opt.h files in your source, give their path with respect to the inc folder.
i.e #include âMiddlewares/Third_Party/Freertos/freertos.hâ #include âMiddlewares/Third_Party/lwip/opt.hâ
that is assuming the files are in those respective folders. If they are in a sub folder, reference as such.
Hope this makes it clear.
Iâm bit confused as to how to use lib_extra_dirs properly. Have tried /Middlewares/Third_Party/LwIP and Middlewares/Third_Party/LwIP combinations in vain. Might be better to look at how Platformio includes/builds external sources.
My guess is that the overall build system expects a flat-directory i.e. where all .c and .h files are placed in the parent library directory which the user wants to compile and get linked to actual project sources.
Also if I do as you suggest, I may have to modify all relevant includes to Middlewares/Third_Party/LwIP/⌠etc., as their folder structure isnât flat. Have attached below the structure inside Middlewares/Thiurd_Party/LwIP/src. Editing the header-includes would be bit tedious, isnât it?
Then in your application source files, where the freertos and the lwip headers are included, modify them to #include "Middlewares/Third_Party/âŚ"to the respective paths for the lwip.h and freertos.h files.
Please note that path should be specified from a ROOT of a project. In the example above, it means that folder Inc is located on the same level as platformio.ini.