From 88543445d8414b94720654f1e5dba900e8a75cce Mon Sep 17 00:00:00 2001 From: Rasmus Melchior Jacobsen Date: Thu, 25 May 2023 22:48:54 +0200 Subject: [PATCH] Fix end address for assertion --- embassy-stm32/src/flash/common.rs | 2 +- embassy-stm32/src/flash/f4.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs index 400831e0a..c190eaf9a 100644 --- a/embassy-stm32/src/flash/common.rs +++ b/embassy-stm32/src/flash/common.rs @@ -91,7 +91,7 @@ pub(super) fn blocking_read(base: u32, size: u32, offset: u32, bytes: &mut [u8]) let start_address = base + offset; #[cfg(flash_f4)] - family::assert_not_corrupted_read(start_address + bytes.len()); + family::assert_not_corrupted_read(start_address + bytes.len() as u32); let flash_data = unsafe { core::slice::from_raw_parts(start_address as *const u8, bytes.len()) }; bytes.copy_from_slice(flash_data); diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index a43efc51b..2dd6d85fd 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs @@ -443,7 +443,7 @@ pub(crate) fn assert_not_corrupted_read(end_address: u32) { const REVISION_3: u16 = 0x2001; #[allow(unused)] - let second_bank_read = get_flash_regions().last().unwrap().bank == FlashBank::Bank2 && end_address > FLASH_SIZE / 2; + let second_bank_read = get_flash_regions().last().unwrap().bank == FlashBank::Bank2 && end_address > (FLASH_SIZE / 2) as u32; #[cfg(any( feature = "stm32f427ai", @@ -491,7 +491,7 @@ pub(crate) fn assert_not_corrupted_read(end_address: u32) { feature = "stm32f439vg", feature = "stm32f439zg", ))] - if second_bank_read && unsafe { &&pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() } + if second_bank_read && unsafe { pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() } { panic!("Read corruption for stm32f42xxG and stm32f43xxG in dual bank mode when PA12 is in use for chips below revision 3, see errata 2.2.11"); }