82df39764a
* 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 <magicse7en@outlook.com> * Update port.c Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com> |
||
---|---|---|
.. | ||
CDK/T-HEAD_CK802 | ||
GCC | ||
XCC/Xtensa |