diff --git a/platform.txt b/platform.txt index 99dc0a102..17cf913ab 100644 --- a/platform.txt +++ b/platform.txt @@ -109,8 +109,7 @@ recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf recipe.objcopy.zip.pattern="{tools.nrfutil.cmd}" dfu genpkg --dev-type 0x0052 --sd-req {build.sd_fwid} --application "{build.path}/{build.project_name}.hex" "{build.path}/{build.project_name}.zip" ## Create uf2 file -#recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" -recipe.objcopy.uf2.pattern=python "{runtime.platform.path}/tools/uf2conv/uf2_wrap.py" "{runtime.platform.path}/tools/uf2conv/uf2conv.py" "{build.board}" "{build.path}" "{build.source.path}" "{build.project_name}" +recipe.objcopy.uf2.pattern="{tools.python.cmd}" "{runtime.platform.path}/tools/uf2conv/uf2conv.py" -f 0xADA52840 -c -o "{build.path}/{build.project_name}.uf2" "{build.path}/{build.project_name}.hex" ## Save bin recipe.output.tmp_file_bin={build.project_name}.bin @@ -129,6 +128,14 @@ recipe.size.regex.data=^(?:\.data|\.bss)\s+([0-9]+).* recipe.output.tmp_file={build.project_name}.hex recipe.output.save_file={build.project_name}.{build.variant}.hex +#*************************************************** +# Select python executable on mac or windows +#*************************************************** + +tools.python.cmd=python +tools.python.cmd.windows=python.exe +tools.python.cmd.macosx=python3 + #*************************************************** # adafruit-nrfutil for uploading # https://github.com/adafruit/Adafruit_nRF52_nrfutil diff --git a/tools/uf2conv/uf2_wrap.py b/tools/uf2conv/uf2_wrap.py deleted file mode 100644 index 75b53337f..000000000 --- a/tools/uf2conv/uf2_wrap.py +++ /dev/null @@ -1,36 +0,0 @@ -import sys -import subprocess - - -def main(uf2_file: str, board_id: str, build_path: str, output_path: str, project_name: str): - if board_id == "TRACKER_T1000_E_LORAWAN": - try: - command = [ - "python", - uf2_file, - "-f", - "0xADA52840", - "-c", - "-o", - f"{output_path}/{project_name}.uf2", - f"{build_path}/{project_name}.hex", - ] - subprocess.run(command, check=True) - except subprocess.CalledProcessError as e: - print(f"Error executing uf2convert.py: {e}") - else: - print( - f"Skipping UF2 conversion for board '{board_id}'" - ) - - -if __name__ == "__main__": - if len(sys.argv) != 6: - print(sys.argv) - print( - "Usage: python script.py " - ) - sys.exit(1) - - uf2_file, board_id, build_path, output_path, project_name = sys.argv[1:] - main(uf2_file, board_id, build_path, output_path, project_name) diff --git a/tools/uf2conv/uf2conv.py b/tools/uf2conv/uf2conv.py index 4a1455e04..e6bf8c481 100644 --- a/tools/uf2conv/uf2conv.py +++ b/tools/uf2conv/uf2conv.py @@ -174,7 +174,7 @@ def get_drives(): "get", "DeviceID,", "VolumeName,", "FileSystem,", "DriveType"]) for line in r.split('\n'): - words = re.split('\s+', line) + words = re.split(r'\s+', line) if len(words) >= 3 and words[1] == "2" and words[2] == "FAT": drives.append(words[0]) else: