From 90d214eb4bffa103d44c679737f1ef66abdc4a9b Mon Sep 17 00:00:00 2001 From: mruddy Date: Fri, 30 Jun 2017 09:02:47 -0400 Subject: [PATCH] add ability for developers to easily avoid locking their flash memory sectors --- Makefile.include | 6 ++++++ memory.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/Makefile.include b/Makefile.include index 15a7d9014e..773be5037f 100644 --- a/Makefile.include +++ b/Makefile.include @@ -59,6 +59,12 @@ else LDSCRIPT = $(TOP_DIR)/memory.ld endif +ifeq ($(MEMORY_PROTECT), 0) +CFLAGS += -DMEMORY_PROTECT=0 +else +CFLAGS += -DMEMORY_PROTECT=1 +endif + LDFLAGS += --static \ -Wl,--start-group \ -lc \ diff --git a/memory.c b/memory.c index f779c2037c..33bd007c6b 100644 --- a/memory.c +++ b/memory.c @@ -27,6 +27,7 @@ void memory_protect(void) { +#if MEMORY_PROTECT // Reference STM32F205 Flash programming manual revision 5 http://www.st.com/resource/en/programming_manual/cd00233952.pdf // Section 2.6 Option bytes // set RDP level 2 WRP for sectors 0 and 1 @@ -45,6 +46,7 @@ void memory_protect(void) // Bit 0 OPTLOCK: Option lock: ignored by flash_program_option_bytes flash_program_option_bytes(0x0FFCCCEC); flash_lock_option_bytes(); +#endif } int memory_bootloader_hash(uint8_t *hash)