-
Notifications
You must be signed in to change notification settings - Fork 7.9k
board: arm64: Add AArch32 virtual machine support for ROC-RK3588-PC #95311
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
|
||
#include <zephyr/arch/arm/mmu/arm_mmu.h> | ||
#include "arm_mmu_priv.h" | ||
#include "zephyr/cache.h" | ||
|
||
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); | ||
|
||
|
@@ -571,7 +572,7 @@ static void arm_mmu_l2_map_page(uint32_t va, uint32_t pa, | |
|
||
if (l1_page_table.entries[l1_index].undefined.id == ARM_MMU_PTE_ID_INVALID || | ||
(l1_page_table.entries[l1_index].undefined.id & ARM_MMU_PTE_ID_SECTION) != 0) { | ||
l2_page_table = arm_mmu_assign_l2_table(pa); | ||
l2_page_table = arm_mmu_assign_l2_table(va); | ||
__ASSERT(l2_page_table != NULL, | ||
"Unexpected L2 page table NULL pointer for VA 0x%08X", | ||
va); | ||
|
@@ -958,6 +959,7 @@ void arch_mem_map(void *virt, uintptr_t phys, size_t size, uint32_t flags) | |
LOG_ERR("__arch_mem_map() returned %d", ret); | ||
k_panic(); | ||
} else { | ||
sys_cache_data_flush_all(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will make the second bug disappear. But the reason I don't know. |
||
invalidate_tlb_all(); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2025 Syswonder | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/dts-v1/; | ||
|
||
#include <arm64/rockchip/rk3588.dtsi> | ||
#include <common/mem.h> | ||
|
||
/ { | ||
model = "Firefly ROC-RK3588"; | ||
compatible = "rockchip,rk3588"; | ||
|
||
chosen { | ||
zephyr,console = &uart3; | ||
zephyr,shell-uart = &uart3; | ||
zephyr,sram = &dram; | ||
}; | ||
|
||
dram: memory@50000000 { | ||
compatible = "mmio-sram"; | ||
device_type = "memory"; | ||
reg = <0x50000000 DT_SIZE_M(1)>; | ||
}; | ||
}; | ||
|
||
&uart3 { | ||
status = "okay"; | ||
current-speed = <115200>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
identifier: roc_rk3588_pc/rk3588_aarch32 | ||
name: Rockchip ROC RK3588 PC AArch32 | ||
type: mcu | ||
arch: arm | ||
toolchain: | ||
- zephyr | ||
- cross-compile | ||
ram: 1024 | ||
testing: | ||
ignore_tags: | ||
- net | ||
- bluetooth |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) 2025 Syswonder | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Platform Configuration | ||
CONFIG_ARM_ARCH_TIMER=y | ||
|
||
# Serial Drivers | ||
CONFIG_SERIAL=y | ||
CONFIG_UART_NS16550=y | ||
CONFIG_UART_INTERRUPT_DRIVEN=y | ||
|
||
# Enable console | ||
CONFIG_CONSOLE=y | ||
CONFIG_UART_CONSOLE=y | ||
|
||
CONFIG_CACHE_MANAGEMENT=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "roc_rk3588_pc.dts" | ||
#include "roc_rk3588_pc_rk3588_aarch64.dts" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -673,6 +673,9 @@ static bool arm_gic_aff_matching(uint64_t gicr_aff, uint64_t aff) | |
uint64_t mask = BIT64_MASK(8); | ||
|
||
return (gicr_aff & mask) == (aff & mask); | ||
#elif defined(CONFIG_ARM) | ||
/* For ARM (AArch32), only compare aff2:aff1:aff0 (lower 24 bits) */ | ||
return (gicr_aff & 0xFFFFFF) == (aff & 0xFFFFFF); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixes the first bug I mentioned. Armv7 doesn't have aff3. |
||
#else | ||
return gicr_aff == aff; | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
# Copyright (c) 2025 Syswonder | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
zephyr_sources_ifdef(CONFIG_ARM_MMU mmu_regions.c) | ||
|
||
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "") | ||
if(CONFIG_SOC_RK3588_AARCH64) | ||
zephyr_sources_ifdef(CONFIG_ARM_MMU aarch64/mmu_regions.c) | ||
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm64/scripts/linker.ld CACHE INTERNAL "") | ||
elseif(CONFIG_SOC_RK3588_AARCH32) | ||
zephyr_sources_ifdef(CONFIG_ARM_AARCH32_MMU aarch32/mmu_regions.c) | ||
zephyr_sources(aarch32/soc.c) | ||
zephyr_include_directories(aarch32) | ||
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld CACHE INTERNAL "") | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
# Copyright (c) 2025 Syswonder | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config SOC_RK3588 | ||
config SOC_RK3588_AARCH64 | ||
select ARM64 | ||
select CPU_CORTEX_A55 | ||
select ARM_ARCH_TIMER | ||
|
||
config SOC_PART_NUMBER | ||
default "RK3588" if SOC_RK3588 | ||
config SOC_RK3588_AARCH32 | ||
select ARM | ||
select CPU_CORTEX_A7 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2025 Syswonder | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include "zephyr/linker/linker-defs.h" | ||
#include <zephyr/devicetree.h> | ||
#include <zephyr/sys/util.h> | ||
#include <zephyr/arch/arm/mmu/arm_mmu.h> | ||
#include <mmu.h> | ||
|
||
static const struct arm_mmu_region mmu_regions[] = { | ||
MMU_REGION_FLAT_ENTRY("vector", (uintptr_t)_vector_start, 0x1000, | ||
MT_NORMAL | MATTR_SHARED | MPERM_R | MPERM_X), | ||
MMU_REGION_FLAT_ENTRY("GIC", DT_REG_ADDR_BY_IDX(DT_NODELABEL(gic), 0), | ||
DT_REG_SIZE_BY_IDX(DT_NODELABEL(gic), 0), | ||
MT_STRONGLY_ORDERED | MPERM_R | MPERM_W), | ||
|
||
MMU_REGION_FLAT_ENTRY("GIC", DT_REG_ADDR_BY_IDX(DT_NODELABEL(gic), 1), | ||
DT_REG_SIZE_BY_IDX(DT_NODELABEL(gic), 1), | ||
MT_STRONGLY_ORDERED | MPERM_R | MPERM_W), | ||
}; | ||
|
||
const struct arm_mmu_config mmu_config = { | ||
.num_regions = ARRAY_SIZE(mmu_regions), | ||
.mmu_regions = mmu_regions, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2025 Syswonder | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <zephyr/device.h> | ||
#include <zephyr/init.h> | ||
#include <zephyr/kernel.h> | ||
#include <zephyr/linker/linker-defs.h> | ||
|
||
#define VECTOR_ADDRESS ((uintptr_t)_vector_start) | ||
|
||
void relocate_vector_table(void) | ||
{ | ||
write_sctlr(read_sctlr() & ~HIVECS); | ||
write_vbar(VECTOR_ADDRESS & VBAR_MASK); | ||
barrier_isync_fence_full(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2025 Syswonder | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef _SOC_RK3588_AARCH32_H_ | ||
#define _SOC_RK3588_AARCH32_H_ | ||
|
||
/* Do not let CMSIS to handle GIC and Timer */ | ||
#define __GIC_PRESENT 0 | ||
#define __TIM_PRESENT 0 | ||
|
||
#endif /* _SOC_RK3588_AARCH32_H_ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ family: | |
socs: | ||
- name: rk3588s | ||
- name: rk3568 | ||
- name: rk3588 | ||
- name: rk3588_aarch64 | ||
- name: rk3588_aarch32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, I think this was a mistake before, but it doesn’t really have any impact.