From: Toni Wilen Date: Tue, 7 Sep 2021 16:15:36 +0000 (+0300) Subject: NVRAM write wraparound fix. X-Git-Tag: 4900~75 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=70eb11c61b46cc474df1eb188c7b35fc9eb2e275;p=francis%2Fwinuae.git NVRAM write wraparound fix. --- diff --git a/flashrom.cpp b/flashrom.cpp index 62defd7b..75138a72 100644 --- a/flashrom.cpp +++ b/flashrom.cpp @@ -333,8 +333,18 @@ static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c) #if EEPROM_LOG write_log(_T("I2C STOP\n")); #endif - if (i2c->write_offset >= 0) - nvram_write(i2c, i2c->write_offset, 16); + if (i2c->write_offset >= 0) { + int len = i2c->size - i2c->write_offset; + if (len > 16) { + len = 16; + } + if (len > 0) { + nvram_write(i2c, i2c->write_offset, len); + } + if (len < 16) { + nvram_write(i2c, 0, 16 - len); + } + } i2c->write_offset = -1; i2c->current_addr = -1; i2c->state = STOPPED;