PlatformIO Community

How use a same chip but with different environment?

OK, my problem is very difficult .
For example, I use the chip STM32L476RG in my project, I make a pcb with it, do not use it as a eval kit, So I have to change some code about configuration in the PIO, like “variant.h” or the “variant.cpp”, even sometimes when I use the FreeRTOS I should change the ldscipt.ld file about stack and heap size.
OK, here is my problem, I make threet boads with same chip but different hardware interface, but they use the same configuration file as I mentioned, So how can I slove the problem, every board with different ldscipt.ld variant h/cpp file and so on.
I know when I use scons tool there are command “–dist” can help me finsh it.

Thank you!

Hm based on your description it seems as you want to use different versions of the variant folder in different environments, which contain all these files like the linker script and varian.cpp/variant.h?

The variant folder is selected by an attribute in the board JSON definition

But the whole variant folder can also be selected by…

…changing the build.variants_dir setting.

I demonstrated what I mean in this example repository: https://github.com/maxgerhardt/pio-custom-stm32duino-variants

You are so kind to the developer everytime, as a not brilliant engineer from China, You helped me too many times.

Thank you very much, the answer is very specifically!

I follow the examples step by step, and succeed! Thank you again!
After I customize my board use the Chip stm32L476RG and has none business with the eval board(The offical nucleo board), Here is the problem, I should use the variant_generic.cpp/h instead of the variant_NUCLEO_L476RG.cpp/h, like the picture show, you can also see my platformio.ini but I do not know how to use it?
iShot2022-03-24 20.59.02
So I try to slove this problem, I find the [/.platformio/packages/framework-arduinoststm32/cores/arduino/variant.h] the macros VARIANT_H = “variant_NUCLEO_L476RG.h”,
but I still do not know how it happened?
image

Hope somebody can help me~

Hi Could you give me some tips