~increscent/rk3128-brom

a960b33b7a6a287ba53af8915f5a31f4cd31c071 — Robert Williams 2 months ago fa29de5
Different memory tests
1 files changed, 18 insertions(+), 8 deletions(-)

M uart/uart.rs
M uart/uart.rs => uart/uart.rs +18 -8
@@ 34,18 34,28 @@ pub extern "C" fn main() {
    uart_puts("Hello, world!\n");

    const WORDS: u32 = 0x1_0000;
    const VALUE: u32 = 0x5C5C5C5C;
    const WRITES: u32 = 1;
    const VALUE1: u32 = 0x5A5A5A5A;
    const VALUE2: u32 = 0xA5A5A5A5;

    for i in 0..WORDS {
        bits::write((DRAM_TEST_BASE + i * 4) as *mut u32, VALUE);
    for _ in 0..WRITES {
        for i in 0..WORDS {
            bits::write((DRAM_TEST_BASE + i * 4) as *mut u32, VALUE1);
        }

        for i in 0..WORDS {
            bits::write((DRAM_TEST_BASE + i * 4) as *mut u32, VALUE2);
        }
    }

    busy_wait();
    busy_wait(0xFFFF);

    for i in 0..WORDS {
        let val = bits::read((DRAM_TEST_BASE + i * 4) as *mut u32);
        if val != VALUE {
            uart_putsx("Oh No! ", val);
        if val != VALUE2 {
            uart_puts("Bad Read! Addr: ");
            uart_putx(DRAM_TEST_BASE + i);
            uart_putsx(" Value: ", val);
        }
    }



@@ 137,8 147,8 @@ fn uart_putsx(s: &str, x: u32) {
    uart_puts("\n");
}

fn busy_wait() {
    for _ in 0..0xFFFF {
fn busy_wait(ops: u32) {
    for _ in 0..ops {
        unsafe {
            core::arch::asm!("nop");
        }