File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ SWAP?=1
1616CORTEX_M0? =0
1717NO_ASM =0
1818EXT_FLASH =0
19+ ALLOW_DOWNGRADE =0
1920
2021LSCRIPT: =hal/$(TARGET ) .ld
2122
@@ -79,6 +80,10 @@ ifeq ($(EXT_FLASH),1)
7980 CFLAGS+=-DEXT_FLASH =1 -DPART_UPDATE_EXT=1 -DPART_SWAP_EXT=1
8081endif
8182
83+ ifeq ($(ALLOW_DOWNGRADE ) ,1)
84+ CFLAGS+ =-DALLOW_DOWNGRADE
85+ endif
86+
8287
8388ifeq ($(SIGN ) ,ED25519)
8489 OBJS+ = ./lib/wolfssl/wolfcrypt/src/sha512.o \
Original file line number Diff line number Diff line change @@ -82,14 +82,18 @@ static int wolfBoot_update(void)
8282 /* Check the first sector to detect interrupted update */
8383 if ((wolfBoot_get_sector_flag (PART_UPDATE , 0 , & flag ) < 0 ) || (flag == SECT_FLAG_NEW ))
8484 {
85- /* In case this is a new update, check
86- * integrity/authenticity of the firmware update
85+ /* In case this is a new update, do the required
86+ * checks on the firmware update
8787 * before starting the swap
8888 */
8989 if (!update .hdr_ok || (wolfBoot_verify_integrity (& update ) < 0 )
9090 || (wolfBoot_verify_authenticity (& update ) < 0 )) {
9191 return -1 ;
9292 }
93+ #ifndef ALLOW_DOWNGRADE
94+ if (wolfBoot_update_firmware_version () <= wolfBoot_current_firmware_version ())
95+ return -1 ;
96+ #endif
9397 }
9498
9599 hal_flash_unlock ();
You can’t perform that action at this time.
0 commit comments