summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralfred gedeon <28123637+alfred2g@users.noreply.github.com>2022-12-05 16:58:26 -0800
committerGitHub <noreply@github.com>2022-12-05 16:58:26 -0800
commit101c263371f5e062d52b8fae5abfb65633ecb32d (patch)
tree008d67d16d9e0b2c59c3694de541b425b6c56fb0
parente85b49ad18c6045c024545097c4e3126cbf3cdd8 (diff)
downloadfreertos-git-101c263371f5e062d52b8fae5abfb65633ecb32d.tar.gz
Fix: Build enable trace facility (#890)
* Fix IAR GCC build for Qemu MPS2 * Add removed file * Add timer function for runtime stats * Add lexicon entry
-rw-r--r--.github/workflows/core-checks.yml2
-rw-r--r--FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h10
-rw-r--r--FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c38
-rw-r--r--lexicon.txt1
4 files changed, 49 insertions, 2 deletions
diff --git a/.github/workflows/core-checks.yml b/.github/workflows/core-checks.yml
index 25cffd473..be7e0ddd6 100644
--- a/.github/workflows/core-checks.yml
+++ b/.github/workflows/core-checks.yml
@@ -82,4 +82,4 @@ jobs:
- name: Qemu MPS2 MPU build Cortex M3
run: cd workspace/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC && make
- name: Qemu MPS2 IAR build Cortex M3
- run: cd workspace/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc && sed -i '/configUSE_STATS_FORMATTING_FUNCTIONS/c\#define configUSE_STATS_FORMATTING_FUNCTIONS 0' ../../FreeRTOSConfig.h && make
+ run: cd workspace/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc && make
diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h
index 26c1dd707..ed8471da2 100644
--- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h
+++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h
@@ -39,6 +39,15 @@
* See http://www.freertos.org/a00110.html
*----------------------------------------------------------*/
+#define configUSE_TRACE_FACILITY 1
+#define configGENERATE_RUN_TIME_STATS 1
+
+void vConfigureTimerForRunTimeStats( void );
+unsigned long ulGetRunTimeCounterValue( void );
+
+#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats( )
+#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
+
#define configUSE_TICKLESS_IDLE 0
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
@@ -48,7 +57,6 @@
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 80 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 60 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 12 )
-#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_MUTEXES 1
diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c
index 72b9c5e9b..d27e53f19 100644
--- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c
+++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c
@@ -50,6 +50,8 @@
#include "FreeRTOS.h"
#include "task.h"
+#include "CMSDK_CM3.h"
+
/* Standard includes. */
#include <stdio.h>
#include <string.h>
@@ -75,6 +77,11 @@ required UART registers. */
#define UART0_BAUDDIV ( * ( ( ( volatile uint32_t * )( UART0_ADDRESS + 16UL ) ) ) )
#define TX_BUFFER_MASK ( 1UL )
+#define TIMER_POSTSCALER ( 8UL )
+
+/* Time at start of day (in ns). */
+static volatile unsigned long ulRunTimeOverflowCount = 0U;
+
/*
* main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
* main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
@@ -307,6 +314,37 @@ void *malloc( size_t size )
for( ;; );
}
+/*-----------------------------------------------------------*/
+void vConfigureTimerForRunTimeStats( void )
+{
+ /* PCLK / SystemCoreClock is 25MHz, Timer clock is always PCLK */
+ CMSDK_TIMER0->CTRL &= ~( CMSDK_TIMER_CTRL_EN_Msk );
+
+ CMSDK_TIMER0->RELOAD = 0xFFFFFFFF;
+
+ /* Enable overflow interrupt and start the timer */
+ CMSDK_TIMER0->CTRL |= CMSDK_TIMER_CTRL_IRQEN_Msk;
+ CMSDK_TIMER0->CTRL |= CMSDK_TIMER_CTRL_EN_Msk;
+
+}
+/*-----------------------------------------------------------*/
+
+unsigned long ulGetRunTimeCounterValue( void )
+{
+ unsigned long ulTimerValue = CMSDK_TIMER0->RELOAD - CMSDK_TIMER0->VALUE;
+
+ /*
+ * 32 bits will overflow after ~ ( 2**32 / 25000000 ) == 171 seconds,
+ * So we remove the lower 8 bits and borrow 8 bits from the overflow counter.
+ */
+
+ ulTimerValue = ( ulTimerValue >> TIMER_POSTSCALER );
+
+ /* Add remaining 8 bits from ulRunTimeOverflowCount */
+ ulTimerValue |= ( ulRunTimeOverflowCount << ( 32UL - TIMER_POSTSCALER ) );
+
+ return ulTimerValue;
+}
diff --git a/lexicon.txt b/lexicon.txt
index 5a30f535d..d0161c920 100644
--- a/lexicon.txt
+++ b/lexicon.txt
@@ -2923,6 +2923,7 @@ ulreportid
ulrestartoffset
ulreturned
ulrlar
+ulruntimeoverflowcount
ulsecondnotificationvalueconst
ulsecondnotifiedconst
ulsecondnotifiedvalueconst