I want to disable the CONFIG_APP_COMPILE_TIME_DATE flag so that the same code always generates the same binary file, regardless of when the code is compiled or recompiled.
I tried to use “pio run -t menuconfig” with no success.
This is what is happening:
Initially I have this configuration in sdkconfig:
#
# Application manager
#
CONFIG_APP_COMPILE_TIME_DATE=y
# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set
# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set
CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16
# end of Application manager
warning: ‘’ is not a valid value for the bool symbol APP_COMPILE_TIME_DATE (defined at packages/framework-espidf/components/app_update/Kconfig.projbuild:3). Assignment ignored.
On the sdkconfig, the flag is active again:
#
# Application manager
#
CONFIG_APP_COMPILE_TIME_DATE=y
# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set
# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set
CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16
# end of Application manager
On the Kconfig.projbuild I have:
config APP_COMPILE_TIME_DATE
bool "Use time/date stamp for app"
default y
help
If set, then the app will be built with the current time/date stamp. It is stored in the app description
structure. If not set, time/date stamp will be excluded from app image. This can be useful for getting the
same binary image files made from the same source, but at different times.
It looks like menuconfig is just activating flags. If a flag is not active, it returns to its default value.
If the default value is False, it works.
If the default value is True, as on the config flag APP_COMPILE_TIME_DATE, it can never be deactivate from the menuconfig.
Can you directly change this to equal n without going through menuconfig?
I don’t think it’ll be that easy to achieve a reproducable / deterministic build, but you can try. For example, if any code in there used __DATE__ or __TIME__, that’s the end of it. And also GCC itself adds some variation, as summarized here.
If I change manually the sdkconfig to “# CONFIG_APP_COMPILE_TIME_DATE is not set”, I can build the firmware.bin without the compile time and date. When I recompile, it always builds the same bin.
If I use the menuconfig again, the configuration is overwritten and the CONFIG_APP_COMPILE_TIME_DATE is active again.
The solution for now will be to restore the CONFIG_APP_COMPILE_TIME_DATE configuration in sdkconfig with a pre build script
Then this seems like a bug in the ESP-IDF menuconfig tool or the Kconfig description so that it emits CONFIG_APP_COMPILE_TIME_DATE= instead of a comment, aka no value at all. Have you checked back with Issues · espressif/esp-idf · GitHub?
All PlatformIO does is call into the ESP-IDF cmake target for menuconfig – not a whole lot is able to go wrong there. Then the Espressif tools and KConfig files take over.
Since the latest platform-espressif32 uses ESP-IDF v4.1, you can also use GitHub - espressif/esp-idf at release/v4.1 to setup a “native” ESP-IDF v4.1 environment and run menuconfig with your steps there. The bug should very likely still appear there; then Espressif would need to issue a bugfix-release for v4.1.