import storage import board import digitalio # --- Configuration --- # Set up the two pins we want to check pin16 = digitalio.DigitalInOut(board.IO16) pin16.direction = digitalio.Direction.INPUT pin16.pull = digitalio.Pull.UP pin17 = digitalio.DigitalInOut(board.IO17) pin17.direction = digitalio.Direction.INPUT pin17.pull = digitalio.Pull.UP # --- Logic --- # By default, the pull-up resistors hold the pins HIGH (True). # If we short a pin to GND, its value will become LOW (False). # We check if BOTH pins are HIGH. # If they are, it's a "normal boot," so we hide the drive. if pin16.value and pin17.value: print("Normal boot: Disabling CIRCUITPY drive.") storage.disable_usb_drive() else: # One of the pins was LOW (grounded), so we # enable the drive for maintenance. print("Storage boot: CIRCUITPY drive is ENABLED.") # We don't need to call storage.enable_usb_drive() # because it's enabled by default. # Clean up the pins so they can be used in code.py if needed pin16.deinit() pin17.deinit() # The boot.py file finishes, and CircuitPython will # either mount the drive or not, based on what we did. # After this, code.py will run.