1- import io
2- import time
31import os
4- import subprocess
5- import shutil
6- import zipfile
72import sys
83
9- import requests
4+ import wintertools .fs
5+ import wintertools .jlink
6+ import wintertools .circuitpython
7+ import wintertools .fw_fetch
8+ import wintertools .uf2_to_bin
109
11- from libwinter import utils
1210
1311DEVICE_NAME = "winterbloom_big_honking_button"
1412USB_DEVICE_ID = "239A:6005"
2523}
2624
2725FILES_TO_DEPLOY = {
28- utils . get_cache_path ("winterbloom_voltageio.py" ): "lib" ,
26+ wintertools . fs . cache_path ("winterbloom_voltageio.py" ): "lib" ,
2927 os .path .join (FIRMWARE_DIR , "winterbloom_bhb" ): "lib" ,
3028 os .path .join (ROOT_DIR , "samples" ): "." ,
3129 os .path .join (ROOT_DIR , "examples" ): "." ,
3836def program_firmware ():
3937 print ("========== PROGRAMMING FIRMWARE ==========" )
4038
41- bootloader_url = utils .find_latest_bootloader (DEVICE_NAME )
42- circuitpython_url = utils .find_latest_circuitpython (DEVICE_NAME )
39+ print ("Checking for latest bootloader & firmware..." )
4340
44- utils .download_file_to_cache (bootloader_url , "bootloader.bin" )
45- firmware_path = utils .download_file_to_cache (circuitpython_url , "firmware.uf2" )
46- utils .convert_uf2_to_bin (firmware_path )
41+ wintertools .fw_fetch .latest_bootloader (DEVICE_NAME )
42+ firmware_path = wintertools .fw_fetch .latest_circuitpython (DEVICE_NAME )
4743
48- utils .run_jlink (JLINK_DEVICE , JLINK_SCRIPT )
44+ wintertools .uf2_to_bin (firmware_path )
45+
46+ wintertools .jlink .run (JLINK_DEVICE , JLINK_SCRIPT )
4947
5048
5149def deploy_circuitpython_code (destination = None ):
5250 print ("========== DEPLOYING CODE ==========" )
5351
5452 if not destination :
5553 print ("Waiting for CIRCUITPY drive..." )
56- destination = utils .wait_for_drive ("CIRCUITPY" )
54+ destination = wintertools . fs .wait_for_drive ("CIRCUITPY" )
5755
5856 print ("Forcing BHB into repl (workaround for CircuitPython issue #3986)" )
59- utils .force_into_repl (USB_DEVICE_ID )
57+ wintertools . circuitpython .force_into_repl (USB_DEVICE_ID )
6058
6159 print ("Cleaning temporary files from src directories..." )
62- utils .clean_pycache (FIRMWARE_DIR )
63- utils .clean_pycache (EXAMPLES_DIR )
60+ wintertools .fs .clean_pycache (FIRMWARE_DIR )
61+ wintertools .fs .clean_pycache (EXAMPLES_DIR )
62+
6463 print ("Downloading files to cache..." )
65- utils .download_files_to_cache (FILES_TO_DOWNLOAD )
64+ wintertools . fs .download_files_to_cache (FILES_TO_DOWNLOAD )
6665 print ("Copying files..." )
67- utils .deploy_files (FILES_TO_DEPLOY , destination )
66+ wintertools . fs .deploy_files (FILES_TO_DEPLOY , destination )
6867
6968 print ("Done copying files, resetting..." )
70- utils .reset_via_serial (USB_DEVICE_ID )
69+ wintertools . circuitpython .reset_via_serial (USB_DEVICE_ID )
7170 print ("Done!" )
7271
7372
@@ -77,8 +76,8 @@ def main():
7776 return
7877
7978 try :
80- circuitpython_drive = utils .find_drive_by_name ("CIRCUITPY" )
81- except :
79+ circuitpython_drive = wintertools . fs .find_drive_by_name ("CIRCUITPY" )
80+ except EnvironmentError :
8281 circuitpython_drive = None
8382
8483 if not circuitpython_drive :
0 commit comments