diff --git a/sim/Cargo.toml b/sim/Cargo.toml index d1cce968..3b42e363 100644 --- a/sim/Cargo.toml +++ b/sim/Cargo.toml @@ -14,6 +14,7 @@ validate-primary-slot = ["mcuboot-sys/validate-primary-slot"] enc-rsa = ["mcuboot-sys/enc-rsa"] enc-kw = ["mcuboot-sys/enc-kw"] bootstrap = ["mcuboot-sys/bootstrap"] +multiimage = ["mcuboot-sys/multiimage"] [dependencies] libc = "0.2.0" diff --git a/sim/mcuboot-sys/Cargo.toml b/sim/mcuboot-sys/Cargo.toml index 37dba5e2..8071ba1b 100644 --- a/sim/mcuboot-sys/Cargo.toml +++ b/sim/mcuboot-sys/Cargo.toml @@ -33,6 +33,9 @@ enc-kw = [] # Allow bootstrapping an empty/invalid primary slot from a valid secondary slot bootstrap = [] +# Support multiple images (currently 2 instead of 1). +multiimage = [] + [build-dependencies] cc = "1.0.25" diff --git a/sim/mcuboot-sys/build.rs b/sim/mcuboot-sys/build.rs index 088b4709..4e293ad4 100644 --- a/sim/mcuboot-sys/build.rs +++ b/sim/mcuboot-sys/build.rs @@ -17,6 +17,7 @@ fn main() { let enc_rsa = env::var("CARGO_FEATURE_ENC_RSA").is_ok(); let enc_kw = env::var("CARGO_FEATURE_ENC_KW").is_ok(); let bootstrap = env::var("CARGO_FEATURE_BOOTSTRAP").is_ok(); + let multiimage = env::var("CARGO_FEATURE_MULTIIMAGE").is_ok(); let mut conf = cc::Build::new(); conf.define("__BOOTSIM__", None); @@ -24,6 +25,7 @@ fn main() { conf.define("MCUBOOT_USE_FLASH_AREA_GET_SECTORS", None); conf.define("MCUBOOT_HAVE_ASSERT_H", None); conf.define("MCUBOOT_MAX_IMG_SECTORS", Some("128")); + conf.define("MCUBOOT_IMAGE_NUMBER", Some(if multiimage { "2" } else { "1" })); if bootstrap { conf.define("MCUBOOT_BOOTSTRAP", None); diff --git a/sim/mcuboot-sys/csupport/generated_dts_board.h b/sim/mcuboot-sys/csupport/generated_dts_board.h index 01c56caa..f5e11f89 100644 --- a/sim/mcuboot-sys/csupport/generated_dts_board.h +++ b/sim/mcuboot-sys/csupport/generated_dts_board.h @@ -12,5 +12,7 @@ #define DT_FLASH_AREA_IMAGE_0_ID 1 #define DT_FLASH_AREA_IMAGE_1_ID 2 #define DT_FLASH_AREA_IMAGE_SCRATCH_ID 3 +#define DT_FLASH_AREA_IMAGE_2_ID 4 +#define DT_FLASH_AREA_IMAGE_3_ID 5 #endif /*__GENERATED_DTS_BOARD_H__*/