sftool_lib/sf32lb56/
ram_command.rs1use crate::common::ram_command::{CommandConfig, RamOps};
2use crate::common::sifli_debug::{SifliDebug, SifliUartCommand};
3use crate::sf32lb56::SF32LB56Tool;
4
5pub use crate::common::ram_command::{Command, DownloadStub, RamCommand, Response};
7
8impl RamCommand for SF32LB56Tool {
9 fn command(&mut self, cmd: Command) -> Result<Response, std::io::Error> {
10 RamOps::send_command_and_wait_response(&mut self.port, cmd, self.base.memory_type.as_str())
11 }
12
13 fn send_data(&mut self, data: &[u8]) -> Result<Response, std::io::Error> {
14 let config = CommandConfig {
15 compat_mode: self.base.compat,
16 ..Default::default()
17 };
18 RamOps::send_data_and_wait_response(&mut self.port, data, &config)
19 }
20}
21
22impl DownloadStub for SF32LB56Tool {
23 fn download_stub(&mut self) -> Result<(), std::io::Error> {
24 self.attempt_connect()?;
26 self.download_stub_impl()?;
27
28 std::thread::sleep(std::time::Duration::from_millis(100));
29 self.port.clear(serialport::ClearBuffer::All)?;
30 self.debug_command(SifliUartCommand::Exit)?;
31
32 if self.base.memory_type == "sd" {
34 RamOps::wait_for_shell_prompt(
36 &mut self.port,
37 b"sd0 OPEN success",
38 1000, 5, )
41 } else {
42 RamOps::wait_for_shell_prompt(
44 &mut self.port,
45 b"msh >",
46 200, 5, )
49 }
50 }
51}