Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ EXT_FLASH?=0
SPI_FLASH?=0
ALLOW_DOWNGRADE?=0
NVM_FLASH_WRITEONCE?=0
WOLFBOOT_VERSION?=0
V?=0
SPMATH?=1
RAM_CODE?=0



## Initializers
CFLAGS:=-D__WOLFBOOT
CFLAGS:=-D__WOLFBOOT -DWOLFBOOT_VERSION=$(WOLFBOOT_VERSION)UL
LSCRIPT:=hal/$(TARGET).ld
LDFLAGS:=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles
OBJS:= \
Expand Down Expand Up @@ -80,6 +82,10 @@ CFLAGS+=-Wall -Wextra -Wno-main -Wstack-usage=1024 -ffreestanding -Wno-unused \
-DWOLFSSL_USER_SETTINGS \
-DPLATFORM_$(TARGET)

ifeq ($(RAM_CODE),1)
CFLAGS+= -DRAM_CODE
endif

ifeq ($(SPI_FLASH),1)
EXT_FLASH=1
CFLAGS+= -DSPI_FLASH=1
Expand Down Expand Up @@ -142,7 +148,8 @@ wolfboot-align.bin: wolfboot.bin
@echo

test-app/image.bin:
@make -C test-app TARGET=$(TARGET) EXT_FLASH=$(EXT_FLASH) SPI_FLASH=$(SPI_FLASH) ARCH=$(ARCH) V=$(V) \
@make -C test-app TARGET=$(TARGET) EXT_FLASH=$(EXT_FLASH) SPI_FLASH=$(SPI_FLASH) ARCH=$(ARCH) \
V=$(V) RAM_CODE=$(RAM_CODE) WOLFBOOT_VERSION=$(WOLFBOOT_VERSION)\
KINETIS=$(KINETIS) KINETIS_CPU=$(KINETIS_CPU) KINETIS_DRIVERS=$(KINETIS_DRIVERS) \
KINETIS_CMSIS=$(KINETIS_CMSIS) NVM_FLASH_WRITEONCE=$(NVM_FLASH_WRITEONCE) \
FREEDOM_E_SDK=$(FREEDOM_E_SDK)
Expand Down
9 changes: 5 additions & 4 deletions hal/cc26x2.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ti-lib.h"

#include "target.h" /* For WOLFBOOT_SECTOR_SIZE */
#include "image.h"
extern void clock_init(void);

char uart_read(void)
Expand All @@ -42,24 +43,24 @@ int uart_read_nonblock(char *c)
}


int hal_flash_write(uint32_t address, const uint8_t *data, int len)
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
FlashProgram(data, address, len);
while(FlashCheckFsmForReady() != FAPI_STATUS_FSM_READY)
;
return 0;
}

void hal_flash_unlock(void)
void RAMFUNCTION hal_flash_unlock(void)
{
}

void hal_flash_lock(void)
void RAMFUNCTION hal_flash_lock(void)
{
}


int hal_flash_erase(uint32_t address, int len)
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
int i = 0;
while (len > 0) {
Expand Down
9 changes: 5 additions & 4 deletions hal/hifive1.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <stdint.h>
#include <target.h>
#include "image.h"
#ifndef ARCH_RISCV
# error "wolfBoot hifive1 HAL: wrong architecture selected. Please compile with ARCH=RISCV."
#endif
Expand All @@ -37,21 +38,21 @@ void hal_prepare_boot(void)

#endif

int hal_flash_write(uint32_t address, const uint8_t *data, int len)
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
return 0;
}

void hal_flash_unlock(void)
void RAMFUNCTION hal_flash_unlock(void)
{
}

void hal_flash_lock(void)
void RAMFUNCTION hal_flash_lock(void)
{
}


int hal_flash_erase(uint32_t address, int len)
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
return 0;
}
Expand Down
5 changes: 4 additions & 1 deletion hal/hifive1.ld
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SECTIONS
KEEP(*(.isr_vector))
*(.text*)
*(.rodata*)
*(.srodata*)
. = ALIGN(4);
_end_text = .;
} > FLASH
Expand All @@ -33,10 +34,12 @@ SECTIONS
_global_pointer = . + 0x800;
*(.sdata*)
. = ALIGN(4);
KEEP(*(.ramcode*))
. = ALIGN(4);
_end_data = .;
} > RAM

.bss :
.bss (NOLOAD) :
{
_start_bss = .;
*(.bss*)
Expand Down
9 changes: 5 additions & 4 deletions hal/kinetis.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <stdint.h>
#include <target.h>
#include "image.h"
#include "fsl_common.h"
#include "fsl_flash.h"
#include "fsl_ftfx_cache.h"
Expand Down Expand Up @@ -300,7 +301,7 @@ static void do_flash_init(void)
FTFx_CACHE_ClearCachePrefetchSpeculation(&pcache, 1);
}

int hal_flash_write(uint32_t address, const uint8_t *data, int len)
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
int w = 0;
int ret;
Expand Down Expand Up @@ -336,16 +337,16 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len)
return 0;
}

void hal_flash_unlock(void)
void RAMFUNCTION hal_flash_unlock(void)
{
}

void hal_flash_lock(void)
void RAMFUNCTION hal_flash_lock(void)
{
}


int hal_flash_erase(uint32_t address, int len)
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
int idx = 0;
do_flash_init();
Expand Down
11 changes: 6 additions & 5 deletions hal/nrf52.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include <stdint.h>
#include "image.h"

/* Assembly helpers */
#define DMB() __asm__ volatile ("dmb")
Expand All @@ -45,13 +46,13 @@
#define TASKS_HFCLKSTOP *((volatile uint32_t *)(CLOCK_CONTROL_BASE + 0x004))
#define TASKS_HFCLKSTARTED *((volatile uint32_t *)(CLOCK_CONTROL_BASE + 0x100))

static void flash_wait_complete(void)
static void RAMFUNCTION flash_wait_complete(void)
{
while (NVMC_READY == 0)
;
}

int hal_flash_write(uint32_t address, const uint8_t *data, int len)
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
int i = 0;
uint32_t *src, *dst;
Expand Down Expand Up @@ -82,16 +83,16 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len)
return 0;
}

void hal_flash_unlock(void)
void RAMFUNCTION hal_flash_unlock(void)
{
}

void hal_flash_lock(void)
void RAMFUNCTION hal_flash_lock(void)
{
}


int hal_flash_erase(uint32_t address, int len)
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
uint32_t end = address + len - 1;
uint32_t p;
Expand Down
9 changes: 5 additions & 4 deletions hal/samr21.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include <stdint.h>
#include "image.h"

/* Clock settings for cpu samd21g18a @ 48MHz */
#define CPU_FREQ (48000000)
Expand Down Expand Up @@ -154,7 +155,7 @@ void hal_prepare_boot(void)
}


int hal_flash_write(uint32_t address, const uint8_t *data, int len)
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
int i = 0;
uint32_t *src, *dst;
Expand Down Expand Up @@ -191,17 +192,17 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len)
return 0;
}

void hal_flash_unlock(void)
void RAMFUNCTION hal_flash_unlock(void)
{
PAC1_WPCLR |= (PAC_WP_NVMCTL);
}

void hal_flash_lock(void)
void RAMFUNCTION hal_flash_lock(void)
{
PAC1_WPSET |= (PAC_WP_NVMCTL);
}

int hal_flash_erase(uint32_t address, int len)
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
while (len > 0) {
NVMCTRL_ADDR = (address >> 1); /* This register holds the address of a 16-bit row */
Expand Down
17 changes: 9 additions & 8 deletions hal/stm32f4.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include <stdint.h>
#include <image.h>
/* STM32 F4 register configuration */

/* Assembly helpers */
Expand Down Expand Up @@ -135,12 +136,12 @@ const uint32_t flash_sector[FLASH_SECTORS + 1] = {
FLASH_TOP
};

static void flash_set_waitstates(int waitstates)
static void RAMFUNCTION flash_set_waitstates(int waitstates)
{
FLASH_ACR |= waitstates | FLASH_ACR_ENABLE_DATA_CACHE | FLASH_ACR_ENABLE_INST_CACHE;
}

static void flash_wait_complete(void)
static RAMFUNCTION void flash_wait_complete(void)
{
while ((FLASH_SR & FLASH_SR_BSY) == FLASH_SR_BSY)
;
Expand All @@ -155,7 +156,7 @@ static void mass_erase(void)
}
*/

static void flash_erase_sector(uint32_t sec)
static void RAMFUNCTION flash_erase_sector(uint32_t sec)
{
uint32_t reg = FLASH_CR & (~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT));
FLASH_CR = reg | (sec & FLASH_CR_SNB_MASK) << FLASH_CR_SNB_SHIFT;
Expand All @@ -166,12 +167,12 @@ static void flash_erase_sector(uint32_t sec)
FLASH_CR &= ~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT);
}

static void clear_errors(void)
static void RAMFUNCTION clear_errors(void)
{
FLASH_SR |= ( FLASH_SR_PGSERR | FLASH_SR_PGPERR | FLASH_SR_PGAERR | FLASH_SR_WRPERR | FLASH_SR_OPERR | FLASH_SR_EOP );
}

int hal_flash_write(uint32_t address, const uint8_t *data, int len)
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
int i;
uint32_t val;
Expand All @@ -188,20 +189,20 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len)
return 0;
}

void hal_flash_unlock(void)
void RAMFUNCTION hal_flash_unlock(void)
{
FLASH_CR |= FLASH_CR_LOCK;
FLASH_KEYR = FLASH_KEY1;
FLASH_KEYR = FLASH_KEY2;
}

void hal_flash_lock(void)
void RAMFUNCTION hal_flash_lock(void)
{
FLASH_CR |= FLASH_CR_LOCK;
}


int hal_flash_erase(uint32_t address, int len)
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
int start = -1, end = -1;
uint32_t end_address;
Expand Down
Loading