From: Sebastien Bourdeauducq Date: Tue, 15 May 2012 17:29:26 +0000 (+0200) Subject: bios: automatically enable hardware memory controller and test memory X-Git-Tag: 24jan2021_ls180~3193 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b6aa40d8450b897d3bb1a0e2bae77da7e842cbb6;p=litex.git bios: automatically enable hardware memory controller and test memory --- diff --git a/software/bios/ddrinit.c b/software/bios/ddrinit.c index c4f4173f..84990ac1 100644 --- a/software/bios/ddrinit.c +++ b/software/bios/ddrinit.c @@ -19,6 +19,7 @@ #include #include +#include #include "ddrinit.h" @@ -42,8 +43,6 @@ static void init_sequence(void) { int i; - printf("Sending initialization sequence...\n"); - /* Bring CKE high */ setaddr(0x0000); CSR_DFII_BA_P0 = 0; @@ -172,11 +171,45 @@ void ddrwr(char *startaddr) CSR_DFII_COMMAND_P1 = DFII_COMMAND_CAS|DFII_COMMAND_WE|DFII_COMMAND_CS|DFII_COMMAND_WRDATA; } +#define TEST_SIZE (4*1024*1024) + +int memtest_silent(void) +{ + volatile unsigned int *array = (unsigned int *)SDRAM_BASE; + int i; + unsigned int prv; + + prv = 0; + for(i=0;i FLASH_OFFSET_REGULAR_BIOS); @@ -449,11 +451,16 @@ int main(int i, char **c) uart_init(); printf(banner); crcbios(); + if(rescue) + printf("Rescue mode\n"); print_mac(); - ddrinit(); + ddr_ok = ddrinit(); + if(ddr_ok) { + printf("Booting...\n"); + } else { + printf("Memory initialization failed\n"); + } - if(rescue) - printf("I: Booting in rescue mode\n"); while(1) { putsnonl("\e[1mBIOS>\e[0m "); diff --git a/software/include/hw/mem.h b/software/include/hw/mem.h new file mode 100644 index 00000000..b440a48e --- /dev/null +++ b/software/include/hw/mem.h @@ -0,0 +1,23 @@ +/* + * Milkymist SoC (Software) + * Copyright (C) 2012 Sebastien Bourdeauducq + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __HW_MEM_H +#define __HW_MEM_H + +#define SDRAM_BASE (0x40000000) + +#endif /* __HW_MEM_H */ diff --git a/tb/asmicon/asmicon_wb.py b/tb/asmicon/asmicon_wb.py index 28f6dc28..78aaddf6 100644 --- a/tb/asmicon/asmicon_wb.py +++ b/tb/asmicon/asmicon_wb.py @@ -10,18 +10,18 @@ from common import sdram_phy, sdram_geom, sdram_timing, DFILogger l2_size = 8192 # in bytes def my_generator(): + #for x in range(20): + #t = TWrite(x, x) + #yield t + #print(str(t) + " delay=" + str(t.latency)) for x in range(20): - t = TWrite(x, x) - yield t - print(str(t) + " delay=" + str(t.latency)) - for x in range(20): - t = TRead(x) - yield t - print(str(t) + " delay=" + str(t.latency)) - for x in range(20): - t = TRead(x+l2_size//4) + t = TRead(4194304//4 + x) yield t print(str(t) + " delay=" + str(t.latency)) + #for x in range(20): + #t = TRead(x+l2_size//4) + #yield t + #print(str(t) + " delay=" + str(t.latency)) def main(): controller = ASMIcon(sdram_phy, sdram_geom, sdram_timing)