forked from dbisu/pico-ducky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.py
61 lines (47 loc) · 1.49 KB
/
boot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import storage
import usb_cdc
import usb_midi
from board import *
from digitalio import DigitalInOut, Pull
# import configuration
try:
from pd.config import config
except ImportError:
print(
"Using default configuration (config_default.py). To use your own settings copy as config.py and modify to taste."
)
from pd.config_default import config
# change the drive's label
def changeDriveLabel(name):
storage.remount("/", readonly=False)
storage.getmount("/").label = name
storage.remount("/", readonly=True)
# check if provided pin is grounded
def isPinGrounded(pin):
checkPin = DigitalInOut(pin)
checkPin.switch_to_input(pull=Pull.UP)
return not checkPin.value
# boilerplate
print("")
print("Configuration")
print("--------------------------------")
print(" > Drive Label =", config["driveLabel"])
print(" > disable CDC =", config["stealth"]["disableCDC"])
print(" > disable MIDI =", config["stealth"]["disableMIDI"])
print("--------------------------------")
# change drive label
changeDriveLabel(config["driveLabel"])
# check GP15 for stealth mode
if isPinGrounded(GP15):
print("GP15 is grounded")
if config["stealth"]["disableCDC"]:
print(" -> disabling CDC...")
usb_cdc.disable()
if config["stealth"]["disableMIDI"]:
print(" -> disabling MIDI...")
usb_midi.disable()
print(" -> disabling USB drive...")
storage.disable_usb_drive()
else:
# normal boot
print("GP15 not grounded => USB drive enabled")