From 6a38e83ff674a6f34dcc5701921ac80d0ae6d3eb Mon Sep 17 00:00:00 2001 From: Michal Sieron Date: Thu, 12 Jan 2023 13:47:38 +0100 Subject: [PATCH] liblitedram/sdram_spd: fix invalid buffer index Signed-off-by: Michal Sieron --- litex/soc/software/liblitedram/sdram_spd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/litex/soc/software/liblitedram/sdram_spd.c b/litex/soc/software/liblitedram/sdram_spd.c index 4f07b4616..9101b7734 100644 --- a/litex/soc/software/liblitedram/sdram_spd.c +++ b/litex/soc/software/liblitedram/sdram_spd.c @@ -31,7 +31,7 @@ static bool sdram_select_spd_page(uint8_t page) { bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool send_stop) { uint8_t page; uint16_t offset; - uint16_t temp_len; + uint16_t temp_len, read_bytes = 0; bool temp_send_stop = false; bool ok = true; @@ -48,8 +48,9 @@ bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool temp_len = len; } - ok &= i2c_read(SPD_RW_ADDR(spd), offset, &buf[page * SDRAM_SPD_PAGE_SIZE], len, temp_send_stop, 1); + ok &= i2c_read(SPD_RW_ADDR(spd), offset, &buf[read_bytes], len, temp_send_stop, 1); len -= temp_len; + read_bytes += temp_len; addr += temp_len; }