diff options
| author | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-25 22:31:24 +0200 |
|---|---|---|
| committer | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-25 22:31:24 +0200 |
| commit | ce331b411c3a6c69fbfefa968319f8eba5ad813f (patch) | |
| tree | 529c3637c9bc434ba184c8af3c401455836c3ea2 /embassy-stm32/src/flash/f4.rs | |
| parent | 8528455a75aa33cf774d72ba6b35a4298bca511e (diff) | |
Only assert_not_corrupted_read if we read from the second bank
Diffstat (limited to 'embassy-stm32/src/flash/f4.rs')
| -rw-r--r-- | embassy-stm32/src/flash/f4.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 8c9c93696..a43efc51b 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -6,6 +6,7 @@ use atomic_polyfill::AtomicBool; | |||
| 6 | #[cfg(feature = "nightly")] | 6 | #[cfg(feature = "nightly")] |
| 7 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
| 8 | use pac::flash::regs::Sr; | 8 | use pac::flash::regs::Sr; |
| 9 | use pac::FLASH_SIZE; | ||
| 9 | 10 | ||
| 10 | use super::{FlashBank, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; | 11 | use super::{FlashBank, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; |
| 11 | use crate::flash::Error; | 12 | use crate::flash::Error; |
| @@ -437,10 +438,13 @@ fn restore_data_cache_state() { | |||
| 437 | } | 438 | } |
| 438 | } | 439 | } |
| 439 | 440 | ||
| 440 | pub(crate) fn assert_not_corrupted_read() { | 441 | pub(crate) fn assert_not_corrupted_read(end_address: u32) { |
| 441 | #[allow(unused)] | 442 | #[allow(unused)] |
| 442 | const REVISION_3: u16 = 0x2001; | 443 | const REVISION_3: u16 = 0x2001; |
| 443 | 444 | ||
| 445 | #[allow(unused)] | ||
| 446 | let second_bank_read = get_flash_regions().last().unwrap().bank == FlashBank::Bank2 && end_address > FLASH_SIZE / 2; | ||
| 447 | |||
| 444 | #[cfg(any( | 448 | #[cfg(any( |
| 445 | feature = "stm32f427ai", | 449 | feature = "stm32f427ai", |
| 446 | feature = "stm32f427ii", | 450 | feature = "stm32f427ii", |
| @@ -463,7 +467,7 @@ pub(crate) fn assert_not_corrupted_read() { | |||
| 463 | feature = "stm32f439vi", | 467 | feature = "stm32f439vi", |
| 464 | feature = "stm32f439zi", | 468 | feature = "stm32f439zi", |
| 465 | ))] | 469 | ))] |
| 466 | if unsafe { pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() } { | 470 | if second_bank_read && unsafe { pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() } { |
| 467 | panic!("Read corruption for stm32f42xxI and stm32f43xxI when PA12 is in use for chips below revision 3, see errata 2.2.11"); | 471 | panic!("Read corruption for stm32f42xxI and stm32f43xxI when PA12 is in use for chips below revision 3, see errata 2.2.11"); |
| 468 | } | 472 | } |
| 469 | 473 | ||
| @@ -487,11 +491,8 @@ pub(crate) fn assert_not_corrupted_read() { | |||
| 487 | feature = "stm32f439vg", | 491 | feature = "stm32f439vg", |
| 488 | feature = "stm32f439zg", | 492 | feature = "stm32f439zg", |
| 489 | ))] | 493 | ))] |
| 490 | if unsafe { | 494 | if second_bank_read && unsafe { &&pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() } |
| 491 | pac::FLASH.optcr().read().db1m() | 495 | { |
| 492 | && pac::DBGMCU.idcode().read().rev_id() < REVISION_3 | ||
| 493 | && !pa12_is_output_pull_low() | ||
| 494 | } { | ||
| 495 | 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"); | 496 | 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"); |
| 496 | } | 497 | } |
| 497 | } | 498 | } |
