From f62dfa20c8f2d512ff9f3add096c6b393aa0af1f Mon Sep 17 00:00:00 2001 From: alfred gedeon Date: Tue, 20 Oct 2020 15:37:14 -0700 Subject: [PATCH 01/10] Fix: C++ compiler warning (#203) --- include/task.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/task.h b/include/task.h index bce2a6b8c..c716132a5 100644 --- a/include/task.h +++ b/include/task.h @@ -129,7 +129,7 @@ typedef struct xMEMORY_REGION typedef struct xTASK_PARAMETERS { TaskFunction_t pvTaskCode; - const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const char * pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ configSTACK_DEPTH_TYPE usStackDepth; void * pvParameters; UBaseType_t uxPriority; From c6636f465f2bc70a31963356e549ebf514f892c3 Mon Sep 17 00:00:00 2001 From: alfred gedeon Date: Wed, 21 Oct 2020 18:40:43 -0700 Subject: [PATCH 02/10] Move markdown files and lexicon into .github directory (#205) * Move markdown files and lexicon into .github directory --- CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 SECURITY.md => .github/SECURITY.md | 0 lexicon.txt => .github/lexicon.txt | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) rename SECURITY.md => .github/SECURITY.md (100%) rename lexicon.txt => .github/lexicon.txt (100%) diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/SECURITY.md b/.github/SECURITY.md similarity index 100% rename from SECURITY.md rename to .github/SECURITY.md diff --git a/lexicon.txt b/.github/lexicon.txt similarity index 100% rename from lexicon.txt rename to .github/lexicon.txt From db62e30bce2101d20946220a9e3719bc47c75587 Mon Sep 17 00:00:00 2001 From: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Date: Thu, 22 Oct 2020 17:09:35 -0700 Subject: [PATCH 03/10] Fix missed yield in xTaskResumeFromISR (#207) If a higher priority task than the currently running task was resumed using xTaskResumeFromISR and the user chose to ignore the return value of xTaskResumeFromISR to initiate a context switch using portYIELD_FROM_ISR, we were not doing the context switch on the next run of the scheduler. This change fixes this by marking a yield as pending to ensure that the context switch is performed on the next run of the scheduler. Signed-off-by: Gaurav Aggarwal --- tasks.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tasks.c b/tasks.c index 94b3e1f86..62ab95a30 100644 --- a/tasks.c +++ b/tasks.c @@ -1949,6 +1949,11 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) { xYieldRequired = pdTRUE; + + /* Mark that a yield is pending in case the user is not + * using the return value to initiate a context switch + * from the ISR using portYIELD_FROM_ISR. */ + xYieldPending = pdTRUE; } else { From f376c3bd71b87c532474aa204861028c577d6dab Mon Sep 17 00:00:00 2001 From: alfred gedeon Date: Fri, 23 Oct 2020 11:33:41 -0700 Subject: [PATCH 04/10] Fix: Pass lexicon.txt as a parameter (#208) * Fix: pass lexicon.txt as a parameter * Fix lexicon location --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 593c384f8..377813b07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: PATH=$PATH:main/tools/spell # Make sure that the portable directory is not included in the spellcheck. sed -i 's/find $DIRNAME/find $DIRNAME -not -path '*portable*'/g' main/tools/spell/find-unknown-comment-words - find-unknown-comment-words --directory kernel/ + find-unknown-comment-words --directory kernel/ --lexicon ./kernel/.github/lexicon.txt if [ "$?" = "0" ]; then exit 0 else From b9748e50eaafdb20a0c2438c0286a255c3f59e4c Mon Sep 17 00:00:00 2001 From: magicse7en Date: Tue, 27 Oct 2020 02:07:32 +0800 Subject: [PATCH 05/10] Xtensa: fix stack overlap coproc_area issue (#118) In function pxPortInitialiseStack of port.c: sp = ( StackType_t * ) ( ( ( UBaseType_t ) ( pxTopOfStack + 1 ) - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf ); We assume XT_CP_SIZE is 0xE4, XT_STK_FRMSZ is 0xA0, pxTopOfStack is 0xA0000000, sp is 0x9FFFFE80. From port.c, we know the frame->a1 as below: frame->a1 = ( UBaseType_t ) sp + XT_STK_FRMSZ; /* physical top of stack frame */ So frame->a1 is 0x9FFFFF20. Therefore the interrupt stack frame range is 0x9FFFFE80 ~ 0x9FFFFF20. The coproc_area is: p = ( uint32_t * ) ( ( ( uint32_t ) pxTopOfStack - XT_CP_SIZE ) & ~0xf ); So its value is 0x9FFFFF10. Obviously, the interrupt stack frame overlaps the coproc_area. Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com> --- portable/ThirdParty/XCC/Xtensa/port.c | 85 ++++++++++++++------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/portable/ThirdParty/XCC/Xtensa/port.c b/portable/ThirdParty/XCC/Xtensa/port.c index 8c304ca96..8b34b49e8 100644 --- a/portable/ThirdParty/XCC/Xtensa/port.c +++ b/portable/ThirdParty/XCC/Xtensa/port.c @@ -90,55 +90,60 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) #endif { - StackType_t *sp, *tp; - XtExcFrame *frame; - #if XCHAL_CP_NUM > 0 - uint32_t *p; - #endif + StackType_t * sp, * tp; + XtExcFrame * frame; - /* Create interrupt stack frame aligned to 16 byte boundary */ - sp = (StackType_t *) (((UBaseType_t)(pxTopOfStack + 1) - XT_CP_SIZE - XT_STK_FRMSZ) & ~0xf); + #if XCHAL_CP_NUM > 0 + uint32_t * p; + #endif - /* Clear the entire frame (do not use memset() because we don't depend on C library) */ - for (tp = sp; tp <= pxTopOfStack; ++tp) - *tp = 0; + /* Create interrupt stack frame aligned to 16 byte boundary */ + sp = ( StackType_t * ) ( ( ( UBaseType_t ) pxTopOfStack - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf ); - frame = (XtExcFrame *) sp; + /* Clear the entire frame (do not use memset() because we don't depend on C library) */ + for( tp = sp; tp <= pxTopOfStack; ++tp ) + { + *tp = 0; + } - /* Explicitly initialize certain saved registers */ - frame->pc = (UBaseType_t) pxCode; /* task entrypoint */ - frame->a0 = 0; /* to terminate GDB backtrace */ - frame->a1 = (UBaseType_t) sp + XT_STK_FRMSZ; /* physical top of stack frame */ - frame->exit = (UBaseType_t) _xt_user_exit; /* user exception exit dispatcher */ + frame = ( XtExcFrame * ) sp; - /* Set initial PS to int level 0, EXCM disabled ('rfe' will enable), user mode. */ - /* Also set entry point argument parameter. */ - #ifdef __XTENSA_CALL0_ABI__ - frame->a2 = (UBaseType_t) pvParameters; - frame->ps = PS_UM | PS_EXCM; - #else - /* + for windowed ABI also set WOE and CALLINC (pretend task was 'call4'd). */ - frame->a6 = (UBaseType_t) pvParameters; - frame->ps = PS_UM | PS_EXCM | PS_WOE | PS_CALLINC(1); - #endif + /* Explicitly initialize certain saved registers */ + frame->pc = ( UBaseType_t ) pxCode; /* task entrypoint */ + frame->a0 = 0; /* to terminate GDB backtrace */ + frame->a1 = ( UBaseType_t ) sp + XT_STK_FRMSZ; /* physical top of stack frame */ + frame->exit = ( UBaseType_t ) _xt_user_exit; /* user exception exit dispatcher */ - #ifdef XT_USE_SWPRI - /* Set the initial virtual priority mask value to all 1's. */ - frame->vpri = 0xFFFFFFFF; - #endif + /* Set initial PS to int level 0, EXCM disabled ('rfe' will enable), user mode. */ + /* Also set entry point argument parameter. */ + #ifdef __XTENSA_CALL0_ABI__ + frame->a2 = ( UBaseType_t ) pvParameters; + frame->ps = PS_UM | PS_EXCM; + #else + /* + for windowed ABI also set WOE and CALLINC (pretend task was 'call4'd). */ + frame->a6 = ( UBaseType_t ) pvParameters; + frame->ps = PS_UM | PS_EXCM | PS_WOE | PS_CALLINC( 1 ); + #endif - #if XCHAL_CP_NUM > 0 - /* Init the coprocessor save area (see xtensa_context.h) */ - /* No access to TCB here, so derive indirectly. Stack growth is top to bottom. + #ifdef XT_USE_SWPRI + /* Set the initial virtual priority mask value to all 1's. */ + frame->vpri = 0xFFFFFFFF; + #endif + + #if XCHAL_CP_NUM > 0 + /* Init the coprocessor save area (see xtensa_context.h) */ + + /* No access to TCB here, so derive indirectly. Stack growth is top to bottom. * //p = (uint32_t *) xMPUSettings->coproc_area; - */ - p = (uint32_t *)(((uint32_t) pxTopOfStack - XT_CP_SIZE) & ~0xf); - p[0] = 0; - p[1] = 0; - p[2] = (((uint32_t) p) + 12 + XCHAL_TOTAL_SA_ALIGN - 1) & -XCHAL_TOTAL_SA_ALIGN; - #endif + */ + p = ( uint32_t * ) ( ( ( uint32_t ) pxTopOfStack - XT_CP_SIZE ) & ~0xf ); + configASSERT( ( uint32_t ) p >= frame->a1 ); + p[ 0 ] = 0; + p[ 1 ] = 0; + p[ 2 ] = ( ( ( uint32_t ) p ) + 12 + XCHAL_TOTAL_SA_ALIGN - 1 ) & -XCHAL_TOTAL_SA_ALIGN; + #endif - return sp; + return sp; } /*-----------------------------------------------------------*/ From 82df39764a813970ba1071ac064063ea010ebed8 Mon Sep 17 00:00:00 2001 From: magicse7en Date: Tue, 27 Oct 2020 02:47:21 +0800 Subject: [PATCH 06/10] Xtensa: fix the coproc_area incorrect issue (#117) * Xtensa: fix the coproc_area incorrect issue foss-xtensa/amazon-freertos#2 mentioned a issue: 1. In function pxPortInitialiseStack(StackType_t *pxTopOfStack....) p = (uint32_t *)(((uint32_t) pxTopOfStack - XT_CP_SIZE) & ~0xf); In function prvInitialiseNewTask (file: task.c) pxTopOfStack = (pxStack + (ulStackDepth - 1)) & (~portBYTE_ALIGNMENT_MASK) So the co-processor area is at p = (uint32_t *)(((uint32_t)((pxStack + (ulStackDepth - 1)) & (~portBYTE_ALIGNMENT_MASK)) - XT_CP_SIZE) & ~0xf); 2. In function vPortStoreTaskMPUSettings( .... , StackType_t pxBottomOfStack ...) xMPUSettings->coproc_area = (StackType_t)((((uint32_t)(pxBottomOfStack + usStackDepth - 1)) - XT_CP_SIZE) & ~0xf); pxBottomOfStack = pxStack => xMPUSettings->coproc_area = (StackType_t*)((((uint32_t)(pxStack+ ulStackDepth - 1)) - XT_CP_SIZE ) & ~0xf); The p is coproc_area that should be equal to xMPUSettings->coproc_area. For example, assume pxStack is 0xa0000000, ulStackDepth is 0x2000, portBYTE_ALIGNMENT_MASK is 0x7f, XT_CP_SIZE is 0x100. The p = (uint32_t)(((uint32_t)((pxStack + (ulStackDepth - 1)) & (~portBYTE_ALIGNMENT_MASK)) - XT_CP_SIZE) & ~0xf) = 0xa0001e80 The xMPUSettings->coproc_area = (StackType_t)((((uint32_t)(pxStack+ usStackDepth - 1)) - XT_CP_SIZE ) & ~0xf) = 0xa0001ef0 Obviously, the p is not equal to the xMPUSettings->coproc_area, which will cause context switching error. Signed-off-by: magicse7en * Update port.c Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com> --- portable/ThirdParty/XCC/Xtensa/port.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/portable/ThirdParty/XCC/Xtensa/port.c b/portable/ThirdParty/XCC/Xtensa/port.c index 8b34b49e8..a62a0de6d 100644 --- a/portable/ThirdParty/XCC/Xtensa/port.c +++ b/portable/ThirdParty/XCC/Xtensa/port.c @@ -212,16 +212,19 @@ BaseType_t xPortSysTickHandler( void ) * Used to set coprocessor area in stack. Current hack is to reuse MPU pointer for coprocessor area. */ #if portUSING_MPU_WRAPPERS -void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) +void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings, + const struct xMEMORY_REGION * const xRegions, + StackType_t * pxBottomOfStack, + uint32_t ulStackDepth ) { - #if XCHAL_CP_NUM > 0 - xMPUSettings->coproc_area = (StackType_t*)((((uint32_t)(pxBottomOfStack + ulStackDepth - 1)) - XT_CP_SIZE ) & ~0xf); + #if XCHAL_CP_NUM > 0 + xMPUSettings->coproc_area = ( StackType_t * ) ( ( uint32_t ) ( pxBottomOfStack + ulStackDepth - 1 )); + xMPUSettings->coproc_area = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) xMPUSettings->coproc_area ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); + xMPUSettings->coproc_area = ( Stacktype_t * ) ( ( ( uint32_t ) xMPUSettings->coproc_area - XT_CP_SIZE ) & ~0xf ); - - /* NOTE: we cannot initialize the coprocessor save area here because FreeRTOS is going to + /* NOTE: we cannot initialize the coprocessor save area here because FreeRTOS is going to * clear the stack area after we return. This is done in pxPortInitialiseStack(). - */ - #endif + */ + #endif } -#endif - +#endif /* if portUSING_MPU_WRAPPERS */ From 94ffcac27cd237be6c7f81db860459af665409b1 Mon Sep 17 00:00:00 2001 From: Cobus van Eeden <35851496+cobusve@users.noreply.github.com> Date: Mon, 26 Oct 2020 13:24:55 -0700 Subject: [PATCH 07/10] Added CODEOWNERS file (#209) --- .github/CODEOWNERS | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..540b2ae37 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,39 @@ +# Each line is a file pattern followed by one or more owners. + +# These owners will be the default owners for everything in +# the repo. Unless a later match takes precedence, +# @global-owner1 and @global-owner2 will be requested for +# review when someone opens a pull request. +* @FreeRTOS/pr-bar-raiser + +# Order is important; the last matching pattern takes the most +# precedence. When someone opens a pull request that only +# modifies JS files, only @js-owner and not the global +# owner(s) will be requested for a review. +# *.c FreeRTOS/pr-bar-raiser + +# You can also use email addresses if you prefer. They'll be +# used to look up users just like we do for commit author +# emails. +# *.go docs@example.com + +# In this example, @doctocat owns any files in the build/logs +# directory at the root of the repository and any of its +# subdirectories. +# /build/logs/ @doctocat + +# The `docs/*` pattern will match files like +# `docs/getting-started.md` but not further nested files like +# `docs/build-app/troubleshooting.md`. +# docs/* docs@example.com + +# In this example, @octocat owns any file in an apps directory +# anywhere in your repository. +# apps/ @octocat + +# In this example, @doctocat owns any file in the `/docs` +# directory in the root of your repository and any of its +# subdirectories. +# /docs/ @doctocat + + From bdb38d85dcc65942bc546c07f1193a983fd16916 Mon Sep 17 00:00:00 2001 From: Jon Snow <5186629+jonsnow1357@users.noreply.github.com> Date: Mon, 26 Oct 2020 16:31:15 -0400 Subject: [PATCH 08/10] update interrupt vector names for ATMega32 (#196) --- portable/GCC/ATMega323/port.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/portable/GCC/ATMega323/port.c b/portable/GCC/ATMega323/port.c index 3aa55c383..47f645532 100644 --- a/portable/GCC/ATMega323/port.c +++ b/portable/GCC/ATMega323/port.c @@ -402,8 +402,8 @@ uint8_t ucHighByte, ucLowByte; * the context is saved at the start of vPortYieldFromTick(). The tick * count is incremented after the context is saved. */ - void SIG_OUTPUT_COMPARE1A( void ) __attribute__ ( ( signal, naked ) ); - void SIG_OUTPUT_COMPARE1A( void ) + void TIMER1_COMPA_vect( void ) __attribute__ ( ( signal, naked ) ); + void TIMER1_COMPA_vect( void ) { vPortYieldFromTick(); asm volatile ( "reti" ); @@ -415,8 +415,8 @@ uint8_t ucHighByte, ucLowByte; * tick count. We don't need to switch context, this can only be done by * manual calls to taskYIELD(); */ - void SIG_OUTPUT_COMPARE1A( void ) __attribute__ ( ( signal ) ); - void SIG_OUTPUT_COMPARE1A( void ) + void TIMER1_COMPA_vect( void ) __attribute__ ( ( signal ) ); + void TIMER1_COMPA_vect( void ) { xTaskIncrementTick(); } From 6a5784598a40adfcb5908db498fe0324c3b00016 Mon Sep 17 00:00:00 2001 From: Carl Lundin <53273776+lundinc2@users.noreply.github.com> Date: Tue, 27 Oct 2020 11:32:09 -0700 Subject: [PATCH 09/10] Upstream stack masking fix to GCC ports. (#210) Co-authored-by: Cobus van Eeden <35851496+cobusve@users.noreply.github.com> --- portable/ThirdParty/GCC/Xtensa_ESP32/port.c | 7 +++++-- portable/ThirdParty/GCC/Xtensa_ESP32_IDF3/port.c | 9 ++++++--- portable/ThirdParty/XCC/Xtensa/port.c | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/portable/ThirdParty/GCC/Xtensa_ESP32/port.c b/portable/ThirdParty/GCC/Xtensa_ESP32/port.c index a87e3cbf8..d3666a503 100644 --- a/portable/ThirdParty/GCC/Xtensa_ESP32/port.c +++ b/portable/ThirdParty/GCC/Xtensa_ESP32/port.c @@ -176,7 +176,7 @@ void _xt_user_exit( void ); #endif /* Create interrupt stack frame aligned to 16 byte boundary */ - sp = ( StackType_t * ) ( ( ( UBaseType_t ) ( pxTopOfStack + 1 ) - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf ); + sp = ( StackType_t * ) ( ( ( UBaseType_t ) pxTopOfStack - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf ); /* Clear the entire frame (do not use memset() because we don't depend on C library) */ for( tp = sp; tp <= pxTopOfStack; ++tp ) @@ -229,6 +229,7 @@ void _xt_user_exit( void ); * //p = (uint32_t *) xMPUSettings->coproc_area; */ p = ( uint32_t * ) ( ( ( uint32_t ) pxTopOfStack - XT_CP_SIZE ) & ~0xf ); + configASSERT( ( uint32_t ) p >= frame->a1 ); p[ 0 ] = 0; p[ 1 ] = 0; p[ 2 ] = ( ( ( uint32_t ) p ) + 12 + XCHAL_TOTAL_SA_ALIGN - 1 ) & -XCHAL_TOTAL_SA_ALIGN; @@ -319,7 +320,9 @@ void vPortYieldOtherCore( BaseType_t coreid ) uint32_t usStackDepth ) { #if XCHAL_CP_NUM > 0 - xMPUSettings->coproc_area = ( StackType_t * ) ( ( ( ( uint32_t ) ( pxBottomOfStack + usStackDepth - 1 ) ) - XT_CP_SIZE ) & ~0xf ); + xMPUSettings->coproc_area = ( StackType_t * ) ( ( uint32_t ) ( pxBottomOfStack + usStackDepth - 1 )); + xMPUSettings->coproc_area = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) xMPUSettings->coproc_area ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); + xMPUSettings->coproc_area = ( StackType_t * ) ( ( ( uint32_t ) xMPUSettings->coproc_area - XT_CP_SIZE ) & ~0xf ); /* NOTE: we cannot initialize the coprocessor save area here because FreeRTOS is going to diff --git a/portable/ThirdParty/GCC/Xtensa_ESP32_IDF3/port.c b/portable/ThirdParty/GCC/Xtensa_ESP32_IDF3/port.c index f6d10d50b..992789a12 100644 --- a/portable/ThirdParty/GCC/Xtensa_ESP32_IDF3/port.c +++ b/portable/ThirdParty/GCC/Xtensa_ESP32_IDF3/port.c @@ -157,7 +157,7 @@ void _xt_user_exit( void ); #endif /* Create interrupt stack frame aligned to 16 byte boundary */ - sp = ( StackType_t * ) ( ( ( UBaseType_t ) ( pxTopOfStack + 1 ) - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf ); + sp = ( StackType_t * ) ( ( ( UBaseType_t ) pxTopOfStack - XT_CP_SIZE - XT_STK_FRMSZ ) & ~0xf ); /* Clear the entire frame (do not use memset() because we don't depend on C library) */ for( tp = sp; tp <= pxTopOfStack; ++tp ) @@ -196,6 +196,7 @@ void _xt_user_exit( void ); * //p = (uint32_t *) xMPUSettings->coproc_area; */ p = ( uint32_t * ) ( ( ( uint32_t ) pxTopOfStack - XT_CP_SIZE ) & ~0xf ); + configASSERT( ( uint32_t ) p >= frame->a1 ); p[ 0 ] = 0; p[ 1 ] = 0; p[ 2 ] = ( ( ( uint32_t ) p ) + 12 + XCHAL_TOTAL_SA_ALIGN - 1 ) & -XCHAL_TOTAL_SA_ALIGN; @@ -286,9 +287,11 @@ void vPortYieldOtherCore( BaseType_t coreid ) uint32_t usStackDepth ) { #if XCHAL_CP_NUM > 0 - xMPUSettings->coproc_area = ( StackType_t * ) ( ( ( ( uint32_t ) ( pxBottomOfStack + usStackDepth - 1 ) ) - XT_CP_SIZE ) & ~0xf ); - + xMPUSettings->coproc_area = ( StackType_t * ) ( ( uint32_t ) ( pxBottomOfStack + usStackDepth - 1 )); + xMPUSettings->coproc_area = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) xMPUSettings->coproc_area ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); + xMPUSettings->coproc_area = ( StackType_t * ) ( ( ( uint32_t ) xMPUSettings->coproc_area - XT_CP_SIZE ) & ~0xf ); + /* NOTE: we cannot initialize the coprocessor save area here because FreeRTOS is going to * clear the stack area after we return. This is done in pxPortInitialiseStack(). */ diff --git a/portable/ThirdParty/XCC/Xtensa/port.c b/portable/ThirdParty/XCC/Xtensa/port.c index a62a0de6d..84978e7d9 100644 --- a/portable/ThirdParty/XCC/Xtensa/port.c +++ b/portable/ThirdParty/XCC/Xtensa/port.c @@ -220,7 +220,7 @@ void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings, #if XCHAL_CP_NUM > 0 xMPUSettings->coproc_area = ( StackType_t * ) ( ( uint32_t ) ( pxBottomOfStack + ulStackDepth - 1 )); xMPUSettings->coproc_area = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) xMPUSettings->coproc_area ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); - xMPUSettings->coproc_area = ( Stacktype_t * ) ( ( ( uint32_t ) xMPUSettings->coproc_area - XT_CP_SIZE ) & ~0xf ); + xMPUSettings->coproc_area = ( StackType_t * ) ( ( ( uint32_t ) xMPUSettings->coproc_area - XT_CP_SIZE ) & ~0xf ); /* NOTE: we cannot initialize the coprocessor save area here because FreeRTOS is going to * clear the stack area after we return. This is done in pxPortInitialiseStack(). From 1431b65110a294720b75af2f80b0f6465220a90f Mon Sep 17 00:00:00 2001 From: filipgeorge Date: Tue, 27 Oct 2020 21:26:52 +0200 Subject: [PATCH 10/10] porthardware.h file update for AVR Mega0 and Dx (#212) * Added guard for ioavr.h include in AVR Dx porthardware.h file. * Added guard for ioavr.h include in AVR Mega0 porthardware.h file. --- portable/IAR/AVR_AVRDx/porthardware.h | 4 +++- portable/IAR/AVR_Mega0/porthardware.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/portable/IAR/AVR_AVRDx/porthardware.h b/portable/IAR/AVR_AVRDx/porthardware.h index 2d17b4202..dbbcd05fc 100644 --- a/portable/IAR/AVR_AVRDx/porthardware.h +++ b/portable/IAR/AVR_AVRDx/porthardware.h @@ -1,7 +1,9 @@ #ifndef PORTHARDWARE_H #define PORTHARDWARE_H -#include +#ifndef __IAR_SYSTEMS_ASM__ + #include +#endif #include "FreeRTOSConfig.h" /*-----------------------------------------------------------*/ diff --git a/portable/IAR/AVR_Mega0/porthardware.h b/portable/IAR/AVR_Mega0/porthardware.h index 4188ae274..793d5899c 100644 --- a/portable/IAR/AVR_Mega0/porthardware.h +++ b/portable/IAR/AVR_Mega0/porthardware.h @@ -1,7 +1,9 @@ #ifndef PORTHARDWARE_H #define PORTHARDWARE_H -#include +#ifndef __IAR_SYSTEMS_ASM__ + #include +#endif #include "FreeRTOSConfig.h" /*-----------------------------------------------------------*/