From: Simon Glass <sjg@chromium.org>
Date: Sat, 6 Feb 2021 16:57:34 +0000 (-0700)
Subject: sandbox: Write out bloblist when exiting
X-Git-Tag: v2025.01-rc5-pxa1908~1941^2~13^2~12
X-Git-Url: http://git.dujemihanovic.xyz/img/login.html?a=commitdiff_plain;h=1c52fcca72b9338c1dd205520a83d1a954d3316a;p=u-boot.git

sandbox: Write out bloblist when exiting

Sandbox provides a way to write out its emulated memory on exit. This
makes it possible to pass a bloblist from one phase (e.g. SPL) to the
next.

However the bloblist is not closed off, so the checksum is generally
invalid. Fix this by finishing up the bloblist before writing the memory
file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index 4ffaf16378..f63cfd38ee 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <bloblist.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <log.h>
@@ -398,8 +399,12 @@ int state_uninit(void)
 {
 	int err;
 
+	log_info("Writing sandbox state\n");
 	state = &main_state;
 
+	/* Finish the bloblist, so that it is correct before writing memory */
+	bloblist_finish();
+
 	if (state->write_ram_buf) {
 		err = os_write_ram_buf(state->ram_buf_fname);
 		if (err) {