Skip to content

Commit

Permalink
Examples: update Fault example for Cortex-M7 (AVH)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiloradCvjetkovic authored and RobertRostohar committed Nov 28, 2024
1 parent 5e32195 commit 85da277
Show file tree
Hide file tree
Showing 29 changed files with 169 additions and 183 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*----------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
* Name: Fault.c
* Purpose: Fault example program
*----------------------------------------------------------------------------*/
Expand All @@ -25,9 +25,9 @@ extern int stdio_init (void);
osThreadId_t tid_AppThread;
osThreadId_t tid_FaultTriggerThread;

/*---------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
* Application thread
*---------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
static __NO_RETURN void AppThread (void *argument) {
volatile uint32_t counter = 0U;

Expand All @@ -39,9 +39,9 @@ static __NO_RETURN void AppThread (void *argument) {
}
}

/*---------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
* Fault trigger thread
*---------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
static __NO_RETURN void FaultTriggerThread (void *argument) {
char ch;

Expand All @@ -50,13 +50,13 @@ static __NO_RETURN void FaultTriggerThread (void *argument) {
// Display user interface message
printf("\r\n--- Fault example ---\r\n\r\n");
printf("To trigger a fault please input a corresponding number:\r\n");
printf(" - 0: terminate the example\r\n");
printf(" - 1: data access (precise) Memory Management fault\r\n");
printf(" - 2: data access (precise) Bus fault\r\n");
printf(" - 3: data access (imprecise) Bus fault\r\n");
printf(" - 4: instruction execution Bus fault\r\n");
printf(" - 5: undefined instruction Usage fault\r\n");
printf(" - 6: divide by 0 Usage fault\r\n\r\n");
printf(" - 0: Terminate the example\r\n");
printf(" - 1: Data access (precise) Memory Management fault\r\n");
printf(" - 2: Data access (precise) Bus fault\r\n");
printf(" - 3: Data access (imprecise) Bus fault\r\n");
printf(" - 4: Instruction execution Bus fault\r\n");
printf(" - 5: Undefined instruction Usage fault\r\n");
printf(" - 6: Divide by 0 Usage fault\r\n\r\n");
printf("Input>");

for (;;) {
Expand All @@ -69,9 +69,9 @@ static __NO_RETURN void FaultTriggerThread (void *argument) {
}
}

/*---------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
* Application main function
*---------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
int main (void) {

SystemCoreClockUpdate(); // Update SystemCoreClock variable
Expand Down Expand Up @@ -114,5 +114,6 @@ int main (void) {
tid_FaultTriggerThread = osThreadNew(FaultTriggerThread, NULL, NULL);
osKernelStart(); // Start thread execution

for (;;);
for (;;) { // Loop forever
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
project:
description: Fault example (Cortex-M7)

packs:
- pack: ARM::CMSIS@>=6.0.0-0
- pack: ARM::CMSIS-RTX@>=5.8.0-0
- pack: ARM::CMSIS-Compiler@>=2.0.0-0
- pack: ARM::CMSIS-View
- pack: ARM::CMSIS-View@^1.2.0-0
- pack: ARM::CMSIS@^6.1.0
- pack: ARM::CMSIS-Compiler@^2.1.0
- pack: ARM::CMSIS-RTX@^5.9.0

groups:
- group: Documentation
Expand All @@ -19,19 +20,25 @@ project:

components:
- component: CMSIS:CORE

- component: CMSIS:OS Tick:SysTick
- component: CMSIS:RTOS2:Keil RTX5&Source

- component: CMSIS-Compiler:CORE
- component: CMSIS-Compiler:STDOUT:Custom
- component: CMSIS-Compiler:STDIN:Custom
- component: CMSIS-Compiler:STDOUT:Custom
- component: CMSIS-Compiler:STDERR:Custom

- component: CMSIS-View:Event Recorder&Semihosting
- component: CMSIS-View:Fault:Record
- component: CMSIS-View:Fault:Storage

- component: Board Support&V2M-MPS2:Common

- component: Device:Startup&C Startup
- component: CMSIS Driver:USART

- component: Device:Startup&C Startup
linker:
- script: ./RTE/Device/CMSDK_CM7_SP_VHT/ac6_arm.sct
for-compiler: AC6

- script: ./RTE/Device/CMSDK_CM7_SP_VHT/gcc_arm.ld
for-compiler: GCC
25 changes: 25 additions & 0 deletions Examples/Fault/FVP_MPS2_Cortex-M7/Fault.csolution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
solution:
description: Fault example (Cortex-M7)
created-for: CMSIS-Toolbox@2.6.0
cdefault:

select-compiler:
# list of tested compilers that can be selected
- compiler: AC6
- compiler: GCC

packs:
- pack: Keil::V2M-MPS2_CMx_BSP@^1.8.0

target-types:
- type: FVP_MPS2_Cortex-M7
board: ARM::V2M-MPS2:B
device: ARM::CMSDK_CM7_SP_VHT

build-types:
- type: Debug
debug: on
optimize: debug

projects:
- project: Fault.cproject.yml
70 changes: 70 additions & 0 deletions Examples/Fault/FVP_MPS2_Cortex-M7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Fault example (Cortex-M7)

This project is a simple **Fault** component example running on an **Arm Cortex-M7** microcontroller simulated by
[**Arm Virtual Hardware**](https://www.arm.com/products/development-tools/simulation/virtual-hardware) with the **FVP_MPS2_Cortex-M7** model simulator.

The application allows triggering of specific faults upon which the fault information is saved and system is reset.
When system restarts the fault information is output via the **Event Recorder**.

The fault information can also be inspected with **Component Viewer** in a debug session.

> **Note**
> This example runs on the [**Arm Virtual Hardware**](https://www.arm.com/products/development-tools/simulation/virtual-hardware) simulator
> and does not require any hardware.
## Prerequisites

### Software

- [**Arm Keil Studio for VS Code**](https://marketplace.visualstudio.com/items?itemName=Arm.keil-studio-pack)
- [**eventlist**](https://github.com/ARM-software/CMSIS-View/releases/tag/tools%2Feventlist%2F1.1.0) **v1.1.0** or newer

## Build and Run

To try the example with the **Arm Keil Studio**, follow the steps below:

1. open the example in the **Visual Studio Code**.
2. in the **Configure Solution** tab select the desired compiler (**AC6** or **GCC**), and click on the **OK** button.
3. build the solution (in the **CMSIS** extension view click on the **Build solution** button).
4. run the **FVP model** from the command line by executing the following command:
- for **AC6**:
```shell
FVP_MPS2_Cortex-M7 -f fvp_config.txt out/Fault/FVP_MPS2_Cortex-M7/Debug/Fault.axf
```
- for **GCC**:
```shell
FVP_MPS2_Cortex-M7 -f fvp_config.txt out/Fault/FVP_MPS2_Cortex-M7/Debug/Fault.elf
```

> **Note**
> **The Arm Virtual Hardware executable files have to be in the environment path**.
> You can install **Arm Virtual Hardware** via **Arm Keil Studio** by following these steps:
> - click on the **Arm Tools**.
> - select **Add Arm Tools Configuration to Workspace**.
> - under **Arm Virtual Hardware for Cortex®-M based on Fast Models** select the latest available version.
> - save the **vcpkg-configuration.json** file.

5. follow the instructions in the **simulator console**.
6. the result of example running is an `EventRecorder.log` file that contains events that were generated during the code execution.
7. view the events by using `eventlist` utility by executing the following command:
```shell
eventlist -I %CMSIS_PACK_ROOT%/ARM/CMSIS-View/1.2.0/Fault/ARM_Fault.scvd -I %CMSIS_PACK_ROOT%/ARM/CMSIS-View/1.2.0/EventRecorder/EventRecorder.scvd -I %CMSIS_PACK_ROOT%/ARM/CMSIS-RTX/5.9.0/RTX5.scvd EventRecorder.log
```

> **Note**
> If `CMSIS-View v1.2.0` or `CMSIS-RTX v5.9.0` packs are not installed, in the previous command replace the corresponding path with the path of the latest installed packs
> (for example replace `%CMSIS_PACK_ROOT%/ARM/CMSIS-View/1.2.0/Fault/` with `%CMSIS_PACK_ROOT%/ARM/CMSIS-View/1.2.1/Fault/`)

## User Interface

This example uses **simulator console** for User Interface.

The fault triggering is done by entering a number via **simulator console**, see possible values below:

- `0` : Terminate the example
- `1` : trigger the Data access (precise) Memory Management fault
- `2` : trigger the Data access (precise) Bus fault
- `3` : trigger the Data access (imprecise) Bus fault
- `4` : trigger the Instruction execution Bus fault
- `5` : trigger the Undefined instruction Usage fault
- `6` : trigger the Divide by 0 Usage fault
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* CSOLUTION generated file: DO NOT EDIT!
* Generated by: csolution version 2.6.0
*
* Project: 'Fault.Debug+FVP_MPS2_Cortex-M7'
* Target: 'Debug+FVP_MPS2_Cortex-M7'
*/

#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H


/*
* Define the Device Header File:
*/
#define CMSIS_device_header "CMSDK_CM7_SP.h"

/* ARM::CMSIS-Compiler:STDERR:Custom@1.1.0 */
#define RTE_CMSIS_Compiler_STDERR /* CMSIS-Compiler STDERR */
#define RTE_CMSIS_Compiler_STDERR_Custom /* CMSIS-Compiler STDERR: Custom */
/* ARM::CMSIS-Compiler:STDIN:Custom@1.1.0 */
#define RTE_CMSIS_Compiler_STDIN /* CMSIS-Compiler STDIN */
#define RTE_CMSIS_Compiler_STDIN_Custom /* CMSIS-Compiler STDIN: Custom */
/* ARM::CMSIS-Compiler:STDOUT:Custom@1.1.0 */
#define RTE_CMSIS_Compiler_STDOUT /* CMSIS-Compiler STDOUT */
#define RTE_CMSIS_Compiler_STDOUT_Custom /* CMSIS-Compiler STDOUT: Custom */
/* ARM::CMSIS-View:Event Recorder&Semihosting@1.6.0 */
#define RTE_CMSIS_View_EventRecorder
#define RTE_CMSIS_View_EventRecorder_DAP
#define RTE_CMSIS_View_EventRecorder_Semihosting
/* ARM::CMSIS-View:Fault:Record@1.1.0 */
#define RTE_CMSIS_View_Fault_Record
/* ARM::CMSIS-View:Fault:Storage@1.1.0 */
#define RTE_CMSIS_View_Fault_Storage
/* ARM::CMSIS:RTOS2:Keil RTX5&Source@5.9.0 */
#define RTE_CMSIS_RTOS2 /* CMSIS-RTOS2 */
#define RTE_CMSIS_RTOS2_RTX5 /* CMSIS-RTOS2 Keil RTX5 */
#define RTE_CMSIS_RTOS2_RTX5_SOURCE /* CMSIS-RTOS2 Keil RTX5 Source */
/* Keil::CMSIS Driver:USART@1.0.3 */
#define RTE_Drivers_USART


#endif /* RTE_COMPONENTS_H */
File renamed without changes.
19 changes: 0 additions & 19 deletions Examples/Fault/VHT_MPS2_Cortex-M7/Fault.csolution.yml

This file was deleted.

115 changes: 0 additions & 115 deletions Examples/Fault/VHT_MPS2_Cortex-M7/README.md

This file was deleted.

Loading

0 comments on commit 85da277

Please sign in to comment.