Skip to content

Commit

Permalink
Remove redundant check, debug assert on ob unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlK90 committed Feb 12, 2022
1 parent cba7ba5 commit a979b19
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TinyUF2 flash unlocker for STM32F411 (easily adaptable to other STM32F4xx)

This small program is meant to unlock the first 4 (=64kb) flash sectors that are occupied by the TinyUF2 bootloader, if they have been locked by it. After the unlock procedure it jumps to the built-in DFU bootloader of the STM32F4 MCUs. This is useful for e.g. self-updating the TinyUF2 bootloader or replacing it with something else.
This small program is meant to unlock the first 2 (=32kb) flash sectors that are occupied by the TinyUF2 bootloader, if they have been locked by it. After the unlock procedure it jumps to the built-in DFU bootloader of the STM32F4 MCUs. This is useful for e.g. self-updating the TinyUF2 bootloader or replacing it with something else.

## Usage

Expand Down
Binary file modified release/tinyuf2-unlocker-stm32f411.uf2
Binary file not shown.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ fn main() -> ! {
let optkeyr = &flash.optkeyr;

// Unprotect flash sectors if it is necessary
if (optcr.read().n_wrp().bits() & FLASH_SECTORS_MASK) != FLASH_SECTORS_MASK {
if optcr.read().n_wrp().bits() != FLASH_SECTORS_MASK {
// Unlock option bytes
if optcr.read().optlock().bit_is_set() {
optkeyr.write(|w| w.optkey().bits(FLASH_OPT_KEY1));
optkeyr.write(|w| w.optkey().bits(FLASH_OPT_KEY2));
assert!(optcr.read().optlock().bit_is_clear());
debug_assert!(optcr.read().optlock().bit_is_clear());
}

// Wait for any flash operations to complete
Expand Down

0 comments on commit a979b19

Please sign in to comment.