Skip to content

Instantly share code, notes, and snippets.

@apritzel
Created January 3, 2022 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apritzel/ba519c7a58e064b926d161f3afd1eaab to your computer and use it in GitHub Desktop.
Save apritzel/ba519c7a58e064b926d161f3afd1eaab to your computer and use it in GitHub Desktop.
U-Boot hack to boot AArch32 kernels from AArch64 EL2 U-Boot
diff --git a/arch/arm/include/asm/macro.h b/arch/arm/include/asm/macro.h
index ec0171e0e6c..430a9f0298a 100644
--- a/arch/arm/include/asm/macro.h
+++ b/arch/arm/include/asm/macro.h
@@ -325,6 +325,8 @@ lr .req x30
eret
1:
+ ldr \tmp, =0x00c00878
+ msr sctlr_el1, \tmp
/* Initialize HCR_EL2 */
ldr \tmp, =(HCR_EL2_RW_AARCH32 | HCR_EL2_HCD_DIS)
msr hcr_el2, \tmp
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 7260eb72a40..0a15114b396 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -17,6 +17,9 @@
#ifdef CONFIG_ARM64
#define CONFIG_SYS_BOOTM_LEN (32 << 20)
+#define CONFIG_ARMV8_SWITCH_TO_EL1
+#else
+#define CONFIG_SYS_BOOTM_LEN (32 << 20)
#endif
/* Serial & console */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment