Skip to content
Open
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: 10 additions & 1 deletion hal/max32666.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ static void RAMFUNCTION icc_disable(void)

static void RAMFUNCTION icc_enable(void)
{
/* Invalidate and re-enable cache */
/* Invalidate cache, wait for completion, then re-enable */
ICC0_INVALIDATE = 1;
while (!(ICC0_CTRL & ICC_CTRL_RDY)) {}
ICC0_CTRL |= ICC_CTRL_EN;
while (!(ICC0_CTRL & ICC_CTRL_RDY)) {}
}
Expand Down Expand Up @@ -325,6 +326,14 @@ void hal_init(void)
FLC0_CLKDIV = FLC_CLKDIV_VALUE;
FLC1_CLKDIV = FLC_CLKDIV_VALUE;

/* Point VTOR at our vector table so faults hit our handlers */
*(volatile uint32_t *)0xE000ED08 = 0x10000000;

/* Disable the ICC read buffer via TME before enabling the cache */
TME_CTRL = 1;
SIR_TRIM_ICC = SIR_TRIM_ICC_RB_DIS;
TME_CTRL = 0;

/* Enable instruction cache */
icc_enable();

Expand Down
5 changes: 5 additions & 0 deletions hal/max32666.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@
#define ICC_CTRL_EN (1UL << 0) /* Cache enable */
#define ICC_CTRL_RDY (1UL << 16) /* Cache ready */

/* Test mode / trim registers */
#define TME_CTRL (*(volatile uint32_t *)0x40000C00UL)
#define SIR_TRIM_ICC (*(volatile uint32_t *)0x4000040CUL)
#define SIR_TRIM_ICC_RB_DIS (1UL << 6) /* Read buffer disable */

/* ============== WDT - Watchdog Timer ============== */
/* MSDK: wdt_regs.h */
#define WDT0_BASE 0x40003000UL
Expand Down
3 changes: 2 additions & 1 deletion src/libwolfboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ int wolfBoot_initialize_encryption(void)
#undef WOLFBOOT_FIXED_PARTITIONS
#endif

#if defined(EXT_FLASH) && !defined(WOLFBOOT_NO_PARTITIONS)
#if defined(EXT_FLASH) && !defined(WOLFBOOT_NO_PARTITIONS) && \
!defined(CUSTOM_PARTITION_TRAILER)
static uint32_t ext_cache;
#endif

Expand Down
5 changes: 4 additions & 1 deletion src/update_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,9 @@ static int RAMFUNCTION wolfBoot_update(int fallback_allowed)
int fallback_image = 0;
#ifndef DISABLE_BACKUP
int rollback_needed = 0;
#ifdef CUSTOM_PARTITION_TRAILER
(void)rollback_needed;
#endif
int bootStateRet = -1;
uint8_t bootState = 0;
#endif
Expand Down Expand Up @@ -1444,7 +1447,7 @@ void RAMFUNCTION wolfBoot_start(void)
int bootRet;
#ifndef WOLFBOOT_SELF_UPDATE_MONOLITHIC
int updateRet;
#ifndef DISABLE_BACKUP
#if !defined(DISABLE_BACKUP) && !defined(CUSTOM_PARTITION_TRAILER)
int resumedFinalErase;
#endif
uint8_t bootState;
Expand Down
Loading