Preserve RW_NVRAM section when doing a full image update

With our classical NVRAM solutions (CMOS and EC), NVRAM contents are
automatically preserved across firmware updates. Some FAFT tests and
possibly other processes rely on this. With the newly-introduced
flash-backed NVRAM (only on boards using updater5.sh, as far as I know),
recovery firmware updates that write the whole image will also overwrite
the NVRAM section (causing previous state to be lost and crossystem to
fail until after the next reboot since the section can only be properly
reinitialized from firmware).

Therefore, this patch introduces code to preserve the contents of the
RW_NVRAM section (if it exists), similar to what was already done with
the VPD and the GBB flags.

BUG=chrome-os-partner:47461
TEST=Run 'chromeos-firmwareupdate --mode=recovery' on Oak, confirm that
crossystem doesn't throw errors and still shows the same (non-default)
NVRAM contents as before the update. Run 'chromeos-firmwareupdate
--mode=recovery --debug' on Jerry, confirm that it still works and I
see "System doesn't have flash NVRAM. Skip." message.

Change-Id: I0ef9b04ead212d8dedb90b616a11a0d1f91f6905
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/319600
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
3 files changed