Files
firmware/test/end2end/flash.py

59 lines
1.5 KiB
Python
Raw Normal View History

2024-08-25 15:27:59 -05:00
# trunk-ignore-all(bandit/B404)
2024-08-25 13:41:58 -05:00
import subprocess
2024-08-25 15:27:59 -05:00
import usb.core
2024-08-25 13:41:58 -05:00
def find_usb_device(vendor_id, product_id):
# Find USB devices
dev = usb.core.find(find_all=True)
# Loop through devices, printing vendor and product ids in decimal and hex
for cfg in dev:
if cfg.idVendor == vendor_id and cfg.idProduct == product_id:
return cfg
return None
2024-08-25 15:27:59 -05:00
2024-08-25 13:41:58 -05:00
# Flash esp32 target
def flash_esp32(pio_env, port):
2024-08-25 15:27:59 -05:00
# trunk-ignore(bandit/B603)
# trunk-ignore(bandit/B607)
subprocess.run(
["platformio", "run", "-e", pio_env, "-t", "upload", "--upload-port", port]
)
2024-08-25 13:41:58 -05:00
def flash_nrf52(pio_env, port):
2024-08-26 16:34:28 -05:00
# trunk-ignore(bandit/B603)
# trunk-ignore(bandit/B607)
subprocess.run(
["platformio", "run", "-e", pio_env, "-t", "upload", "--upload-port", port]
)
def find_usb_device(vendor_id, product_id):
# Find USB devices
dev = usb.core.find(find_all=True)
# Loop through devices, printing vendor and product ids in decimal and hex
for cfg in dev:
if cfg.idVendor == vendor_id and cfg.idProduct == product_id:
return cfg
return None
# Flash esp32 target
def flash_esp32(pio_env, port):
# trunk-ignore(bandit/B603)
# trunk-ignore(bandit/B607)
subprocess.run(
["platformio", "run", "-e", pio_env, "-t", "upload", "--upload-port", port]
)
def flash_nrf52(pio_env, port):
2024-08-25 15:27:59 -05:00
# trunk-ignore(bandit/B603)
# trunk-ignore(bandit/B607)
subprocess.run(
["platformio", "run", "-e", pio_env, "-t", "upload", "--upload-port", port]
)