Skip to content

Commit b2ca18d

Browse files
chrisrukgrega
authored andcommitted
Allow use of own custom firmware
If user creates directory called 'data/' where they run their Python script from and places following files in: * firmware.bin * signature.bin * version This custom firmware will then be used instead of bundled firmware.
1 parent dd6ee6d commit b2ca18d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

buildhat/devices.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ def __init__(self, port):
7272
def _setup(**kwargs):
7373
if Device._instance:
7474
return
75-
data = os.path.join(os.path.dirname(sys.modules["buildhat"].__file__), "data/")
75+
if (
76+
os.path.isdir(os.path.join(os.getcwd(), "data/"))
77+
and os.path.isfile(os.path.join(os.getcwd(), "data", "firmware.bin"))
78+
and os.path.isfile(os.path.join(os.getcwd(), "data", "signature.bin"))
79+
and os.path.isfile(os.path.join(os.getcwd(), "data", "version"))
80+
):
81+
data = os.path.join(os.getcwd(), "data/")
82+
else:
83+
data = os.path.join(os.path.dirname(sys.modules["buildhat"].__file__), "data/")
7684
firm = os.path.join(data, "firmware.bin")
7785
sig = os.path.join(data, "signature.bin")
7886
ver = os.path.join(data, "version")

0 commit comments

Comments
 (0)