mirror of https://github.com/wolfSSL/wolfBoot.git
Added SWAP=0 option, fixed some warnings
parent
34a8ae443d
commit
7f02df51c9
4
Makefile
4
Makefile
|
@ -11,6 +11,7 @@ SIGN?=ED25519
|
||||||
TARGET?=stm32f4
|
TARGET?=stm32f4
|
||||||
DEBUG?=0
|
DEBUG?=0
|
||||||
VTOR?=1
|
VTOR?=1
|
||||||
|
SWAP?=1
|
||||||
|
|
||||||
LSCRIPT:=hal/$(TARGET).ld
|
LSCRIPT:=hal/$(TARGET).ld
|
||||||
|
|
||||||
|
@ -60,6 +61,9 @@ ifeq ($(VTOR),0)
|
||||||
CFLAGS+=-DNO_VTOR
|
CFLAGS+=-DNO_VTOR
|
||||||
endif
|
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
|
LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles -mcpu=cortex-m3 -mthumb -nostdlib
|
||||||
|
|
|
@ -54,7 +54,6 @@ static void flash_wait_complete(void)
|
||||||
int hal_flash_write(uint32_t address, const uint8_t *data, int len)
|
int hal_flash_write(uint32_t address, const uint8_t *data, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint32_t val;
|
|
||||||
NVMC_CONFIG = NVMC_CONFIG_WEN;
|
NVMC_CONFIG = NVMC_CONFIG_WEN;
|
||||||
flash_wait_complete();
|
flash_wait_complete();
|
||||||
/* Set 8-bit write */
|
/* Set 8-bit write */
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
#define FLASH_DEV_NAME "flash"
|
#define FLASH_DEV_NAME "flash"
|
||||||
#define FLASH_ALIGN 4
|
#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_OFFSET 0x20000
|
||||||
#define FLASH_AREA_IMAGE_0_SIZE 0x20000
|
#define FLASH_AREA_IMAGE_0_SIZE 0x20000
|
||||||
#define FLASH_AREA_IMAGE_1_OFFSET 0x40000
|
#define FLASH_AREA_IMAGE_1_OFFSET 0x40000
|
||||||
|
@ -19,9 +23,7 @@
|
||||||
!defined(FLASH_AREA_IMAGE_0_OFFSET) || \
|
!defined(FLASH_AREA_IMAGE_0_OFFSET) || \
|
||||||
!defined(FLASH_AREA_IMAGE_0_SIZE) || \
|
!defined(FLASH_AREA_IMAGE_0_SIZE) || \
|
||||||
!defined(FLASH_AREA_IMAGE_1_OFFSET) || \
|
!defined(FLASH_AREA_IMAGE_1_OFFSET) || \
|
||||||
!defined(FLASH_AREA_IMAGE_1_SIZE) || \
|
!defined(FLASH_AREA_IMAGE_1_SIZE)
|
||||||
!defined(FLASH_AREA_IMAGE_SCRATCH_OFFSET) || \
|
|
||||||
!defined(FLASH_AREA_IMAGE_SCRATCH_SIZE)
|
|
||||||
#error "Target support is incomplete; cannot build wolfboot."
|
#error "Target support is incomplete; cannot build wolfboot."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1332,9 +1332,11 @@ boot_go(struct boot_rsp *rsp)
|
||||||
rc = flash_area_open(fa_id, &BOOT_IMG_AREA(&boot_data, slot));
|
rc = flash_area_open(fa_id, &BOOT_IMG_AREA(&boot_data, slot));
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
}
|
}
|
||||||
|
#ifndef WOLFBOOT_OVERWRITE_ONLY
|
||||||
rc = flash_area_open(FLASH_AREA_IMAGE_SCRATCH,
|
rc = flash_area_open(FLASH_AREA_IMAGE_SCRATCH,
|
||||||
&BOOT_SCRATCH_AREA(&boot_data));
|
&BOOT_SCRATCH_AREA(&boot_data));
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Determine the sector layout of the image slots and scratch area. */
|
/* Determine the sector layout of the image slots and scratch area. */
|
||||||
rc = boot_read_sectors();
|
rc = boot_read_sectors();
|
||||||
|
|
|
@ -75,6 +75,7 @@ static struct area_desc flash_areas[1] = {
|
||||||
.id = FLASH_AREA_IMAGE_1,
|
.id = FLASH_AREA_IMAGE_1,
|
||||||
.num_areas = 1
|
.num_areas = 1
|
||||||
},
|
},
|
||||||
|
#ifndef WOLFBOOT_OVERWRITE_ONLY
|
||||||
{
|
{
|
||||||
.whole = {
|
.whole = {
|
||||||
.fa_id = FLASH_AREA_IMAGE_SCRATCH,
|
.fa_id = FLASH_AREA_IMAGE_SCRATCH,
|
||||||
|
@ -87,6 +88,10 @@ static struct area_desc flash_areas[1] = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.num_slots = 3
|
.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,
|
int flash_area_write(const struct flash_area *area, uint32_t off, const void *src,
|
||||||
uint32_t len)
|
uint32_t len)
|
||||||
{
|
{
|
||||||
uint32_t address;
|
|
||||||
BOOT_LOG_DBG("%s: area=%d, off=%x, len=%x", __func__,
|
BOOT_LOG_DBG("%s: area=%d, off=%x, len=%x", __func__,
|
||||||
area->fa_id, off, len);
|
area->fa_id, off, len);
|
||||||
hal_flash_unlock();
|
hal_flash_unlock();
|
||||||
|
|
Loading…
Reference in New Issue