mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
Merge pull request #1566 from antmicro/msieron/sdram-read-spd-fix
liblitedram/sdram_spd: fix invalid buffer index
This commit is contained in:
commit
8b14e64906
1 changed files with 3 additions and 2 deletions
|
@ -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) {
|
bool sdram_read_spd(uint8_t spd, uint16_t addr, uint8_t *buf, uint16_t len, bool send_stop) {
|
||||||
uint8_t page;
|
uint8_t page;
|
||||||
uint16_t offset;
|
uint16_t offset;
|
||||||
uint16_t temp_len;
|
uint16_t temp_len, read_bytes = 0;
|
||||||
bool temp_send_stop = false;
|
bool temp_send_stop = false;
|
||||||
|
|
||||||
bool ok = true;
|
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;
|
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;
|
len -= temp_len;
|
||||||
|
read_bytes += temp_len;
|
||||||
addr += temp_len;
|
addr += temp_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue