From 7f02df51c9a35d0a6e76cbac348e146d974b5108 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Sun, 21 Oct 2018 10:04:21 +0200 Subject: [PATCH] Added SWAP=0 option, fixed some warnings --- Makefile | 4 ++++ hal/nrf52.c | 1 - include/target.h | 8 +++++--- lib/bootutil/src/loader.c | 2 ++ src/run.c | 6 +++++- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 6430e76d..48c6cf24 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ SIGN?=ED25519 TARGET?=stm32f4 DEBUG?=0 VTOR?=1 +SWAP?=1 LSCRIPT:=hal/$(TARGET).ld @@ -60,6 +61,9 @@ ifeq ($(VTOR),0) CFLAGS+=-DNO_VTOR endif +ifeq ($(SWAP),0) + CFLAGS+=-DWOLFBOOT_OVERWRITE_ONLY +endif LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles -mcpu=cortex-m3 -mthumb -nostdlib diff --git a/hal/nrf52.c b/hal/nrf52.c index 34c8148a..cd9be01b 100644 --- a/hal/nrf52.c +++ b/hal/nrf52.c @@ -54,7 +54,6 @@ static void flash_wait_complete(void) int hal_flash_write(uint32_t address, const uint8_t *data, int len) { int i; - uint32_t val; NVMC_CONFIG = NVMC_CONFIG_WEN; flash_wait_complete(); /* Set 8-bit write */ diff --git a/include/target.h b/include/target.h index 70c0f9c3..52a17505 100644 --- a/include/target.h +++ b/include/target.h @@ -4,6 +4,10 @@ #define FLASH_DEV_NAME "flash" #define FLASH_ALIGN 4 +/* Example flash partitioning. + * Ensure that your firmware entry point is + * at FLASH_AREA_IMAGE_0_OFFSET + 0x100 + */ #define FLASH_AREA_IMAGE_0_OFFSET 0x20000 #define FLASH_AREA_IMAGE_0_SIZE 0x20000 #define FLASH_AREA_IMAGE_1_OFFSET 0x40000 @@ -19,9 +23,7 @@ !defined(FLASH_AREA_IMAGE_0_OFFSET) || \ !defined(FLASH_AREA_IMAGE_0_SIZE) || \ !defined(FLASH_AREA_IMAGE_1_OFFSET) || \ - !defined(FLASH_AREA_IMAGE_1_SIZE) || \ - !defined(FLASH_AREA_IMAGE_SCRATCH_OFFSET) || \ - !defined(FLASH_AREA_IMAGE_SCRATCH_SIZE) + !defined(FLASH_AREA_IMAGE_1_SIZE) #error "Target support is incomplete; cannot build wolfboot." #endif diff --git a/lib/bootutil/src/loader.c b/lib/bootutil/src/loader.c index 02844ec3..f49f39ed 100644 --- a/lib/bootutil/src/loader.c +++ b/lib/bootutil/src/loader.c @@ -1332,9 +1332,11 @@ boot_go(struct boot_rsp *rsp) rc = flash_area_open(fa_id, &BOOT_IMG_AREA(&boot_data, slot)); assert(rc == 0); } +#ifndef WOLFBOOT_OVERWRITE_ONLY rc = flash_area_open(FLASH_AREA_IMAGE_SCRATCH, &BOOT_SCRATCH_AREA(&boot_data)); assert(rc == 0); +#endif /* Determine the sector layout of the image slots and scratch area. */ rc = boot_read_sectors(); diff --git a/src/run.c b/src/run.c index 78e8ff4b..e69e1902 100644 --- a/src/run.c +++ b/src/run.c @@ -75,6 +75,7 @@ static struct area_desc flash_areas[1] = { .id = FLASH_AREA_IMAGE_1, .num_areas = 1 }, +#ifndef WOLFBOOT_OVERWRITE_ONLY { .whole = { .fa_id = FLASH_AREA_IMAGE_SCRATCH, @@ -87,6 +88,10 @@ static struct area_desc flash_areas[1] = { } }, .num_slots = 3 +#else + }, + .num_slots = 2 +#endif } } ; @@ -144,7 +149,6 @@ int flash_area_read(const struct flash_area *area, uint32_t off, void *dst, int flash_area_write(const struct flash_area *area, uint32_t off, const void *src, uint32_t len) { - uint32_t address; BOOT_LOG_DBG("%s: area=%d, off=%x, len=%x", __func__, area->fa_id, off, len); hal_flash_unlock();