From e0b083d74a12cf1782ee2671e0884514e7bef5e2 Mon Sep 17 00:00:00 2001 From: Reinhard Keil Date: Wed, 23 Sep 2026 11:31:38 +0200 Subject: [PATCH 1/9] Added templates for Native CMake/Zephyr, CI test for NonSecureOnly --- .github/workflows/SimpleTZ-CI.yml | 56 +++++++++++++++++-- README.md | 4 +- SimpleTrustZone/SimpleTZ.csolution.yml | 2 + .../Multicore/Core0/MyName0.cproject.yml | 1 + .../Multicore/Core1/MyName1.cproject.yml | 1 + Templates/NativeCMake/MyName.csolution.yml | 40 +++++++++++++ Templates/NativeCMake/README.md | 18 ++++++ Templates/README.md | 10 +++- Templates/Simple/MyName.cproject.yml | 5 +- .../TrustZone/NonSecure/MyNameNS.cproject.yml | 1 + .../TrustZone/Secure/MyNameS.cproject.yml | 1 + Templates/UnitTest/Test0/MyName0.cproject.yml | 1 + Templates/UnitTest/Test1/MyName1.cproject.yml | 1 + Templates/ZephyrWest/MyName.csolution.yml | 40 +++++++++++++ Templates/ZephyrWest/README.md | 17 ++++++ 15 files changed, 189 insertions(+), 9 deletions(-) create mode 100644 Templates/NativeCMake/MyName.csolution.yml create mode 100644 Templates/NativeCMake/README.md create mode 100644 Templates/ZephyrWest/MyName.csolution.yml create mode 100644 Templates/ZephyrWest/README.md diff --git a/.github/workflows/SimpleTZ-CI.yml b/.github/workflows/SimpleTZ-CI.yml index 0752b90..2e134e3 100644 --- a/.github/workflows/SimpleTZ-CI.yml +++ b/.github/workflows/SimpleTZ-CI.yml @@ -15,7 +15,8 @@ on: - cron: '00 20 * * 6' jobs: - Build: + TrustZone: + name: TrustZone (${{ matrix.build.type }}, ${{ matrix.compiler.name }}) strategy: matrix: @@ -46,12 +47,11 @@ jobs: with: python-version: '3.14' - - name: Build project CM33_s and CM33_ns for build-type ${{ matrix.build.type }} with ${{ matrix.compiler.name }} + - name: Build secure and non-secure projects working-directory: ./SimpleTrustZone/ run: cbuild SimpleTZ.csolution.yml --packs --active AVH@${{ matrix.build.type }} --toolchain ${{ matrix.compiler.name }} - - - name: Execute project CM33_s and CM33_ns for build-type ${{ matrix.build.type }} with ${{ matrix.compiler.name }} using FVP_MPS2_Cortex-M33 + - name: Execute secure and non-secure projects on FVP working-directory: ./SimpleTrustZone/ run: | FVP_MPS2_Cortex-M33 \ @@ -59,3 +59,51 @@ jobs: -a ./out/CM33_s/AVH/${{ matrix.build.type }}/CM33_s.${{ matrix.compiler.ext }} \ -f ./../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt \ --stat + + NonSecureOnly: + name: Non-secure only (${{ matrix.build.type }}, ${{ matrix.compiler.name }}) + strategy: + matrix: + compiler: [ + {name: AC6, ext: axf} + ] + build: [ + {type: Release}, + {type: Debug} + ] + + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v7.0.1 + + - name: Install tools + uses: ARM-software/cmsis-actions/vcpkg@v1.3 + with: + config: ".ci/vcpkg-configuration.json" + + - name: Activate Arm tool license + uses: ARM-software/cmsis-actions/armlm@v1.3 + + - name: Set up Python + uses: actions/setup-python@v7.0.0 + with: + python-version: '3.14' + + - name: Build secure project to create HEX file and CMSE library + working-directory: ./SimpleTrustZone/ + run: cbuild SimpleTZ.csolution.yml --packs --context CM33_s.${{ matrix.build.type }}+AVH --toolchain ${{ matrix.compiler.name }} + + - name: Build non-secure-only target + working-directory: ./SimpleTrustZone/ + run: cbuild SimpleTZ.csolution.yml --active AVH-NS-only@${{ matrix.build.type }} --toolchain ${{ matrix.compiler.name }} + + - name: Execute non-secure-only target on FVP + working-directory: ./SimpleTrustZone/ + run: | + FVP_MPS2_Cortex-M33 \ + -a ./out/CM33_s/AVH/${{ matrix.build.type }}/CM33_s.hex \ + -a ./out/CM33_ns/AVH-NS-only/${{ matrix.build.type }}/CM33_ns.${{ matrix.compiler.ext }} \ + -f ./../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt \ + --stat diff --git a/README.md b/README.md index c7242de..a46576e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This is a collection of [CMSIS-Toolbox](https://open-cmsis-pack.github.io/cmsis- ## Tool Requirements -The examples use **CMSIS-Toolbox 2.14.0** or higher. Depending on the example, additional tools include CMake, Ninja, Arm Compiler 6, GCC, CLANG, Arm Virtual Hardware Fixed Virtual Platforms (AVH FVP), and STM32CubeMX. Refer to the README of each example for its specific requirements. +The examples use **CMSIS-Toolbox 2.14.0** or higher; the Native CMake integration template requires version 2.15.0 or higher. Depending on the example, additional tools include CMake, Ninja, Arm Compiler 6, GCC, CLANG, Arm Virtual Hardware Fixed Virtual Platforms (AVH FVP), STM32CubeMX, and West with a Zephyr workspace. Refer to the README of each example or template for its specific requirements. Refer to [**Installation of the CMSIS-Toolbox**](https://open-cmsis-pack.github.io/cmsis-toolbox/installation) for information on the setup of a development environment with these tools. @@ -43,7 +43,7 @@ The project files contain a list of software packs that are used. When using the ## Template Projects -The directory [Templates](./Templates) contains structural templates for simple single-core, multi-core, TrustZone, and unit-test projects. They are not ready-to-build examples, but may be used as a starting point for an application. +The directory [Templates](./Templates) contains structural templates for simple single-core, multi-core, TrustZone, and unit-test projects. It also contains integration templates for existing [Zephyr applications built with West](./Templates/ZephyrWest) and [native CMake projects](./Templates/NativeCMake). They are not ready-to-build examples, but may be used as a starting point for an application. ## GitHub Action Workflows diff --git a/SimpleTrustZone/SimpleTZ.csolution.yml b/SimpleTrustZone/SimpleTZ.csolution.yml index b1827a4..504e3f3 100644 --- a/SimpleTrustZone/SimpleTZ.csolution.yml +++ b/SimpleTrustZone/SimpleTZ.csolution.yml @@ -50,6 +50,8 @@ solution: args: --stat - set: Release images: + - image: out/CM33_s/AVH/Release/CM33_s.hex + load: image - project-context: CM33_ns.Release debugger: name: Arm-FVP diff --git a/Templates/Multicore/Core0/MyName0.cproject.yml b/Templates/Multicore/Core0/MyName0.cproject.yml index f0c0e6e..ce464da 100644 --- a/Templates/Multicore/Core0/MyName0.cproject.yml +++ b/Templates/Multicore/Core0/MyName0.cproject.yml @@ -10,6 +10,7 @@ project: groups: - group: Source Files + # Add at least one source file # files: # - file: main_core0.c # - file: MyFile1.c diff --git a/Templates/Multicore/Core1/MyName1.cproject.yml b/Templates/Multicore/Core1/MyName1.cproject.yml index 92923a4..2e96871 100644 --- a/Templates/Multicore/Core1/MyName1.cproject.yml +++ b/Templates/Multicore/Core1/MyName1.cproject.yml @@ -10,6 +10,7 @@ project: groups: - group: Source Files + # Add at least one source file # files: # - file: main_core1.c # - file: MyFile1.c diff --git a/Templates/NativeCMake/MyName.csolution.yml b/Templates/NativeCMake/MyName.csolution.yml new file mode 100644 index 0000000..22e9673 --- /dev/null +++ b/Templates/NativeCMake/MyName.csolution.yml @@ -0,0 +1,40 @@ +solution: +# Integrate an existing native CMake project + + created-for: CMSIS-Toolbox@2.15.0 + compiler: GCC + +# List the packs that define the device and board + packs: + - pack: MyVendor::MyDevice_DFP +# - pack: MyVendor::MyBoard_BSP + + target-types: + - type: MyTargetName + device: MyDeviceName +# board: MyBoardName + target-set: + - set: Debug + images: + - project-context: MyNativeProject.Debug + - set: Release + images: + - project-context: MyNativeProject.Release + + build-types: + - type: Debug + - type: Release + +# Reference an existing native CMake project + projects: + - cmake: + source: ./MyNativeProject + project-id: MyNativeProject + generator: Ninja + configure: + - -DCMAKE_BUILD_TYPE=$BuildType$ + - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + target: MyNativeProject + images: + - image: MyNativeProject.elf + type: elf diff --git a/Templates/NativeCMake/README.md b/Templates/NativeCMake/README.md new file mode 100644 index 0000000..114af01 --- /dev/null +++ b/Templates/NativeCMake/README.md @@ -0,0 +1,18 @@ +# Native CMake Integration Template + +This template shows the minimum structure for integrating an existing native CMake project into a *csolution project*. It does not describe the CMake files generated internally for `*.cproject.yml` builds. + +Before using the template: + +- Replace the pack, board, and device placeholders in `MyName.csolution.yml`. +- Replace `./MyNativeProject` with the directory containing the native project's `CMakeLists.txt`. +- Adapt the configure options, build target, and output image paths to the native project. +- Ensure the native project configures its compiler and linker for the selected target. + +Build the Debug target with: + +```bash +cbuild MyName.csolution.yml --active MyTargetName@Debug --packs +``` + +For a complete application, refer to [Arm-Examples/CMSIS-CMake](https://github.com/Arm-Examples/CMSIS-CMake). diff --git a/Templates/README.md b/Templates/README.md index 2e41574..13cc570 100644 --- a/Templates/README.md +++ b/Templates/README.md @@ -1,6 +1,6 @@ # CMSIS-Toolbox Templates -These generic templates show the file structure for different types of `csolution` projects. They are not ready-to-build example projects; use them as a starting point for your own application. +These generic templates show the file structure for different types of `csolution` projects and for integrating external build systems. They are not ready-to-build example projects; use them as a starting point for your own application. To use a template, copy the content of its folder to your application folder. Then adapt the names, replace the placeholders, and add the required application content. @@ -24,6 +24,14 @@ The [TrustZone](./TrustZone) template separates the secure and non-secure parts The [UnitTest](./UnitTest) template contains independent test projects that share common support through a reusable layer. It does not use target sets because the projects are separate test executables, typically used in CI. Use `--context .Debug` or `--context .Release` to select all matching test projects. +### ZephyrWest + +The [ZephyrWest](./ZephyrWest) template integrates an existing Zephyr application using the West build system. The Zephyr workspace and application remain responsible for their sources and configuration. + +### NativeCMake + +The [NativeCMake](./NativeCMake) template integrates an existing native CMake project using CMSIS-Toolbox 2.15.0 or higher. The native project remains responsible for its `CMakeLists.txt`, toolchain setup, build targets, and output images. + ## Pack Ownership Pack declarations define which software packs are available within solution, project, or layer scope. Avoid duplicate or conflicting pack requirements so projects and layers remain reusable. diff --git a/Templates/Simple/MyName.cproject.yml b/Templates/Simple/MyName.cproject.yml index 9e1772d..f7e6829 100644 --- a/Templates/Simple/MyName.cproject.yml +++ b/Templates/Simple/MyName.cproject.yml @@ -7,8 +7,9 @@ project: groups: - group: Source Files - files: - - file: main.c + # Add at least one source file +# files: +# - file: main.c # - file: MyFile1.c # - group: MyGroup diff --git a/Templates/TrustZone/NonSecure/MyNameNS.cproject.yml b/Templates/TrustZone/NonSecure/MyNameNS.cproject.yml index d92d5b0..e41bde7 100644 --- a/Templates/TrustZone/NonSecure/MyNameNS.cproject.yml +++ b/Templates/TrustZone/NonSecure/MyNameNS.cproject.yml @@ -13,6 +13,7 @@ project: groups: - group: Source Files + # Add at least one source file # files: # - file: main_ns.c # - file: MyFile1.c diff --git a/Templates/TrustZone/Secure/MyNameS.cproject.yml b/Templates/TrustZone/Secure/MyNameS.cproject.yml index 95477ce..3feae72 100644 --- a/Templates/TrustZone/Secure/MyNameS.cproject.yml +++ b/Templates/TrustZone/Secure/MyNameS.cproject.yml @@ -9,6 +9,7 @@ project: groups: - group: Source Files + # Add at least one source file # files: # - file: main.c # - file: MyFile1.c diff --git a/Templates/UnitTest/Test0/MyName0.cproject.yml b/Templates/UnitTest/Test0/MyName0.cproject.yml index a9280c8..da0f167 100644 --- a/Templates/UnitTest/Test0/MyName0.cproject.yml +++ b/Templates/UnitTest/Test0/MyName0.cproject.yml @@ -7,6 +7,7 @@ project: groups: - group: Source Files + # Add at least one source file # files: # - file: main.c # - file: MyFile1.c diff --git a/Templates/UnitTest/Test1/MyName1.cproject.yml b/Templates/UnitTest/Test1/MyName1.cproject.yml index a9280c8..da0f167 100644 --- a/Templates/UnitTest/Test1/MyName1.cproject.yml +++ b/Templates/UnitTest/Test1/MyName1.cproject.yml @@ -7,6 +7,7 @@ project: groups: - group: Source Files + # Add at least one source file # files: # - file: main.c # - file: MyFile1.c diff --git a/Templates/ZephyrWest/MyName.csolution.yml b/Templates/ZephyrWest/MyName.csolution.yml new file mode 100644 index 0000000..8f44867 --- /dev/null +++ b/Templates/ZephyrWest/MyName.csolution.yml @@ -0,0 +1,40 @@ +solution: +# Integrate an existing Zephyr application using the West build system + + created-for: CMSIS-Toolbox@2.14.0 + compiler: GCC + +# List the packs that define the device and board + packs: + - pack: MyVendor::MyDevice_DFP +# - pack: MyVendor::MyBoard_BSP + +# Map the CMSIS target to a Zephyr board + target-types: + - type: MyTargetName + device: MyDeviceName +# board: MyBoardName + variables: + - west-board: my_zephyr_board + target-set: + - set: Debug + images: + - project-context: MyZephyrApp.Debug + - set: Release + images: + - project-context: MyZephyrApp.Release + + build-types: + - type: Debug + west-defs: + - CONFIG_DEBUG: y + + - type: Release + west-defs: + - CONFIG_SIZE_OPTIMIZATIONS: y + +# Reference an existing application in the West workspace + projects: + - west: + app-path: ./MyZephyrApp + project-id: MyZephyrApp diff --git a/Templates/ZephyrWest/README.md b/Templates/ZephyrWest/README.md new file mode 100644 index 0000000..457e433 --- /dev/null +++ b/Templates/ZephyrWest/README.md @@ -0,0 +1,17 @@ +# Zephyr West Integration Template + +This template shows the minimum structure for integrating an existing Zephyr application into a *csolution project* using the West build system. + +Before using the template: + +- Install Zephyr and initialize a West workspace as described in the [Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/develop/getting_started/index.html). +- Replace the pack, board, device, and `west-board` placeholders in `MyName.csolution.yml`. +- Replace `./MyZephyrApp` with the path to an application in the West workspace. + +Build the Debug target with: + +```bash +cbuild MyName.csolution.yml --active MyTargetName@Debug --packs +``` + +For a complete multi-board example with debugging and CI workflows, refer to [Arm-Examples/CMSIS-Zephyr](https://github.com/Arm-Examples/CMSIS-Zephyr). From 9affbf43086b65e61a8159d6c5091e49eb4ab608 Mon Sep 17 00:00:00 2001 From: Reinhard Keil Date: Wed, 23 Sep 2026 12:03:47 +0200 Subject: [PATCH 2/9] SimpleTZ improved, GCC test added --- .github/workflows/SimpleTZ-CI.yml | 6 ++++-- SimpleTrustZone/CM33_ns/main_ns.c | 3 +-- SimpleTrustZone/README.md | 16 ++++++++++++++++ SimpleTrustZone/SimpleTZ.csolution.yml | 2 +- SimpleTrustZone/cdefault.yml | 1 - 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/SimpleTZ-CI.yml b/.github/workflows/SimpleTZ-CI.yml index 2e134e3..c5e4504 100644 --- a/.github/workflows/SimpleTZ-CI.yml +++ b/.github/workflows/SimpleTZ-CI.yml @@ -21,7 +21,8 @@ jobs: matrix: compiler: [ - {name: AC6, ext: axf} + {name: AC6, ext: axf}, + {name: GCC, ext: elf} ] build: [ {type: Release}, @@ -65,7 +66,8 @@ jobs: strategy: matrix: compiler: [ - {name: AC6, ext: axf} + {name: AC6, ext: axf}, + {name: GCC, ext: elf} ] build: [ {type: Release}, diff --git a/SimpleTrustZone/CM33_ns/main_ns.c b/SimpleTrustZone/CM33_ns/main_ns.c index e029cfe..b7f3b56 100644 --- a/SimpleTrustZone/CM33_ns/main_ns.c +++ b/SimpleTrustZone/CM33_ns/main_ns.c @@ -24,7 +24,6 @@ *---------------------------------------------------------------------------*/ #include -#include #include "interface.h" // Interface API @@ -52,7 +51,7 @@ int main(void) { val2 = func2(func3, 2); printf("func2(func3, 2) = %d\n", val2); - exit(0); + printf("\x04"); // EOT (0x04) stops simulation while (1); } diff --git a/SimpleTrustZone/README.md b/SimpleTrustZone/README.md index 49eb842..c8d099e 100644 --- a/SimpleTrustZone/README.md +++ b/SimpleTrustZone/README.md @@ -51,6 +51,22 @@ The solution provides `Debug` and `Release` target sets. Select the required set Replace `AC6` with `GCC` to build a target set with the GCC compiler. +## Use an Existing Secure Image + +The `AVH-NS-only` target demonstrates how to build a non-secure application against an existing secure application. It builds only `CM33_ns` and reuses two outputs previously generated for the `AVH` target: + +- `CM33_s.hex`, which is loaded together with the non-secure application. +- `CM33_s_CMSE_Lib.o`, which provides the secure callable interface used to link the non-secure application. + +The existing secure outputs must match the selected build type and compiler. Build the `AVH` target before building the corresponding `AVH-NS-only` target: + +```txt +> cbuild SimpleTZ.csolution.yml --packs --active AVH@Debug --toolchain AC6 +> cbuild SimpleTZ.csolution.yml --active AVH-NS-only@Debug --toolchain AC6 +``` + +When using VS Code, first select and build `AVH@Debug` or `AVH@Release` in the Manage Solution view. Then select the matching `AVH-NS-only` target set and build or run it. Building `AVH-NS-only` first in a clean workspace fails because the secure HEX file and CMSE library do not yet exist. + ## Execute the project on Arm Virtual Hardware ```txt diff --git a/SimpleTrustZone/SimpleTZ.csolution.yml b/SimpleTrustZone/SimpleTZ.csolution.yml index 504e3f3..358c96b 100644 --- a/SimpleTrustZone/SimpleTZ.csolution.yml +++ b/SimpleTrustZone/SimpleTZ.csolution.yml @@ -42,7 +42,7 @@ solution: images: - image: out/CM33_s/AVH/Debug/CM33_s.hex load: image - - project-context: CM33_ns.Debug + - project-context: CM33_ns.Release debugger: name: Arm-FVP model: FVP_MPS2_Cortex-M33 diff --git a/SimpleTrustZone/cdefault.yml b/SimpleTrustZone/cdefault.yml index b3de87a..0a7283a 100644 --- a/SimpleTrustZone/cdefault.yml +++ b/SimpleTrustZone/cdefault.yml @@ -13,7 +13,6 @@ default: - -masm=auto Link: - --entry=Reset_Handler - - --map - --info summarysizes - --summary_stderr - --diag_suppress=L6314W From 607703f522523b754ef3b9a75b14c1b9f0fd9857 Mon Sep 17 00:00:00 2001 From: Reinhard Keil Date: Wed, 23 Sep 2026 12:17:28 +0200 Subject: [PATCH 3/9] Fixed GCC issues --- .github/workflows/SimpleTZ-CI.yml | 2 +- SimpleTrustZone/README.md | 2 +- SimpleTrustZone/SimpleTZ.csolution.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/SimpleTZ-CI.yml b/.github/workflows/SimpleTZ-CI.yml index c5e4504..c11a74f 100644 --- a/.github/workflows/SimpleTZ-CI.yml +++ b/.github/workflows/SimpleTZ-CI.yml @@ -99,7 +99,7 @@ jobs: - name: Build non-secure-only target working-directory: ./SimpleTrustZone/ - run: cbuild SimpleTZ.csolution.yml --active AVH-NS-only@${{ matrix.build.type }} --toolchain ${{ matrix.compiler.name }} + run: cbuild SimpleTZ.csolution.yml --context CM33_ns.${{ matrix.build.type }}+AVH-NS-only --toolchain ${{ matrix.compiler.name }} - name: Execute non-secure-only target on FVP working-directory: ./SimpleTrustZone/ diff --git a/SimpleTrustZone/README.md b/SimpleTrustZone/README.md index c8d099e..49670d4 100644 --- a/SimpleTrustZone/README.md +++ b/SimpleTrustZone/README.md @@ -62,7 +62,7 @@ The existing secure outputs must match the selected build type and compiler. Bui ```txt > cbuild SimpleTZ.csolution.yml --packs --active AVH@Debug --toolchain AC6 -> cbuild SimpleTZ.csolution.yml --active AVH-NS-only@Debug --toolchain AC6 +> cbuild SimpleTZ.csolution.yml --context CM33_ns.Debug+AVH-NS-only --toolchain AC6 ``` When using VS Code, first select and build `AVH@Debug` or `AVH@Release` in the Manage Solution view. Then select the matching `AVH-NS-only` target set and build or run it. Building `AVH-NS-only` first in a clean workspace fails because the secure HEX file and CMSE library do not yet exist. diff --git a/SimpleTrustZone/SimpleTZ.csolution.yml b/SimpleTrustZone/SimpleTZ.csolution.yml index 358c96b..504e3f3 100644 --- a/SimpleTrustZone/SimpleTZ.csolution.yml +++ b/SimpleTrustZone/SimpleTZ.csolution.yml @@ -42,7 +42,7 @@ solution: images: - image: out/CM33_s/AVH/Debug/CM33_s.hex load: image - - project-context: CM33_ns.Release + - project-context: CM33_ns.Debug debugger: name: Arm-FVP model: FVP_MPS2_Cortex-M33 From caa58987c5bd099371c30a38448c0fdefa50a743 Mon Sep 17 00:00:00 2001 From: Reinhard Keil Date: Wed, 23 Sep 2026 12:27:51 +0200 Subject: [PATCH 4/9] FVP simlimit, EOT termination added --- .github/workflows/Hello-CI.yml | 2 +- .github/workflows/SimpleTZ-CI.yml | 4 ++-- FVP/FVP_MPS2_Cortex-M33/fvp_config.txt | 7 ++++--- Hello/README.md | 4 ++-- SimpleTrustZone/README.md | 2 +- SimpleTrustZone/SimpleTZ.csolution.yml | 8 ++++---- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/Hello-CI.yml b/.github/workflows/Hello-CI.yml index 730f72e..0b25fed 100644 --- a/.github/workflows/Hello-CI.yml +++ b/.github/workflows/Hello-CI.yml @@ -66,7 +66,7 @@ jobs: -a $EXEC \ -f ./../FVP/FVP_Corstone_SSE-300/fvp_config.txt \ -C mps3_board.uart0.out_file=$LOG \ - --simlimit 60 --stat + --simlimit 10 --stat echo "Show simulation UART output for ${{ matrix.toolchain }} ${{ matrix.build_type }}" cat $LOG diff --git a/.github/workflows/SimpleTZ-CI.yml b/.github/workflows/SimpleTZ-CI.yml index c11a74f..27279b8 100644 --- a/.github/workflows/SimpleTZ-CI.yml +++ b/.github/workflows/SimpleTZ-CI.yml @@ -59,7 +59,7 @@ jobs: -a ./out/CM33_ns/AVH/${{ matrix.build.type }}/CM33_ns.${{ matrix.compiler.ext }} \ -a ./out/CM33_s/AVH/${{ matrix.build.type }}/CM33_s.${{ matrix.compiler.ext }} \ -f ./../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt \ - --stat + --simlimit 10 --stat NonSecureOnly: name: Non-secure only (${{ matrix.build.type }}, ${{ matrix.compiler.name }}) @@ -108,4 +108,4 @@ jobs: -a ./out/CM33_s/AVH/${{ matrix.build.type }}/CM33_s.hex \ -a ./out/CM33_ns/AVH-NS-only/${{ matrix.build.type }}/CM33_ns.${{ matrix.compiler.ext }} \ -f ./../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt \ - --stat + --simlimit 10 --stat diff --git a/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt b/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt index e343a66..51ff098 100644 --- a/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt +++ b/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt @@ -1,8 +1,9 @@ # Parameters: # instance.parameter=value #(type, mode) default = 'def value' : description : [min..max] #-------------------------------------------------------------------------------------------------------------------------------------------------- -fvp_mps2.mps2_visualisation.disable-visualisation=1 # (bool , init-time) default = '0' : Enable/disable visualisation -cpu0.semihosting-heap_limit=0x0 # (int , init-time) default = '0x10700000' : Virtual address of top of heap : [0x0..0xFFFFFFFF] +fvp_mps2.mps2_visualisation.disable-visualisation=1 # (bool , init-time) default = '0' : Enable/disable visualisation +fvp_mps2.UART0.shutdown_on_eot=1 # (bool , init-time) default = '0' : Shutdown simulation when an EOT (ASCII 4) character is transmitted +cpu0.semihosting-heap_limit=0x0 # (int , init-time) default = '0x10700000' : Virtual address of top of heap : [0x0..0xFFFFFFFF] cpu0.semihosting-stack_base=0x0 # (int , init-time) default = '0x10700000' : Virtual address of base of descending stack : [0x0..0xFFFFFFFF] cpu0.semihosting-stack_limit=0x0 # (int , init-time) default = '0x10800000' : Virtual address of stack limit : [0x0..0xFFFFFFFF] cpu0.ITM=0 # (bool , init-time) default = '1' : Level of instrumentation trace supported. false : No ITM trace included, true: ITM trace included @@ -10,4 +11,4 @@ cpu0.INITSVTOR=0x00000000 # (int , init-time) defa cpu0.SAU=0x8 # (int , init-time) default = '0x4' : Number of SAU regions (0 => no SAU) : [0x0..0x8] idau.NUM_IDAU_REGION=0x0 # (int , init-time) default = '0xA' : fvp_mps2.DISABLE_GATING=1 # (bool , init-time) default = '0' : Disable Memory gating logic -#-------------------------------------------------------------------------------------------------------------------------------------------------- \ No newline at end of file +#-------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/Hello/README.md b/Hello/README.md index 4ec473c..aca9319 100644 --- a/Hello/README.md +++ b/Hello/README.md @@ -44,13 +44,13 @@ The project is configured for execution on [**Arm Virtual Hardware**](https://de #### For debug type ```bash -> FVP_Corstone_SSE-300 -f ../FVP/FVP_Corstone_SSE-300/fvp_config.txt -a ./out/Hello/CS300/Debug/Hello.axf +> FVP_Corstone_SSE-300 -f ../FVP/FVP_Corstone_SSE-300/fvp_config.txt -a ./out/Hello/CS300/Debug/Hello.axf --simlimit 10 ``` #### For release type ```bash -> FVP_Corstone_SSE-300 -f ../FVP/FVP_Corstone_SSE-300/fvp_config.txt -a ./out/Hello/CS300/Release/Hello.axf +> FVP_Corstone_SSE-300 -f ../FVP/FVP_Corstone_SSE-300/fvp_config.txt -a ./out/Hello/CS300/Release/Hello.axf --simlimit 10 ``` ### Use this project with Keil Studio diff --git a/SimpleTrustZone/README.md b/SimpleTrustZone/README.md index 49670d4..3bfe056 100644 --- a/SimpleTrustZone/README.md +++ b/SimpleTrustZone/README.md @@ -70,7 +70,7 @@ When using VS Code, first select and build `AVH@Debug` or `AVH@Release` in the M ## Execute the project on Arm Virtual Hardware ```txt -> FVP_MPS2_Cortex-M33 -a ./out/CM33_ns/AVH/Debug/CM33_ns.axf -a ./out/CM33_s/AVH/Debug/CM33_s.axf -f ./../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt --stat +> FVP_MPS2_Cortex-M33 -a ./out/CM33_ns/AVH/Debug/CM33_ns.axf -a ./out/CM33_s/AVH/Debug/CM33_s.axf -f ./../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt --simlimit 10 --stat telnetterminal0: Listening for serial connection on port 5000 telnetterminal1: Listening for serial connection on port 5001 diff --git a/SimpleTrustZone/SimpleTZ.csolution.yml b/SimpleTrustZone/SimpleTZ.csolution.yml index 504e3f3..bfd42b2 100644 --- a/SimpleTrustZone/SimpleTZ.csolution.yml +++ b/SimpleTrustZone/SimpleTZ.csolution.yml @@ -24,7 +24,7 @@ solution: name: Arm-FVP model: FVP_MPS2_Cortex-M33 config-file: ../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt - args: --stat + args: --simlimit 10 --stat - set: Release images: - project-context: CM33_ns.Release @@ -33,7 +33,7 @@ solution: name: Arm-FVP model: FVP_MPS2_Cortex-M33 config-file: ../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt - args: --stat + args: --simlimit 10 --stat - type: AVH-NS-only device: ARM::ARMCM33 @@ -47,7 +47,7 @@ solution: name: Arm-FVP model: FVP_MPS2_Cortex-M33 config-file: ../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt - args: --stat + args: --simlimit 10 --stat - set: Release images: - image: out/CM33_s/AVH/Release/CM33_s.hex @@ -57,7 +57,7 @@ solution: name: Arm-FVP model: FVP_MPS2_Cortex-M33 config-file: ../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt - args: --stat + args: --simlimit 10 --stat build-types: - type: Debug # toolchain options for 'debug' From 134cf6887a8e34023f9f02c1d2550a2f65b419f2 Mon Sep 17 00:00:00 2001 From: Reinhard Keil Date: Wed, 23 Sep 2026 12:46:09 +0200 Subject: [PATCH 5/9] cleaned retargeting, FVP setup --- FVP/FVP_MPS2_Cortex-M33/fvp_config.txt | 2 ++ SimpleTrustZone/CM33_ns/CM33_ns.cproject.yml | 3 +++ SimpleTrustZone/CM33_ns/main_ns.c | 1 + SimpleTrustZone/CM33_s/CM33_s.cproject.yml | 4 ++- SimpleTrustZone/SimpleTZ.cbuild-pack.yml | 25 +++++++++-------- SimpleTrustZone/SimpleTZ.csolution.yml | 1 + SimpleTrustZone/retarget_stdio.c | 28 ++++++++++++++++++++ 7 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 SimpleTrustZone/retarget_stdio.c diff --git a/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt b/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt index 51ff098..6525910 100644 --- a/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt +++ b/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt @@ -3,6 +3,8 @@ #-------------------------------------------------------------------------------------------------------------------------------------------------- fvp_mps2.mps2_visualisation.disable-visualisation=1 # (bool , init-time) default = '0' : Enable/disable visualisation fvp_mps2.UART0.shutdown_on_eot=1 # (bool , init-time) default = '0' : Shutdown simulation when an EOT (ASCII 4) character is transmitted +fvp_mps2.UART0.out_file=- # (string, init-time) default = '' : Send UART output to stdout +fvp_mps2.UART0.unbuffered_output=1 # (bool , init-time) default = '0' : Disable UART output buffering cpu0.semihosting-heap_limit=0x0 # (int , init-time) default = '0x10700000' : Virtual address of top of heap : [0x0..0xFFFFFFFF] cpu0.semihosting-stack_base=0x0 # (int , init-time) default = '0x10700000' : Virtual address of base of descending stack : [0x0..0xFFFFFFFF] cpu0.semihosting-stack_limit=0x0 # (int , init-time) default = '0x10800000' : Virtual address of stack limit : [0x0..0xFFFFFFFF] diff --git a/SimpleTrustZone/CM33_ns/CM33_ns.cproject.yml b/SimpleTrustZone/CM33_ns/CM33_ns.cproject.yml index 397251a..84c8e1e 100644 --- a/SimpleTrustZone/CM33_ns/CM33_ns.cproject.yml +++ b/SimpleTrustZone/CM33_ns/CM33_ns.cproject.yml @@ -9,6 +9,7 @@ project: - group: Non-secure Code files: - file: main_ns.c + - file: ../retarget_stdio.c - group: CMSE Library files: - file: $cmse-lib(CM33_s)$ @@ -18,4 +19,6 @@ project: components: - component: CMSIS:CORE + - component: CMSIS-Compiler:CORE + - component: CMSIS-Compiler:STDOUT:Custom - component: Device:Startup&C Startup diff --git a/SimpleTrustZone/CM33_ns/main_ns.c b/SimpleTrustZone/CM33_ns/main_ns.c index b7f3b56..4693000 100644 --- a/SimpleTrustZone/CM33_ns/main_ns.c +++ b/SimpleTrustZone/CM33_ns/main_ns.c @@ -52,6 +52,7 @@ int main(void) { printf("func2(func3, 2) = %d\n", val2); printf("\x04"); // EOT (0x04) stops simulation + fflush(stdout); while (1); } diff --git a/SimpleTrustZone/CM33_s/CM33_s.cproject.yml b/SimpleTrustZone/CM33_s/CM33_s.cproject.yml index 2a14942..9e0b468 100644 --- a/SimpleTrustZone/CM33_s/CM33_s.cproject.yml +++ b/SimpleTrustZone/CM33_s/CM33_s.cproject.yml @@ -6,12 +6,15 @@ project: - group: Secure Code files: - file: main_s.c + - file: ../retarget_stdio.c - group: Interface files: - file: interface.c components: - component: CMSIS:CORE + - component: CMSIS-Compiler:CORE + - component: CMSIS-Compiler:STDOUT:Custom - component: Device:Startup&C Startup - component: CMSIS-View:Event Recorder&DAP @@ -19,4 +22,3 @@ project: type: - elf - hex - \ No newline at end of file diff --git a/SimpleTrustZone/SimpleTZ.cbuild-pack.yml b/SimpleTrustZone/SimpleTZ.cbuild-pack.yml index 449e4d1..8bdd8a0 100644 --- a/SimpleTrustZone/SimpleTZ.cbuild-pack.yml +++ b/SimpleTrustZone/SimpleTZ.cbuild-pack.yml @@ -1,11 +1,14 @@ -cbuild-pack: - resolved-packs: - - resolved-pack: ARM::CMSIS@6.1.0 - selected-by-pack: - - ARM::CMSIS - - resolved-pack: ARM::CMSIS-View@1.2.0 - selected-by-pack: - - ARM::CMSIS-View - - resolved-pack: ARM::Cortex_DFP@1.1.0 - selected-by-pack: - - ARM::Cortex_DFP +cbuild-pack: + resolved-packs: + - resolved-pack: ARM::CMSIS@6.1.0 + selected-by-pack: + - ARM::CMSIS + - resolved-pack: ARM::CMSIS-Compiler@2.3.0 + selected-by-pack: + - ARM::CMSIS-Compiler + - resolved-pack: ARM::CMSIS-View@1.2.0 + selected-by-pack: + - ARM::CMSIS-View + - resolved-pack: ARM::Cortex_DFP@1.1.0 + selected-by-pack: + - ARM::Cortex_DFP diff --git a/SimpleTrustZone/SimpleTZ.csolution.yml b/SimpleTrustZone/SimpleTZ.csolution.yml index bfd42b2..a0c7169 100644 --- a/SimpleTrustZone/SimpleTZ.csolution.yml +++ b/SimpleTrustZone/SimpleTZ.csolution.yml @@ -9,6 +9,7 @@ solution: packs: - pack: ARM::CMSIS + - pack: ARM::CMSIS-Compiler - pack: ARM::Cortex_DFP - pack: ARM::CMSIS-View diff --git a/SimpleTrustZone/retarget_stdio.c b/SimpleTrustZone/retarget_stdio.c new file mode 100644 index 0000000..5f49b52 --- /dev/null +++ b/SimpleTrustZone/retarget_stdio.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2026 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include "retarget_stdout.h" + +#define UART0_BASE 0x40004000U +#define UART0_DATA (*(volatile uint32_t *)(UART0_BASE + 0x000U)) +#define UART0_STATE (*(volatile uint32_t *)(UART0_BASE + 0x004U)) +#define UART0_CTRL (*(volatile uint32_t *)(UART0_BASE + 0x008U)) +#define UART0_BAUDDIV (*(volatile uint32_t *)(UART0_BASE + 0x010U)) +#define UART_TX_FULL (1UL << 0) +#define UART_TX_ENABLE (1UL << 0) + +int stdout_putchar(int ch) { + if ((UART0_CTRL & UART_TX_ENABLE) == 0U) { + UART0_BAUDDIV = 16U; + UART0_CTRL = UART_TX_ENABLE; + } + while ((UART0_STATE & UART_TX_FULL) != 0U) { + } + UART0_DATA = (uint32_t)(uint8_t)ch; + return ch; +} From 0a14d79859bf2d6fb78f501405710e9a0d19a881 Mon Sep 17 00:00:00 2001 From: Reinhard Keil Date: Wed, 23 Sep 2026 14:18:13 +0200 Subject: [PATCH 6/9] fixed FVP output for NS-only --- .github/workflows/SimpleTZ-CI.yml | 2 +- FVP/FVP_MPS2_Cortex-M33/fvp_config.txt | 3 +++ SimpleTrustZone/SimpleTZ.csolution.yml | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/SimpleTZ-CI.yml b/.github/workflows/SimpleTZ-CI.yml index 27279b8..d8abd77 100644 --- a/.github/workflows/SimpleTZ-CI.yml +++ b/.github/workflows/SimpleTZ-CI.yml @@ -105,7 +105,7 @@ jobs: working-directory: ./SimpleTrustZone/ run: | FVP_MPS2_Cortex-M33 \ - -a ./out/CM33_s/AVH/${{ matrix.build.type }}/CM33_s.hex \ -a ./out/CM33_ns/AVH-NS-only/${{ matrix.build.type }}/CM33_ns.${{ matrix.compiler.ext }} \ + -a ./out/CM33_s/AVH/${{ matrix.build.type }}/CM33_s.hex \ -f ./../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt \ --simlimit 10 --stat diff --git a/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt b/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt index 6525910..b9c3c59 100644 --- a/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt +++ b/FVP/FVP_MPS2_Cortex-M33/fvp_config.txt @@ -5,6 +5,9 @@ fvp_mps2.mps2_visualisation.disable-visualisation=1 # (bool , init-time) defa fvp_mps2.UART0.shutdown_on_eot=1 # (bool , init-time) default = '0' : Shutdown simulation when an EOT (ASCII 4) character is transmitted fvp_mps2.UART0.out_file=- # (string, init-time) default = '' : Send UART output to stdout fvp_mps2.UART0.unbuffered_output=1 # (bool , init-time) default = '0' : Disable UART output buffering +fvp_mps2.telnetterminal0.start_telnet=0 # (bool , init-time) default = '1' : Do not launch an external terminal +fvp_mps2.telnetterminal1.start_telnet=0 # (bool , init-time) default = '1' : Do not launch an external terminal +fvp_mps2.telnetterminal2.start_telnet=0 # (bool , init-time) default = '1' : Do not launch an external terminal cpu0.semihosting-heap_limit=0x0 # (int , init-time) default = '0x10700000' : Virtual address of top of heap : [0x0..0xFFFFFFFF] cpu0.semihosting-stack_base=0x0 # (int , init-time) default = '0x10700000' : Virtual address of base of descending stack : [0x0..0xFFFFFFFF] cpu0.semihosting-stack_limit=0x0 # (int , init-time) default = '0x10800000' : Virtual address of stack limit : [0x0..0xFFFFFFFF] diff --git a/SimpleTrustZone/SimpleTZ.csolution.yml b/SimpleTrustZone/SimpleTZ.csolution.yml index a0c7169..2092ae8 100644 --- a/SimpleTrustZone/SimpleTZ.csolution.yml +++ b/SimpleTrustZone/SimpleTZ.csolution.yml @@ -41,9 +41,9 @@ solution: target-set: - set: Debug images: + - project-context: CM33_ns.Debug - image: out/CM33_s/AVH/Debug/CM33_s.hex load: image - - project-context: CM33_ns.Debug debugger: name: Arm-FVP model: FVP_MPS2_Cortex-M33 @@ -51,9 +51,9 @@ solution: args: --simlimit 10 --stat - set: Release images: + - project-context: CM33_ns.Release - image: out/CM33_s/AVH/Release/CM33_s.hex load: image - - project-context: CM33_ns.Release debugger: name: Arm-FVP model: FVP_MPS2_Cortex-M33 From 3f52d078da6bef34312a9dd8c02c7a8f2bc91737 Mon Sep 17 00:00:00 2001 From: Reinhard Keil Date: Wed, 23 Sep 2026 14:24:46 +0200 Subject: [PATCH 7/9] added CI output comparison --- .github/workflows/SimpleTZ-CI.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/SimpleTZ-CI.yml b/.github/workflows/SimpleTZ-CI.yml index d8abd77..432ef75 100644 --- a/.github/workflows/SimpleTZ-CI.yml +++ b/.github/workflows/SimpleTZ-CI.yml @@ -55,11 +55,19 @@ jobs: - name: Execute secure and non-secure projects on FVP working-directory: ./SimpleTrustZone/ run: | - FVP_MPS2_Cortex-M33 \ + output="$(FVP_MPS2_Cortex-M33 \ -a ./out/CM33_ns/AVH/${{ matrix.build.type }}/CM33_ns.${{ matrix.compiler.ext }} \ -a ./out/CM33_s/AVH/${{ matrix.build.type }}/CM33_s.${{ matrix.compiler.ext }} \ -f ./../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt \ - --simlimit 10 --stat + --simlimit 10 --stat 2>&1)" + printf '%s\n' "$output" + + actual="$(printf '%s\n' "$output" | grep -E '^Jump to non-secure application at 0x[[:xdigit:]]{8}$|^Non-secure application\.\.\.$|^func1\(1\) = 4$|^func2\(func3, 2\) = 9$' | sed -E 's/^(Jump to non-secure application at )0x[[:xdigit:]]{8}$/\1
/')" + expected=$'Jump to non-secure application at
\nNon-secure application...\nfunc1(1) = 4\nfunc2(func3, 2) = 9' + if [[ "$actual" != "$expected" ]]; then + printf 'Unexpected application output.\nExpected:\n%s\nActual:\n%s\n' "$expected" "$actual" + exit 1 + fi NonSecureOnly: name: Non-secure only (${{ matrix.build.type }}, ${{ matrix.compiler.name }}) @@ -104,8 +112,16 @@ jobs: - name: Execute non-secure-only target on FVP working-directory: ./SimpleTrustZone/ run: | - FVP_MPS2_Cortex-M33 \ + output="$(FVP_MPS2_Cortex-M33 \ -a ./out/CM33_ns/AVH-NS-only/${{ matrix.build.type }}/CM33_ns.${{ matrix.compiler.ext }} \ -a ./out/CM33_s/AVH/${{ matrix.build.type }}/CM33_s.hex \ -f ./../FVP/FVP_MPS2_Cortex-M33/fvp_config.txt \ - --simlimit 10 --stat + --simlimit 10 --stat 2>&1)" + printf '%s\n' "$output" + + actual="$(printf '%s\n' "$output" | grep -E '^Jump to non-secure application at 0x[[:xdigit:]]{8}$|^Non-secure application\.\.\.$|^func1\(1\) = 4$|^func2\(func3, 2\) = 9$' | sed -E 's/^(Jump to non-secure application at )0x[[:xdigit:]]{8}$/\1
/')" + expected=$'Jump to non-secure application at
\nNon-secure application...\nfunc1(1) = 4\nfunc2(func3, 2) = 9' + if [[ "$actual" != "$expected" ]]; then + printf 'Unexpected application output.\nExpected:\n%s\nActual:\n%s\n' "$expected" "$actual" + exit 1 + fi From 93258d56f59cfb534aec408e80c3ae326ff1df76 Mon Sep 17 00:00:00 2001 From: Reinhard Keil Date: Wed, 23 Sep 2026 15:07:47 +0200 Subject: [PATCH 8/9] Aligned README files --- README.md | 2 +- SimpleTrustZone/README.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a46576e..2e0ed0d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Examples in this repository: :------------------------------------|:---------------------------------- [Hello](./Hello) | A simple project to get started. Requires no hardware as it runs on [AVH-FVP](https://github.com/ARM-software/AVH) simulation models. [DualCore](./DualCore) | Application with multiple processors that runs on the [NXP FRDM-K32L3A6](https://www.keil.arm.com/boards/nxp-frdm-k32l3a6-989d2e5/projects/) board. -[SimpleTrustZone](./SimpleTrustZone) | Simple TrustZone example that shows the concept of secure and non-secure projects. Runs on [AVH-FVP](https://github.com/ARM-software/AVH) simulation models. +[SimpleTrustZone](./SimpleTrustZone) | Simple TrustZone example that shows secure and non-secure projects, including how to use a prebuilt secure image. Runs on [AVH-FVP](https://github.com/ARM-software/AVH) simulation models. [CubeMX](./CubeMX) | Project that uses [STM32CubeMX](https://github.com/Open-CMSIS-Pack/cmsis-toolbox/tree/main/docs/CubeMX.md) for device configuration and contains a RAM and ROM target. Each *csolution project* example shows different aspects of the CMSIS-Toolbox. For example, the [CubeMX](./CubeMX) *csolution project* contains two targets that show RAM and ROM execution. diff --git a/SimpleTrustZone/README.md b/SimpleTrustZone/README.md index 3bfe056..c1dfd9d 100644 --- a/SimpleTrustZone/README.md +++ b/SimpleTrustZone/README.md @@ -53,7 +53,7 @@ Replace `AC6` with `GCC` to build a target set with the GCC compiler. ## Use an Existing Secure Image -The `AVH-NS-only` target demonstrates how to build a non-secure application against an existing secure application. It builds only `CM33_ns` and reuses two outputs previously generated for the `AVH` target: +The `AVH-NS-only` target demonstrates the CMSIS-Toolbox concept [Use a Prebuilt Secure Image](https://open-cmsis-pack.github.io/cmsis-toolbox/build-overview/#use-a-prebuilt-secure-image). It builds only `CM33_ns` and reuses two outputs previously generated for the `AVH` target: - `CM33_s.hex`, which is loaded together with the non-secure application. - `CM33_s_CMSE_Lib.o`, which provides the secure callable interface used to link the non-secure application. @@ -67,6 +67,8 @@ The existing secure outputs must match the selected build type and compiler. Bui When using VS Code, first select and build `AVH@Debug` or `AVH@Release` in the Manage Solution view. Then select the matching `AVH-NS-only` target set and build or run it. Building `AVH-NS-only` first in a clean workspace fails because the secure HEX file and CMSE library do not yet exist. +The non-secure executable is listed before the secure HEX file in the target set and FVP invocation. This load order lets the executable configure the debug session before the prebuilt secure image is overlaid. + ## Execute the project on Arm Virtual Hardware ```txt From f41232e09e1bbb9666ce1062c14c1c801923026c Mon Sep 17 00:00:00 2001 From: Reinhard Keil Date: Thu, 24 Sep 2026 10:20:24 +0200 Subject: [PATCH 9/9] added comments to retarget*.c --- SimpleTrustZone/retarget_stdio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/SimpleTrustZone/retarget_stdio.c b/SimpleTrustZone/retarget_stdio.c index 5f49b52..df265ea 100644 --- a/SimpleTrustZone/retarget_stdio.c +++ b/SimpleTrustZone/retarget_stdio.c @@ -4,25 +4,37 @@ * SPDX-License-Identifier: Apache-2.0 */ +/* + * Common stdout retargeting implementation for both the Secure and + * Non-secure parts of the application. + */ + #include #include "retarget_stdout.h" +/* UART0 memory-mapped registers used for polling-based output. */ #define UART0_BASE 0x40004000U #define UART0_DATA (*(volatile uint32_t *)(UART0_BASE + 0x000U)) #define UART0_STATE (*(volatile uint32_t *)(UART0_BASE + 0x004U)) #define UART0_CTRL (*(volatile uint32_t *)(UART0_BASE + 0x008U)) #define UART0_BAUDDIV (*(volatile uint32_t *)(UART0_BASE + 0x010U)) + +/* Status and control bits required by the transmit path. */ #define UART_TX_FULL (1UL << 0) #define UART_TX_ENABLE (1UL << 0) int stdout_putchar(int ch) { + /* Initialize the UART on first use, preserving an existing setup. */ if ((UART0_CTRL & UART_TX_ENABLE) == 0U) { UART0_BAUDDIV = 16U; UART0_CTRL = UART_TX_ENABLE; } + + /* Wait until the transmit FIFO has room for the next character. */ while ((UART0_STATE & UART_TX_FULL) != 0U) { } + UART0_DATA = (uint32_t)(uint8_t)ch; return ch; }