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 RamOps::send_command_and_wait_response(&mut self.port, cmd, self.base.memory_type.as_str())
12 }
13
14 fn send_data(&mut self, data: &[u8]) -> Result<Response> {
15 let config = CommandConfig {
16 compat_mode: self.base.compat,
17 ..Default::default()
18 };
19 RamOps::send_data_and_wait_response(&mut self.port, data, &config)
20 }
21}
22
23impl DownloadStub for SF32LB56Tool {
24 fn download_stub(&mut self) -> Result<()> {
25 self.attempt_connect()?;
27 self.download_stub_impl()?;
28
29 std::thread::sleep(std::time::Duration::from_millis(100));
30 self.port.clear(serialport::ClearBuffer::All)?;
31 self.debug_command(SifliUartCommand::Exit)?;
32
33 if self.base.memory_type == "sd" {
35 RamOps::wait_for_shell_prompt(
37 &mut self.port,
38 b"sd0 OPEN success",
39 1000, 5, )
42 } else {
43 RamOps::wait_for_shell_prompt(
45 &mut self.port,
46 b"msh >",
47 200, 5, )
50 }
51 }
52}