diff --git a/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/_index.md b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/_index.md new file mode 100644 index 0000000000..411eb97625 --- /dev/null +++ b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/_index.md @@ -0,0 +1,53 @@ +--- +title: Porting Zephyr and Running Applications on the Corstone-320 MPS4 Platform +minutes_to_complete: 45 + +who_is_this_for: + This topic is for embedded developers who want to run the Zephyr RTOS on the Arm Corstone-320 MPS4 FPGA platform. It focuses on the board enablement work and application workflow. + +learning_objectives: + - Set up Zephyr development environment for Corstone-320 MPS4 + - Configure device tree and board support packages to port Zephyr RTOS to MPS4 platform + - Build and run applications + +prerequisites: + - Basic familiarity with embedded C programming + - Basic knowledge of Zephyr RTOS + - A Corstone-320 MPS4 FPGA development board + - A Linux development environment, for example Ubuntu 20.04 or later + - Git + - Python 3.8 or higher + +author: Sue Wu, Arm + +skilllevels: Introductory +subjects: RTOS Fundamentals +armips: + - Cortex-M + - Corstone-320 +tools_software_languages: + - Zephyr + - GCC + - C + - MPS4 board +operatingsystems: + - Linux + +further_reading: + - resource: + title: Zephyr Project Documentation + link: https://docs.zephyrproject.org/latest/index.html + type: website + - resource: + title: Zephyr Sample applications and Demo + link: https://docs.zephyrproject.org/latest/samples/index.html + type: website + - resource: + title: MPS4 board + link: https://developer.arm.com/documentation/102577/0000?lang=en + type: website + +weight: 1 +layout: "learningpathall" +learning_path_main_page: "yes" +--- diff --git a/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/_next-steps.md b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/_next-steps.md new file mode 100644 index 0000000000..727b395ddd --- /dev/null +++ b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/_next-steps.md @@ -0,0 +1,8 @@ +--- +# ================================================================================ +# FIXED, DO NOT MODIFY THIS FILE +# ================================================================================ +weight: 21 # The weight controls the order of the pages. _index.md always has weight 1. +title: "Next Steps" # Always the same, html page title. +layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing. +--- diff --git a/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/how-to-1.md b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/how-to-1.md new file mode 100644 index 0000000000..cd6e285122 --- /dev/null +++ b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/how-to-1.md @@ -0,0 +1,15 @@ +--- +title: Set up Zephyr build environment +weight: 2 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + +## Set up the development environment +This section describes the tools and environment you need for Corstone-320 MPS4 development with Zephyr. + +### Install the Zephyr build tools + +- Follow the Zephyr Project [Getting Started Guide — Zephyr Project Documentation](https://docs.zephyrproject.org/latest/develop/getting_started/index.html) to install the required packages and set up the Zephyr workspace. +- Download and install [arm-gnu-toolchain from Arm GNU Toolchain](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) diff --git a/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/how-to-2.md b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/how-to-2.md new file mode 100644 index 0000000000..d68ded74b1 --- /dev/null +++ b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/how-to-2.md @@ -0,0 +1,269 @@ +--- +title: Add Zephyr board support for Corstone-320 MPS4 platform +weight: 3 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + +## Port Zephyr and run an application on Corstone-320 MPS4 + +### CS320 MPS4 Platform overview + +The Arm® Corstone™ SSE-320 FPGA Image for MPS4 (FI101) provides an FPGA implementation that runs on the MPS4 board. The image includes an Arm Cortex-M85 processor, an Arm Ethos-U85 NPU, and an Arm CoreLink DMA-350 direct memory access (DMA) controller. This setup provides a practical environment for developing and evaluating embedded applications, including machine learning workloads. + +Download the latest Corstone-320 FPGA image and review the platform documentations: +* [Arm® Corstone™ SSE-320 with Cortex®-M85 and Ethos™-U85 : Example FPGA (FI101)](https://developer.arm.com/downloads/view/FI101) +* [SSE-320 FPGA Image for MPS4 Application Note](https://developer.arm.com/documentation/109762/0100/?lang=en) +* [Arm® MPS4 FPGA Prototyping Board Technical Reference Manual](https://developer.arm.com/documentation/102577/latest/) +* [Arm® Corstone™ SSE-320 Example Subsystem Software Programmers Guide](https://developer.arm.com/documentation/109759/latest/) + + +### Add Zephyr board support for Corstone-320 MPS4 + +#### Understanding Zephyr board support architecture +Zephyr organizes hardware support in a hierarchy: + +``` +Board → SoC → CPU Cluster → CPU Core → Architecture +``` + +For Corstone-320 MPS4, this hierarchy looks like: +- **Board**: `mps4` (your custom board name in Zephyr) +- **SoC**: `corstone320` (Corstone-320 subsystem) +- **CPU Cluster**: `m85` (Cortex-M85 cluster) +- **CPU Core**: Single Cortex-M85 core +- **Architecture**: ARMv8.1-M with Helium + +#### Create the board directory structure + +Create a board directory under boards/arm/mps4/. Use the following structure: + +``` +boards/arm/mps4/ +├── board.yml # Board metadata +├── board.cmake # Build system integration +├── doc/ # Optional documentation +│ ├── index.rst +├── Kconfig.mps4 # Board Kconfig entry +├── Kconfig.defconfig # Default Kconfig settings +├── mps4_corstone320_fpga_defconfig # Board defconfig fragment +├── mps4_corstone320_fpga.dts # Device tree source +└── mps4_corstone320_fpga.yaml # Test runner metadata +``` + +#### Add the essential board files + +- board.yml +board.yml is board metadata, use board.yml to describe the board name, vendor, SoC, and variants. + +``` +board: + name: mps4 + full_name: MPS4 + vendor: arm + socs: + - name: 'corstone320' + variants: + - name: 'fpga' +``` + +- mps4_corstone320_fpga.dts + +The device tree describes the Corstone-320 MPS4 hardware. Base on the content on [SSE-320 FPGA Image for MPS4 Application Note](https://developer.arm.com/documentation/109762/0100/?lang=en) and tailor it to the peripherals and memory map you use. + +The following example shows a device tree that defines memory regions and enables UART and Ethos-U: + + +```dts +/dts-v1/; + +#include +#include +#include +#include + +{ + compatible = "arm,mps4-fpga"; + #address-cells = <1>; + #size-cells = <1>; + + chosen { + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,sram = &sram; + zephyr,flash = &isram; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-m85"; + reg = <0>; + #address-cells = <1>; + #size-cells = <1>; + + mpu: mpu@e000ed90 { + compatible = "arm,armv8.1m-mpu"; + reg = <0xe000ed90 0x40>; + }; + }; + }; + + ethosu { + #address-cells = <1>; + #size-cells = <0>; + interrupt-parent = <&nvic>; + + ethosu0: ethosu@50004000 { + compatible = "arm,ethos-u"; + reg = <0x50004000>; + interrupts = <16 3>; + secure-enable; + privilege-enable; + status = "okay"; + }; + }; + + + itcm: itcm@10000000 { + compatible = "zephyr,memory-region"; + reg = <0x10000000 DT_SIZE_K(32)>; + zephyr,memory-region = "ITCM"; + }; + + sram: sram@12000000 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x12000000 DT_SIZE_M(2)>; + zephyr,memory-region = "SRAM"; + }; + + rom: rom@11000000 { + compatible = "zephyr,memory-region"; + reg = <0x11000000 DT_SIZE_K(128)>; + zephyr,memory-region = "ROM"; + }; + + dtcm: dtcm@30000000 { + compatible = "zephyr,memory-region"; + reg = <0x30000000 DT_SIZE_K(32)>; + zephyr,memory-region = "DTCM"; + }; + + isram: sram@31000000 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x31000000 DT_SIZE_M(4)>; + zephyr,memory-region = "ISRAM"; + }; + + + soc { + peripheral@50000000 { + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x50000000 0x10000000>; + + #include "mps4_common_soc_peripheral_fpga.dtsi" + }; + }; +}; + +#include "mps4_common.dtsi" +``` +- mps4_common_soc_peripheral_fpga.dtsi + +This file defines the SoC peripherals for the MPS4 FPGA build. The following example configures a fixed system clock and two UART instances. + +``` +sysclk: system-clock { + compatible = "fixed-clock"; + clock-frequency = <50000000>; + #clock-cells = <0>; +}; + +uart0: uart@9303000 { + compatible = "arm,cmsdk-uart"; + reg = <0x9303000 0x1000>; + interrupts = <34 3 49 3>; + interrupt-names = "tx", "rx"; + clocks = <&sysclk>; + current-speed = <115200>; +}; + +uart1: uart@9304000 { + compatible = "arm,cmsdk-uart"; + reg = <0x9304000 0x1000>; + interrupts = <36 3 35 3>; + interrupt-names = "tx", "rx"; + clocks = <&sysclk>; + current-speed = <115200>; +}; + +pinctrl: pinctrl { + compatible = "arm,mps4-pinctrl"; + status = "okay"; +}; + +``` + +- Kconfig Files + +Zephyr uses Kconfig to configure build-time features. The MPS4 platform uses three Kconfig-related files: + +- Kconfig.mps4 +- Kconfig.defconfig +- Kconfig + +Kconfig.mps4 is the base configuration, it selects the SoC series and the specific SoC variant. + +```kconfig.mps4 +config BOARD_MPS4 + select SOC_SERIES_MPS4 + select SOC_MPS4_CORSTONE315 if BOARD_MPS4_CORSTONE315_FVP || BOARD_MPS4_CORSTONE315_FVP_NS + select SOC_MPS4_CORSTONE320 if BOARD_MPS4_CORSTONE320_FVP || BOARD_MPS4_CORSTONE320_FVP_NS || BOARD_MPS4_CORSTONE320_FPGA + +``` + +Kconfig.defconfig and Kconfig are to provide default values for features and drivers that your board requires. + +```kconfig.defconfig +if BOARD_MPS4_CORSTONE315_FVP || BOARD_MPS4_CORSTONE320_FVP || BOARD_MPS4_CORSTONE320_FPGA + +config UART_INTERRUPT_DRIVEN + default y # 串口默认启用中断驱动 + +config ROMSTART_REGION_ADDRESS + default $(dt_nodelabel_reg_addr_hex,rom) if BOARD_MPS4_CORSTONE320_FPGA + default $(dt_nodelabel_reg_addr_hex,itcm) + +config ROMSTART_REGION_SIZE + default $(dt_nodelabel_reg_size_hex,rom,0,k) if BOARD_MPS4_CORSTONE320_FPGA + default $(dt_nodelabel_reg_size_hex,itcm,0,k) + +``` + +The mps4_corstone320_fpga_defconfig file is a Kconfig fragment that Zephyr merges into the final .config when you build an application for this board. The following example enables TrustZone, MPU support, GPIO, and console over UART, and it builds a Secure image that relocates the ROM start region. + +```kconfig +CONFIG_RUNTIME_NMI=y +CONFIG_ARM_TRUSTZONE_M=y +CONFIG_ARM_MPU=y + +# GPIOs +CONFIG_GPIO=y + +# Serial +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_SERIAL=y + +# Build a Secure firmware image +CONFIG_TRUSTED_EXECUTION_SECURE=y +# ROMSTART_REGION address and size are defined in Kconfig.defconfig +CONFIG_ROMSTART_RELOCATION_ROM=y + +``` + diff --git a/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/how-to-3.md b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/how-to-3.md new file mode 100644 index 0000000000..2bcd25b6e0 --- /dev/null +++ b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/how-to-3.md @@ -0,0 +1,55 @@ +--- +title: Build and run the hello_world sample for CS320 MPS4 platform +weight: 4 + +### FIXED, DO NOT MODIFY +layout: learningpathall +--- + +## Build the hello_world sample for MPS4 + +The Zephyr hello_world sample prints “Hello World” to the console. Use it to validate that your board support and toolchain configuration work. + +1. Activate your Python virtual environment for Zephyr. +2. Set the toolchain environment variables. Replace with the directory where you installed the Arm GNU Toolchain. + ```bash + export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb + export GNUARMEMB_TOOLCHAIN_PATH=arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi-install-path/ + ``` +3. Build the sample for the Corstone-320 FPGA variant: + ```bash + west build -p always -b mps4/corstone320/fpga zephyr/samples/hello_world -- -DCONFIG_ROMSTART_RELOCATION_ROM=y + ``` +After a successful build, the output file zephyr.elf is available under build/zephyr/. The ELF image contains the application and the Zephyr kernel libraries. + +## Run the application on the MPS4 board +1. Download the board files from [FI101](https://developer.arm.com/downloads/view/FI101?sortBy=availableBy&revision=r1p0-00eac0-2), +2. Set up the MPS4 platform according to the [Using the FI101 on MPS4 board](https://developer.arm.com/documentation/109762/0100/?lang=en). + +For the hello_world application, place the vector table in the FPGA boot ROM at address 0x11000000, and place the remaining code and data in SRAM at address 0x31000000. Create vector.bin and app.bin from zephyr.elf by using arm-none-eabi-objcopy. + +Update images.txt under /MB/HBI0376B/FI101 to load the two images: + + ``` +IMAGE0PORT: 2 +IMAGE0ADDRESS: 0x00_1100_0000 ; Address to load into +IMAGE0UPDATE: RAM +IMAGE0FILE: \SOFTWARE\vector.bin ; Image/data to be loaded + +IMAGE1PORT: 1 +IMAGE1ADDRESS: 0x31000000 ; Address to load into +IMAGE1UPDATE: RAM +IMAGE1FILE: \SOFTWARE\app.bin ; Image/data to be loaded + ``` + +Copy vector.bin and app.bin to \SOFTWARE, then power on the board. +If the setup is correct, the UART console prints the “Hello World” message, similar to the following example: + + ![alt text](image.png) + +## What you accomplished +In this Learning Path, you learned +- How to explore the Corstone‑320 architecture, created board support files and configured device tree and Kconfig options to port Zephyr RTOS for the target hardware. +- How to built and run the Zephyr hello_world sample on MPS4 board. + +These steps help you further customize Zephyr on the CS320 MPS4 platform and validate a complete build-and-run workflow. diff --git a/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/image.png b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/image.png new file mode 100644 index 0000000000..5628bb32e6 Binary files /dev/null and b/content/learning-paths/embedded-and-microcontrollers/zephyr_cs320_mps4/image.png differ