diff --git a/src/lib/OPTIONS/options.cpp b/src/lib/OPTIONS/options.cpp index 20c50f90f6..645d47a4b9 100644 --- a/src/lib/OPTIONS/options.cpp +++ b/src/lib/OPTIONS/options.cpp @@ -26,7 +26,6 @@ const char *wifi_ap_address = "10.0.0.1"; // Discriminator value used to determine if the device has been reflashed and therefore // the SPIFSS settings are obsolete and the flashed settings should be used in preference -// If STM32, this contains part of the flashed UID used to determine if bind phrase flashed uint32_t flash_discriminator; #if !defined(TARGET_UNIFIED_TX) && !defined(TARGET_UNIFIED_RX) @@ -167,8 +166,11 @@ firmware_options_t firmwareOptions; bool options_init() { firmwareOptions = flashedOptions; - // Use the last 4 digits of the UID as the flash discriminator - flash_discriminator = flashedOptions.uid[2] << 24 | flashedOptions.uid[3] << 16 | flashedOptions.uid[4] << 8 | flashedOptions.uid[5]; +#if defined(TARGET_STM32) && defined(FLASH_DISCRIM) + // This is defined by the build_flags.py and used by STM32 (ESP gets it from json) + // It is always defined even though intellisense doesn't pick it up + flash_discriminator = FLASH_DISCRIM; +#endif return true; } diff --git a/src/python/build_flags.py b/src/python/build_flags.py index 44f9c591a6..4ba7d1577b 100644 --- a/src/python/build_flags.py +++ b/src/python/build_flags.py @@ -136,16 +136,17 @@ def get_git_sha(): def get_version(): return string_to_ascii(env.get('GIT_VERSION')) +json_flags['flash-discriminator'] = randint(1,2**32-1) + process_flags("user_defines.txt") process_flags("super_defines.txt") # allow secret super_defines to override user_defines version_to_env() build_flags.append("-DLATEST_COMMIT=" + get_git_sha()) build_flags.append("-DLATEST_VERSION=" + get_version()) build_flags.append("-DTARGET_NAME=" + re.sub("_VIA_.*", "", target_name)) +build_flags.append("-DFLASH_DISCRIM=" + str(json_flags['flash-discriminator'])) condense_flags() -json_flags['flash-discriminator'] = randint(1,2**32-1) - if '-DRADIO_SX127X=1' in build_flags: # disallow setting 2400s for 900 if fnmatch.filter(build_flags, '*-DRegulatory_Domain_ISM_2400') or \