From 912f356650e182dd9bfa1922d601faa9b39930dd Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Sun, 21 Jul 2024 20:15:44 +0200 Subject: [PATCH] [SC64][SW] Added USB speed test --- sw/deployer/src/main.rs | 9 +++++++++ sw/deployer/src/sc64/mod.rs | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/sw/deployer/src/main.rs b/sw/deployer/src/main.rs index f538822..dd4aa9a 100644 --- a/sw/deployer/src/main.rs +++ b/sw/deployer/src/main.rs @@ -890,6 +890,15 @@ fn handle_firmware_command( fn handle_test_command(connection: Connection) -> Result<(), sc64::Error> { let mut sc64 = init_sc64(connection, false)?; + println!("{}: USB", "[SC64 Tests]".bold()); + + print!(" Performing USB speed test... "); + stdout().flush().unwrap(); + + let (read_speed, write_speed) = sc64.test_usb_speed()?; + + println!("Read speed: {read_speed:.2} MiB/s, Write speed: {write_speed:.2} MiB/s"); + println!("{}: SDRAM (pattern)", "[SC64 Tests]".bold()); let sdram_pattern_tests = [ diff --git a/sw/deployer/src/sc64/mod.rs b/sw/deployer/src/sc64/mod.rs index 181db2f..2b1a721 100644 --- a/sw/deployer/src/sc64/mod.rs +++ b/sw/deployer/src/sc64/mod.rs @@ -752,6 +752,22 @@ impl SC64 { } } + pub fn test_usb_speed(&mut self) -> Result<(f64, f64), Error> { + const TEST_ADDRESS: u32 = SDRAM_ADDRESS; + const TEST_LENGTH: usize = SDRAM_LENGTH; + const MIB_DIVIDER: f64 = 1024.0 * 1024.0; + + let read_time = std::time::Instant::now(); + let data = self.command_memory_read(TEST_ADDRESS, TEST_LENGTH)?; + let read_speed = (TEST_LENGTH as f64 / MIB_DIVIDER) / read_time.elapsed().as_secs_f64(); + + let write_time = std::time::Instant::now(); + self.command_memory_write(TEST_ADDRESS, &data)?; + let write_speed = (TEST_LENGTH as f64 / MIB_DIVIDER) / write_time.elapsed().as_secs_f64(); + + Ok((read_speed, write_speed)) + } + pub fn test_sdram_pattern( &mut self, pattern: MemoryTestPattern,