boot.py
 1  # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
 2  # SPDX-License-Identifier: MIT
 3  """
 4  CircuitPython Essentials Storage CP Filesystem boot.py file
 5  
 6  REMOVE THIS LINE AND ALL TEXT BELOW BEFORE SUBMITTING TO GITHUB.
 7  This file is specific to boards like ESP32-S2/S3 where the boot button is used for bootloader and
 8  safe mode, and therefore the button must be pressed at the right time to get into readonly mode.
 9  
10  There are two things to be updated in this file to match your board:
11  * Update OBJECT_PIN to match the pin name to which the button or pin is attached.
12  * Update UP_OR_DOWN to match the Pull necessary for the chosen pin.
13  
14  For example:
15  If using the boot button on a QT Py ESP32-S2, OBJECT_PIN to BUTTON.
16  
17  For example:
18  If using the boot button on a QT Py ESP32-S2, update UP_OR_DOWN to UP.
19  """
20  import time
21  import board
22  import digitalio
23  import storage
24  import neopixel
25  
26  pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
27  
28  button = digitalio.DigitalInOut(board.OBJECT_PIN)
29  button.switch_to_input(pull=digitalio.Pull.UP_OR_DOWN)
30  
31  # Turn the NeoPixel white for one second to indicate when to press the boot button.
32  pixel.fill((255, 255, 255))
33  time.sleep(1)
34  
35  # If the button is connected to ground, the filesystem is writable by CircuitPython
36  storage.remount("/", readonly=button.value)