Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing Ham Fisted Over the Air Update Routines #4

Open
4 tasks
Mikefly123 opened this issue Jan 6, 2025 · 0 comments
Open
4 tasks

Implementing Ham Fisted Over the Air Update Routines #4

Mikefly123 opened this issue Jan 6, 2025 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Mikefly123
Copy link
Member

Mikefly123 commented Jan 6, 2025

What Should This New Feature Do?

It is unlikely that we are able to launch the satellite with all of the software perfectly configured for its mission. Even if we could, we might one day decide we want to change the way something works on orbit and therefore need the ability to send it a software update! Ideally there would be a fully update upload, verification, switchover, and fallback system that is implemented into the flight code, but for now we want to just see if we can use the tools that are already within the circuitpy_flight_software to force an update onto the satellite!

This is an issue to track developing code that can do the following:

  • Setup a command to be sent to a satellite.
  • Accept from the user a block of code that they would like to write to the satellite file system
  • Send that block of code to the satellite and have it written permanently into the file system
  • Attempt to execute that new code that is on the remote file system

How Might We Be Able to Do This?

Right now, within cdh.py there are a few command functions that will hopefully give us the tools to make this happen. Specifically, when the cdh.message_handler() function is called, one of the things it can result in is passing command args to:

def exec_cmd(cubesat, args):
    print(f"exec: {args}")
    exec(args)

Giving us the ability to execute strings as arbitrary blocks of code.

The hacker LMBFAO has indicated to us that the execution of the following code block should place the remote CircuitPy device into a mode where it is able to write to its own filesystem:

import storage
storage.remount("/", readonly=False, disable_concurrent_write_protection=True)

This will only set the file system to readonly=False for the current boot. To have the filesystem set to be writable at all times, we might need to do something like this:

with open("/boot.py", "w") as f:
  f.write("import storage\nstorage.disable_usb_drive()")
import microcontroller
microcontroller.reset()

What if We Had Access to the Target Device Itself?

For future implementations of Over the Air Updating we will want to try and improve cdh.py to have more helper functions that assist with the process of uplinking new code, verifying that will probably work, and then switching over. A quick Google search reveals at least one proposed implementation of this in the open source cOTA library.

@Mikefly123 Mikefly123 added enhancement New feature or request help wanted Extra attention is needed labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant