Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion arch/arm/core/mmu/arm_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Copy link
Contributor Author

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.

__ASSERT(l2_page_table != NULL,
"Unexpected L2 page table NULL pointer for VA 0x%08X",
va);
Expand Down Expand Up @@ -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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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();
}
}
Expand Down
3 changes: 2 additions & 1 deletion boards/firefly/roc_rk3588_pc/Kconfig.roc_rk3588_pc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# SPDX-License-Identifier: Apache-2.0

config BOARD_ROC_RK3588_PC
select SOC_RK3588
select SOC_RK3588_AARCH64 if BOARD_ROC_RK3588_PC_RK3588_AARCH64 || BOARD_ROC_RK3588_PC_RK3588_AARCH64_SMP
select SOC_RK3588_AARCH32 if BOARD_ROC_RK3588_PC_RK3588_AARCH32
3 changes: 2 additions & 1 deletion boards/firefly/roc_rk3588_pc/board.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ board:
full_name: ROC-RK3588-PC (Quad-core Cortex-A55)
vendor: firefly
socs:
- name: rk3588
- name: rk3588_aarch64
variants:
- name: smp
- name: rk3588_aarch32
64 changes: 39 additions & 25 deletions boards/firefly/roc_rk3588_pc/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ Overview
The ROC-RK3588-PC is an Octa-Core 64-Bit Mini Computer powered by Rockchip RK3588, which supports up to 32GB RAM.
It features M.2 PCIe3.0 interface for NVMe SSD expansion and provides rich interfaces including HDMI 2.1, DP1.4.
Supporting WiFi 6 wireless transmission and Gigabit Ethernet, it enables high-speed network connectivity.
More information can refer to `Firefly website <firefly_website_>`_.

RK3588 octa-core 64-bit processor (4×Cortex-A76+4×Cortex-A55), with 8nm lithography process,
has frequency up to 2.4GHz. Integrated with ARM Mali-G610 MP4 quad-core GPU and built-in AI accelerator NPU,
it provides 6Tops computing power. Zephyr OS is ported to run on it.

The RK3588 has a cluster with quad-core Cortex-A55 and quad-core Cortex-A76 of which the
cores are all single-threaded. Both Cortex-A55 and Cortex-A76 processors implement the ARMv8-A architecture.
And the processors support both the AArch32 and AArch64 execution states at all Exception levels (EL0 to EL3).
Zephyr currently supports running natively on bare-metal RK3588 with quad-core Cortex-A55, as well as running as a virtual machine in both AArch64 and AArch32 modes.

- Board features:

Expand All @@ -24,11 +25,6 @@ it provides 6Tops computing power. Zephyr OS is ported to run on it.

- Supports WiFi 6 (802.11 a/b/g/n/ac/ax)
- Supports BT 5.0
- Display:

- HDMI 2.1 (8K@60fps)
- HDMI 2.0 (4K@60fps)
- DP 1.4 (8K@30fps)
- USB:

- Two USB 3.0
Expand Down Expand Up @@ -63,43 +59,61 @@ Cortex-A76 cores run up to 2.4 GHz and Cortex-A55 cores run up to 1.8 GHz.
Serial Port
-----------

This board configuration uses a single serial communication channel with the
CPU's UART2.
This board configuration uses UART2 and UART3 as the serial ports.
When Zephyr runs in bare-metal mode, UART2 is used as the serial port.
When Zephyr runs in virtual machine, UART3 can be used as the serial port.
The Hypervisor is responsible for correctly initializing UART3.

Programming and Debugging
*************************

.. zephyr:board-supported-runners::
Running on Bare Metal or AArch64 Virtual Machine
=================================================

To run Zephyr on bare-metal RK3588 hardware or within an AArch64 virtual machine, use this configuration for basic Zephyr applications and kernel tests.
For example, with the :zephyr:code-sample:`synchronization` sample:

.. zephyr-app-commands::
:zephyr-app: samples/synchronization
:host-os: unix
:board: roc_rk3588_pc/rk3588_aarch64
:goals: build

Use U-Boot to load the zephyr.bin to the memory and kick it:
Then use U-Boot to load the zephyr.bin to the memory and kick it:

.. code-block:: console

tftp 0x50000000 zephyr.bin; dcache flush; icache flush; dcache off; icache off; go 0x50000000

Use this configuration to run basic Zephyr applications and kernel tests,
for example, with the :zephyr:code-sample:`synchronization` sample:
For SMP (Symmetric Multiprocessing) support on ``roc_rk3588_pc//smp``, use this configuration to build Zephyr SMP applications.
For example, with the :zephyr:code-sample:`synchronization` sample:

.. zephyr-app-commands::
:zephyr-app: samples/synchronization
:host-os: unix
:board: roc_rk3588_pc
:goals: run
:board: roc_rk3588_pc/rk3588_aarch64/smp
:goals: build

To run Zephyr within an AArch64 virtual machine, use the same build commands as for bare-metal. However, the way to launch Zephyr will depend on the hypervisor.

For ``roc_rk3588_pc//smp`` support, use this configuration to run Zephyr smp applications and subsys tests,
for example, with the :zephyr:code-sample:`synchronization` sample:
Running within AArch32 Virtual Machine
======================================

To run Zephyr within an AArch32 virtual machine, use this configuration for basic Zephyr applications and kernel tests.
For example, with the :zephyr:code-sample:`synchronization` sample:

.. zephyr-app-commands::
:zephyr-app: samples/synchronization
:host-os: unix
:board: roc_rk3588_pc//smp
:goals: run
:board: roc_rk3588_pc/rk3588_aarch32
:goals: build

Then launch Zephyr using a hypervisor that supports AArch32 guest mode, such as `hvisor <hvisor_website_>`_.

References
==========

More information can refer to Firefly official website:
`Firefly website`_.
.. target-notes::

.. _Firefly website:
https://en.t-firefly.com/product/industry/rocrk3588pc.html?theme=pc
.. _firefly_website: https://en.t-firefly.com/product/industry/rocrk3588pc.html?theme=pc
.. _hvisor_website: https://github.com/syswonder/hvisor
Binary file added boards/firefly/roc_rk3588_pc/doc/rk3588_pc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions boards/firefly/roc_rk3588_pc/roc_rk3588_pc_rk3588_aarch32.dts
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>;
};
12 changes: 12 additions & 0 deletions boards/firefly/roc_rk3588_pc/roc_rk3588_pc_rk3588_aarch32.yaml
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
@@ -1,4 +1,4 @@
identifier: roc_rk3588_pc
identifier: roc_rk3588_pc/rk3588_aarch64
name: Rockchip ROC RK3588 PC
type: mcu
arch: arm64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
@@ -1,4 +1,4 @@
identifier: roc_rk3588_pc/rk3588/smp
identifier: roc_rk3588_pc/rk3588_aarch64/smp
name: Rockchip ROC RK3588 PC SMP
type: mcu
arch: arm64
Expand Down
3 changes: 3 additions & 0 deletions drivers/interrupt_controller/intc_gicv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
13 changes: 9 additions & 4 deletions soc/rockchip/rk35/rk3588/CMakeLists.txt
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()
7 changes: 4 additions & 3 deletions soc/rockchip/rk35/rk3588/Kconfig
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
14 changes: 12 additions & 2 deletions soc/rockchip/rk35/rk3588/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

if SOC_RK3588

rsource "Kconfig.defconfig.rk3588"
config FLASH_SIZE
default 0

endif # SOC_SERIES_RK3588
config FLASH_BASE_ADDRESS
default 0

config NUM_IRQS
default 370

config SYS_CLOCK_HW_CYCLES_PER_SEC
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)

endif
18 changes: 0 additions & 18 deletions soc/rockchip/rk35/rk3588/Kconfig.defconfig.rk3588

This file was deleted.

11 changes: 10 additions & 1 deletion soc/rockchip/rk35/rk3588/Kconfig.soc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@ config SOC_RK3588
bool
select SOC_SERIES_RK35

config SOC_RK3588_AARCH64
bool
select SOC_RK3588

config SOC_RK3588_AARCH32
bool
select SOC_RK3588

config SOC
default "rk3588" if SOC_RK3588
default "rk3588_aarch32" if SOC_RK3588_AARCH32
default "rk3588_aarch64" if SOC_RK3588_AARCH64
26 changes: 26 additions & 0 deletions soc/rockchip/rk35/rk3588/aarch32/mmu_regions.c
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,
};
17 changes: 17 additions & 0 deletions soc/rockchip/rk35/rk3588/aarch32/soc.c
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();
}
13 changes: 13 additions & 0 deletions soc/rockchip/rk35/rk3588/aarch32/soc.h
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_ */
3 changes: 2 additions & 1 deletion soc/rockchip/soc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ family:
socs:
- name: rk3588s
- name: rk3568
- name: rk3588
- name: rk3588_aarch64
- name: rk3588_aarch32