From f8a32a1cfa4aaa01a1b75b17f6e47d6ae3055d26 Mon Sep 17 00:00:00 2001 From: Maximilian Brune Date: Tue, 20 Jan 2026 18:23:35 +0100 Subject: [PATCH] include/fmap.h: Require FMAP_FLASH_SIZE == CONFIG_ROM_SIZE In our current tree this is always the case. The coreboot code (as far as I know) doesn't have a hard requirement on that. But if these values differ then it is usually always a mistake made by the programmer and it is hard to catch since the value don't really depend on each other. So until a time in which there comes a platform which needs a flashmap that doesn't cover the whole flash, this check is introduced. For that purpose we need to replace the default .config file for tests, because otherwise the check won't match. The config file that is used now is based on the fact that we use the same mainboard for the `.config` as for the `fmap_config.h` in `tests/include/tests/lib/fmap/fmap_config.h` Signed-off-by: Maximilian Brune Change-Id: I8bc05a17a2630516ede949660b4fc428f199f3ab Reviewed-on: https://review.coreboot.org/c/coreboot/+/90264 Reviewed-by: Jakub "Kuba" Czapiga Tested-by: build bot (Jenkins) --- src/include/fmap.h | 8 ++++++++ tests/Makefile.common | 2 +- tests/include/tests/lib/fmap_config.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/include/fmap.h b/src/include/fmap.h index 900bfff542..1fadaef3c5 100644 --- a/src/include/fmap.h +++ b/src/include/fmap.h @@ -13,6 +13,14 @@ #error "FMAP must always start flash address 0" #endif +/* This is usually the case. And it can to lead to confusion if one them is updated without the + * other. There is however no code that has a hard dependency on this check. So if there comes + * a platform at some point, which has a Flashmap which doesn't cover the whole flash, we can + * remove the check again. */ +#if FMAP_SECTION_FLASH_SIZE != CONFIG_ROM_SIZE + #error "ROM_SIZE must always be equal to FMAP flash size" +#endif + /* Return the name of the boot region. Falls back to COREBOOT, if not overridden * by any multi-slot mechanism (e.g Intel Top Swap, vboot). */ const char *cbfs_fmap_region_hint(void); diff --git a/tests/Makefile.common b/tests/Makefile.common index cfb6fe945e..085e4cffc4 100644 --- a/tests/Makefile.common +++ b/tests/Makefile.common @@ -18,7 +18,7 @@ CMAKE := cmake OBJCOPY ?= objcopy OBJDUMP ?= objdump -TEST_DEFAULT_CONFIG ?= $(top)/configs/config.emulation_qemu_x86_i440fx +TEST_DEFAULT_CONFIG ?= $(top)/configs/config.google_octopus_spi_flash_console TEST_DOTCONFIG := $(testobj)/.config TEST_KCONFIG_AUTOHEADER := $(testobj)/config.src.h TEST_KCONFIG_AUTOCONFIG := $(testobj)/auto.conf diff --git a/tests/include/tests/lib/fmap_config.h b/tests/include/tests/lib/fmap_config.h index 5b3540020b..690ee19fca 100644 --- a/tests/include/tests/lib/fmap_config.h +++ b/tests/include/tests/lib/fmap_config.h @@ -8,5 +8,6 @@ * Keeps the build tests from failing since fmap.h needs fmap_config.h */ #define FMAP_SECTION_FLASH_START 0 +#define FMAP_SECTION_FLASH_SIZE 0x1000000 #endif