eive-tmtc/pus_tc/devs/ploc_upater.py

149 lines
5.2 KiB
Python
Raw Normal View History

2021-08-07 14:34:26 +02:00
# -*- coding: utf-8 -*-
"""
2021-08-20 08:40:18 +02:00
@file ploc_udpater.py
@brief Commands to initiate update transfer to ploc supervisor. This only updates the software of the MPSoC, it is not
possible to update the software of the supervisor.
2021-08-07 14:34:26 +02:00
The supervisor is programmed by Thales.
@author J. Meier
@date 10.07.2021
"""
import struct
from tmtccmd.config.definitions import QueueCommands
from tmtccmd.tc.packer import TcQueueT
2021-10-01 10:55:56 +02:00
from spacepackets.ecss.tc import PusTelecommand
2021-08-07 14:34:26 +02:00
latchup_id_dict = {
"0": "0.85V",
"1": "1.8V",
"2": "MISC",
"3": "3.3V",
"4": "NVM_4XO",
"5": "MISSION",
2022-01-18 14:03:56 +01:00
"6": "SAFECOTS",
2021-08-07 14:34:26 +02:00
}
class UpdaterActionIds:
2021-08-20 08:40:18 +02:00
UPDATE_A_UBOOT = 0
UPDATE_A_BITSTREAM = 1
UPDATE_A_LINUX = 2
UPDATE_A_APP_SW = 3
UPDATE_B_UBOOT = 4
UPDATE_B_BITSTREAM = 5
UPDATE_B_LINUX = 6
UPDATE_B_LINUX = 7
2021-08-07 14:34:26 +02:00
class ImagePathDefs:
2021-08-20 08:40:18 +02:00
imageAuboot = "/mnt/sd0/ploc/updateAuboot.bin"
imageAbitsream = "/mnt/sd0/ploc/updateAbitstream.bin"
imageAlinux = "/mnt/sd0/ploc/updateAlinux.bin"
imageAappsw = "/mnt/sd0/ploc/updateAappsw.bin"
imageBuboot = "/mnt/sd0/ploc/updateBuboot.bin"
imageBbitsream = "/mnt/sd0/ploc/updateBbitstream.bin"
imageBlinux = "/mnt/sd0/ploc/updateBlinux.bin"
imageBappsw = "/mnt/sd0/ploc/updateBappsw.bin"
2021-08-07 14:34:26 +02:00
2022-01-18 14:03:56 +01:00
def pack_ploc_updater_test_into(
object_id: bytearray, tc_queue: TcQueueT, op_code: str
) -> TcQueueT:
2021-08-07 14:34:26 +02:00
tc_queue.appendleft(
2022-01-18 14:03:56 +01:00
(
QueueCommands.PRINT,
"Testing PLOC updater with object id: 0x" + object_id.hex(),
)
2021-08-07 14:34:26 +02:00
)
if op_code == "0":
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Update uboot on partition A")
)
command = (
object_id
+ struct.pack("!I", UpdaterActionIds.UPDATE_A_UBOOT)
+ bytearray(ImagePathDefs.imageAuboot, "utf-8")
)
2021-08-07 14:34:26 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
2021-08-08 15:02:29 +02:00
if op_code == "1":
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Update bitstream on parition A")
)
command = (
object_id
+ struct.pack("!I", UpdaterActionIds.UPDATE_A_BITSTREAM)
+ bytearray(ImagePathDefs.imageAbitsream, "utf-8")
)
2021-08-08 15:02:29 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "2":
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Update linux on partition A")
)
command = (
object_id
+ struct.pack("!I", UpdaterActionIds.UPDATE_A_LINUX)
+ bytearray(ImagePathDefs.imageAlinux, "utf-8")
)
2021-08-08 15:02:29 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "3":
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Update application on partition A")
)
command = (
object_id
+ struct.pack("!I", UpdaterActionIds.UPDATE_A_APP_SW)
+ bytearray(ImagePathDefs.imageAappsw, "utf-8")
)
2021-08-20 08:40:18 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=33, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "4":
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Update uboot on partition B")
)
command = (
object_id
+ struct.pack("!I", UpdaterActionIds.UPDATE_B_UBOOT)
+ bytearray(ImagePathDefs.imageBuboot, "utf-8")
)
2021-08-20 08:40:18 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "5":
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Update bitstream on parition B")
)
command = (
object_id
+ struct.pack("!I", UpdaterActionIds.UPDATE_B_BITSTREAM)
+ bytearray(ImagePathDefs.imageBbitsream, "utf-8")
)
2021-08-20 08:40:18 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "6":
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Update linux on partition B")
)
command = (
object_id
+ struct.pack("!I", UpdaterActionIds.UPDATE_B_LINUX)
+ bytearray(ImagePathDefs.imageBlinux, "utf-8")
)
2021-08-20 08:40:18 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "7":
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Update application on partition B")
)
command = (
object_id
+ struct.pack("!I", UpdaterActionIds.UPDATE_B_APP_SW)
+ bytearray(ImagePathDefs.imageBappsw, "utf-8")
)
2021-08-08 15:02:29 +02:00
command = PusTelecommand(service=8, subservice=128, ssc=33, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())