aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/cbfstool/cbfstool.h1
-rw-r--r--util/cbfstool/util.c10
2 files changed, 11 insertions, 0 deletions
diff --git a/util/cbfstool/cbfstool.h b/util/cbfstool/cbfstool.h
index dc52bfb16b..5804fdef50 100644
--- a/util/cbfstool/cbfstool.h
+++ b/util/cbfstool/cbfstool.h
@@ -56,6 +56,7 @@ struct rom {
/* Function prototypes */
/* util.c */
+void flashinit(void *ptr, size_t len);
int open_rom(struct rom *rom, const char *filename);
int create_rom(struct rom *rom, const unsigned char *filename, int size,
const char *bootblockname, int bootblocksize,
diff --git a/util/cbfstool/util.c b/util/cbfstool/util.c
index b36e9187a0..f0c0b293cf 100644
--- a/util/cbfstool/util.c
+++ b/util/cbfstool/util.c
@@ -25,6 +25,13 @@
#include <sys/mman.h>
#include "cbfstool.h"
+int uninitialized_flash_value = 0xff;
+
+void flashinit(void *ptr, size_t len)
+{
+ memset(ptr, uninitialized_flash_value, len);
+}
+
int get_size(const char *size)
{
char *next;
@@ -203,6 +210,9 @@ int create_rom(struct rom *rom, const unsigned char *filename,
return -1;
}
+ /* mmap'ed pages are by default zero-filled. Fix that. */
+ flashinit(rom->ptr, romsize);
+
/* This is a pointer to the header for easy access */
rom->header = (struct cbfs_header *)
ROM_PTR(rom, rom->size - 16 - bootblocksize - sizeof(struct cbfs_header));