Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/flight-software/boot.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's bring this into the pysquared repo. How about we create a new module inside of pysquared called boot and we can add this as a callable function from that module. It looks like the function might take 3 arguments: mount_points, wait_time, and attempts. Once it's in pysquared, we can write tests and reuse this in the other board repos.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import time

import storage

mount_points = [
"/sd",
]

wait_time = 0.02

storage.disable_usb_drive()
print("Disabling USB drive")
time.sleep(wait_time)

storage.mount("/", False)
print("Remounting root filesystem")
time.sleep(wait_time)

attempts = 0
while attempts < 5:
attempts += 1
try:
for path in mount_points:
try:
os.mkdir(path)
print(f"Mount point {path} created.")
except OSError:
print(f"Mount point {path} already exists.")
except Exception as e:
print(f"Error creating mount point {path}: {e}")
time.sleep(wait_time)
continue

break

storage.enable_usb_drive()
print("Enabling USB drive")
10 changes: 10 additions & 0 deletions src/flight-software/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from lib.pysquared.rtc.manager.microcontroller import MicrocontrollerManager
from lib.pysquared.sleep_helper import SleepHelper
from lib.pysquared.watchdog import Watchdog
from lib.pysquared.sd_card import SDCardManager
from version import __version__

boot_time: float = time.time()
Expand All @@ -45,6 +46,7 @@
(boot_count := Counter(index=Register.boot_count)).increment()
error_count: Counter = Counter(index=Register.error_count)


logger: Logger = Logger(
error_counter=error_count,
colorized=False,
Expand Down Expand Up @@ -77,6 +79,13 @@
board.SPI0_MISO,
)

sdCard: SDCardManager = SDCardManager(
spi0,
board.SPI0_CS1
)

logger.sd_card = sdCard

radio = RFM9xManager(
logger,
config.radio,
Expand All @@ -85,6 +94,7 @@
initialize_pin(logger, board.RF1_RST, digitalio.Direction.OUTPUT, True),
)


packet_manager = PacketManager(
logger,
radio,
Expand Down
8 changes: 8 additions & 0 deletions src/flight-software/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from lib.pysquared.rtc.manager.microcontroller import MicrocontrollerManager
from lib.pysquared.sleep_helper import SleepHelper
from lib.pysquared.watchdog import Watchdog
from lib.pysquared.sd_card import SDCardManager
from version import __version__

boot_time: float = time.time()
Expand Down Expand Up @@ -63,6 +64,13 @@
board.SPI0_MISO,
)

sdCard: SDCardManager = SDCardManager(
spi0,
board.SPI0_CS1
)

logger.sd_card = sdCard

radio = RFM9xManager(
logger,
config.radio,
Expand Down
Loading