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