Skip to content

Commit

Permalink
[SC64][SW] Added USB speed test
Browse files Browse the repository at this point in the history
  • Loading branch information
Polprzewodnikowy committed Jul 21, 2024
1 parent 631f140 commit 912f356
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sw/deployer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
16 changes: 16 additions & 0 deletions sw/deployer/src/sc64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 912f356

Please sign in to comment.