Skip to content

Instantly share code, notes, and snippets.

@nmenon

nmenon/behavior Secret

Created January 7, 2022 19:25
Show Gist options
  • Save nmenon/f07bcd834cac0bf692ff77281828ea66 to your computer and use it in GitHub Desktop.
Save nmenon/f07bcd834cac0bf692ff77281828ea66 to your computer and use it in GitHub Desktop.
serror trap in u-boot instead of tf-a
U-Boot SPL 2022.01-rc4-21506-g0047313bd644 (Jan 07 2022 - 13:16:31 -0600)
SYSFW ABI: 3.1 (firmware rev 0x0015 '21.5.1--w2022.01-am62x (Terrifi')
am625_init: board_init_f done
am625_init: spl_boot_device: devstat = 0x4343 bootmedia = 0x8 bootindex = 0
Trying to boot from MMC2
U-Boot 2022.01-rc4-21506-g0047313bd644 (Jan 07 2022 - 13:16:31 -0600)
SoC: AM62X SR1.0
Model: Texas Instruments AM625 SK
EEPROM not available at 0x50, trying to read at 0x51
Board: AM62-SKEVM rev E1
DRAM: 2 GiB
MMC: mmc@fa00000: 1
Loading Environment from MMC... MMC Device 0 not found
*** Warning - No MMC card found, using default environment
In: serial@2800000
Out: serial@2800000
Err: serial@2800000
Net:
Warning: ethernet@8000000 (eth0) using random MAC address - 5a:be:b5:75:d9:b3
eth0: ethernet@8000000
Hit any key to stop autoboot: 0
=> mw 0x9010 10
"Error" handler, esr 0xbf000000
elr: 0000000080818fc0 lr : 0000000080819250 (reloc)
elr: 00000000fff44fc0 lr : 00000000fff45250
x0 : 0000000000000000 x1 : 00000000fffe4000
x2 : 0000000000000004 x3 : 00000000fdf130a2
x4 : 0000000000000100 x5 : 0000000000000000
x6 : 00000000fffb7d12 x7 : 0000000000000044
x8 : 0000000000000010 x9 : 0000000000000008
x10: 0000000000000000 x11: 00000000ffffffd0
x12: 000000000000000a x13: 000000000001869f
x14: 00000000fdf02010 x15: 0000000000000002
x16: 00000000fff3b214 x17: 0000000000000000
x18: 00000000fdf0bdd0 x19: 0000000000000000
x20: 0000000000000000 x21: 0000000000000000
x22: 00000000fdf128d0 x23: 0000000000000000
x24: 0000000000000000 x25: 0000000000000000
x26: 0000000000000000 x27: 0000000000000000
x28: 00000000fdf130c0 x29: 00000000fdf01df0
Code: 90000501 7100027f 1a9f07e0 b90ad820 (121e7a81)
Resetting CPU ...
resetting ...
System reset not supported on this platform
### ERROR ### Please RESET the board ###
+ifeq (${DEBUG},0)
+ CRASH_REPORTING := 1
+ HANDLE_EA_EL3_FIRST := 1
+endif
diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile
index b965848e2350..213bf684802b 100644
--- a/arch/arm/mach-k3/Makefile
+++ b/arch/arm/mach-k3/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_ARM64) += arm64-mmu.o
obj-$(CONFIG_CPU_V7R) += r5_mpu.o lowlevel_init.o
obj-$(CONFIG_TI_SECURE_DEVICE) += security.o
obj-$(CONFIG_ARM64) += cache.o
+obj-$(CONFIG_ARM64) += arm64-misc.o
ifeq ($(CONFIG_SPL_BUILD),y)
obj-$(CONFIG_K3_LOAD_SYSFW) += sysfw-loader.o
endif
diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
index caf9a3e9c5d9..fb4c40eead41 100644
--- a/arch/arm/mach-k3/am625_init.c
+++ b/arch/arm/mach-k3/am625_init.c
@@ -65,6 +65,8 @@ static void ctrl_mmr_unlock(void)
mmr_unlock(PADCFG_MMR1_BASE, 1);
}
+void __asm_k3_enable_serror(void);
+
void board_init_f(ulong dummy)
{
struct udevice *dev;
@@ -72,6 +74,8 @@ void board_init_f(ulong dummy)
#if defined(CONFIG_CPU_V7R)
setup_k3_mpu_regions();
+#else
+ __asm_k3_enable_serror();
#endif
/*
diff --git a/arch/arm/mach-k3/arm64-misc.S b/arch/arm/mach-k3/arm64-misc.S
new file mode 100644
index 000000000000..86b9481fc0e4
--- /dev/null
+++ b/arch/arm/mach-k3/arm64-misc.S
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+
+#if defined(CONFIG_SPL_BUILD)
+ENTRY(__asm_k3_enable_serror)
+ /* unmask SError and abort */
+ msr daifclr, #4
+
+ /* Set HCR_EL2[AMO] so SError @EL2 is taken */
+ mrs x0, hcr_el2
+ orr x0, x0, #0x20 /* AMO */
+ msr hcr_el2, x0
+ isb
+ ret
+ENDPROC(__asm_k3_enable_serror)
+#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment