Skip to content

Commit

Permalink
board: s32z2xxdc2: allow the code to be executed from code RAM
Browse files Browse the repository at this point in the history
- Trace32 runner: no need to configure TE bit in CFG_CORE
register in the cmm start-up script, it can be configured
at Zephyr start-up code when required (via SCTRL register)

- MPU static regions also needs to be updated for XIP and
non-XIP

Signed-off-by: Dat Nguyen Duy <[email protected]>
  • Loading branch information
Dat-NguyenDuy committed Nov 8, 2024
1 parent 36c1859 commit 359eaaf
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
13 changes: 13 additions & 0 deletions boards/nxp/s32z2xxdc2/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,17 @@ config NET_L2_ETHERNET

endif # NETWORKING

if XIP
# Offset between CRAM AXIM and CRAM AXIF, code will be downloaded
# over AXIM interface
config BUILD_OUTPUT_ADJUST_LMA
default "-0x47800000"

config CPU_CORTEX_R52_ICACHE_FLASH_WAY
default 4

config CPU_CORTEX_R52_DCACHE_FLASH_WAY
default 1
endif # XIP

endif # BOARD_S32Z2XXDC2_S32Z270_RTU0 || BOARD_S32Z2XXDC2_S32Z270_RTU1
2 changes: 1 addition & 1 deletion boards/nxp/s32z2xxdc2/s32z2xxdc2_s32z270_rtu0_defconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2022,2024 NXP
# SPDX-License-Identifier: Apache-2.0

CONFIG_XIP=n
CONFIG_XIP=y
CONFIG_ISR_STACK_SIZE=512
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=8000000
Expand Down
2 changes: 1 addition & 1 deletion boards/nxp/s32z2xxdc2/s32z2xxdc2_s32z270_rtu1_defconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2022,2024 NXP
# SPDX-License-Identifier: Apache-2.0

CONFIG_XIP=n
CONFIG_XIP=y
CONFIG_ISR_STACK_SIZE=512
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=8000000
Expand Down
15 changes: 3 additions & 12 deletions boards/nxp/s32z2xxdc2/support/startup.cmm
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,17 @@
; - Core0 and Core2 (redundancy) operate as a lockstep pair *
; - Core1 and Core3 (redundancy) operate as a lockstep pair *
; default: yes *
; - thumb set to "yes" to select the T32 instruction set at reset *
; default: no *
; *
;*******************************************************************************

ENTRY %LINE &args
LOCAL &rtuStartAddr &cfgCoreAddr &coreId &rtuId &thumbBit &spltLckBit
LOCAL &rtuStartAddr &cfgCoreAddr &coreId &rtuId &spltLckBit

&command=STRing.SCANAndExtract("&args","command=","debug")
&elfFile=STRing.SCANAndExtract("&args","elfFile=","")
&rtu=STRing.SCANAndExtract("&args","rtu=","0")
&core=STRing.SCANAndExtract("&args","core=","0")
&lockstep=STRing.SCANAndExtract("&args","lockstep=","yes")
&thumb=STRing.SCANAndExtract("&args","thumb=","no")

IF ("&elfFile"=="")
(
Expand All @@ -59,12 +56,6 @@ IF (&core<0||&core>3)
ENDDO
)

; select ARMv8 instruction set at reset for all Cortex-R52 cores (CFG_CORE.THUMB bit)
IF ("&thumb"=="yes")
&thumbBit="1"
ELSE
&thumbBit="0"

; select lock-step or split-lock mode (CFG_CORE.SPLT_LCK bit)
IF ("&lockstep"=="yes")
&spltLckBit="0"
Expand Down Expand Up @@ -126,8 +117,8 @@ GOSUB EnableRTU1
; Init RTU SRAM
DO ~~/demo/arm/hardware/s32z27/misc/s32z27_init_rtu&(rtu)_sram.cmm

; Set reset value for TE bit and split-lock mode
Data.Set EZAXI:&cfgCoreAddr %Long 0yXXXXxxxxXXXXxxxxXXXXxxxxXXXXx&(thumbBit)x&(spltLckBit) ; CFG_CORE
; Set reset value for split-lock mode
Data.Set EZAXI:&cfgCoreAddr %Long 0yXXXXxxxxXXXXxxxxXXXXxxxxXXXXxxx&(spltLckBit) ; CFG_CORE

; Write loop to self instruction
Data.Set EAXI:&rtuStartAddr %Long 0xFFFEF7FF
Expand Down
17 changes: 11 additions & 6 deletions soc/nxp/s32/s32ze/mpu_regions.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@
#define DEVICE_REGION_END 0x76FFFFFFUL

static const struct arm_mpu_region mpu_regions[] = {
MPU_REGION_ENTRY("vector",
(uintptr_t)_vector_start,
REGION_RAM_TEXT_ATTR((uintptr_t)_vector_end)),

MPU_REGION_ENTRY("SRAM_TEXT",
(uintptr_t)__text_region_start,
(uintptr_t)__rom_region_start,
REGION_RAM_TEXT_ATTR((uintptr_t)__rodata_region_start)),

MPU_REGION_ENTRY("SRAM_RODATA",
(uintptr_t)__rodata_region_start,
REGION_RAM_RO_ATTR((uintptr_t)__rodata_region_end)),
#ifdef CONFIG_XIP
REGION_RAM_RO_ATTR(CONFIG_FLASH_BASE_ADDRESS + KB(CONFIG_FLASH_SIZE))
#else
REGION_RAM_RO_ATTR((uintptr_t)__rodata_region_end)
#endif
),

Check notice on line 26 in soc/nxp/s32/s32ze/mpu_regions.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

soc/nxp/s32/s32ze/mpu_regions.c:26 - MPU_REGION_ENTRY("SRAM_TEXT", - (uintptr_t)__rom_region_start, + MPU_REGION_ENTRY("SRAM_TEXT", (uintptr_t)__rom_region_start, REGION_RAM_TEXT_ATTR((uintptr_t)__rodata_region_start)), - MPU_REGION_ENTRY("SRAM_RODATA", - (uintptr_t)__rodata_region_start, + MPU_REGION_ENTRY("SRAM_RODATA", (uintptr_t)__rodata_region_start, #ifdef CONFIG_XIP REGION_RAM_RO_ATTR(CONFIG_FLASH_BASE_ADDRESS + KB(CONFIG_FLASH_SIZE)) #else REGION_RAM_RO_ATTR((uintptr_t)__rodata_region_end) #endif - ), + ),
MPU_REGION_ENTRY("SRAM_DATA",
#ifdef CONFIG_XIP
(uintptr_t)_image_ram_start,
#else
(uintptr_t)__rom_region_end,
#endif
REGION_RAM_ATTR((uintptr_t)__kernel_ram_end)),

MPU_REGION_ENTRY("DEVICE",
Expand Down

0 comments on commit 359eaaf

Please sign in to comment.