Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tools/build/sdk_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,14 @@ def BuildJLinkLoadScript(main_env):
generate_uart_download_sh(main_env, device, memory, download_list)
generate_sftool_param(main_env, device, memory, download_file)

def get_baud_rate():
baud_rate = os.getenv("SIFLI_DOWNLOAD_BAUD_RATE", "").strip()
if baud_rate.isdigit():
rate_num = int(baud_rate)
if 115200 <= rate_num <= 3000000:
return f"-b {rate_num}"
return ""


def generate_uart_download_bat(main_env, device, memory, download_list, ImgDownUart_PATH):
uart_comment = '''@echo off
Expand Down Expand Up @@ -1815,7 +1823,7 @@ def generate_uart_download_bat(main_env, device, memory, download_list, ImgDownU
cd %CURR_PATH%
'''.format(ImgDownUart_PATH, main_env['JLINK_DEVICE']))
else:
uart_comment += MakeLine(f"sftool -p COM%input% -c {device} -m {memory.lower()} write_flash {download_list}\n")
uart_comment += MakeLine(f"sftool -p COM%input% {get_baud_rate()} -c {device} -m {memory.lower()} write_flash {download_list}\n")
uart_comment += MakeLine('if "%ENV_ROOT%"=="" pause\n')

uart_f = open(os.path.join(main_env['build_dir'], 'uart_download.bat'), 'w')
Expand Down Expand Up @@ -1893,7 +1901,7 @@ def generate_uart_download_sh(main_env, device, memory,download_list):
if os.getenv("LEGACY_ENV"):
uart_comment += MakeLine('echo "Legacy mode is not supported on Linux/macOS"')
else:
uart_comment += MakeLine(f'sftool -p "$input" -c {device} -m {memory.lower()} write_flash {download_list}\n')
uart_comment += MakeLine(f'sftool -p "$input" {get_baud_rate()} -c {device} -m {memory.lower()} write_flash {download_list}\n')

uart_sh_path = os.path.join(main_env['build_dir'], 'uart_download.sh')
uart_f = open(uart_sh_path, 'w')
Expand Down
10 changes: 9 additions & 1 deletion tools/sdk_py_actions/flash_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,16 @@ def flash_callback(

raise UsageError(f"Unsupported protocol: {protocol}")

def get_baud_rate():
baud_rate = os.getenv("SIFLI_DOWNLOAD_BAUD_RATE", "").strip()
if baud_rate.isdigit():
rate_num = int(baud_rate)
if 115200 <= rate_num <= 3000000:
return rate_num
return 1000000

def register(registry: CommandRegistry) -> None:
baud = get_baud_rate()
registry.command(
path="flash",
callback=flash_callback,
Expand All @@ -192,7 +200,7 @@ def register(registry: CommandRegistry) -> None:
"names": ["-b", "--baud"],
"help": "Baud rate for UART flash.",
"type": int,
"default": 1000000,
"default": baud,
},
{
"names": ["-d", "--device"],
Expand Down