update flashloader
This commit is contained in:
parent
71fa3c5820
commit
0df05d8fba
@ -2,16 +2,15 @@
|
|||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
from spacepackets.ecss.defs import PusService
|
from spacepackets.ecss.defs import PusService
|
||||||
from spacepackets.ecss.tm import PusTm
|
from spacepackets.ecss.tm import PusTm
|
||||||
from tmtccmd.com import ComInterface
|
|
||||||
import toml
|
import toml
|
||||||
import struct
|
import struct
|
||||||
import logging
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
import time
|
import time
|
||||||
import enum
|
import enum
|
||||||
from tmtccmd.com.serial_base import SerialCfg
|
from com_interface import ComInterface
|
||||||
from tmtccmd.com.serial_cobs import SerialCobsComIF
|
from com_interface.serial_base import SerialCfg
|
||||||
from tmtccmd.com.ser_utils import prompt_com_port
|
from com_interface.serial_cobs import SerialCobsComIF
|
||||||
from crcmod.predefined import PredefinedCrc
|
from crcmod.predefined import PredefinedCrc
|
||||||
from spacepackets.ecss.tc import PusTc
|
from spacepackets.ecss.tc import PusTc
|
||||||
from spacepackets.ecss.pus_verificator import PusVerificator, StatusField
|
from spacepackets.ecss.pus_verificator import PusVerificator, StatusField
|
||||||
@ -101,15 +100,7 @@ class ImageLoader:
|
|||||||
)
|
)
|
||||||
self.verificator.add_tc(action_tc)
|
self.verificator.add_tc(action_tc)
|
||||||
self.com_if.send(bytes(action_tc.pack()))
|
self.com_if.send(bytes(action_tc.pack()))
|
||||||
data_available = self.com_if.data_available(0.4)
|
self.await_for_command_copletion("boot image selection command")
|
||||||
if not data_available:
|
|
||||||
_LOGGER.warning("no reply received for boot image selection command")
|
|
||||||
for reply in self.com_if.receive():
|
|
||||||
result = self.verificator.add_tm(
|
|
||||||
Service1Tm.from_tm(PusTm.unpack(reply, 0), UnpackParams(0))
|
|
||||||
)
|
|
||||||
if result is not None and result.completed:
|
|
||||||
_LOGGER.info("received boot image selection command confirmation")
|
|
||||||
|
|
||||||
def handle_ping_cmd(self):
|
def handle_ping_cmd(self):
|
||||||
_LOGGER.info("Sending ping command")
|
_LOGGER.info("Sending ping command")
|
||||||
@ -122,16 +113,26 @@ class ImageLoader:
|
|||||||
)
|
)
|
||||||
self.verificator.add_tc(ping_tc)
|
self.verificator.add_tc(ping_tc)
|
||||||
self.com_if.send(bytes(ping_tc.pack()))
|
self.com_if.send(bytes(ping_tc.pack()))
|
||||||
|
self.await_for_command_copletion("ping command")
|
||||||
|
|
||||||
data_available = self.com_if.data_available(0.4)
|
def await_for_command_copletion(self, context: str):
|
||||||
if not data_available:
|
done = False
|
||||||
_LOGGER.warning("no ping reply received")
|
now = time.time()
|
||||||
|
while time.time() - now < 2.0:
|
||||||
|
if not self.com_if.data_available():
|
||||||
|
time.sleep(0.2)
|
||||||
|
continue
|
||||||
for reply in self.com_if.receive():
|
for reply in self.com_if.receive():
|
||||||
result = self.verificator.add_tm(
|
result = self.verificator.add_tm(
|
||||||
Service1Tm.from_tm(PusTm.unpack(reply, 0), UnpackParams(0))
|
Service1Tm.from_tm(PusTm.unpack(reply, 0), UnpackParams(0))
|
||||||
)
|
)
|
||||||
if result is not None and result.completed:
|
if result is not None and result.completed:
|
||||||
_LOGGER.info("received ping completion reply")
|
_LOGGER.info(f"received {context} reply")
|
||||||
|
done = True
|
||||||
|
if done:
|
||||||
|
break
|
||||||
|
if not done:
|
||||||
|
_LOGGER.warning(f"no {context} reply received")
|
||||||
|
|
||||||
def handle_corruption_cmd(self, target: Target):
|
def handle_corruption_cmd(self, target: Target):
|
||||||
if target == Target.BOOTLOADER:
|
if target == Target.BOOTLOADER:
|
||||||
@ -300,12 +301,12 @@ def main() -> int:
|
|||||||
if "serial_port" in parsed_toml:
|
if "serial_port" in parsed_toml:
|
||||||
serial_port = parsed_toml["serial_port"]
|
serial_port = parsed_toml["serial_port"]
|
||||||
if serial_port is None:
|
if serial_port is None:
|
||||||
serial_port = prompt_com_port()
|
serial_port = input("Please specify the serial port manually: ")
|
||||||
serial_cfg = SerialCfg(
|
serial_cfg = SerialCfg(
|
||||||
com_if_id="ser_cobs",
|
com_if_id="ser_cobs",
|
||||||
serial_port=serial_port,
|
serial_port=serial_port,
|
||||||
baud_rate=BAUD_RATE,
|
baud_rate=BAUD_RATE,
|
||||||
serial_timeout=0.1,
|
polling_frequency=0.1,
|
||||||
)
|
)
|
||||||
verificator = PusVerificator()
|
verificator = PusVerificator()
|
||||||
com_if = SerialCobsComIF(serial_cfg)
|
com_if = SerialCobsComIF(serial_cfg)
|
||||||
|
@ -1 +1 @@
|
|||||||
serial_port = "/dev/ttyUSB0"
|
serial_port = "/dev/ttyUSB1"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
spacepackets == 0.24
|
spacepackets == 0.28
|
||||||
tmtccmd == 8.0.2
|
com-interface == 0.1
|
||||||
toml == 0.10
|
toml == 0.10
|
||||||
pyelftools == 0.31
|
pyelftools == 0.31
|
||||||
crcmod == 1.7
|
crcmod == 1.7
|
||||||
|
@ -451,7 +451,7 @@ mod app {
|
|||||||
cx.local.encoded_buf[send_size + 1] = 0;
|
cx.local.encoded_buf[send_size + 1] = 0;
|
||||||
cx.local
|
cx.local
|
||||||
.uart_tx
|
.uart_tx
|
||||||
.write(&cx.local.encoded_buf[0..send_size + 2])
|
.write_all(&cx.local.encoded_buf[0..send_size + 2])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
occupied_len -= 1;
|
occupied_len -= 1;
|
||||||
Mono::delay(2.millis()).await;
|
Mono::delay(2.millis()).await;
|
||||||
|
@ -1149,8 +1149,7 @@ impl RxWithInterrupt {
|
|||||||
let mut result = IrqResultMaxSizeOrTimeout::default();
|
let mut result = IrqResultMaxSizeOrTimeout::default();
|
||||||
|
|
||||||
let irq_status = self.0.regs.read_irq_status();
|
let irq_status = self.0.regs.read_irq_status();
|
||||||
let irq_enabled = self.0.regs.read_irq_enabled();
|
let rx_enabled = self.0.regs.read_enable().rx();
|
||||||
let rx_enabled = irq_enabled.rx();
|
|
||||||
|
|
||||||
// Half-Full interrupt. We have a guaranteed amount of data we can read.
|
// Half-Full interrupt. We have a guaranteed amount of data we can read.
|
||||||
if irq_status.rx() {
|
if irq_status.rx() {
|
||||||
@ -1187,8 +1186,8 @@ impl RxWithInterrupt {
|
|||||||
// While there is data in the FIFO, write it into the reception buffer
|
// While there is data in the FIFO, write it into the reception buffer
|
||||||
match self.0.read() {
|
match self.0.read() {
|
||||||
Ok(byte) => {
|
Ok(byte) => {
|
||||||
buf[result.bytes_read] = byte;
|
buf[context.rx_idx] = byte;
|
||||||
result.bytes_read += 1;
|
context.rx_idx += 1;
|
||||||
}
|
}
|
||||||
Err(_) => break,
|
Err(_) => break,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user