Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/sim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ jobs:
features:
- "sig-ecdsa,sig-ecdsa-mbedtls,sig-ed25519,enc-kw,bootstrap"
- "sig-rsa,sig-rsa3072,overwrite-only,validate-primary-slot,swap-move,swap-offset"
- "enc-rsa,enc-rsa max-align-32"
- "enc-aes256-rsa,enc-aes256-rsa max-align-32"
- "enc-ec256,enc-ec256 overwrite-only validate-primary-slot max-align-16,enc-ec256 max-align-32"
- "enc-aes256-ec256,enc-aes256-ec256 max-align-32"
- "enc-x25519,enc-x25519 max-align-32"
- "enc-aes256-x25519,enc-aes256-x25519 max-align-32"
- "enc-rsa,enc-rsa max-align-32,enc-rsa max-align-64,enc-rsa max-align-128"
- "enc-aes256-rsa,enc-aes256-rsa max-align-32,enc-aes256-rsa max-align-64,enc-aes256-rsa max-align-128"
- "enc-ec256,enc-ec256 overwrite-only validate-primary-slot max-align-16,enc-ec256 max-align-32,enc-ec256 max-align-64,enc-ec256 max-align-128"
- "enc-aes256-ec256,enc-aes256-ec256 max-align-32,enc-aes256-ec256 max-align-64,enc-aes256-ec256 max-align-128"
- "enc-x25519,enc-x25519 max-align-32,enc-x25519 max-align-64,enc-x25519 max-align-128"
- "enc-aes256-x25519,enc-aes256-x25519 max-align-32,enc-aes256-x25519 max-align-64,enc-aes256-x25519 max-align-128"
- "sig-rsa overwrite-only,sig-ecdsa overwrite-only,sig-ecdsa-mbedtls overwrite-only,multiimage overwrite-only"
- "sig-rsa validate-primary-slot,sig-ecdsa validate-primary-slot,sig-ecdsa-mbedtls validate-primary-slot,sig-rsa multiimage validate-primary-slot"
- "enc-kw overwrite-only,enc-kw overwrite-only max-align-32"
- "enc-rsa overwrite-only,enc-rsa overwrite-only max-align-32"
- "enc-aes256-kw overwrite-only,enc-aes256-kw overwrite-only max-align-32"
- "enc-kw overwrite-only,enc-kw overwrite-only max-align-32,enc-kw overwrite-only max-align-64,enc-kw overwrite-only max-align-128"
- "enc-rsa overwrite-only,enc-rsa overwrite-only max-align-32,enc-rsa overwrite-only max-align-64,enc-rsa overwrite-only max-align-128"
- "enc-aes256-kw overwrite-only,enc-aes256-kw overwrite-only max-align-32,enc-aes256-kw overwrite-only max-align-64,enc-aes256-kw overwrite-only max-align-128"
- "sig-rsa enc-rsa validate-primary-slot,swap-move enc-rsa sig-rsa validate-primary-slot bootstrap,swap-offset enc-rsa sig-rsa validate-primary-slot bootstrap"
- "sig-rsa enc-kw validate-primary-slot bootstrap,sig-ed25519 enc-x25519 validate-primary-slot"
- "sig-ecdsa enc-kw validate-primary-slot"
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
- "ram-load enc-aes256-kw multiimage"
- "ram-load enc-aes256-kw sig-ecdsa-mbedtls multiimage"
- "custom-crypto,custom-crypto overwrite-only,custom-crypto validate-primary-slot,custom-crypto swap-offset"
- "custom-enc-crypto,custom-enc-crypto validate-primary-slot,custom-enc-crypto swap-offset validate-primary-slot max-align-32"
- "custom-enc-crypto,custom-enc-crypto validate-primary-slot,custom-enc-crypto swap-offset validate-primary-slot max-align-32,custom-enc-crypto swap-offset validate-primary-slot max-align-64,custom-enc-crypto swap-offset validate-primary-slot max-align-128"
runs-on: ubuntu-latest
env:
MULTI_FEATURES: ${{ matrix.features }}
Expand Down
2 changes: 1 addition & 1 deletion boot/bootutil/include/bootutil/bootutil_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ extern "C" {
#ifdef MCUBOOT_BOOT_MAX_ALIGN

#if defined(MCUBOOT_SWAP_USING_MOVE) || defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_OFFSET)
_Static_assert(MCUBOOT_BOOT_MAX_ALIGN >= 8 && MCUBOOT_BOOT_MAX_ALIGN <= 32,
_Static_assert(MCUBOOT_BOOT_MAX_ALIGN >= 8 && MCUBOOT_BOOT_MAX_ALIGN <= 128,
"Unsupported value for MCUBOOT_BOOT_MAX_ALIGN for SWAP upgrade modes");
#endif

Expand Down
4 changes: 2 additions & 2 deletions docs/imgtool.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ primary slot and adds a header and trailer that the bootloader is expecting:
--public-key-format [hash|full]
In what format to add the public key to the
image manifest: full key or hash of the key.
--max-align [8|16|32] Maximum flash alignment. Set if flash
--max-align [8|16|32|64|128] Maximum flash alignment. Set if flash
alignment of the primary and secondary slot
differ and any of them is larger than 8.
--align [1|2|4|8|16|32] Alignment used by swap update modes.
--align [1|2|4|8|16|32|64|128] Alignment used by swap update modes.
-v, --version TEXT [required]
-s, --security-counter TEXT Specify the value of security counter. Use
the `auto` keyword to automatically generate
Expand Down
2 changes: 1 addition & 1 deletion scripts/imgtool/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ def _trailer_size(self, write_size, max_sectors, overwrite_only, enckey,
if overwrite_only:
return self.max_align * 2 + magic_align_size
else:
if write_size not in set([1, 2, 4, 8, 16, 32]):
if write_size not in set([1, 2, 4, 8, 16, 32, 64, 128]):
raise click.BadParameter(f"Invalid alignment: {write_size}")
m = DEFAULT_MAX_SECTORS if max_sectors is None else max_sectors
trailer = m * 3 * write_size # status area
Expand Down
5 changes: 3 additions & 2 deletions scripts/imgtool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,12 @@ def convert(self, value, param, ctx):
help='Specify the value of security counter. Use the `auto` '
'keyword to automatically generate it from the image version.')
@click.option('-v', '--version', callback=validate_version, required=True)
@click.option('--align', type=click.Choice(['1', '2', '4', '8', '16', '32']),
@click.option('--align', type=click.Choice(['1', '2', '4', '8', '16', '32',
'64', '128']),
default='1',
required=False,
help='Alignment used by swap update modes.')
@click.option('--max-align', type=click.Choice(['8', '16', '32']),
@click.option('--max-align', type=click.Choice(['8', '16', '32','64', '128']),
required=False,
help='Maximum flash alignment. Set if flash alignment of the '
'primary and secondary slot differ and any of them is larger '
Expand Down
2 changes: 2 additions & 0 deletions sim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ direct-xip = ["mcuboot-sys/direct-xip"]
downgrade-prevention = ["mcuboot-sys/downgrade-prevention"]
max-align-16 = ["mcuboot-sys/max-align-16"]
max-align-32 = ["mcuboot-sys/max-align-32"]
max-align-64 = ["mcuboot-sys/max-align-64"]
Comment thread
URNHere marked this conversation as resolved.
max-align-128 = ["mcuboot-sys/max-align-128"]
hw-rollback-protection = ["mcuboot-sys/hw-rollback-protection"]
check-load-addr = ["mcuboot-sys/check-load-addr"]
custom-crypto = ["mcuboot-sys/custom-crypto"]
Expand Down
6 changes: 6 additions & 0 deletions sim/mcuboot-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ max-align-16 = []
# Support images with 32-byte maximum write alignment value.
max-align-32 = []

# Support images with 64-byte maximum write alignment value.
max-align-64 = []

# Support images with 128-byte maximum write alignment value.
max-align-128 = []

# Use logical sectors. Enable exactly one of the sized features; each
# implies the `logical-sectors` umbrella that code can test against
# without caring about the size.
Expand Down
8 changes: 7 additions & 1 deletion sim/mcuboot-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ fn main() {
let direct_xip = env::var("CARGO_FEATURE_DIRECT_XIP").is_ok();
let max_align_16 = env::var("CARGO_FEATURE_MAX_ALIGN_16").is_ok();
let max_align_32 = env::var("CARGO_FEATURE_MAX_ALIGN_32").is_ok();
let max_align_64 = env::var("CARGO_FEATURE_MAX_ALIGN_64").is_ok();
let max_align_128 = env::var("CARGO_FEATURE_MAX_ALIGN_128").is_ok();
let hw_rollback_protection = env::var("CARGO_FEATURE_HW_ROLLBACK_PROTECTION").is_ok();
let check_load_addr = env::var("CARGO_FEATURE_CHECK_LOAD_ADDR").is_ok();
let custom_crypto = env::var("CARGO_FEATURE_CUSTOM_CRYPTO").is_ok();
Expand All @@ -56,7 +58,11 @@ fn main() {
conf.conf.define("MCUBOOT_HAVE_ASSERT_H", None);
conf.conf.define("MCUBOOT_MAX_IMG_SECTORS", Some("128"));

if max_align_32 {
if max_align_128 {
conf.conf.define("MCUBOOT_BOOT_MAX_ALIGN", Some("128"));
} else if max_align_64 {
conf.conf.define("MCUBOOT_BOOT_MAX_ALIGN", Some("64"));
} else if max_align_32 {
conf.conf.define("MCUBOOT_BOOT_MAX_ALIGN", Some("32"));
} else if max_align_16 {
conf.conf.define("MCUBOOT_BOOT_MAX_ALIGN", Some("16"));
Expand Down
45 changes: 43 additions & 2 deletions sim/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,26 @@ impl ImagesBuilder {
flash.insert(dev_id, dev);
(flash, Rc::new(areadesc), &[Caps::SwapUsingScratch, Caps::OverwriteUpgrade, Caps::SwapUsingMove, Caps::RamLoad, Caps::DirectXip])
}
DeviceName::RA6M3 => {
// Renesas Flash: 8 sectors of 8K, 30 sectors of 32K (1MB variant).
let dev = SimFlash::new(vec![
//First 8 sectors of 8K (64K), these are usually used to store mcuboot
8 * 1024, 8 * 1024, 8 * 1024, 8 * 1024, 8 * 1024, 8 * 1024, 8 * 1024, 8 * 1024,
//Next 30 sectors of 32K (960K), these are usually used to store the images
32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024,
32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024,
32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024, 32*1024 ],
align as usize, erased_val);
let dev_id = 0;
let mut areadesc = AreaDesc::new();
areadesc.add_flash_sectors(dev_id, &dev);
areadesc.add_image(0x020000, 0x020000, FlashId::Image0, dev_id);
areadesc.add_image(0x040000, 0x020000, FlashId::Image1, dev_id);
areadesc.add_image(0x060000, 0x020000, FlashId::ImageScratch, dev_id);
let mut flash = SimMultiFlash::new();
flash.insert(dev_id, dev);
(flash, Rc::new(areadesc), &[Caps::SwapUsingMove, Caps::SwapUsingOffset])
}
}
}

Expand Down Expand Up @@ -2713,7 +2733,7 @@ pub struct SlotInfo {
pub dev_id: u8,
}

#[cfg(all(not(feature = "max-align-16"), not(feature = "max-align-32")))]
#[cfg(all(not(feature = "max-align-16"), not(feature = "max-align-32"), not(feature = "max-align-64"), not(feature = "max-align-128")))]
const MAGIC: &[u8] = &[0x77, 0xc2, 0x95, 0xf3,
0x60, 0xd2, 0xef, 0x7f,
0x35, 0x52, 0x50, 0x0f,
Expand All @@ -2731,6 +2751,18 @@ const MAGIC: &[u8] = &[0x20, 0x00, 0x2d, 0xe1,
0x8d, 0x77, 0x67, 0x9c,
0x11, 0x0f, 0x1f, 0x8a];

#[cfg(feature = "max-align-64")]
const MAGIC: &[u8] = &[0x40, 0x00, 0x2d, 0xe1,
0x5d, 0x29, 0x41, 0x0b,
0x8d, 0x77, 0x67, 0x9c,
0x11, 0x0f, 0x1f, 0x8a];

#[cfg(feature = "max-align-128")]
const MAGIC: &[u8] = &[0x80, 0x00, 0x2d, 0xe1,
0x5d, 0x29, 0x41, 0x0b,
0x8d, 0x77, 0x67, 0x9c,
0x11, 0x0f, 0x1f, 0x8a];

// Replicates defines found in bootutil.h
const BOOT_MAGIC_GOOD: Option<u8> = Some(1);
const BOOT_MAGIC_UNSET: Option<u8> = Some(3);
Expand Down Expand Up @@ -2808,7 +2840,7 @@ pub fn show_sizes() {
}
}

#[cfg(all(not(feature = "max-align-16"), not(feature = "max-align-32")))]
#[cfg(all(not(feature = "max-align-16"), not(feature = "max-align-32"),not(feature = "max-align-64"), not(feature = "max-align-128")))]
fn test_alignments() -> &'static [usize] {
&[1, 2, 4, 8]
}
Expand All @@ -2823,6 +2855,15 @@ fn test_alignments() -> &'static [usize] {
&[32]
}

#[cfg(feature = "max-align-64")]
fn test_alignments() -> &'static [usize] {
&[64]
}

#[cfg(feature = "max-align-128")]
fn test_alignments() -> &'static [usize] {
&[128]
}
/// For testing, some of the tests are quite slow. This will query for an
/// environment variable `MCUBOOT_SKIP_SLOW_TESTS`, which can be set to avoid
/// running these tests.
Expand Down
4 changes: 3 additions & 1 deletion sim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct Args {
#[derive(Copy, Clone, Debug, Deserialize)]
pub enum DeviceName {
Stm32f4, Stm32f4SpiFlash, Stm32f769, K64f, K64fBig, K64fMulti, Nrf52840, Nrf52840SpiFlash,
Nrf52840UnequalSlots, Nrf52840UnequalSlotsLargerSlot1,PSOCEdgeE8x, SmallPages,
Nrf52840UnequalSlots, Nrf52840UnequalSlotsLargerSlot1, PSOCEdgeE8x, SmallPages, RA6M3,
}

pub static ALL_DEVICES: &[DeviceName] = &[
Expand All @@ -80,6 +80,7 @@ pub static ALL_DEVICES: &[DeviceName] = &[
DeviceName::Nrf52840UnequalSlotsLargerSlot1,
DeviceName::PSOCEdgeE8x,
DeviceName::SmallPages,
DeviceName::RA6M3
];

impl fmt::Display for DeviceName {
Expand All @@ -97,6 +98,7 @@ impl fmt::Display for DeviceName {
DeviceName::Nrf52840UnequalSlotsLargerSlot1 => "Nrf52840UnequalSlotsLargerSlot1",
DeviceName::PSOCEdgeE8x => "PSOCEdgeE8x",
DeviceName::SmallPages => "smallpages",
DeviceName::RA6M3 => "RA6M3",
};
f.write_str(name)
}
Expand Down
Loading