From 0348f79b45ad04878451d9f98618770cce717183 Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Sun, 24 May 2026 13:44:03 +0200 Subject: [PATCH] bsp/arm/tms570: Add VIM vector table ECC support for 4357x variants - introduces a variant-aware tms570_vim_t struct so the ECC version (on the 4357 variants) can be represented and we can set the required flags - adds the required LC4357 VIM ECC initialization sequence: set fallback vector (FBVECADDR), enable ECC and then clear ECC error flags after the for loop rewrites the vector table. See TRM section 19.5.1 Interrupt Vector Table Operation which states: It is recommended to restore the content of the VIM before clearing the ECCSTAT. --- bsps/arm/tms570/irq/irq.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/bsps/arm/tms570/irq/irq.c b/bsps/arm/tms570/irq/irq.c index e109734334..4a7ab549b4 100644 --- a/bsps/arm/tms570/irq/irq.c +++ b/bsps/arm/tms570/irq/irq.c @@ -361,9 +361,40 @@ void bsp_interrupt_facility_initialize(void) solution remaps that to address zero. */ +#if TMS570_VARIANT == 4357 + /* FBVECADDR value is indeterminate after reset until explicitly set. */ + TMS570_VIM_ECC.FBVECADDR = + (uint32_t) (uintptr_t) _ARMV4_Exception_interrupt; + + /* + * Enable ECC for the LC4357 VIM vector table (disabled by default) + * + * ECCCTL settings: + * SBE_EVT: disable to avoid sending single-bit errors to the ESM + * EDAC: detection-only mode (see TMS570LC4357 Silicon Errata VIM#28) + * TEST_DIAG: disable - we're in a normal start-up path + * ECCENA: enable ECC/SECDED feature + */ + TMS570_VIM_ECC.ECCCTL = + TMS570_VIM_ECCCTL_SBE_EVT_EN( TMS570_VIM_ECCCTL_SBE_EVT_DISABLE ) | + TMS570_VIM_ECCCTL_EDAC_MODE( TMS570_VIM_ECCCTL_EDAC_DISABLE ) | + TMS570_VIM_ECCCTL_TEST_DIAG_EN( TMS570_VIM_ECCCTL_TEST_DIAG_DISABLE ) | + TMS570_VIM_ECCCTL_ECCENA( TMS570_VIM_ECCCTL_ECC_ENABLE ); +#endif + for ( i = 0; i <= 94; ++i ) { vim_vec[i] = _ARMV4_Exception_interrupt; } + +#if TMS570_VARIANT == 4357 + /* + * Clear any latched errors after the ECC bits were generated above + * to start from a clean state at start-up. + */ + TMS570_VIM_ECC.ECCSTAT = + TMS570_VIM_ECCSTAT_SBERR | TMS570_VIM_ECCSTAT_UERR; +#endif + /* Clear bit VE in SCTLR register to not use VIM IRQ exception bypass*/ asm volatile ("mrc p15, 0, %0, c1, c0, 0\n": "=r" (sctlr)); /*