From 6bbfee44e7bbf0781eef6a4eb3d5bbe25eaa19a9 Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Mon, 20 May 2024 16:23:41 +0200 Subject: [PATCH] [SC64][SW] Added inverted own address SDRAM tests --- sw/bootloader/src/test.c | 12 ++++++++---- sw/deployer/src/main.rs | 5 ++++- sw/deployer/src/sc64/mod.rs | 8 ++++++-- sw/deployer/src/sc64/types.rs | 7 +++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/sw/bootloader/src/test.c b/sw/bootloader/src/test.c index 0a661fd..0046c78 100644 --- a/sw/bootloader/src/test.c +++ b/sw/bootloader/src/test.c @@ -33,7 +33,9 @@ static uint32_t r_buffer[TEST_BUFFER_SIZE / sizeof(uint32_t)] __attribute__((ali static void fill_own_address (uint32_t *buffer, int size, uint32_t pattern, uint32_t offset) { for (int i = 0; i < (size / sizeof(uint32_t)); i++) { - buffer[i] = offset + (i * sizeof(uint32_t)); + uint32_t value = offset + (i * sizeof(uint32_t)); + value ^= pattern; + buffer[i] = value; } } @@ -361,13 +363,15 @@ static void test_sdram (void) { sdram_test_t phase_0_tests[] = { { .name = "Own address: ", .fill = fill_own_address, .pattern = 0x00000000, .fade = 0 }, + { .name = "Own address~: ", .fill = fill_own_address, .pattern = 0xFFFFFFFF, .fade = 0 }, { .name = "All zeros: ", .fill = fill_pattern, .pattern = 0x00000000, .fade = 0 }, { .name = "All ones: ", .fill = fill_pattern, .pattern = 0xFFFFFFFF, .fade = 0 }, { .name = "0xAAAA5555: ", .fill = fill_pattern, .pattern = 0xAAAA5555, .fade = 0 }, { .name = "0x5555AAAA: ", .fill = fill_pattern, .pattern = 0x5555AAAA, .fade = 0 }, - { .name = "Random (1/3): ", .fill = fill_random, .pattern = 0x00000000, .fade = 0 }, - { .name = "Random (2/3): ", .fill = fill_random, .pattern = 0x00000000, .fade = 0 }, - { .name = "Random (3/3): ", .fill = fill_random, .pattern = 0x00000000, .fade = 0 }, + { .name = "Random (1/4): ", .fill = fill_random, .pattern = 0x00000000, .fade = 0 }, + { .name = "Random (2/4): ", .fill = fill_random, .pattern = 0x00000000, .fade = 0 }, + { .name = "Random (3/4): ", .fill = fill_random, .pattern = 0x00000000, .fade = 0 }, + { .name = "Random (4/4): ", .fill = fill_random, .pattern = 0x00000000, .fade = 0 }, { .name = NULL }, }; diff --git a/sw/deployer/src/main.rs b/sw/deployer/src/main.rs index 360c1a2..15af878 100644 --- a/sw/deployer/src/main.rs +++ b/sw/deployer/src/main.rs @@ -887,13 +887,16 @@ fn handle_test_command(connection: Connection) -> Result<(), sc64::Error> { println!("{}: SDRAM (pattern)", "[SC64 Tests]".bold()); let sdram_pattern_tests = [ - (sc64::MemoryTestPattern::OwnAddress, None), + (sc64::MemoryTestPattern::OwnAddress(false), None), + (sc64::MemoryTestPattern::OwnAddress(true), None), (sc64::MemoryTestPattern::AllZeros, None), (sc64::MemoryTestPattern::AllOnes, None), (sc64::MemoryTestPattern::Custom(0xAAAA5555), None), (sc64::MemoryTestPattern::Custom(0x5555AAAA), None), (sc64::MemoryTestPattern::Random, None), (sc64::MemoryTestPattern::Random, None), + (sc64::MemoryTestPattern::Random, None), + (sc64::MemoryTestPattern::Random, None), (sc64::MemoryTestPattern::Custom(0x00010001), None), (sc64::MemoryTestPattern::Custom(0xFFFEFFFE), None), (sc64::MemoryTestPattern::Custom(0x00020002), None), diff --git a/sw/deployer/src/sc64/mod.rs b/sw/deployer/src/sc64/mod.rs index 82691f6..aa44584 100644 --- a/sw/deployer/src/sc64/mod.rs +++ b/sw/deployer/src/sc64/mod.rs @@ -759,9 +759,13 @@ impl SC64 { let mut test_data = vec![0u32; SDRAM_LENGTH / item_size]; match pattern { - MemoryTestPattern::OwnAddress => { + MemoryTestPattern::OwnAddress(inverted) => { for (index, item) in test_data.iter_mut().enumerate() { - *item = (index * item_size) as u32; + let mut value = (index * item_size) as u32; + if inverted { + value ^= 0xFFFFFFFFu32; + } + *item = value; } } MemoryTestPattern::AllZeros => test_data.fill(0x00000000u32), diff --git a/sw/deployer/src/sc64/types.rs b/sw/deployer/src/sc64/types.rs index 1bbe158..8699207 100644 --- a/sw/deployer/src/sc64/types.rs +++ b/sw/deployer/src/sc64/types.rs @@ -984,7 +984,7 @@ impl Display for DiagnosticData { } pub enum MemoryTestPattern { - OwnAddress, + OwnAddress(bool), AllZeros, AllOnes, Random, @@ -999,7 +999,10 @@ pub struct MemoryTestPatternResult { impl Display for MemoryTestPattern { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - MemoryTestPattern::OwnAddress => f.write_str("Own address"), + MemoryTestPattern::OwnAddress(inverted) => f.write_fmt(format_args!( + "Own address{}", + if *inverted { "~" } else { "" } + )), MemoryTestPattern::AllZeros => f.write_str("All zeros"), MemoryTestPattern::AllOnes => f.write_str("All ones"), MemoryTestPattern::Random => f.write_str("Random"),