Lines Matching +full:0 +full:- +full:dev
1 // Copyright (c) 2019-2021 Linaro LTD
2 // Copyright (c) 2019-2020 JUUL Labs
3 // Copyright (c) 2019-2023 Arm Limited
5 // SPDX-License-Identifier: Apache-2.0
57 /// For testing, use a non-zero offset for the ram-load, to make sure the offset is getting used
83 /// When doing multi-image, there is an instance of this information for
91 /// The Rust-side representation of an image. For unencrypted images, this
101 /// multi-image builds, these may not correspond with the offsets. This has to be computed early,
140 pub fn new(device: DeviceName, align: usize, erased_val: u8) -> Result<Self, String> { in new()
152 for image in 0..num_images { in new()
156 0 => FlashId::Image0, in new()
165 0 => FlashId::Image1, in new()
179 trailer_off: primary_base + primary_len - offset_from_end, in new()
182 index: 0, in new()
188 trailer_off: secondary_base + secondary_len - offset_from_end, in new()
210 for &dev in ALL_DEVICES { in each_device()
212 for &erased_val in &[0, 0xff] { in each_device()
213 match Self::new(dev, align, erased_val) { in each_device()
215 Err(msg) => warn!("Skipping {}: {}", dev, msg), in each_device()
223 …pub fn make_no_upgrade_image(self, deps: &DepTest, img_manipulation: ImageManipulation) -> Images { in make_no_upgrade_image()
237 let prim = install_image(&mut flash, &slots[0], in make_no_upgrade_image()
238 maximal(42784), &ram, &*dep, ImageManipulation::None, Some(0)); in make_no_upgrade_image()
242 maximal(46928), &ram, &*dep, ImageManipulation::BadSignature, Some(0)) in make_no_upgrade_image()
246 let prim = install_image(&mut flash, &slots[0], in make_no_upgrade_image()
247 maximal(42784), &ram, &*dep, img_manipulation, Some(0)); in make_no_upgrade_image()
251 maximal(46928), &ram, &*dep, img_manipulation, Some(0)) in make_no_upgrade_image()
270 pub fn make_image(self, deps: &DepTest, permanent: bool) -> Images { in make_image()
286 0 in make_image()
296 pub fn make_bad_secondary_slot_image(self) -> Images { in make_bad_secondary_slot_image()
301 let primaries = install_image(&mut bad_flash, &slots[0], in make_bad_secondary_slot_image()
302 maximal(32784), &ram, &dep, ImageManipulation::None, Some(0)); in make_bad_secondary_slot_image()
304 maximal(41928), &ram, &dep, ImageManipulation::BadSignature, Some(0)); in make_bad_secondary_slot_image()
319 pub fn make_oversized_secondary_slot_image(self) -> Images { in make_oversized_secondary_slot_image()
324 let primaries = install_image(&mut bad_flash, &slots[0], in make_oversized_secondary_slot_image()
325 maximal(32784), &ram, &dep, ImageManipulation::None, Some(0)); in make_oversized_secondary_slot_image()
327 ImageSize::Oversized, &ram, &dep, ImageManipulation::None, Some(0)); in make_oversized_secondary_slot_image()
342 pub fn make_erased_secondary_image(self) -> Images { in make_erased_secondary_image()
347 let primaries = install_image(&mut flash, &slots[0], in make_erased_secondary_image()
348 maximal(32784), &ram, &dep,ImageManipulation::None, Some(0)); in make_erased_secondary_image()
364 pub fn make_bootstrap_image(self) -> Images { in make_bootstrap_image()
371 maximal(32784), &ram, &dep, ImageManipulation::None, Some(0)); in make_bootstrap_image()
386 pub fn make_oversized_bootstrap_image(self) -> Images { in make_oversized_bootstrap_image()
393 ImageSize::Oversized, &ram, &dep, ImageManipulation::None, Some(0)); in make_oversized_bootstrap_image()
409 pub fn make_image_with_security_counter(self, security_cnt: Option<u32>) -> Images { in make_image_with_security_counter()
414 let primaries = install_image(&mut flash, &slots[0], in make_image_with_security_counter()
433 …pub fn make_device(device: DeviceName, align: usize, erased_val: u8) -> (SimMultiFlash, Rc<AreaDes… in make_device()
440 let dev = SimFlash::new(vec![16 * 1024, 16 * 1024, 16 * 1024, 16 * 1024, 64 * 1024, in make_device() localVariable
445 let dev_id = 0; in make_device()
447 areadesc.add_flash_sectors(dev_id, &dev); in make_device()
448 areadesc.add_image(0x020000, 0x020000, FlashId::Image0, dev_id); in make_device()
449 areadesc.add_image(0x040000, 0x020000, FlashId::Image1, dev_id); in make_device()
450 areadesc.add_image(0x060000, 0x020000, FlashId::ImageScratch, dev_id); in make_device()
453 flash.insert(dev_id, dev); in make_device()
458 let dev = SimFlash::new(vec![4096; 128], align as usize, erased_val); in make_device() localVariable
460 let dev_id = 0; in make_device()
462 areadesc.add_flash_sectors(dev_id, &dev); in make_device()
463 areadesc.add_image(0x020000, 0x020000, FlashId::Image0, dev_id); in make_device()
464 areadesc.add_image(0x040000, 0x020000, FlashId::Image1, dev_id); in make_device()
465 areadesc.add_image(0x060000, 0x001000, FlashId::ImageScratch, dev_id); in make_device()
468 flash.insert(dev_id, dev); in make_device()
474 let dev = SimFlash::new(vec![4096; 128], align as usize, erased_val); in make_device() localVariable
476 let dev_id = 0; in make_device()
478 areadesc.add_flash_sectors(dev_id, &dev); in make_device()
479 areadesc.add_simple_image(0x020000, 0x020000, FlashId::Image0, dev_id); in make_device()
480 areadesc.add_simple_image(0x040000, 0x020000, FlashId::Image1, dev_id); in make_device()
481 areadesc.add_simple_image(0x060000, 0x020000, FlashId::ImageScratch, dev_id); in make_device()
484 flash.insert(dev_id, dev); in make_device()
490 let dev = SimFlash::new(vec![4096; 128], align as usize, erased_val); in make_device() localVariable
492 let dev_id = 0; in make_device()
494 areadesc.add_flash_sectors(dev_id, &dev); in make_device()
495 areadesc.add_image(0x008000, 0x034000, FlashId::Image0, dev_id); in make_device()
496 areadesc.add_image(0x03c000, 0x034000, FlashId::Image1, dev_id); in make_device()
497 areadesc.add_image(0x070000, 0x00d000, FlashId::ImageScratch, dev_id); in make_device()
500 flash.insert(dev_id, dev); in make_device()
504 let dev = SimFlash::new(vec![4096; 128], align as usize, erased_val); in make_device() localVariable
506 let dev_id = 0; in make_device()
508 areadesc.add_flash_sectors(dev_id, &dev); in make_device()
509 areadesc.add_image(0x008000, 0x03c000, FlashId::Image0, dev_id); in make_device()
510 areadesc.add_image(0x044000, 0x03b000, FlashId::Image1, dev_id); in make_device()
513 flash.insert(dev_id, dev); in make_device()
523 areadesc.add_flash_sectors(0, &dev0); in make_device()
526 areadesc.add_image(0x008000, 0x068000, FlashId::Image0, 0); in make_device()
527 areadesc.add_image(0x000000, 0x068000, FlashId::Image1, 1); in make_device()
528 areadesc.add_image(0x068000, 0x018000, FlashId::ImageScratch, 1); in make_device()
531 flash.insert(0, dev0); in make_device()
537 let dev = SimFlash::new(vec![4096; 256], align as usize, erased_val); in make_device() localVariable
539 let dev_id = 0; in make_device()
541 areadesc.add_flash_sectors(dev_id, &dev); in make_device()
542 areadesc.add_image(0x020000, 0x020000, FlashId::Image0, dev_id); in make_device()
543 areadesc.add_image(0x040000, 0x020000, FlashId::Image1, dev_id); in make_device()
544 areadesc.add_image(0x060000, 0x001000, FlashId::ImageScratch, dev_id); in make_device()
545 areadesc.add_image(0x080000, 0x020000, FlashId::Image2, dev_id); in make_device()
546 areadesc.add_image(0x0a0000, 0x020000, FlashId::Image3, dev_id); in make_device()
549 flash.insert(dev_id, dev); in make_device()
555 pub fn num_images(&self) -> usize { in num_images()
566 pub fn run_basic_upgrade(&self, permanent: bool) -> Option<i32> { in run_basic_upgrade()
570 if !self.verify_images(&flash, 0, 1) { in run_basic_upgrade()
578 pub fn run_bootstrap(&self) -> bool { in run_bootstrap()
580 let mut fails = 0; in run_bootstrap()
590 if !self.verify_images(&flash, 0, 1) { in run_bootstrap()
595 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_bootstrap()
602 if fails > 0 { in run_bootstrap()
606 fails > 0 in run_bootstrap()
609 pub fn run_oversized_bootstrap(&self) -> bool { in run_oversized_bootstrap()
611 let mut fails = 0; in run_oversized_bootstrap()
623 if self.verify_images(&flash, 0, 1) { in run_oversized_bootstrap()
628 if self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_oversized_bootstrap()
635 if fails > 0 { in run_oversized_bootstrap()
639 fails > 0 in run_oversized_bootstrap()
645 pub fn run_check_deps(&self, deps: &DepTest) -> bool { in run_check_deps()
655 fn is_swap_upgrade(&self) -> bool { in is_swap_upgrade()
659 pub fn run_basic_revert(&self) -> bool { in run_basic_revert()
664 let mut fails = 0; in run_basic_revert()
671 if !self.verify_images(&flash, 0, 0) { in run_basic_revert()
678 fails > 0 in run_basic_revert()
681 pub fn run_perm_with_fails(&self) -> bool { in run_perm_with_fails()
686 let mut fails = 0; in run_perm_with_fails()
698 if !self.verify_images(&flash, 0, 1) { in run_perm_with_fails()
703 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_perm_with_fails()
715 if self.is_swap_upgrade() && !self.verify_images(&flash, 1, 0) { in run_perm_with_fails()
722 if fails > 0 { in run_perm_with_fails()
727 fails > 0 in run_perm_with_fails()
730 pub fn run_perm_with_random_fails(&self, total_fails: usize) -> bool { in run_perm_with_random_fails()
735 let mut fails = 0; in run_perm_with_random_fails()
740 let primary_slot_ok = self.verify_images(&flash, 0, 1); in run_perm_with_random_fails()
743 self.verify_images(&flash, 1, 0) in run_perm_with_random_fails()
754 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_perm_with_random_fails()
765 if fails > 0 { in run_perm_with_random_fails()
769 fails > 0 in run_perm_with_random_fails()
772 pub fn run_revert_with_fails(&self) -> bool { in run_revert_with_fails()
777 let mut fails = 0; in run_revert_with_fails()
793 fails > 0 in run_revert_with_fails()
796 pub fn run_norevert(&self) -> bool { in run_norevert()
802 let mut fails = 0; in run_norevert()
815 if !self.verify_images(&flash, 0, 1) { in run_norevert()
819 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_norevert()
832 self.mark_permanent_upgrades(&mut flash, 0); in run_norevert()
834 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_norevert()
845 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_norevert()
850 if !self.verify_images(&flash, 0, 1) { in run_norevert()
855 if fails > 0 { in run_norevert()
859 fails > 0 in run_norevert()
863 pub fn run_oversizefail_upgrade(&self) -> bool { in run_oversizefail_upgrade()
865 let mut fails = 0; in run_oversizefail_upgrade()
875 self.mark_upgrades(&mut flash, 0); in run_oversizefail_upgrade()
876 self.mark_permanent_upgrades(&mut flash, 0); in run_oversizefail_upgrade()
879 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_oversizefail_upgrade()
892 if !self.verify_images(&flash, 0, 0) { in run_oversizefail_upgrade()
896 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_oversizefail_upgrade()
902 if fails > 0 { in run_oversizefail_upgrade()
906 fails > 0 in run_oversizefail_upgrade()
911 pub fn run_nodowngrade(&self) -> bool { in run_nodowngrade()
917 let mut fails = 0; in run_nodowngrade()
927 if !self.verify_images(&flash, 0, 0) { in run_nodowngrade()
932 if fails > 0 { in run_nodowngrade()
936 fails > 0 in run_nodowngrade()
942 pub fn run_norevert_newimage(&self) -> bool { in run_norevert_newimage()
949 let mut fails = 0; in run_norevert_newimage()
951 info!("Try non-revert on imgtool generated image"); in run_norevert_newimage()
953 self.mark_upgrades(&mut flash, 0); in run_norevert_newimage()
957 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_norevert_newimage()
970 if !self.verify_images(&flash, 0, 0) { in run_norevert_newimage()
974 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_norevert_newimage()
985 if fails > 0 { in run_norevert_newimage()
989 fails > 0 in run_norevert_newimage()
995 pub fn run_signfail_upgrade(&self) -> bool { in run_signfail_upgrade()
997 let mut fails = 0; in run_signfail_upgrade()
1007 self.mark_upgrades(&mut flash, 0); in run_signfail_upgrade()
1008 self.mark_permanent_upgrades(&mut flash, 0); in run_signfail_upgrade()
1011 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_signfail_upgrade()
1024 if !self.verify_images(&flash, 0, 0) { in run_signfail_upgrade()
1028 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_signfail_upgrade()
1034 if fails > 0 { in run_signfail_upgrade()
1038 fails > 0 in run_signfail_upgrade()
1043 pub fn run_secondary_leftover_trailer(&self) -> bool { in run_secondary_leftover_trailer()
1049 let mut fails = 0; in run_secondary_leftover_trailer()
1064 if !self.verify_images(&flash, 0, 0) { in run_secondary_leftover_trailer()
1074 if fails > 0 { in run_secondary_leftover_trailer()
1078 fails > 0 in run_secondary_leftover_trailer()
1081 fn trailer_sz(&self, align: usize) -> usize { in trailer_sz()
1085 fn status_sz(&self, align: usize) -> usize { in status_sz()
1092 pub fn run_with_status_fails_complete(&self) -> bool { in run_with_status_fails_complete()
1098 let mut fails = 0; in run_with_status_fails_complete()
1103 self.mark_bad_status_with_rate(&mut flash, 0, 1.0); in run_with_status_fails_complete()
1113 if result.asserts() != 0 { in run_with_status_fails_complete()
1118 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in run_with_status_fails_complete()
1124 if !self.verify_images(&flash, 0, 1) { in run_with_status_fails_complete()
1130 re-run of boot_go should just work"); in run_with_status_fails_complete()
1136 if fails > 0 { in run_with_status_fails_complete()
1140 fails > 0 in run_with_status_fails_complete()
1146 pub fn run_with_status_fails_with_reset(&self) -> bool { in run_with_status_fails_with_reset()
1152 let mut fails = 0; in run_with_status_fails_with_reset()
1160 self.mark_bad_status_with_rate(&mut flash, 0, 0.5); in run_with_status_fails_with_reset()
1165 if asserts != 0 { in run_with_status_fails_with_reset()
1170 self.reset_bad_status(&mut flash, 0); in run_with_status_fails_with_reset()
1186 if fails > 0 { in run_with_status_fails_with_reset()
1190 fails > 0 in run_with_status_fails_with_reset()
1193 let mut fails = 0; in run_with_status_fails_with_reset()
1198 self.mark_bad_status_with_rate(&mut flash, 0, 1.0); in run_with_status_fails_with_reset()
1203 if asserts == 0 { in run_with_status_fails_with_reset()
1208 fails > 0 in run_with_status_fails_with_reset()
1214 pub fn run_direct_xip(&self) -> bool { in run_direct_xip()
1241 /// Test the ram-loading.
1242 pub fn run_ram_load(&self) -> bool { in run_ram_load()
1251 let ram = RamBlock::new(self.ram.total - RAM_LOAD_ADDR, RAM_LOAD_ADDR); in run_ram_load()
1259 error!("Failed to execute ram-load"); in run_ram_load()
1265 let place = self.ram.lookup(&image.slots[0]); in run_ram_load()
1266 let ram_image = ram.borrow_part(place.offset as usize - RAM_LOAD_ADDR as usize, in run_ram_load()
1273 let src_image = &image.upgrades.plain[0..src_sz]; in run_ram_load()
1274 let ram_image = &ram_image[0..src_sz]; in run_ram_load()
1285 /// Test the split ram-loading.
1286 pub fn run_split_ram_load(&self) -> bool { in run_split_ram_load()
1295 let ram = RamBlock::new(self.ram.total - RAM_LOAD_ADDR, RAM_LOAD_ADDR); in run_split_ram_load()
1302 error!("Failed to execute ram-load"); in run_split_ram_load()
1309 let place = self.ram.lookup(&image.slots[0]); in run_split_ram_load()
1310 let ram_image = ram.borrow_part(place.offset as usize - RAM_LOAD_ADDR as usize, in run_split_ram_load()
1317 let src_image = &image.upgrades.plain[0..src_sz]; in run_split_ram_load()
1318 let ram_image = &ram_image[0..src_sz]; in run_split_ram_load()
1329 pub fn run_hw_rollback_prot(&self) -> bool { in run_hw_rollback_prot()
1337 c::set_security_counter(0, 30); in run_hw_rollback_prot()
1345 let counter_val = c::get_security_counter(0); in run_hw_rollback_prot()
1354 pub fn run_ram_load_boot_with_result(&self, expected_result: bool) -> bool { in run_ram_load_boot_with_result()
1362 let ram = RamBlock::new(self.ram.total - RAM_LOAD_ADDR, RAM_LOAD_ADDR); in run_ram_load_boot_with_result()
1386 let dev = flash.get_mut(&dev_id).unwrap(); in mark_bad_status_with_rate() localVariable
1387 let align = dev.align(); in mark_bad_status_with_rate()
1390 let status_off = off + len - self.trailer_sz(align); in mark_bad_status_with_rate()
1393 let _ = dev.add_bad_region(status_off, self.status_sz(align), rate); in mark_bad_status_with_rate()
1404 let dev = flash.get_mut(&dev_id).unwrap(); in reset_bad_status() localVariable
1405 dev.reset_bad_regions(); in reset_bad_status()
1409 dev.set_verify_writes(false); in reset_bad_status()
1415 fn try_upgrade(&self, stop: Option<i32>, permanent: bool) -> (SimMultiFlash, i32) { in try_upgrade()
1423 let mut counter = stop.unwrap_or(0); in try_upgrade()
1430 x if x.success() => (false, -counter), in try_upgrade()
1434 counter = 0; in try_upgrade()
1445 (flash, count - counter) in try_upgrade()
1448 fn try_revert(&self, count: usize) -> SimMultiFlash { in try_revert()
1452 for i in 0 .. count { in try_revert()
1459 fn try_revert_with_fail_at(&self, stop: i32) -> bool { in try_revert_with_fail_at()
1461 let mut fails = 0; in try_revert_with_fail_at()
1470 // In a multi-image setup, copy done might be set if any number of in try_revert_with_fail_at()
1472 if !self.verify_trailers_loose(&flash, 0, None, None, BOOT_FLAG_UNSET) { in try_revert_with_fail_at()
1482 if !self.verify_images(&flash, 0, 1) { in try_revert_with_fail_at()
1487 if !self.verify_images(&flash, 1, 0) { in try_revert_with_fail_at()
1492 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in try_revert_with_fail_at()
1516 if !self.verify_images(&flash, 0, 0) { in try_revert_with_fail_at()
1527 if !self.verify_trailers(&flash, 0, BOOT_MAGIC_GOOD, in try_revert_with_fail_at()
1543 if !self.verify_images(&flash, 0, 0) { in try_revert_with_fail_at()
1552 fails > 0 in try_revert_with_fail_at()
1556 fn try_random_fails(&self, total_ops: i32, count: usize) -> (SimMultiFlash, Vec<i32>) { in try_random_fails()
1562 let mut resets = vec![0i32; count]; in try_random_fails()
1572 remaining_ops -= reset_counter; in try_random_fails()
1587 fn verify_images(&self, flash: &SimMultiFlash, slot: usize, against: usize) -> bool { in verify_images()
1591 0 => &image.primaries, in verify_images()
1599 fn verify_dep_images(&self, flash: &SimMultiFlash, deps: &DepTest) -> bool { in verify_dep_images()
1602 if !verify_image(flash, &image.slots[0], in verify_dep_images()
1619 copy_done: Option<u8>) -> bool { in verify_trailers_loose()
1630 copy_done: Option<u8>) -> bool { in verify_trailers()
1653 /// "{prefix}-001.mcubin" depending on how many images there are.
1659 format!("{}-{:>0}.mcubin", prefix, id) in debug_dump()
1669 fn new(slots: &[[SlotInfo; 2]]) -> RamData { in new()
1672 // println!("Setup:-------------");
1684 addr += imgs[0].len as u32;
1694 fn lookup(&self, slot: &SlotInfo) -> &SlotPlace { in lookup()
1703 println!("---- Flash configuration ----"); in show_flash()
1705 println!(" {:3}: 0x{:08x}, 0x{:08x}", in show_flash()
1721 #[cfg(not(feature = "max-align-32"))]
1722 fn tralier_estimation(dev: &dyn Flash) -> usize { in tralier_estimation()
1723 c::boot_trailer_sz(dev.align() as u32) as usize in tralier_estimation()
1726 #[cfg(feature = "max-align-32")]
1727 fn tralier_estimation(dev: &dyn Flash) -> usize { in tralier_estimation()
1729 let sector_size = dev.sector_iter().next().unwrap().size as u32; in tralier_estimation()
1731 align_up(c::boot_trailer_sz(dev.align() as u32), sector_size) as usize in tralier_estimation()
1734 fn image_largest_trailer(dev: &dyn Flash) -> usize { in image_largest_trailer()
1739 // c::boot_status_sz(dev.align() as u32) as usize in image_largest_trailer()
1740 16 + 4 * dev.align() in image_largest_trailer()
1742 let sector_size = dev.sector_iter().next().unwrap().size as u32; in image_largest_trailer()
1743 align_up(c::boot_trailer_sz(dev.align() as u32), sector_size) as usize in image_largest_trailer()
1745 tralier_estimation(dev) in image_largest_trailer()
1757 …s: &dyn Depender, img_manipulation: ImageManipulation, security_counter:Option<u32>) -> ImageData { in install_image()
1761 let dev = flash.get_mut(&dev_id).unwrap(); in install_image() localVariable
1782 ImageManipulation::OverlapImages(false) => place.offset - 1, in install_image()
1786 0 in install_image()
1792 let trailer = image_largest_trailer(dev); in install_image()
1794 info!("slot: 0x{:x}, HDR: 0x{:x}, trailer: 0x{:x}", in install_image()
1796 slot_len - HDR_SIZE - trailer - tlv_len in install_image()
1799 let trailer = image_largest_trailer(dev); in install_image()
1801 info!("slot: 0x{:x}, HDR: 0x{:x}, trailer: 0x{:x}", in install_image()
1805 slot_len - HDR_SIZE - trailer - tlv_len + dev.align()*4 in install_image()
1819 _pad2: 0, in install_image()
1822 let mut b_header = [0; HDR_SIZE]; in install_image()
1829 let mut b_img = vec![0; len]; in install_image()
1846 let is_encrypted = (tlv.get_flags() & flag) != 0; in install_image()
1853 let nonce = GenericArray::from_slice(&[0; 16]); in install_image()
1880 let align = dev.align(); in install_image()
1882 while buf.len() % align != 0 { in install_image()
1883 buf.push(dev.erased_val()); in install_image()
1892 while encbuf.len() % align != 0 { in install_image()
1893 encbuf.push(dev.erased_val()); in install_image()
1897 // Since images are always non-encrypted in the primary slot, we first write in install_image()
1898 // an encrypted image, re-read to use for verification, erase + flash in install_image()
1899 // un-encrypted. In the secondary slot the image is written un-encrypted, in install_image()
1902 // In the case of ram-load when encryption is enabled both slots have to in install_image()
1905 if slot.index == 0 && !Caps::RamLoad.present() { in install_image()
1909 dev.write(offset, &encbuf).unwrap(); in install_image()
1911 let mut enc = vec![0u8; encbuf.len()]; in install_image()
1912 dev.read(offset, &mut enc).unwrap(); in install_image()
1916 dev.erase(offset, slot_len).unwrap(); in install_image()
1921 dev.write(offset, &buf).unwrap(); in install_image()
1923 let mut copy = vec![0u8; buf.len()]; in install_image()
1924 dev.read(offset, &mut copy).unwrap(); in install_image()
1933 dev.write(offset, &buf).unwrap(); in install_image()
1935 let mut copy = vec![0u8; buf.len()]; in install_image()
1936 dev.read(offset, &mut copy).unwrap(); in install_image()
1941 dev.erase(offset, slot_len).unwrap(); in install_image()
1943 dev.write(offset, &encbuf).unwrap(); in install_image()
1945 let mut enc = vec![0u8; encbuf.len()]; in install_image()
1946 dev.read(offset, &mut enc).unwrap(); in install_image()
1962 fn install_no_image() -> ImageData { in install_no_image()
1964 size: 0, in install_no_image()
1972 fn make_tlv() -> TlvGen { in make_tlv()
2002 // The non-encrypted configuration. in make_tlv()
2020 /// Find the image contents for the given slot. This assumes that slot 0
2022 fn find(&self, slot: usize) -> &Vec<u8> { in find()
2027 (true, 0) => &self.plain, in find()
2033 fn size(&self) -> usize { in size()
2039 fn verify_image(flash: &SimMultiFlash, slot: &SlotInfo, images: &ImageData) -> bool { in verify_image()
2044 let mut copy = vec![0u8; buf.len()]; in verify_image()
2046 let dev = flash.get(&dev_id).unwrap(); in verify_image() localVariable
2047 dev.read(offset, &mut copy).unwrap(); in verify_image()
2050 for i in 0 .. buf.len() { in verify_image()
2065 copy_done: Option<u8>) -> bool { in verify_trailer()
2072 let mut copy = vec![0u8; c::boot_magic_sz() + c::boot_max_align() * 3]; in verify_trailer()
2075 let dev = flash.get(&dev_id).unwrap(); in verify_trailer() localVariable
2076 let erased_val = dev.erased_val(); in verify_trailer()
2077 dev.read(offset, &mut copy).unwrap(); in verify_trailer()
2081 let magic_off = (c::boot_max_align() * 3) + (c::boot_magic_sz() - MAGIC.len()); in verify_trailer()
2135 // If there are any partitions in this device that start at 0, and in install_ptable()
2143 area.off == 0 && in install_ptable()
2149 .filter(|area| area.device_id == id && area.off == 0) in install_ptable()
2158 write!(&mut buf, "mcuboot\0").unwrap(); in install_ptable()
2169 buf.write_u32::<LittleEndian>(0).unwrap(); in install_ptable()
2172 let dev = flash.get_mut(&id).unwrap(); in install_ptable() localVariable
2175 while buf.len() % dev.align() != 0 { in install_ptable()
2176 buf.push(0); in install_ptable()
2179 dev.write(0, &buf).unwrap(); in install_ptable()
2218 #[cfg(not(feature = "max-align-32"))]
2219 const MAGIC: &[u8] = &[0x77, 0xc2, 0x95, 0xf3,
2220 0x60, 0xd2, 0xef, 0x7f,
2221 0x35, 0x52, 0x50, 0x0f,
2222 0x2c, 0xb6, 0x79, 0x80];
2224 #[cfg(feature = "max-align-32")]
2225 const MAGIC: &[u8] = &[0x20, 0x00, 0x2d, 0xe1,
2226 0x5d, 0x29, 0x41, 0x0b,
2227 0x8d, 0x77, 0x67, 0x9c,
2228 0x11, 0x0f, 0x1f, 0x8a];
2239 let dev = flash.get_mut(&slot.dev_id).unwrap(); in mark_upgrade() localVariable
2240 let align = dev.align(); in mark_upgrade()
2242 if offset % align != 0 || MAGIC.len() % align != 0 { in mark_upgrade()
2246 let mut buf = vec![dev.erased_val(); c::boot_max_align()]; in mark_upgrade()
2247 let magic_off = (offset % align) + (c::boot_magic_sz() - MAGIC.len()); in mark_upgrade()
2249 dev.write(offset - (offset % align), &buf).unwrap(); in mark_upgrade()
2251 dev.write(offset, MAGIC).unwrap(); in mark_upgrade()
2265 let dev = flash.get_mut(&slot.dev_id).unwrap(); in mark_permanent_upgrade() localVariable
2266 let align = dev.align(); in mark_permanent_upgrade()
2267 let mut ok = vec![dev.erased_val(); align]; in mark_permanent_upgrade()
2268 ok[0] = 1u8; in mark_permanent_upgrade()
2270 dev.write(off, &ok).unwrap(); in mark_permanent_upgrade()
2273 // Drop some pseudo-random gibberish onto the data.
2275 let mut seed_block = [0u8; 32]; in splat()
2277 buf.write_u32::<LittleEndian>(0x135782ea).unwrap(); in splat()
2278 buf.write_u32::<LittleEndian>(0x92184728).unwrap(); in splat()
2285 /// Return a read-only view into the raw bytes of this object
2287 fn as_raw(&self) -> &[u8] { in as_raw()
2293 /// Determine whether it makes sense to test this configuration with a maximally-sized image.
2295 fn maximal(size: usize) -> ImageSize { in maximal()
2309 println!("{:2}: {} (0x{:x})", min, msize, msize); in show_sizes()
2313 #[cfg(not(feature = "max-align-32"))]
2314 fn test_alignments() -> &'static [usize] { in test_alignments()
2318 #[cfg(feature = "max-align-32")]
2319 fn test_alignments() -> &'static [usize] { in test_alignments()
2326 fn skip_slow_test() -> bool { in skip_slow_test()