From 493f7b10d2dbc0b2f251c3439d8bbb38121d42a3 Mon Sep 17 00:00:00 2001 From: Manuel Arguelles Date: Fri, 26 May 2023 00:00:00 +0000 Subject: [PATCH] boards: arm: introduce NXP MR-CANHUBK3 board MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NXP MR-CANHUBK3 is an evaluation board for mobile robotics applications. It features an NXP S32K344 MCU based on an Arm Cortex-M7 core (lock-step). By default, this board configuration uses Lauterbach TRACE32 West runner for flashing and debugging applications, but other debuggers can be used to download the program to flash. Co-authored-by: Dat Nguyen Duy Co-authored-by: Cong Nguyen Huu Signed-off-by: Manuel Argüelles --- boards/arm/mr_canhubk3/Kconfig.board | 7 + boards/arm/mr_canhubk3/Kconfig.defconfig | 9 ++ boards/arm/mr_canhubk3/board.cmake | 17 +++ boards/arm/mr_canhubk3/mr_canhubk3.dts | 39 ++++++ boards/arm/mr_canhubk3/mr_canhubk3.yaml | 11 ++ boards/arm/mr_canhubk3/mr_canhubk3_defconfig | 19 +++ boards/arm/mr_canhubk3/support/debug.cmm | 13 ++ boards/arm/mr_canhubk3/support/flash.cmm | 13 ++ boards/arm/mr_canhubk3/support/startup.cmm | 128 +++++++++++++++++++ 9 files changed, 256 insertions(+) create mode 100644 boards/arm/mr_canhubk3/Kconfig.board create mode 100644 boards/arm/mr_canhubk3/Kconfig.defconfig create mode 100644 boards/arm/mr_canhubk3/board.cmake create mode 100644 boards/arm/mr_canhubk3/mr_canhubk3.dts create mode 100644 boards/arm/mr_canhubk3/mr_canhubk3.yaml create mode 100644 boards/arm/mr_canhubk3/mr_canhubk3_defconfig create mode 100644 boards/arm/mr_canhubk3/support/debug.cmm create mode 100644 boards/arm/mr_canhubk3/support/flash.cmm create mode 100644 boards/arm/mr_canhubk3/support/startup.cmm diff --git a/boards/arm/mr_canhubk3/Kconfig.board b/boards/arm/mr_canhubk3/Kconfig.board new file mode 100644 index 0000000000..3cea453a2a --- /dev/null +++ b/boards/arm/mr_canhubk3/Kconfig.board @@ -0,0 +1,7 @@ +# Copyright 2023 NXP +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_MR_CANHUBK3 + bool "mr_canhubk3" + depends on SOC_SERIES_S32K3_M7 + select SOC_PART_NUMBER_S32K344 diff --git a/boards/arm/mr_canhubk3/Kconfig.defconfig b/boards/arm/mr_canhubk3/Kconfig.defconfig new file mode 100644 index 0000000000..51acd02877 --- /dev/null +++ b/boards/arm/mr_canhubk3/Kconfig.defconfig @@ -0,0 +1,9 @@ +# Copyright 2023 NXP +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_MR_CANHUBK3 + +config BOARD + default "mr_canhubk3" + +endif # BOARD_MR_CANHUBK3 diff --git a/boards/arm/mr_canhubk3/board.cmake b/boards/arm/mr_canhubk3/board.cmake new file mode 100644 index 0000000000..50b093e650 --- /dev/null +++ b/boards/arm/mr_canhubk3/board.cmake @@ -0,0 +1,17 @@ +# Copyright 2023 NXP +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(trace32 + "--startup-args" + "elfFile=${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME}" +) +if(${CONFIG_XIP}) + board_runner_args(trace32 "loadTo=flash") +else() + board_runner_args(trace32 "loadTo=sram") +endif() + +board_runner_args(jlink "--device=S32K344") + +include(${ZEPHYR_BASE}/boards/common/trace32.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/arm/mr_canhubk3/mr_canhubk3.dts b/boards/arm/mr_canhubk3/mr_canhubk3.dts new file mode 100644 index 0000000000..601101361c --- /dev/null +++ b/boards/arm/mr_canhubk3/mr_canhubk3.dts @@ -0,0 +1,39 @@ +/* + * Copyright 2023 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "NXP MR-CANHUBK3"; + compatible = "nxp,mr_canhubk3"; + + chosen { + zephyr,sram = &sram0_1; + zephyr,flash = &flash0; + zephyr,itcm = &itcm; + zephyr,dtcm = &dtcm; + zephyr,code-partition = &code_partition; + }; +}; + +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + ivt_header: partition@0 { + label = "ivt-header"; + reg = <0x00000000 0x100>; + }; + + code_partition: partition@100 { + label = "code-partition"; + reg = <0x00000100 (DT_SIZE_K(4048) - 0x100)>; + }; + }; +}; diff --git a/boards/arm/mr_canhubk3/mr_canhubk3.yaml b/boards/arm/mr_canhubk3/mr_canhubk3.yaml new file mode 100644 index 0000000000..6ac915e77b --- /dev/null +++ b/boards/arm/mr_canhubk3/mr_canhubk3.yaml @@ -0,0 +1,11 @@ +# Copyright 2023 NXP +# SPDX-License-Identifier: Apache-2.0 + +identifier: mr_canhubk3 +name: NXP MR-CANHUBK3 +type: mcu +arch: arm +ram: 1024 +flash: 1024 +toolchain: + - zephyr diff --git a/boards/arm/mr_canhubk3/mr_canhubk3_defconfig b/boards/arm/mr_canhubk3/mr_canhubk3_defconfig new file mode 100644 index 0000000000..f80f8fdc71 --- /dev/null +++ b/boards/arm/mr_canhubk3/mr_canhubk3_defconfig @@ -0,0 +1,19 @@ +# Copyright 2023 NXP +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_BOARD_MR_CANHUBK3=y +CONFIG_SOC_S32K344_M7=y +CONFIG_SOC_SERIES_S32K3_M7=y +CONFIG_BUILD_OUTPUT_HEX=y + +# Use Systick as system clock +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=160000000 + +# Run from internal Flash +CONFIG_XIP=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# Use no-cached memory for HAL +CONFIG_NOCACHE_MEMORY=y diff --git a/boards/arm/mr_canhubk3/support/debug.cmm b/boards/arm/mr_canhubk3/support/debug.cmm new file mode 100644 index 0000000000..276f5d63e5 --- /dev/null +++ b/boards/arm/mr_canhubk3/support/debug.cmm @@ -0,0 +1,13 @@ +;******************************************************************************* +; Copyright 2023 NXP * +; SPDX-License-Identifier: Apache-2.0 * +; * +; Lauterbach TRACE32 start-up script for debugging mr_canhubk3 * +; * +;******************************************************************************* + +ENTRY %LINE &args + +DO ~~~~/startup.cmm command=debug &args + +ENDDO diff --git a/boards/arm/mr_canhubk3/support/flash.cmm b/boards/arm/mr_canhubk3/support/flash.cmm new file mode 100644 index 0000000000..59601b7f36 --- /dev/null +++ b/boards/arm/mr_canhubk3/support/flash.cmm @@ -0,0 +1,13 @@ +;******************************************************************************* +; Copyright 2023 NXP * +; SPDX-License-Identifier: Apache-2.0 * +; * +; Lauterbach TRACE32 start-up script for flashing mr_canhubk3 * +; * +;******************************************************************************* + +ENTRY %LINE &args + +DO ~~~~/startup.cmm command=flash &args + +ENDDO diff --git a/boards/arm/mr_canhubk3/support/startup.cmm b/boards/arm/mr_canhubk3/support/startup.cmm new file mode 100644 index 0000000000..2a7194937a --- /dev/null +++ b/boards/arm/mr_canhubk3/support/startup.cmm @@ -0,0 +1,128 @@ +;******************************************************************************* +; Copyright 2023 NXP * +; * +; Lauterbach Trace32 start-up script for S32K344 / Cortex-M7 * +; * +; Parameters: * +; - command operation to execute * +; valid values: flash, debug * +; - elfFile filepath of ELF to load * +; - loadTo if "flash", the application will be downloaded to SoC * +; program flash by a flash programming routine; if "sram" it * +; will be downloaded to SoC SRAM. * +; valid values: flash, sram * +; default: flash * +; - eraseFlash if set to "yes", the whole content in Flash device will be * +; erased before the application is downloaded to either Flash * +; or SRAM. This routine takes time to execute * +; default: "no" * +; - verifyFlash if set to "yes", verify after program application to Flash * +; default: "no" * +;******************************************************************************* + +ENTRY %LINE &args + +&command=STRing.SCANAndExtract("&args","command=","") +&elfFile=STRing.SCANAndExtract("&args","elfFile=","") +&loadTo=STRing.SCANAndExtract("&args","loadTo=","flash") +&eraseFlash=STRing.SCANAndExtract("&args","eraseFlash=","no") +&verifyFlash=STRing.SCANAndExtract("&args","verifyFlash=","no") + +IF ("&elfFile"=="") +( + PRINT %ERROR "Missing ELF file path" + PLIST + STOP + ENDDO +) + +; Initialize debugger +RESet +SYStem.RESet +SYStem.CPU S32K344-M7 +SYStem.CONFIG.DEBUGPORTTYPE JTAG +SYStem.Option.DUALPORT ON +SYStem.Option.DisMode THUMB +SYStem.MemAccess DAP +SYStem.JtagClock 10MHz +Trace.DISable +TrOnchip.Set MMERR OFF +TrOnchip.Set BUSERR OFF +SYStem.Up + +; Init SRAM +DO ~~/demo/arm/hardware/s32k3/scripts/init_sram.cmm + +; Only declares flash, does not execute flash programming +DO ~~/demo/arm/flash/s32k3.cmm PREPAREONLY + +; The prepare cmm is protecting flash area for HSE firmware, but +; since HSE firmware usage feature is not enabled, this region can +; be used by application core, marked as programmable. +FLASH.CHANGEtype 0x007D4000--0x7F3FFF TARGET + +IF ("&eraseFlash"=="yes") +( + FLASH.Erase ALL +) + +IF ("&loadTo"=="flash") +( + ; Switch target flash to reprogramming state, erase virtual flash programming memory, + ; all target non-empty flash sectors are marked as pending, to be reprogrammed. + FLASH.ReProgram ALL /Erase + + ; Write contents of the file to virtual Flash programming memory + Data.LOAD.Elf &elfFile + + ; Program only changed sectors to target flash and erase obsolete code + FLASH.ReProgram off + + IF ("&verifyFlash"=="yes") + ( + Data.LOAD.Elf &elfFile /DIFF + + IF FOUND() + ( + AREA.view + PRINT %ERROR "ERROR ! Failed to download the code to flash" + Data.LOAD.Elf &elfFile /ComPare + ENDDO + ) + ) + + ; Reset the processor + SYStem.Up +) +ELSE +( + ; Init ITCM + DO ~~/demo/arm/hardware/s32k3/scripts/init_itcm.cmm + + Data.LOAD.Elf &elfFile +) + +IF ("&command"=="flash") +( + ; Execute the application and quit + Go + QUIT +) +ELSE IF ("&command"=="debug") +( + ; Setup minimal debug environment + WinCLEAR + SETUP.Var.%SpotLight + WinPOS 0. 0. 120. 30. + List.auto + WinPOS 125. 0. 80. 10. + Frame.view + WinPOS 125. 18. + Register.view /SpotLight +) +ELSE +( + PRINT %ERROR "Invalid command" +) + +ENDDO