Skip to content

Commit

Permalink
Fix STM32 flashing with same bind phrase
Browse files Browse the repository at this point in the history
  • Loading branch information
CapnBry committed Jan 24, 2024
1 parent 5c2451a commit b0ec402
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/lib/OPTIONS/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/python/build_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit b0ec402

Please sign in to comment.