What does `set(SHIELD ssd1306_128x32)` actually do?

Hello, I was taking a look at the LittlevGL example today. I was able to get it working on my test bench using a 5340dk and some random Oled displays we have laying around the office. The example requires the `set(SHIELD ssd1306_128x32)` line to be added to the CMakeLists.txt file. I was under the impression that the cmake flag was simply adding an overlay file to the project at compile time:

```
/ {
	chosen {
		zephyr,display = &ssd1306_ssd1306_128x64;
	};
};

&arduino_i2c {
	status = "okay";

	ssd1306_ssd1306_128x64: ssd1306@3c {
		compatible = "solomon,ssd1306fb";
		reg = <0x3c>;
		width = <128>;
		height = <64>;
		segment-offset = <0>;
		page-offset = <0>;
		display-offset = <0>;
		multiplex-ratio = <63>;
		segment-remap;
		com-invdir;
		prechargep = <0x22>;
	};
};

I tried copying the contents of this overlay into my own board overlay file, then removing the cmake line and rebuilding. Unfortunately, Lvgl won't output to the display without the cmake line. So the line must be doing other things or implementing the overlay in another way? Very new to zephyr and trying to understand what is going on here. I tried searching the documentation for anything related to setting the shield variable but couldn't find anything. What else is the shield variable doing and where can I find the documentation on this usage?

Thanks!


Also:
I noticed a weird behavior with the Vs Code extension. When *adding* a cmake line, you MUST add it in the cmakelists.txt file itself. Adding an entry in the 'Edit Build Configurations' menu has no effect. When *removing* a cmake line you must removing it from the file AND the 'Edit Build Configurations` menu, otherwise the line will persist on the next build. Very strange.
**Update**
Turns out you need to use a different syntax when adding the cmake line to the `Edit Build Configuration` menu: using `-DSHIELD:STRING="ssd1306_128x64"` works just fine to add and remove from the via the menu.

  • Hi Brian,

    The set command sets variables.

    ZEPHYR_BASE, BOARD, and SHIELD are specific zephyr variables used during the build system.

    SHIELD is another zephyr variable also known as “add-on” or “daughter boards”, attach to a board to extend its features. In Zephyr, the shield feature provides Zephyr-formatted shield descriptions for easier compatibility with applications.

    Shield configuration files are available in the board directory under /boards/shields/

    Shield overlay, kconfig and defconfig files are present in specific sheild folder. Sheild activation can be done by:
    either putting -DSHEILD argument in the build configuration
    or setting SHIELD variable through the set command.

    You can read more about shields here.

    Regards,

    Naeem

Related