Platformio not see external changes in .c/.h

I am using platformio+vscode c esp32/arduino on CYD(Cheap Yellow Display). I use LVGL for the GUI and the interface files are generated by EEZ. In general, it is not that important.

The point is this: some of the build files are generated by an external program and put into src/ui. These are the usual .h and .c files. But platformio doesn’t see changes in these files until I run Full Clean (regular clean doesn’t help). I get the usual compilation errors when I reference non-existent entities, e.g.

src/main.cpp: In function ‘void action_editor_uni(lv_event_t*)’:
src/main.cpp:393:37: error: ‘objects_t’ {aka ‘struct _objects_t’} has no member named ‘profile_prev_button’; did you mean ‘profile_editor’?
Serial.println((uintptptr_t)objects.profile_prev_button);
^~~~~~~~~~~~~~~~~~~
profile_editor
*** [.pio/build/esp-cyd/src/main.cpp.o] Error 1

But objects.profile_prev_button absolutely exists, I can see it if I go to src/ui/screen.c file with the editor. However, I guess it doesn’t exist in .pio/build/esp-cyd/src/ui/screen.o, because screen.o is built from a previous version of screen.c, and platformio for some reason doesn’t see the change in src/ui/screen.c and doesn’t think it’s necessary to rebuild the object file. Full Clean solves the problem, but it is inconvenient for me to download all the libraries again and rebuild the project completely every time I change the interface, even though one file has changed.

Can you tell me what I should do in this situation?

What is this external program? Where does it come from, what does it do?

This is all very difficult to understand.

Can you provide the content of your platformio.ini and the smallest possible example so that this can be reproduced?

I copy the files into the folder with a bash script.


[env:esp-cyd]
platform = espressif32
board = esp32dev
framework = arduino
board_upload.flash_size = 4MB
monitor_filters = esp32_exception_decoder, colorize, time

debug_init_break = tbreak setup
debug_tool = esp-prog


board_build.partitions = 4MB_OTA_FACTORY.csv
    
upload_speed = 921600
               
upload_port = /dev/cu.wch*
monitor_port = /dev/cu.wch*
monitor_speed = 115200


lib_deps =
    bblanchon/ArduinoJson@^7.0.4
    knolleary/PubSubClient@^2.8
    lib/modbus-esp8266-4.1.1/src
    src/ui
	SD
	FS
	SPI
    lib/lvgl-9.1.0
    bodmer/TFT_eSPI@^2.5.34
    https://github.com/PaulStoffregen/XPT2046_Touchscreen.git#v1.4

build_flags =
    -DLV_CONF_SKIP
    -DLV_USE_DEMO_WIDGETS
    -DLV_USE_TFT_ESPI
    -DUSER_SETUP_LOADED
    -DUSE_HSPI_PORT
    -DTFT_MISO=12
    -DTFT_MOSI=13
    -DTFT_SCLK=14
    -DTFT_CS=15
    -DTFT_DC=2
    -DTFT_RST=-1
    -DTFT_BL=-1
    -DTFT_BACKLIGHT_ON=HIGH
    -DSPI_FREQUENCY=55000000
    -DSPI_READ_FREQUENCY=20000000
    -DSPI_TOUCH_FREQUENCY=2500000
    -DILI9341_2_DRIVER
    -DTOUCH_CS=33

build_src_filter =
  +<*>
  -<.git/>
  -<.svn/>

Reproducing the behavior should be easy:
1)echo “uint8_t test=0;” > src/ui/test.h
2)add “lib_deps = src/ui” in .ini
3)add “#include <test.h>” to the code and try to use the variable “Serial.print(test);”
4)In my project it will not be found until full clean is executed

Thanks for providing your platformio.ini which explains the issues you have.

You’re lib_deps contains several errors:

  • src/ui is wrong, please remove this
  • SD, FS and SPI are builtin libraries provided by the Arduino Framework and are also wrong here. Please remove them

You can also remove

build_src_filter =
  +<*>
  -<.git/>
  -<.svn/>

Wrong as stated above

That’s where the issue occours.
Either you include it by #include "ui/test.h" or put the test.h it in the include folder and include it simly by #include "test.h"

The file ./src/ui/test.h is not a library, but it is part of your source files.

Yeah, I guess that’s it. Now I can see changes in files right after exporting them with a graphical editor. Thank you very much!

1 Like