CalgaryToSpace / CTS-SAT-1-OBC-Firmware

Firmware for the CTS-SAT-1 ("FrontierSat") mission. Runs on the STM32-based Onboard Computer.
MIT License
4 stars 0 forks source link

MPI over-the-air firmware upgrade #18

Open DeflateAwning opened 4 months ago

DeflateAwning commented 4 months ago

Telecommand 1: uplink chunk of new MPI firmware

Function must write the incoming data to the "arg 2" byte address in a file in the filesystem.

Telecommand 2: check hash of new MPI firmware

Telecommand 3: flash MPI with a specific MPI firmware file

This telecommand must also verify the hash before flashing.

JohnathanBurchill commented 1 month ago

Wondering how to write MPI firmware bytes to a specific location in a file in the filesystem.

Looking at the lfs functions, the write and seek functions zero-pad if the requested position is beyond the current file size.

Would this be sensible?

For every page,

  1. lfs_file_open for appending
  2. lfs_file_seek to the target address
  3. lfs_file_write the transmitted bytes
  4. lfs_file_close, and, possibly lfs_file_sync

Prior to flashing to the MPI, lfs_file_truncate to the target file size (rather than doing this for each page). Or do this first, in which case the first telecommand would be for target address 0.

DeflateAwning commented 1 month ago

Totally out of curiousity, did your work-in-progress solution read the response from the MPI after each page/chunk was transmitted, or did it just "fire-hose" data towards the MPI?

JohnathanBurchill commented 1 month ago

I'm reading the text response each time. Eventually we should just check for a hash response. This so far is between the terminal and the dev kit, no MPI.

I've gotten writing to memory working, sort of. The first page gets written, then the dev kit hangs on the second one. LFS writing is very slow. Needs troubleshooting.

DeflateAwning commented 1 month ago

Good insight! I'll investigate the LFS speed issue (I've noticed it too); just created Issue #57 to track the progress of the LFS performance assessment and improvements.