Browse Source

chore: typo tweaks

pull/62/head
drbh 7 months ago
parent
commit
6648b17ccd
  1. 2
      src/commands/control.rs
  2. 6
      src/commands/mod.rs
  3. 2
      src/firmware.rs
  4. 4
      src/lib.rs
  5. 19
      src/main.rs
  6. 4
      src/operations.rs
  7. 2
      src/regs.rs

2
src/commands/control.rs

@ -180,7 +180,7 @@ impl Command for SetPower {
}
}
/// SDI print support, only avaliable for WCH-LinkE
/// SDI print support, only available for WCH-LinkE
/// Firmware version >= 2.10
#[derive(Debug)]
pub struct SetSDIPrintEnabled(pub bool);

6
src/commands/mod.rs

@ -205,7 +205,7 @@ impl Command for ConfigChip {
}
}
/// Get Chip UID, the UID is also avaliable in the `wchisp` command.
/// Get Chip UID, the UID is also available in the `wchisp` command.
// ??? 0x11, 0x01, _ (riscvchip)
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum GetChipInfo {
@ -280,7 +280,7 @@ pub enum Reset {
Soft, // the most common reset
Normal,
/// wlink_chip_reset, chip reset
// The memory is not reseted
// The memory is not reset
Chip,
}
impl Command for Reset {
@ -424,5 +424,5 @@ impl Command for DisableDebug {
// 81 FE 01 00 DisEncrypt
// 81 0D 01 0F ClearCodeFlashB
// 81 0D 02 08 xx ClearCodeFlash
// 81 11 01 0D unkown in query info, before GetChipRomRamSplit
// 81 11 01 0D unknown in query info, before GetChipRomRamSplit
// 81 0d 02 ee 00 stop flash ?

2
src/firmware.rs

@ -32,7 +32,7 @@ impl Section {
/// The abstract representation of a firmware image.
#[derive(Debug, Clone)]
pub enum Firmware {
/// A single section, with address unddefined.
/// A single section, with address undefined.
Binary(Vec<u8>),
/// Multiple sections, with different addresses.
Sections(Vec<Section>),

4
src/lib.rs

@ -41,7 +41,7 @@ pub enum RiscvChip {
CH59X = 0x0B, // 11
/// CH643 RISC-V4C series, RGB Display Driver MCU
CH643 = 0x0C, // 12
/// CH32X035 RISC-V4C USB-PD series, fallbak as CH643
/// CH32X035 RISC-V4C USB-PD series, fallback as CH643
CH32X035 = 0x0D, // 13
/// CH32L103 RISC-V4C low power series, USB-PD
CH32L103 = 0x0E, // 14
@ -143,7 +143,7 @@ impl RiscvChip {
log::warn!("The debug interface has been opened, there is a risk of code leakage.");
log::warn!("Please ensure that the debug interface has been closed before leaving factory!");
// 81 0d 01 04
// should test returen value
// should test return value
let resp = probe.send_command(commands::RawCommand::<0x0d>(vec![0x04]))?;
log::debug!("TODO, handle CH56X resp {:?}", resp);
}

19
src/main.rs

@ -139,7 +139,7 @@ enum Commands {
},
/// Debug, check status
Status {},
/// Swifth mode from RV to DAP or vice versa
/// Switch mode from RV to DAP or vice versa
ModeSwitch {
#[arg(long)]
rv: bool,
@ -300,7 +300,7 @@ fn main() -> Result<()> {
sess.reset_debug_module()?;
sess.ensure_mcu_halt()?;
will_detach = false; // detach will ersume the MCU
will_detach = false; // detach will resume the MCU
let dmstatus: regs::Dmstatus = sess.probe.read_dmi_reg()?;
log::info!("{dmstatus:#x?}");
@ -348,7 +348,7 @@ fn main() -> Result<()> {
}
Firmware::Sections(sections) => {
// Flash section by section
if address != None {
if address.is_some() {
log::warn!("--address is ignored when flashing ELF or ihex");
}
for section in sections {
@ -404,12 +404,12 @@ fn main() -> Result<()> {
ResetMode::Halt => {
sess.ensure_mcu_halt()?;
will_detach = false; // detach will ersume the MCU
will_detach = false; // detach will resume the MCU
}
ResetMode::Dm => {
sess.reset_debug_module()?;
will_detach = false; // detach will ersume the MCU
will_detach = false; // detach will resume the MCU
}
}
sleep(Duration::from_millis(300));
@ -449,11 +449,12 @@ fn main() -> Result<()> {
pub fn parse_number(s: &str) -> std::result::Result<u32, String> {
let s = s.replace('_', "").to_lowercase();
if let Some(hex_str) = s.strip_prefix("0x") {
Ok(u32::from_str_radix(hex_str, 16)
.unwrap_or_else(|_| panic!("error while parsering {s:?}")))
Ok(
u32::from_str_radix(hex_str, 16)
.unwrap_or_else(|_| panic!("error while parsing {s:?}")),
)
} else if let Some(bin_str) = s.strip_prefix("0b") {
Ok(u32::from_str_radix(bin_str, 2)
.unwrap_or_else(|_| panic!("error while parsering {s:?}")))
Ok(u32::from_str_radix(bin_str, 2).unwrap_or_else(|_| panic!("error while parsing {s:?}")))
} else {
Ok(s.parse().expect("must be a number"))
}

4
src/operations.rs

@ -56,7 +56,7 @@ impl ProbeSession {
if expected_chip.is_none() {
probe.send_command(commands::SetSpeed {
riscvchip: resp.chip_family as u8,
speed: speed,
speed,
})?;
}
@ -79,7 +79,7 @@ impl ProbeSession {
Ok(ProbeSession {
probe,
chip_family: chip_info.chip_family,
speed: speed,
speed,
})
}

2
src/regs.rs

@ -111,7 +111,7 @@ pub const CSRS: &[(&str, u16)] = &[
("corecfgr", 0xbc0),
];
/// Physical Memory Protection CSRs, only avaliable for QingkeV4
/// Physical Memory Protection CSRs, only available for QingkeV4
pub const PMP_CSRS: &[(&str, u16)] = &[
("pmpcfg0", 0x3A0),
("pmpaddr0", 0x3B0),

Loading…
Cancel
Save