]> begriffs open source - freertos/log
freertos
5 years agoXtensa: fix the coproc_area incorrect issue (#117)
magicse7en [Mon, 26 Oct 2020 18:47:21 +0000 (02:47 +0800)]
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 <magicse7en@outlook.com>
* Update port.c

Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com>
5 years agoXtensa: fix stack overlap coproc_area issue (#118)
magicse7en [Mon, 26 Oct 2020 18:07:32 +0000 (02:07 +0800)]
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>
5 years agoFix: Pass lexicon.txt as a parameter (#208)
alfred gedeon [Fri, 23 Oct 2020 18:33:41 +0000 (11:33 -0700)]
Fix: Pass lexicon.txt as a parameter (#208)

* Fix: pass lexicon.txt as a parameter

* Fix lexicon location

5 years agoFix missed yield in xTaskResumeFromISR (#207)
Gaurav-Aggarwal-AWS [Fri, 23 Oct 2020 00:09:35 +0000 (17:09 -0700)]
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 <aggarg@amazon.com>
5 years agoMove markdown files and lexicon into .github directory (#205)
alfred gedeon [Thu, 22 Oct 2020 01:40:43 +0000 (18:40 -0700)]
Move markdown files and lexicon into .github directory (#205)

* Move markdown files and lexicon into .github directory

5 years agoFix: C++ compiler warning (#203)
alfred gedeon [Tue, 20 Oct 2020 22:37:14 +0000 (15:37 -0700)]
Fix: C++ compiler warning (#203)

5 years agoRecently vTaskDelayUntil() was updated to xTaskDelayUntil() because the function...
RichardBarry [Sun, 11 Oct 2020 21:04:49 +0000 (14:04 -0700)]
Recently vTaskDelayUntil() was updated to xTaskDelayUntil() because the function now returns a value.  The PR didn't make the same change in the MPU port, or update the constants required to include the xTaskDelayUntil() function in the build. (#199)

This PR:
Changes the INCLUDE_vTaskDelayUntil compile time constant to INCLUDE_xTaskDelayUntil.
Updates FreeRTOS.h to ensure backward compatibility for projects that already have INCLUDE_vTaskDelayUntil defined.
Updates the MPU prototypes, wrapper and implementation to use the updated xTaskDelayUntil() function.

Tests to be checked into the FreeRTOS/FreeRTOS repository after this PR.

5 years agoxStreamBufferSend() caps the maximum amount of data a stream buffer can send to the...
RichardBarry [Sun, 11 Oct 2020 04:47:54 +0000 (21:47 -0700)]
xStreamBufferSend() caps the maximum amount of data a stream buffer can send to the maximum capacity of the buffer - however the value to which the length is capped was wrong, and is correct by this check in.  Likewise when sending to a message buffer if the send length is too long the block time is set to 0 to ensure the sending task does not wait indefinitely for the impossible send to complete - but the length check was wrong, and is corrected by this check in. (#195)

5 years agoMinor updates to formatting and MISRA compliance of the PR used to update the vTaskDe...
RichardBarry [Sun, 11 Oct 2020 04:42:38 +0000 (21:42 -0700)]
Minor updates to formatting and MISRA compliance of the PR used to update the vTaskDelayUntil() function to xTaskDelayUntil(). (#198)

5 years agomatching the preprocessor conditionals for xTaskGetCurrentTaskHandle() (#197)
Joseph Julicher [Fri, 9 Oct 2020 01:44:30 +0000 (18:44 -0700)]
matching the preprocessor conditionals for xTaskGetCurrentTaskHandle() (#197)

5 years agovTaskDelayUntil improvement (#77) 187/head
Spacefish [Fri, 9 Oct 2020 00:46:47 +0000 (02:46 +0200)]
vTaskDelayUntil improvement (#77)

* vTaskDelayUntil improvement

* suggestions implemented

* xTaskDelayUntil #define added

* doc small fix

* small formatting stuff

* more small formatting stuff

* Update lexicon.txt

Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com>
Co-authored-by: Carl Lundin <lundinc@amazon.com>
5 years agoReintroduce Espressif's IDF v4.2 changes to ESP32 port (#193)
Carl Lundin [Thu, 8 Oct 2020 18:03:27 +0000 (11:03 -0700)]
Reintroduce Espressif's IDF v4.2 changes to ESP32 port (#193)

* Renamed old port to ESP_IDF_V3

* Update ESP32 port files to support IDF v4.2.

* Add changes required to support ESP32-S2

Co-authored-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
5 years agoPosix: Fix no task switching issue if a task ended its main function (#184)
Reda Maher [Tue, 6 Oct 2020 01:06:51 +0000 (03:06 +0200)]
Posix: Fix no task switching issue if a task ended its main function (#184)

* Posix: Fix no task switching issue if a task ended

When the main function of a task exits, no task switching happened.
This is because all the remaining tasks are waiting on the condition
variable. The fix is to trigger a task switch and mark the exiting
task as "Dying" to be suspened and exited properly from the scheduler.

* Posix: Assert and stop if the Task function returned

* Posix: just assert if a task returned from its main function

Co-authored-by: alfred gedeon <alfred2g@hotmail.com>
5 years agoNo functional changes. (#194)
RichardBarry [Sun, 4 Oct 2020 04:26:22 +0000 (21:26 -0700)]
No functional changes. (#194)

Shorted overly verbose and opinionated comments in xStreamBufferSend().
Remove the unnecessary xIsFeasible variable from xStreamBufferSend().

5 years agoOpenOCD Support: Re-introduce uxTopUsedPriority (#188)
David Chalco [Thu, 1 Oct 2020 19:40:21 +0000 (12:40 -0700)]
OpenOCD Support: Re-introduce uxTopUsedPriority (#188)

* re-introduce uxTopUsedPriority. Prevent removal by optimization

* Make uxTopUsedPriority volatile to avoid optimizer + code comment

Co-authored-by: Cobus van Eeden <35851496+cobusve@users.noreply.github.com>
5 years agoUpdate issue templates
Cobus van Eeden [Thu, 1 Oct 2020 00:58:12 +0000 (17:58 -0700)]
Update issue templates

5 years agoUpdate issue templates (#191)
Cobus van Eeden [Thu, 1 Oct 2020 00:28:28 +0000 (17:28 -0700)]
Update issue templates (#191)

5 years agoCreate config.yml (#190)
Cobus van Eeden [Thu, 1 Oct 2020 00:10:49 +0000 (17:10 -0700)]
Create config.yml (#190)

5 years agoPosix: Free the allocated memory after deleting a task or ending the scheduler (...
Reda Maher [Tue, 29 Sep 2020 21:06:10 +0000 (23:06 +0200)]
Posix: Free the allocated memory after deleting a task or ending the scheduler (#181)

* Posix: Free Idle task resources after ending the scheduler

In case of using Posix simulator and ending the scheduler, it does
not free the resources allocated by the idle task. This
causes the memory checkers (Valgrind, Address Sanitizers, ..) to
complain.

* Posix: Free the condition variable memory in the correct place

In case of deleting a task from another task, the deletion happens
immediately and the thread is canceled but the memory allocated by
the task condition variable is not freed. This causes the memory
checkers (Valgrind, Address sanitizers, ..) to complain.

* Posix: End Timer thread and free its resources after ending the scheduler

5 years agoFix Stack alignment for Microchip PIC32MX port (#182)
Gaurav-Aggarwal-AWS [Mon, 28 Sep 2020 07:16:18 +0000 (00:16 -0700)]
Fix Stack alignment for Microchip PIC32MX port (#182)

* Fix Stack alignment for Microchip PIC32MX port

The stack of a task was not 8 byte aligned. Adding one more unused space
at the beginning of task stack (before simulated context) ensures that
the stack is 8 byte aligned. The stack (with simulated context) of a
newly created task looks like the following:

                    +------------+
                    | UNUSED     |
                    +------------+
                    | UNUSED     |
                    +------------+
                    | 0xDEADBEEF |
                    +------------+
                    | 0x12345678 |
                ^   +------------+
                |   | CAUSE      | <-- SP After Context Restore
                |   +------------+
                |   | STATUS     |
                |   +------------+
                |   | EPC        |
                |   +------------+
                |   | ra         |
                |   +------------+
                |   | s8         |
                |   +------------+
                |   | t9         |
                |   +------------+
                |   | t8         |
                |   +------------+
                |   | t7         |
                |   +------------+
                |   | t6         |
                |   +------------+
                |   | t5         |
                |   +------------+
                |   | t4         |
                |   +------------+
                |   | t3         |
                |   +------------+
                |   | t2         |
                |   +------------+
                |   | t1         |
                |   +------------+
    Context     |   | t0         |
  (132 bytes)   |   +------------+
                |   | a3         |
                |   +------------+
                |   | a2         |
                |   +------------+
                |   | a1         |
                |   +------------+
                |   | a0         |
                |   +------------+
                |   | v1         |
                |   +------------+
                |   | v0         |
                |   +------------+
                |   | s7         |
                |   +------------+
                |   | s6         |
                |   +------------+
                |   | s5         |
                |   +------------+
                |   | s4         |
                |   +------------+
                |   | s3         |
                |   +------------+
                |   | s2         |
                |   +------------+
                |   | s1         |
                |   +------------+
                |   | s0         |
                |   +------------+
                |   | at         |
                |   +------------+
                |   | HI         |
                |   +------------+
                |   | LO         |
                |   +------------+
                V   |            |
                    +------------+
                    |            | <-- SP After Context Save
                    +------------+

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
* Update comment

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoMaintenance: Add readme.txt in each Renesas RX folder to show recommended port (...
NoMaY (a user of Japan.RenesasRulz.com) [Mon, 28 Sep 2020 07:09:49 +0000 (16:09 +0900)]
Maintenance: Add readme.txt in each Renesas RX folder to show recommended port (#152)

* Maintenance: Add readme.txt in each Renesas RX folder to show recomended port
* Update readme.txt in each Renesas RX folder regarding to Notes *1 and *2 (both are RX100 port)

5 years agoMaintenance: Github workflow URL checker (#179)
alfred gedeon [Thu, 24 Sep 2020 19:35:22 +0000 (12:35 -0700)]
Maintenance: Github workflow URL checker (#179)

* Remove non needed spell checks

* FreeRTOS Kernel Spelling Update (#170)

* FreeRTOS Kernel Spelling Update

* Added spell check to kernel repository.
* Fixed small spelling errors in various kernel source files.
* Added documentation for spellcheck.

Note: Only kernel files are checked for spelling, and portable files are ignored.

* Fix exit 0

* Remove spell

* add echo

* Call script from ci

* Fix script location

* Print pwd

* Fix script

* Fix script

* Remove some lines from script

* uncomment lines and fix exit

* use bash instead of sh

* Move url checker to the action directory

* Separate spell and url checkers

* Fix bad merge from master

* Fix yml file error

* Add another step to the url checker

Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com>
5 years agoFix some broken/redirected URL (#172)
alfred gedeon [Mon, 21 Sep 2020 22:49:55 +0000 (15:49 -0700)]
Fix some broken/redirected URL (#172)

* Style: fix some broken/redirect links

* Fix: atmel url

* Fix microchip typo

* Fix url links

* Fix shortcut link

* Comment: fix line wrapping

* Style: fix line wrapping to 80 chars

* Add now microchip beside Atmel

* Fix link in History

* Add Now Microchip before Atmel link

* Comment: add *

5 years agoUpdated wording of ulTaskNotifyTakeIndexed fix (#178) V10.4.1-kernel-only
Cobus van Eeden [Fri, 18 Sep 2020 17:22:09 +0000 (10:22 -0700)]
Updated wording of ulTaskNotifyTakeIndexed fix (#178)

5 years agoUpdate History.txt and fix versioning in asm files (#177)
Cobus van Eeden [Fri, 18 Sep 2020 15:05:13 +0000 (08:05 -0700)]
Update History.txt and fix versioning in asm files (#177)

5 years agoUpdate version number to 10.4.1 (#173)
David Chalco [Thu, 17 Sep 2020 22:25:15 +0000 (15:25 -0700)]
Update version number to 10.4.1 (#173)

5 years agoFix: Rename parameter uxIndexToNotify to uxIndexToWaitOn (#174)
Ravishankar Bhagavandas [Thu, 17 Sep 2020 20:16:39 +0000 (13:16 -0700)]
Fix: Rename parameter uxIndexToNotify to uxIndexToWaitOn (#174)

5 years agoFreeRTOS Kernel Spelling Update (#170)
Carl Lundin [Wed, 16 Sep 2020 18:17:39 +0000 (11:17 -0700)]
FreeRTOS Kernel Spelling Update (#170)

* FreeRTOS Kernel Spelling Update

* Added spell check to kernel repository.
* Fixed small spelling errors in various kernel source files.
* Added documentation for spellcheck.

Note: Only kernel files are checked for spelling, and portable files are ignored.

5 years agoFix broken #warning message in ARM_CMx_MPU/portmacro.h between 10.3.1 and 10.4.0... V10.4.0-kernel-only
NoMaY (a user of Japan.RenesasRulz.com) [Tue, 15 Sep 2020 08:55:55 +0000 (17:55 +0900)]
Fix broken #warning message in ARM_CMx_MPU/portmacro.h between 10.3.1 and 10.4.0 (#171)

5 years agoSets the version number to 10.4.0 in assembly files. The (#166)
RichardBarry [Mon, 14 Sep 2020 16:49:46 +0000 (09:49 -0700)]
Sets the version number to 10.4.0 in assembly files.  The (#166)

assembly files were missed when the other source files had
their version numbers updated.

5 years agoUpdate version number to 10.4.0 (#153)
David Chalco [Fri, 11 Sep 2020 02:49:34 +0000 (19:49 -0700)]
Update version number to 10.4.0 (#153)

5 years agoUpdate History.txt (#160)
yngki [Thu, 10 Sep 2020 22:01:08 +0000 (15:01 -0700)]
Update History.txt (#160)

* Update History.txt

* Update History.txt

Co-authored-by: Cobus van Eeden <35851496+cobusve@users.noreply.github.com>
5 years agoFix: Comment - xTaskIncrementTick loop - to adhere to demo requirement (#162)
alfred gedeon [Thu, 10 Sep 2020 21:36:34 +0000 (14:36 -0700)]
Fix: Comment - xTaskIncrementTick loop - to adhere to demo requirement (#162)

Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
5 years agoRevert "RISC-V: Add RV32E / FPU support for GCC (#140)" (#163)
Joseph Julicher [Thu, 10 Sep 2020 19:46:15 +0000 (12:46 -0700)]
Revert "RISC-V: Add RV32E / FPU support for GCC (#140)" (#163)

This reverts commit 0037a6c574f43937d181d4d47fdc2bdd562bbcc3.

5 years agoAdd url link for Linux Simulator documentation (#161)
Cobus van Eeden [Wed, 9 Sep 2020 21:35:52 +0000 (14:35 -0700)]
Add url link for Linux Simulator documentation (#161)

5 years agoRISC-V: Add RV32E / FPU support for GCC (#140)
Emmanuel Puerto [Wed, 9 Sep 2020 18:06:16 +0000 (20:06 +0200)]
RISC-V: Add RV32E / FPU support for GCC (#140)

* Change vPortSetupTimerInterrupt in order to have 64bits access on rv64

* Support RV32E - RISC-V architecture (GCC)

Signed-off-by: Emmanuel Puerto <emmanuel.puerto@sifive.com>
* Support FPU - RISC-V architecture (GCC)

Signed-off-by: Emmanuel Puerto <emmanuel.puerto@sifive.com>
* Fix interrupt managment and FPU initialization

5 years agoIntroduce Trusted Firmware M support in Kernel on ARM Cortex M33 (#108)
sherryzhang [Wed, 9 Sep 2020 15:15:50 +0000 (23:15 +0800)]
Introduce Trusted Firmware M support in Kernel on ARM Cortex M33 (#108)

This port adds the support that FreeRTOS applications can call the secure
    services in Trusted Firmware M(TF-M) via PSA Platform Security
    Architecture(PSA) API based on Arm Cortex-M33 platform with GCC compiler.

    More information:
    PSA - https://www.arm.com/why-arm/architecture/platform-security-architecture
    TF-M - https://git.trustedfirmware.org/trusted-firmware-m.git/

Change-Id: I2e771b66e8d75927abc2505a187a16250d504db2
Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
5 years agoSynopsys ARC v1 Port: add support to Synopsys ARC v1 series cores (#110)
YuguoWH [Tue, 8 Sep 2020 15:40:17 +0000 (23:40 +0800)]
Synopsys ARC v1 Port: add support to Synopsys ARC v1 series cores (#110)

* Synopsys Port: Adding support to Synopsys ARC v1 series cores
ARC v1 cores include ARC605, ARC610d, and ARC710d

Signed-off-by: Yuguo Zou <yuguo.zou@synopsys.com>
* Synopsys ARC v1 port: run uncrustify to fix code style

Signed-off-by: Yuguo Zou <yuguo.zou@synopsys.com>
* Synopsys port: modify license headers, change copyright only

Signed-off-by: Yuguo Zou <yuguo.zou@synopsys.com>
5 years agoChange the Linux Port to use condition variables instead of Signals (#156)
alfred gedeon [Mon, 7 Sep 2020 16:56:28 +0000 (09:56 -0700)]
Change the Linux Port to use condition variables instead of Signals (#156)

* Posix port with pthread cond instead of signals
* Comment: replace signal with pthread_cond
Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
5 years agoFix compiler warning in config assert() on 64 bit architecture (#158)
RichardBarry [Mon, 7 Sep 2020 05:08:00 +0000 (22:08 -0700)]
Fix compiler warning in config assert() on 64 bit architecture (#158)

* Replace the following code that was used to force an assert:
configASSERT( pxTCB->ulNotifiedValue[ uxIndexToNotify ] == ~0UL );

with:
configASSERT( xTickCount == ( TickType_t ) 0 );

Because the former generates a warning on 64-bit architectures.

5 years agoChange the header file name into lower case so it can work on GNU/Linux for MinGW...
Ming Yue [Fri, 28 Aug 2020 21:59:30 +0000 (14:59 -0700)]
Change the header file name into lower case so it can work on GNU/Linux for MinGW cross-compiling. (#144)

5 years agoRevert "Fix: Add Parenthesis around if-statement in macro (#138)" (#148)
alfred gedeon [Fri, 28 Aug 2020 21:19:31 +0000 (14:19 -0700)]
Revert "Fix: Add Parenthesis around if-statement in macro (#138)" (#148)

This reverts commit 45e97bd246e115ca9ebdd6538939478c6c6e6343.

5 years agoRevert "Fix race condition when tracing is enabled (#95)" (#149)
Ming Yue [Fri, 28 Aug 2020 21:17:29 +0000 (14:17 -0700)]
Revert "Fix race condition when tracing is enabled (#95)" (#149)

This reverts commit 61635d5b8b7ae1e783026f37eb66757509010130.

5 years agoUpdate history.txt (#150)
RichardBarry [Fri, 28 Aug 2020 21:14:29 +0000 (14:14 -0700)]
Update history.txt (#150)

* Update History.txt ready for the 10.4.0 release.

5 years agoUse unsigned constant in pdMS_TO_TICKS(). (#147)
Gary Wicker [Fri, 28 Aug 2020 18:50:31 +0000 (11:50 -0700)]
Use unsigned constant in pdMS_TO_TICKS(). (#147)

5 years agoRevert "Fix inaccurate ticks in windows port (#142)" (#143)
Cobus van Eeden [Thu, 27 Aug 2020 19:06:03 +0000 (12:06 -0700)]
Revert "Fix inaccurate ticks in windows port (#142)" (#143)

This reverts commit d85fd461d9a17811f8d0d8fa11fcebf7fa542ee4.

5 years agoFix inaccurate ticks in windows port (#142)
Cobus van Eeden [Thu, 27 Aug 2020 17:12:51 +0000 (10:12 -0700)]
Fix inaccurate ticks in windows port (#142)

5 years agoRemoving general-inquiry.md to divert people to the forums. (#141)
Cobus van Eeden [Wed, 26 Aug 2020 19:08:39 +0000 (12:08 -0700)]
Removing general-inquiry.md to divert people to the forums. (#141)

5 years agoFix: Add Parenthesis around if-statement in macro (#138)
alfred gedeon [Wed, 26 Aug 2020 17:50:35 +0000 (10:50 -0700)]
Fix: Add Parenthesis around if-statement in macro (#138)

Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
5 years agoUpdate Renesas GCC compiler ports (#135)
Ravishankar Bhagavandas [Mon, 24 Aug 2020 22:32:45 +0000 (15:32 -0700)]
Update Renesas GCC compiler ports (#135)

* Add RX200 GCC compiler

Signed-off-by: Dinh Van Nam <vannam.dinh.xt@renesas.com>
* Update GCC compiler for:
 * RX600v2
 * RX600
 * RX100

Signed-off-by: Dinh Van Nam <vannam.dinh.xt@renesas.com>
* Use configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H flag

* Use configINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H flag RX100, RX200

Co-authored-by: Dinh Van Nam <vannam.dinh.xt@renesas.com>
5 years agoStyle: Add uncrustify guards, fix asm (#136)
alfred gedeon [Mon, 24 Aug 2020 22:32:02 +0000 (15:32 -0700)]
Style: Add uncrustify guards, fix asm (#136)

Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
5 years agoStyle: Make freertos.org = FreeRTOS.org and add https (#134)
alfred gedeon [Fri, 21 Aug 2020 18:30:39 +0000 (11:30 -0700)]
Style: Make freertos.org = FreeRTOS.org and add https (#134)

* Style: make freertos.org = FreeRTOS.org also add https

* Style: Fix freertos into FreeRTOS

* Style: Fix freertos into FreeRTOS

Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
5 years agoFix compiler issues cause by formatting assembly code on ESP32 port (#133)
Carl Lundin [Fri, 21 Aug 2020 17:55:58 +0000 (10:55 -0700)]
Fix compiler issues cause by formatting assembly code on ESP32 port (#133)

5 years agoStyle: Change FreeRTOS websites in comments (#131)
alfred gedeon [Thu, 20 Aug 2020 21:59:28 +0000 (14:59 -0700)]
Style: Change FreeRTOS websites in comments (#131)

* Style: Change FreeRTOS websites in comments

* Style: Change freertos to FreeRTOS in comments

* Style: Remove broken link

Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
5 years agoRevert "Update ESP32 port files (#92)" (#132)
Carl Lundin [Thu, 20 Aug 2020 21:41:44 +0000 (14:41 -0700)]
Revert "Update ESP32 port files (#92)" (#132)

This reverts commit adbfca54200d9665eb6b94da302b5268616072c0.

5 years agofinish up PR67. Also add missing <\pre> tags (#130)
David Chalco [Tue, 18 Aug 2020 23:28:02 +0000 (16:28 -0700)]
finish up PR67. Also add missing <\pre> tags (#130)

5 years agoStackMacros now includes stack_macros (#129)
Joseph Julicher [Tue, 18 Aug 2020 19:30:12 +0000 (12:30 -0700)]
StackMacros now includes stack_macros (#129)

5 years agoMoving the function prototypes to headers (#128)
Joseph Julicher [Tue, 18 Aug 2020 18:29:00 +0000 (11:29 -0700)]
Moving the function prototypes to headers (#128)

* Removing StackMacros.h

* Moving 4 Function Prototypes out of the C files into the headers

* Revert "Removing StackMacros.h"

This reverts commit cdd8307817048c794d038588aa00833b0532401b.

5 years agoStyle: Uncrustify kernel file - remove tab == 4 spaces (#123)
alfred gedeon [Mon, 17 Aug 2020 23:16:11 +0000 (16:16 -0700)]
Style: Uncrustify kernel file - remove tab == 4 spaces (#123)

* Style: uncrystify kernel files and remove tabs

* Style: uncrystify kernel files and remove tabs

Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
5 years agoadded a warning concerning the incomplete testing of the RX700v3_DFPU port (#124)
Joseph Julicher [Mon, 17 Aug 2020 22:33:10 +0000 (15:33 -0700)]
added a warning concerning the incomplete testing of the RX700v3_DFPU port (#124)

5 years agoStyle: Remove tabs and tab == 4 spaces (#120)
alfred gedeon [Mon, 17 Aug 2020 21:50:56 +0000 (14:50 -0700)]
Style: Remove tabs and tab == 4 spaces (#120)

* Style: Remove tabls and tab == 4 spaces

* Style: remove xx accidentally left

* Style: revert uncrustify for untested portable directories

* Style: revert more uncrustify files

* Style: Revert more uncrustified files

* Style: Revert some uncrutified files

* Style: change more files

* Style: remove t tab == 4 spaces

* Style: remove tabs = spaces

* Style: revert changed files

* Style: redo the stuyles

* Style: add uncrustify disable parsing for asm

Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
5 years agoStyle: Revert uncrustify for portable directories (#122)
alfred gedeon [Mon, 17 Aug 2020 17:51:02 +0000 (10:51 -0700)]
Style: Revert uncrustify for portable directories (#122)

* Style: revert uncrustify portable directories

* Style: Uncrustify Some Portable files

Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>
5 years agoAdd Renesas RXv3 port layer supporting RXv3's double precision FPU (#104)
NoMaY (a user of Japan.RenesasRulz.com) [Fri, 14 Aug 2020 18:16:48 +0000 (03:16 +0900)]
Add Renesas RXv3 port layer supporting RXv3's double precision FPU (#104)

5 years agoUse pdTRUE/pdFALSE instead of TRUE/FALSE in xStreamBufferSend(). (#114)
Yuhui Zheng [Wed, 12 Aug 2020 04:44:57 +0000 (21:44 -0700)]
Use pdTRUE/pdFALSE instead of TRUE/FALSE in xStreamBufferSend(). (#114)

5 years agoUpdate stream_buffer.c (#94)
Simon Beaudoin [Mon, 10 Aug 2020 16:55:04 +0000 (12:55 -0400)]
Update stream_buffer.c (#94)

Add necessary checks when sending data to the stream/message buffer in order to avoid a task deadlock when attempting to write a longer stream/message than the underlying buffer can write.

5 years agoFix race condition when tracing is enabled (#95)
Simon Beaudoin [Mon, 10 Aug 2020 16:46:39 +0000 (12:46 -0400)]
Fix race condition when tracing is enabled (#95)

* Update port.c

I discovered a very snicky and tricky race condition scenario when integrating tracealyzer code into our project.

A little background  on CortexR5 : When the IRQ line (comming from the interrupt controller, to which every peripheral IRQ lines connect) of the processor rises and the IRQ Enable bit in the status register of the CPU permits it, the CPU traps into interrupt mode. Several things happen. First, the CPU finishes the instruction it was performing. Second, it places the content of the CPSR register into the SPSR_irq register. And third, the mode of the CPU is changed to IRQ_Mode and /!\ THE IRQ ENABLE BIT IN CPSR_irq IS AUTOMATICALLY CLEARED /!\. The reason is to ensure that upon landing into IRQ code, we find ourselves automatically in a critical section because we cannot be interrupted again because the bit is cleared. The programmer can, if he wants, re-enable IRQs inside IRQ code itself to allow interrupt nesting. But it has to be wanted and meditated.

Now, inside portASM.S, at the end of 'FreeRTOS_IRQ_Handler' assembly function, a call to 'vTaskSwitchContextConst' is made if the variable 'ulPortYieldRequired' was set by someone while executing the interrupt. Before branching to that function, a 'CPSID i' instruction was placed to ensure that interrupts are disabled in case someone re-enabled it. Inside 'vTaskSwitchContext', there is the macro 'traceTASK_SWITCHED_OUT' that gets populated when tracing is enabled.

The bug is right there.. If the macro is populated and inside that macro there is a matching call to 'ulPortSetInterruptMask' and 'vPortClearInterruptMask', a race condition can occure is there is a OS Tick timer interrupt waiting at the interrupt controller's door. Upon calling 'vTaskSwitchContext', the interrupts are not masked in the interrupt controller, the only barrier against the CPU servicing that tick interrupt while already performing the function is that the IRQ Enable bit cleared. 'ulPortSetInterruptMask'
does what's its supposed to do, but doesn't take into account the IRQ Enable bit in CPSR. Wheter or not the bit was cleared, the function sets it at the end. When calling the matching 'vPortClearInterruptMask', the function clears the interrupt mask in the interrupt controller. Because the IRQ Enable bit (that was cleared) has been set no matter what in 'ulPortSetInterruptMask', the CPU services the OS Tick Interrupt right away.

The bug is there : instead of completing the 'vTaskSwitchContext' function, the CPU re-enters the switch context path right after 'traceTASK_SWITCHED_OUT' thus corrupting the CPU state and eventually triggering either an undefined instruction, data or instruction abort.

* Update port.c

Error on my part, this is the right inline asm code to retreive CPSR register

* Update port.c

Forgot an * while writing comment..

5 years agoFix: Two one line fixes, xTaskCheckForTimeOut() and ulTaskGenericNotifyValueClear...
RichardBarry [Sun, 9 Aug 2020 23:18:57 +0000 (16:18 -0700)]
Fix: Two one line fixes, xTaskCheckForTimeOut() and ulTaskGenericNotifyValueClear(). (#82)

ulTaskGenericNotifyValueClear() returned the notification value of the
currently running task, not the target task.  Now it returns the
notification value of the target task.

Some users expected xTaskCheckForTimeOut() to clear the 'last wake time'
value each time a timeout occurred, whereas it only did that in one path.
It now clears the last wake time in all paths that return that a timeout
occurred.

5 years agoAllow application to override TEX,S,C and B bits for Flash and RAM (#113)
Gaurav-Aggarwal-AWS [Sun, 9 Aug 2020 01:37:14 +0000 (18:37 -0700)]
Allow application to override TEX,S,C and B bits for Flash and RAM (#113)

The TEX,  Shareable (S), Cacheable (C) and Bufferable (B) bits define
the memory type, and where necessary the cacheable and shareable
properties of the memory region.

The default values for these bits, as configured in our MPU ports, are
sometimes not suitable for application. One such example is when the MCU
has a cache, the application writer may not want to mark the memory as
shareable to avoid disabling the cache. This change allows the
application writer to override default vales for TEX, S C and B bits for
Flash and RAM in their FreeRTOSConfig.h. The following two new
configurations are introduced:

- configTEX_S_C_B_FLASH
- configTEX_S_C_B_SRAM

If undefined, the default values for the above configurations are
TEX=000, S=1, C=1, B=1. This ensures backward compatibility.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoUpdate to AVR_Mega0 and AVR_Dx GCC ports + addition of their IAR equivalents (#106)
m17336 [Thu, 6 Aug 2020 23:24:05 +0000 (02:24 +0300)]
Update to AVR_Mega0 and AVR_Dx GCC ports + addition of their IAR equivalents (#106)

* Removed TICK_stop() macro from portable/GCC/{AVR_AVRDx, AVR_Mega0}/porthardware.h because it is not used anywhere.

* Updated indentation in portable/GCC/{AVR_AVRDx, AVR_Mega0}/* files.

* Added portable/IAR/{AVR_AVRDx, AVR_Mega0 folders.

5 years agoIAR Embedded Workbench modified behaviour of weak declaration "#pragma weak" in relea...
DavidJurajdaNXP [Fri, 31 Jul 2020 04:00:10 +0000 (06:00 +0200)]
IAR Embedded Workbench modified behaviour of weak declaration "#pragma weak" in release 8.50.5. (#83)

This modification result in build error in case of FreeRTOS CM0 port.
To fix the issue use __weak in function definition instead.

5 years agoUpdate ESP32 port files (#92)
Shubham Kulkarni [Fri, 31 Jul 2020 03:58:51 +0000 (09:28 +0530)]
Update ESP32 port files (#92)

Add changes required to support ESP32-S2

5 years agoChange the xRunningPrivileged check from "!=true" to "==false" (#109)
Gaurav-Aggarwal-AWS [Fri, 31 Jul 2020 02:32:31 +0000 (19:32 -0700)]
Change the xRunningPrivileged check from "!=true" to "==false" (#109)

The expected behaviour of portIS_PRIVILEGED is:
- return 0 if the processor is not running privileged.
- return 1 if the processor is running privileged.

Some TI ports do not return 1 when the processor is running privileged
causing the following check to fail: if( xRunningPrivileged != pdTRUE )

This commit change the check to: if( xRunningPrivileged == pdFALSE ). It
ensures that the check is successful even on the ports which return incorrect
value from portIS_PRIVILEGED when the processor is running privileged.

See https://forums.freertos.org/t/kernel-bug-nested-mpu-wrapper-calls-generate-an-exception/10391

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoUse configSYSTICK_CLOCK_HZ to configure SysTick (#103)
Gaurav-Aggarwal-AWS [Fri, 24 Jul 2020 16:45:42 +0000 (09:45 -0700)]
Use configSYSTICK_CLOCK_HZ to configure SysTick (#103)

configSYSTICK_CLOCK_HZ should be used to configure SysTick to support
the use case when the clock for SysTick timer is scaled from the main
CPU clock.

configSYSTICK_CLOCK_HZ is defined to configCPU_CLOCK_HZ when it is not
defined in FreeRTOSConfig.h.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoAdd support for 16 MPU regions to Cortex-M4 MPU ports (#96)
Gaurav-Aggarwal-AWS [Fri, 24 Jul 2020 14:47:41 +0000 (07:47 -0700)]
Add support for 16 MPU regions to Cortex-M4 MPU ports (#96)

ARMv7-M supports 8 or 16 MPU regions. FreeRTOS Cortex-M4 MPU ports so
far assumed 8 regions. This change adds support for 16 MPU regions. The
hardware with 16 MPU regions must define configTOTAL_MPU_REGIONS to 16
in their FreeRTOSConfig.h.

If left undefined, it defaults to 8 for backward compatibility.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoSpecify where the uncrustify config is (#102)
Carl Lundin [Fri, 24 Jul 2020 00:00:14 +0000 (17:00 -0700)]
Specify where the uncrustify config is (#102)

5 years agoSynopsys ARC update, with updated BSP support (#99)
YuguoWH [Thu, 23 Jul 2020 00:14:09 +0000 (08:14 +0800)]
Synopsys ARC update, with updated BSP support (#99)

Update BSP APIs to latest version
Remove unused macro which could have caused warnings
(Code Style) Manually align some macros

Signed-off-by: Yuguo Zou <yuguo.zou@synopsys.com>
5 years agoAdded GCC port files for AVR Mega0 and AVR Dx. (#101)
m17336 [Tue, 21 Jul 2020 22:11:57 +0000 (01:11 +0300)]
Added GCC port files for AVR Mega0 and AVR Dx. (#101)

5 years agoRmove MPU_pvPortMalloc and MPU_vPortFree from mpu_wrappers.c (#88)
Gaurav-Aggarwal-AWS [Thu, 16 Jul 2020 02:46:35 +0000 (19:46 -0700)]
Rmove MPU_pvPortMalloc and MPU_vPortFree from mpu_wrappers.c (#88)

These definitions were not useful because the corresponding mapping was
removed from mpu_wrappers.h earlier.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoUpdate incorrect port in comments (#87)
Gaurav-Aggarwal-AWS [Thu, 16 Jul 2020 02:44:57 +0000 (19:44 -0700)]
Update incorrect port in comments (#87)

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoUpdate portNVIC_SYSPRI2_REG to portNVIC_SHPR3_REG (#86)
Gaurav-Aggarwal-AWS [Thu, 16 Jul 2020 02:44:45 +0000 (19:44 -0700)]
Update portNVIC_SYSPRI2_REG to portNVIC_SHPR3_REG (#86)

The reason for the change is that the register is called System Handler
Priority Register 3 (SHPR3).

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoPlace privileged symbols correctly (#84)
Gaurav-Aggarwal-AWS [Tue, 14 Jul 2020 23:22:42 +0000 (16:22 -0700)]
Place privileged symbols correctly (#84)

Some of the privileged symbols were not being placed in their respective
sections. This commit addresses those and places them in
privileged_functions or privileged_data section.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoAdd support for privileged heap to ARMV8-M ports (#85)
Gaurav-Aggarwal-AWS [Tue, 14 Jul 2020 23:22:14 +0000 (16:22 -0700)]
Add support for privileged heap to ARMV8-M ports (#85)

If xTaskCreate API is used to create a task, the task's stack is
allocated on heap using pvPortMalloc. This places the task's stack
in the privileged data section, if the heap is placed in the
privileged data section.

We use a separate MPU region to grant a task access to its stack.
If the task's stack is in the privileged data section, this results in
overlapping MPU regions as privileged data section is already protected
using a separate MPU region. ARMv8-M does not allow overlapping MPU
regions and this results in a fault. This commit ensures to not use a
separate MPU region for the task's stack if it lies within the
privileged data section.

Note that if the heap memory is placed in the privileged data section,
the xTaskCreate API cannot be used to create an unprivileged task as
the task's stack will be in the privileged data section and the task
won't have access to it. xTaskCreateRestricted and
xTaskCreateRestrictedStatic API should be used to create unprivileged
tasks.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoStyle: uncrustify kernel files
Alfred Gedeon [Wed, 8 Jul 2020 00:42:07 +0000 (17:42 -0700)]
Style: uncrustify kernel files

5 years agoStyle: uncrustify
Alfred Gedeon [Thu, 2 Jul 2020 05:58:33 +0000 (22:58 -0700)]
Style: uncrustify

5 years agoStyle: uncrustify
Alfred Gedeon [Thu, 2 Jul 2020 05:57:36 +0000 (22:57 -0700)]
Style: uncrustify

5 years agoStyle: uncrustify
Alfred Gedeon [Thu, 2 Jul 2020 05:55:52 +0000 (22:55 -0700)]
Style: uncrustify

5 years agoStyle: uncrusitfy
Alfred Gedeon [Thu, 2 Jul 2020 05:27:40 +0000 (22:27 -0700)]
Style: uncrusitfy

5 years agoStyle: uncrustify kernel files
Alfred Gedeon [Thu, 2 Jul 2020 05:20:44 +0000 (22:20 -0700)]
Style: uncrustify kernel files

5 years agoImprovement to O.F. protections (#75)
David Chalco [Tue, 30 Jun 2020 18:03:30 +0000 (11:03 -0700)]
Improvement to O.F. protections (#75)

* Added protection for xQueueGenericCreate

* prevent eventual invalid state change from int8 overflow

* Append period at end of comment. To be consistent with file.

* check operand, not destination

* parantheses -- to not show assumptive precendence

* Per request, less dependence on stdint by defining and checking against queueINT8_MAX instead

5 years agoUpdate mpu_wrappers with task notification changes (#79)
Gaurav-Aggarwal-AWS [Fri, 26 Jun 2020 16:35:28 +0000 (09:35 -0700)]
Update mpu_wrappers with task notification changes (#79)

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoAdded index to all trace points. (#69)
eriktamlin [Wed, 17 Jun 2020 23:38:06 +0000 (01:38 +0200)]
Added index to all trace points. (#69)

5 years agoFix out of offset errors when LTO is enabled (#71)
Gaurav-Aggarwal-AWS [Wed, 10 Jun 2020 17:03:11 +0000 (10:03 -0700)]
Fix out of offset errors when LTO is enabled (#71)

When Link Time Optimization (LTO) is enabled, some of the LDR
instructions result in out of range access. The reason is that the
default generated literal pool is too far and not within the permissible
range of 4K.

This commit adds LTORG assembly instructions at required places to
ensure that access to literals remain in the permissible range of 4K.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
5 years agoRenamed trace point in prvNotifyQueueSetContainer() so it isn't a d… (#47)
cykro82 [Tue, 2 Jun 2020 17:50:02 +0000 (19:50 +0200)]
Renamed trace point in prvNotifyQueueSetContainer() so it isn't a d… (#47)

* * Renamed trace point in prvNotifyQueueSetContainer() so it isn't a duplicate of the trace point in xQueueGenericSend()

* * Fixed backwards compatibility.

Co-authored-by: Erik Tamlin <erik.tamlin@percepio.com>
5 years agoUpdated History.txt for task notification array change (#65)
RichardBarry [Thu, 28 May 2020 16:55:17 +0000 (09:55 -0700)]
Updated History.txt for task notification array change (#65)

Updated History.txt to note the single task notification per task has been replaced with an array of task notifications per task.

5 years agoupdates FreeRTOS.h to handle new usages of task notify (#64)
syntroniks [Thu, 28 May 2020 15:12:24 +0000 (10:12 -0500)]
updates FreeRTOS.h to handle new usages of task notify (#64)

5 years agoRemoving vPortEndScheduler() implementation, since it's not implemented according...
Yuhui Zheng [Wed, 27 May 2020 21:08:44 +0000 (14:08 -0700)]
Removing vPortEndScheduler() implementation, since it's not implemented according to spec. (#61)

Refer to https://www.freertos.org/a00133.html.
The issue with the implementation is that, if only stop kernel tick the program will keep executing current task.
The desired behavior is to at least return/jump to the next instruction after vTaskStartScheduler().

Signed-off-by: Yuhui Zheng <10982575+yuhui-zheng@users.noreply.github.com>
5 years agoFeature/multiple direct to task notifications (#63)
RichardBarry [Wed, 27 May 2020 19:28:48 +0000 (12:28 -0700)]
Feature/multiple direct to task notifications (#63)

Description
Before this change each task had a single direct to task notification value and state as described here: https://www.FreeRTOS.org/RTOS-task-notifications.html. After this change each task has an array of task notifications, so more than one task notification value and state per task. The new FreeRTOSConfig.h compile time constant configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the array.

Each notification within the array operates independently - a task can only block on one notification within the array at a time and will not be unblocked by a notification sent to any other array index.

Task notifications were introduced as a light weight method for peripheral drivers to pass data and events to tasks without the need for an intermediary object such as a semaphore - for example, to unblock a task from an ISR when the operation of a peripheral completed. That use case only requires a single notification value. Their popularity and resultant expanded use cases have since made the single value a limitation - especially as FreeRTOS stream and message buffers themselves use the notification mechanism. This change resolves that limitation. Stream and message buffers still use the task notification at array index 0, but now application writers can avoid any conflict that might have with their own use of task notifications by using notifications at array indexes other than 0.

The pre-existing task notification API functions work in a backward compatible way by always using the task notification at array index 0. For each such function there is now an equivalent that is postfixed "Indexed" and takes an additional parameter to specify which index within the array it should operate upon. For example, xTaskNotify() is the original that only operates on array index 0. xTaskNotifyIndexed() is the new function that can operate on any array index.

Test Steps
The update is tested using the Win32 demo (PR to be created in the FreeRTOS/FreeRTOS github repo), which has been updated to build and run a new test file FreeRTOS/Demo/Common/Minimal/TaskNotifyArray.c. The tests in that file are in addition to, not a replacement for those in FreeRTOS/Demo/Common/Minimal/TaskNotify.c.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

5 years agoAdding volatile to tasks.c's runtime information to protect against compiler optimiza...
Daniel Glaser [Fri, 22 May 2020 17:26:41 +0000 (19:26 +0200)]
Adding volatile to tasks.c's runtime information to protect against compiler optimization (#62)

As discussed in https://forums.freertos.org/t/make-runtime-stats-working-with-compiler-optimization-enabled/9846 and on lined out on https://blog.the78mole.de/freertos-debugging-on-stm32-cpu-usage/, adding the volatile prevents the run-time stats variable being optimized away when used with compiler optimizations.

5 years agoFix/clear MIE bit in initial RISC-V mstatus register. (#57)
RichardBarry [Sat, 2 May 2020 05:35:42 +0000 (22:35 -0700)]
Fix/clear MIE bit in initial RISC-V mstatus register. (#57)

* fix: CLEAR MIE BIT IN INITIAL RISC-V MSTATUS VALUE
The MIE bit in the RISC-V MSTATUS register is used to globally enable
or disable interrupts.  It is copied into the MPIE bit and cleared
on entry to an interrupt, and then copied back from the MPIE bit on
exit from an interrupt.

When a task is created it is given an initial MSTATUS value that is
derived from the current MSTATUS value with the MPIE bit force to 1,
but the MIE bit is not forced into any state.  This change forces
the MIE bit to 0 (interrupts disabled).

Why:
If a task is created before the scheduler is started the MIE bit
will happen to be 0 (interrupts disabled), which is fine.  If a
task is created after the scheduler has been started the MIE bit
is set (interrupts enabled), causing interrupts to unintentionally
become enabled inside the interrupt in which the task is first
moved to the running state - effectively breaking a critical
section which in turn could cause a crash if enabling interrupts
causes interrupts to nest.  It is only an issue when starting a
newly created task that was created after the scheduler was started.

Related Issues:
https://forums.freertos.org/t/risc-v-port-pxportinitialisestack-issue-about-mstatus-value-onto-the-stack/9622
Co-authored-by: Cobus van Eeden <35851496+cobusve@users.noreply.github.com>
5 years agoFix Linux port Valgrind errors (#56)
alfred gedeon [Tue, 28 Apr 2020 21:42:34 +0000 (14:42 -0700)]
Fix Linux port Valgrind errors (#56)

Fix Valgrind uninitialized variables warning.
Co-authored-by: Alfred Gedeon <gedeonag@amazon.com>