From 2fd6d0e7e1074e72f2f4828677249b0c42c66f3a Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 25 Feb 2019 14:38:24 +0100 Subject: [PATCH] soc/software/bios/sdram: improve write_level robustness --- litex/soc/software/bios/sdram.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/litex/soc/software/bios/sdram.c b/litex/soc/software/bios/sdram.c index eb8dda03..d3d07583 100644 --- a/litex/soc/software/bios/sdram.c +++ b/litex/soc/software/bios/sdram.c @@ -277,13 +277,14 @@ int write_level(void) unsigned char taps_scan[ERR_DDRPHY_DELAY]; int one_window_active; - int one_window_start; + int one_window_start, one_window_best_start; + int one_window_count, one_window_best_count; int delays[NBMODULES]; - int ok; + int ok; - err_ddrphy_wdly = (ERR_DDRPHY_DELAY*14)/16 - ddrphy_half_sys8x_taps_read(); + err_ddrphy_wdly = ERR_DDRPHY_DELAY - ddrphy_half_sys8x_taps_read(); printf("Write leveling:\n"); @@ -291,12 +292,12 @@ int write_level(void) cdelay(100); for(i=0;i one_window_best_count) { + one_window_best_start = one_window_start; + one_window_best_count = one_window_count; + } + } } else { if (taps_scan[j]) { one_window_active = 1; @@ -339,7 +349,7 @@ int write_level(void) } } } - delays[i] = one_window_start; + delays[i] = one_window_best_start; /* configure write delay */ write_delay_rst(i); -- 2.30.2