Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platforms: add imx93 #372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

platforms: add imx93 #372

wants to merge 1 commit into from

Conversation

lsf37
Copy link
Member

@lsf37 lsf37 commented Dec 2, 2024

Currently there are no boards yet in CI for this platform. (To be changed in the next few months).

Should be merged after the following PRs are merged:

Currently there are no boards yet in CI for this platform. (To be
changed in the next few months).

Signed-off-by: Gerwin Klein <[email protected]>
@Ivan-Velickovic
Copy link
Contributor

Does it work with the problematic combinations like SMP + HYP + MCS?

I guess it doesn't matter until we actually get the hardware.

@lsf37
Copy link
Member Author

lsf37 commented Dec 2, 2024

Does it work with the problematic combinations like SMP + HYP + MCS?

I guess it doesn't matter until we actually get the hardware.

Yup, it works on SMP + HYP + MCS (Indan does have the hardware, the plan is to donate it to the foundation when the port is complete).

@Indanz
Copy link
Contributor

Indanz commented Dec 3, 2024

Yes, all combinations I tried work for me. Only configuration not supported is Aarch32.

@lsf37
Copy link
Member Author

lsf37 commented Dec 3, 2024

Was there a blocker for AArch32 or would it just be additional work? (I don't think we need it, just curious)

@Indanz
Copy link
Contributor

Indanz commented Dec 3, 2024

I think the GICv3 code was only tested with 64-bits. But we could set the GIC in backward compatibility mode and use the GICv2 driver on Aarch32. Or just review and test the GICv3 kernel driver for 32-bit. So no real blockers, just some additional work one way or the other.

@Ivan-Velickovic
Copy link
Contributor

I think the GICv3 code was only tested with 64-bits. But we could set the GIC in backward compatibility mode and use the GICv2 driver on Aarch32. Or just review and test the GICv3 kernel driver for 32-bit. So no real blockers, just some additional work one way or the other.

I thought we ran the i.MX8MM-EVK in 32-bit mode which has GICv3?

@Ivan-Velickovic
Copy link
Contributor

IMX8MM_EVK:
arch: arm
modes: [32, 64]
smp: [64]
platform: imx8mm-evk
req: [imx8mm]
march: armv8a

@Indanz
Copy link
Contributor

Indanz commented Dec 4, 2024

I did a quick test with the below patch applied, but for me it hangs in Elfloader with no output.
The command I used to build was:

$ ../test/init-build.sh -DPLATFORM=imx93 -DKernelArmExportPCNTUser=ON -DKernelArmExportPTMRUser=ON -DRELEASE=OFF -DMCS=ON -DAARCH32=TRUE -DCROSS_COMPILER_PREFIX=arm-linux-gnueabihf- ElfloaderArmV8LeaveAarch64=ON

diff --git a/libsel4/sel4_plat_include/imx93/sel4/plat/api/constants.h b/libsel4/sel4_plat_include/imx93/sel4/plat/api/constants.h
index 0496273f6..c22c1eefd 100644
--- a/libsel4/sel4_plat_include/imx93/sel4/plat/api/constants.h
+++ b/libsel4/sel4_plat_include/imx93/sel4/plat/api/constants.h
@@ -7,3 +7,8 @@
 
 #include <sel4/config.h>
 #include <sel4/arch/constants_cortex_a55.h>
+
+#if CONFIG_WORD_SIZE == 32
+/* First address in the virtual address space that is not accessible to user level */
+#define seL4_UserTop 0xe0000000
+#endif
diff --git a/src/arch/arm/armv/armv8-a/32/machine_asm.S b/src/arch/arm/armv/armv8-a/32/machine_asm.S
index 671d0de81..eabf76ebf 100644
--- a/src/arch/arm/armv/armv8-a/32/machine_asm.S
+++ b/src/arch/arm/armv/armv8-a/32/machine_asm.S
@@ -7,9 +7,9 @@
 #include <config.h>
 #include <machine/assembler.h>
 
-#if defined(CONFIG_ARM_CORTEX_A53)
+#if defined(CONFIG_ARM_CORTEX_A53) || defined(CONFIG_ARM_CORTEX_A55)
 
-/* A53 hardware does not support TLB locking */
+/* ARMv8 hardware does not support TLB locking */
 BEGIN_FUNC(lockTLBEntry)
     bx lr
 END_FUNC(lockTLBEntry)
diff --git a/src/plat/imx93/config.cmake b/src/plat/imx93/config.cmake
index 5d6ed8faf..b405617d4 100644
--- a/src/plat/imx93/config.cmake
+++ b/src/plat/imx93/config.cmake
@@ -9,15 +9,21 @@ cmake_minimum_required(VERSION 3.7.2)
 declare_platform(imx93 KernelPlatformIMX93 PLAT_IMX93 KernelArchARM)
 
 if(KernelPlatformIMX93)
-    declare_seL4_arch(aarch64)
+    declare_seL4_arch(aarch64 aarch32 arm_hyp)
     set(KernelArmCortexA55 ON)
     set(KernelArchArmV8a ON)
     set(KernelArmGicV3 ON)
     config_set(KernelARMPlatform ARM_PLAT ${KernelPlatform})
     list(APPEND KernelDTSList "tools/dts/${KernelPlatform}.dts")
-    list(APPEND KernelDTSList "src/plat/imx93/overlay-${KernelPlatform}.dts")
+    if(KernelSel4ArchAarch32)
+        list(APPEND KernelDTSList "src/plat/imx93/overlay-${KernelPlatform}-32.dts")
+    else()
+        list(APPEND KernelDTSList "src/plat/imx93/overlay-${KernelPlatform}.dts")
+    endif()
     declare_default_headers(
         TIMER_FREQUENCY 24000000
+        CLK_MAGIC 2863311531llu
+        CLK_SHIFT 36u
         TIMER drivers/timer/arm_generic.h
         TIMER_OVERHEAD_TICKS 1
         NUM_PPI 32

The alternative DTS file is necessary to avoid overflowing 32-bits on the memory range.

Any suggestions?

@Ivan-Velickovic
Copy link
Contributor

@Indanz I don't fully understand why this is the case for the i.MX8 based boards in AArch32 mode but it might be worth a shot doing something like this:

https://github.com/seL4/seL4_tools/blob/bef85f32a4829c5062fd6c808c7cab57b816cd9f/cmake-tool/helpers/application_settings.cmake#L40-L48

@Indanz
Copy link
Contributor

Indanz commented Dec 5, 2024

@Indanz I don't fully understand why this is the case for the i.MX8 based boards in AArch32 mode

The ElfloaderArmV8LeaveAarch64 is to tell Elfloader that it will start in 64-bit mode and hence needs to exit to 32-bit mode before it can proceed.

The comment is talking about ElfloaderImage needing to be set to binary, instead of uimage. I've only tried elf, which didn't work for me with bootelf. Why that doesn't work may also apply to uimage I guess, but haven't found out why. I don't know if setting IMAGE_START_ADDR somehow forces the image to be binary automatically or something.

Anyway, thanks for the hint, I'll fiddle with IMAGE_START_ADDR and see if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants