Demo application related:
+ Update the RZ IAR project so it targets the RZ RSK rather than custom hardware.
+ Update the RZ ARM/DS-5 project so it targets the RZ RSK rather than custom hardware.
+ Updated RX64M demos to use the new iodefine.h naming.

Cortex-A9 port related:
+ Update IAR, ARM and GCC Cortex-A9 port layers to include a 'task exit error' function which is called if a task attempts to incorrectly exit its implementing function.
+ Moved the instruction which switches into system mode out of the restore context macro, as it is only needed when starting the first task.

Core kernel files related:
+ Ensure there are no references to the mutexes held count when mutexes are excluded from the build.
diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/.cproject b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/.cproject
index 5b91ada..b4a6fcd 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/.cproject
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/.cproject
@@ -1,7 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>

-<?fileVersion 4.0.0?>

-

-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">

+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">

 	<storageModule moduleId="org.eclipse.cdt.core.settings">

 		<cconfiguration id="com.arm.eclipse.build.config.baremetal.exe.debug.2085733085">

 			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.arm.eclipse.build.config.baremetal.exe.debug.2085733085" moduleId="org.eclipse.cdt.core.settings" name="Debug">

@@ -97,8 +95,10 @@
 	<storageModule moduleId="cdtBuildSystem" version="4.0.0">

 		<project id="FreeRTOS_Demo.com.arm.eclipse.build.project.baremetal.exe.508091358" name="Bare-metal Executable" projectType="com.arm.eclipse.build.project.baremetal.exe"/>

 	</storageModule>

-	<storageModule moduleId="refreshScope" versionNumber="1">

-		<resource resourceType="PROJECT" workspacePath="/FreeRTOS_Demo"/>

+	<storageModule moduleId="refreshScope" versionNumber="2">

+		<configuration configurationName="Debug">

+			<resource resourceType="PROJECT" workspacePath="/FreeRTOS_Demo"/>

+		</configuration>

 	</storageModule>

 	<storageModule moduleId="scannerConfiguration">

 		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>

@@ -110,4 +110,5 @@
 		</scannerConfigBuildInfo>

 	</storageModule>

 	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>

+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>

 </cproject>

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/RTOSDemo.ewd b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/RTOSDemo.ewd
index 81e55ac..a29a4a9 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/RTOSDemo.ewd
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/RTOSDemo.ewd
@@ -45,11 +45,11 @@
         </option>

         <option>

           <name>MemFile</name>

-          <state>$TOOLKIT_DIR$\CONFIG\debugger\Renesas\R7S721000.ddf</state>

+          <state>$TOOLKIT_DIR$\CONFIG\debugger\Renesas\R7S721001.ddf</state>

         </option>

         <option>

           <name>RunToEnable</name>

-          <state>1</state>

+          <state>0</state>

         </option>

         <option>

           <name>RunToName</name>

@@ -89,7 +89,7 @@
         </option>

         <option>

           <name>OCLastSavedByProductVersion</name>

-          <state>7.10.1.6733</state>

+          <state>7.20.2.7418</state>

         </option>

         <option>

           <name>OCDownloadAttachToProgram</name>

@@ -1259,7 +1259,7 @@
         </option>

         <option>

           <name>CCXds100InterfaceList</name>

-          <version>1</version>

+          <version>2</version>

           <state>0</state>

         </option>

         <option>

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/RTOSDemo.ewp b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/RTOSDemo.ewp
index f0b9b6d..17ad6e7 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/RTOSDemo.ewp
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/RTOSDemo.ewp
@@ -87,7 +87,7 @@
         </option>

         <option>

           <name>OGLastSavedByProductVersion</name>

-          <state>7.10.1.6733</state>

+          <state>7.20.2.7418</state>

         </option>

         <option>

           <name>GeneralEnableMisra</name>

@@ -99,7 +99,7 @@
         </option>

         <option>

           <name>OGChipSelectEditMenu</name>

-          <state>R7S721000	Renesas R7S721000</state>

+          <state>R7S721001	Renesas R7S721001</state>

         </option>

         <option>

           <name>GenLowLevelInterface</name>

@@ -163,7 +163,7 @@
       <name>ICCARM</name>

       <archiveVersion>2</archiveVersion>

       <data>

-        <version>30</version>

+        <version>31</version>

         <wantNonLocal>1</wantNonLocal>

         <debug>1</debug>

         <option>

@@ -413,6 +413,10 @@
           <version>0</version>

           <state>0</state>

         </option>

+        <option>

+          <name>CCGuardCalls</name>

+          <state>1</state>

+        </option>

       </data>

     </settings>

     <settings>

@@ -714,11 +718,11 @@
         </option>

         <option>

           <name>IlinkIcfOverride</name>

-          <state>1</state>

+          <state>0</state>

         </option>

         <option>

           <name>IlinkIcfFile</name>

-          <state>$PROJ_DIR$\r7s721000.icf</state>

+          <state>$TOOLKIT_DIR$\config\linker\Renesas\r7s721001.icf</state>

         </option>

         <option>

           <name>IlinkIcfFileSlave</name>

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.dbgdt b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.dbgdt
index e64432a..bc1b042 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.dbgdt
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.dbgdt
@@ -39,7 +39,7 @@
       

       

       

-    <Wnd2>

+    <Wnd3>

         <Tabs>

           <Tab>

             <Identity>TabID-6824-27546</Identity>

@@ -55,7 +55,7 @@
           </Tab>

         <Tab><Identity>TabID-11794-23690</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab></Tabs>

         

-      <SelectedTab>0</SelectedTab></Wnd2><Wnd3>

+      <SelectedTab>0</SelectedTab></Wnd3><Wnd4>

         <Tabs>

           <Tab>

             <Identity>TabID-17573-27549</Identity>

@@ -67,20 +67,20 @@
           </Tab>

         </Tabs>

         

-      <SelectedTab>0</SelectedTab></Wnd3></Windows>

+      <SelectedTab>0</SelectedTab></Wnd4><Wnd5><Tabs><Tab><Identity>TabID-8721-7680</Identity><TabName>Disassembly</TabName><Factory>Disassembly</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd5></Windows>

     <Editor>

       

       

       

       

-    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>122</YPos2><SelStart2>6677</SelStart2><SelEnd2>6677</SelEnd2></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\Full-Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>410</YPos2><SelStart2>19389</SelStart2><SelEnd2>19389</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Common\Minimal\QueueOverwrite.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>178</YPos2><SelStart2>8141</SelStart2><SelEnd2>8141</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>

+    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\Full-Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>64</YPos2><SelStart2>8123</SelStart2><SelEnd2>8123</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\Blinky-Demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>64</YPos2><SelStart2>9979</SelStart2><SelEnd2>9979</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>112</YPos2><SelStart2>6090</SelStart2><SelEnd2>6090</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\cstartup.s</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>132</YPos2><SelStart2>5456</SelStart2><SelEnd2>5456</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\LowLevelInitialise.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>24</YPos2><SelStart2>1341</SelStart2><SelEnd2>1341</SelEnd2></Tab><ActiveTab>4</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\modules\armv7a_cp15_drv.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>727</YPos2><SelStart2>20604</SelStart2><SelEnd2>20604</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>

     <Positions>

       

       

       

       

       

-    <Top><Row0><Sizes><Toolbar-0134b418><key>iaridepm.enu1</key></Toolbar-0134b418></Sizes></Row0><Row1><Sizes><Toolbar-13399d38><key>debuggergui.enu1</key></Toolbar-13399d38></Sizes></Row1></Top><Left><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>716</Bottom><Right>302</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>180952</sizeVertCX><sizeVertCY>731161</sizeVertCY></Rect></Wnd3></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203666</sizeVertCY></Rect></Wnd2></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>

+    <Top><Row0><Sizes><Toolbar-00D172A8><key>iaridepm.enu1</key></Toolbar-00D172A8></Sizes></Row0><Row1><Sizes><Toolbar-12B3ABF8><key>debuggergui.enu1</key></Toolbar-12B3ABF8></Sizes></Row1></Top><Left><Row0><Sizes><Wnd4><Rect><Top>-2</Top><Left>-2</Left><Bottom>718</Bottom><Right>302</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>180952</sizeVertCX><sizeVertCY>731707</sizeVertCY></Rect></Wnd4></Sizes></Row0></Left><Right><Row0><Sizes><Wnd5><Rect><Top>-2</Top><Left>-2</Left><Bottom>718</Bottom><Right>699</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>417262</sizeVertCX><sizeVertCY>731707</sizeVertCY></Rect></Wnd5></Sizes></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203252</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>

   </Desktop>

 </Project>

 

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.dni b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.dni
index 168f8bb..c22cb97 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.dni
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.dni
@@ -14,7 +14,7 @@
 Watch1=_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0

 CStepIntDis=_ 0

 [DebugChecksum]

-Checksum=1422761829

+Checksum=-1045357403

 [Jet]

 JetConnSerialNo=73866

 JetConnFoundProbes=

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.wsdt b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.wsdt
index fb28973..f5a6e5b 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.wsdt
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/IAR/settings/RTOSDemo.wsdt
@@ -64,14 +64,14 @@
       

       

       

-    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>62</YPos2><SelStart2>6677</SelStart2><SelEnd2>6677</SelEnd2></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\Full-Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>410</YPos2><SelStart2>19389</SelStart2><SelEnd2>19389</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\Blinky-Demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>63</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>

+    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\Full-Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>64</YPos2><SelStart2>8123</SelStart2><SelEnd2>8123</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\Blinky-Demo\main_blinky.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>64</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Source\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>112</YPos2><SelStart2>0</SelStart2><SelEnd2>0</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\cstartup.s</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>132</YPos2><SelStart2>5456</SelStart2><SelEnd2>5456</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\LowLevelInitialise.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>14</YPos2><SelStart2>1341</SelStart2><SelEnd2>1341</SelEnd2></Tab><ActiveTab>4</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\modules\armv7a_cp15_drv.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>727</YPos2><SelStart2>20604</SelStart2><SelEnd2>20604</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>

     <Positions>

       

       

       

       

       

-    <Top><Row0><Sizes><Toolbar-013BA3C8><key>iaridepm.enu1</key></Toolbar-013BA3C8></Sizes></Row0></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>692</Bottom><Right>380</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>227381</sizeVertCX><sizeVertCY>706721</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>246</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>248</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>252546</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203666</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>

+    <Top><Row0><Sizes><Toolbar-00D172A8><key>iaridepm.enu1</key></Toolbar-00D172A8></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>693</Bottom><Right>380</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>227381</sizeVertCX><sizeVertCY>706301</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>247</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>249</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>253049</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203252</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>

   </Desktop>

 </Workspace>

 

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/LEDs.c b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/LEDs.c
index 9fdaf7f..c284125 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/LEDs.c
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/LEDs.c
@@ -1,5 +1,5 @@
 /*

-    FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd. 

+    FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd.

     All rights reserved

 

     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.

@@ -64,7 +64,7 @@
 */

 

 /*-----------------------------------------------------------

- * Simple IO routines to control the LEDs.

+ * Simple IO routines to control an LED.

  *-----------------------------------------------------------*/

 

 /* Scheduler includes. */

@@ -81,17 +81,24 @@
 

 void vParTestInitialise( void )

 {

-	/* Initialise P4_10 for LED1. */

-	PORT4.PMCn.BIT.PMCn10 = 0;

-	PORT4.Pn.BIT.Pn10 = 1;

-	PORT4.PMn.BIT.PMn10 = 0;

-	PORT4.PIPCn.BIT.PIPCn10 = 0;

+	/* Initialise P7_01 for LED0. */

+	PORT7.PMCn.BIT.PMCn1 = 0;

+	PORT7.Pn.BIT.Pn1 = 1;

+	PORT7.PMn.BIT.PMn1 = 0;

+	PORT7.PIPCn.BIT.PIPCn1 = 0;

+}

+/*-----------------------------------------------------------*/

 

-	/* Initialise P4_11 for LED2. */

-	PORT4.PMCn.BIT.PMCn11 = 0;

-	PORT4.Pn.BIT.Pn11 = 1;

-	PORT4.PMn.BIT.PMn11 = 0;

-	PORT4.PIPCn.BIT.PIPCn11 = 0;

+void vParTestToggleLED( unsigned long ulLED )

+{

+	if( ulLED == 0 )

+	{

+		taskENTER_CRITICAL();

+		{

+			PORT7.Pn.BIT.Pn1 = !PORT7.Pn.BIT.Pn1;

+		}

+		taskEXIT_CRITICAL();

+	}

 }

 /*-----------------------------------------------------------*/

 

@@ -100,37 +107,13 @@
 	/* A high value turns the LED off. */

 	xValue = !xValue;

 

-	taskENTER_CRITICAL();

+	if( ulLED == 0 )

 	{

-		if( ulLED == 0 )

+		taskENTER_CRITICAL();

 		{

-			PORT4.Pn.BIT.Pn10 = xValue;

+			PORT7.Pn.BIT.Pn1 = xValue;

 		}

-

-		if( ulLED == 1 )

-		{

-			PORT4.Pn.BIT.Pn11 = xValue;

-		}

+		taskEXIT_CRITICAL();

 	}

-	taskEXIT_CRITICAL();

 }

 /*-----------------------------------------------------------*/

-

-void vParTestToggleLED( unsigned long ulLED )

-{

-	taskENTER_CRITICAL();

-	{

-		if( ulLED == 0 )

-		{

-			PORT4.Pn.BIT.Pn10 = !PORT4.Pn.BIT.Pn10;

-		}

-

-		if( ulLED == 1 )

-		{

-			PORT4.Pn.BIT.Pn11 = !PORT4.Pn.BIT.Pn11;

-		}

-	}

-	taskEXIT_CRITICAL();

-}

-/*-----------------------------------------------------------*/

-

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/vbar_init.s b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/vbar_init.s
index fe7e5e1..7a610b9 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/vbar_init.s
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/RenesasFiles/common/vbar_init.s
@@ -57,6 +57,14 @@
 ;	LDR r0, =||Image$$VECTOR_TABLE$$Base||

 	MCR p15, 0, r0, c12, c0, 0

 

+;===================================================================

+; Set low vectors

+;===================================================================

+

+    MRC  p15, 0, r0, c1, c0, 0   ;/* Read CP15 System Control register (SCTLR) */

+    BIC  r0, r0, #(0x1 << 13)    ;/* Clear V bit 13 to set Low Vectors  */

+    MCR  p15, 0, r0, c1, c0, 0   ;/* Write CP15 System Control register */

+    ISB

 	BX		lr

 

 	ENDFUNC

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/main.c b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/main.c
index d7136fe..1807a73 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/main.c
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/Source/main.c
@@ -1,5 +1,5 @@
 /*

-    FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd. 

+    FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd.

     All rights reserved

 

     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.

diff --git a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/target_scripts/init_RZ-A1H.ds b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/target_scripts/init_RZ-A1H.ds
index b8c1e51..3300f21 100644
--- a/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/target_scripts/init_RZ-A1H.ds
+++ b/FreeRTOS/Demo/CORTEX_A9_RZ_R7S72100_IAR_DS-5/target_scripts/init_RZ-A1H.ds
@@ -1,11 +1,10 @@
-stop

-pause 500

 reset

 stop

 #reset

 

 info memory

 memory S:0x00000000 S:0x07ffffff ro

+memory S:0x08000000 S:0x0fffffff cache

 memory S:0x3fffff80 S:0x3fffffff nocache noverify

 memory S:0xfcfe0000 S:0xfcfeffff nocache noverify

 

@@ -21,7 +20,8 @@
 

 # ;*Writing to On-Chip Data-Retention RAM is enabled.

 # ;SYSCR3.RRAMWE3=RRAMWE2=RRAMWE1=RRAMWE0=1

-mem set 0xfcfe0408 32 0xf

+memory set S:0xFCFE0408 0 {(unsigned char)0x0F}

+x/1b 0xfcfe0408

 

 ######################################

 # CS0 Port Setting					##

@@ -39,12 +39,6 @@
 mem set 0xfcfe3620 16 0x0000        # PFCE8

 mem set 0xfcfe3520 16 0x0000        # PFC8

 mem set 0xfcfe7220 16 0xffff        # PIPC8

-# P7_6(WE0#), P7_8(RD#), P7_0(CS0#),

-mem set 0xfcfe341c 16 0xff41        # PMC7

-mem set 0xfcfe3A1c 16 0x0000        # PFCAE7

-mem set 0xfcfe361c 16 0x0000        # PFCE7

-mem set 0xfcfe351c 16 0x0000        # PFC7

-mem set 0xfcfe721c 16 0xff41        # PIPC7

 # P3_7(CS1#),

 mem set 0xfcfe340c 16 0x0080        # PMC3

 mem set 0xfcfe3A0c 16 0x0080        # PFCAE3

@@ -52,4 +46,47 @@
 mem set 0xfcfe350c 16 0x0000        # PFC3

 mem set 0xfcfe720c 16 0x0080        # PIPC3

 

+# SRSR - SDRAM Setup?

+# P7_8(RD#), P7_7(WE1#), P7_6(WE0#), P7_5(RD/WR#), P7_4(CKE), P7_3(CAS#), P7_2(RAS#), P7_1(CS3#), P7_0(CS0#)

+mem set 0xfcfe341c 16 0xffff        # PMC7

+mem set 0xfcfe3A1c 16 0x0000        # PFCAE7

+mem set 0xfcfe361c 16 0x0000        # PFCE7

+mem set 0xfcfe351c 16 0x0000        # PFC7

+mem set 0xfcfe721c 16 0xffff        # PIPC7

+# P5_8(CS2#),

+mem set 0xfcfe3414 16 0x0100        # PMC5

+mem set 0xfcfe3A14 16 0x0100        # PFCAE5

+mem set 0xfcfe3614 16 0x0000        # PFCE5

+mem set 0xfcfe3514 16 0x0100        # PFC5

+mem set 0xfcfe7214 16 0x0100        # PIPC5

 

+# disable verify on SDRAM setup registers

+memory S:0x3fffc000 S:0x3fffffff nocache noverify

+

+######################################

+# CS2 SDRAM Setting                 ##

+######################################

+mem set 0x3fffc00c 32 0x00004C00    # CS2BCR - SDRAM

+mem set 0x3fffc030 32 0x00000080    # CS2WCR - SDRAM

+mem set 0x3fffd040 16 0x0000        # SDRAM_MODE_CS2

+

+######################################

+# CS3 SDRAM Setting                 ##

+######################################

+wait 0.5s

+mem set 0x3fffc010 32 0x00004C00    # CS3BCR - SDRAM

+mem set 0x3fffc034 32 0x00002492    # CS3WCR - SDRAM

+mem set 0x3fffc04c 32 0x00120812    # SDCR

+mem set 0x3fffc058 32 0xA55A0020    # RTCOR

+mem set 0x3fffc050 32 0xA55A0010    # RTCSR

+mem set 0x3fffe040 16 0x0000        # SDRAM_MODE_CS3

+# SRSR - SDRAM Setup?

+

+#SRSR - Not used - updated to include SDRAM setup

+# P7_6(WE0#), P7_8(RD#), P7_0(CS0#),

+#mem set 0xfcfe341c 16 0xff41        # PMC7

+#mem set 0xfcfe3A1c 16 0x0000        # PFCAE7

+#mem set 0xfcfe361c 16 0x0000        # PFCE7

+#mem set 0xfcfe351c 16 0x0000        # PFC7

+#mem set 0xfcfe721c 16 0xff41        # PIPC7

+#SRSR - Not used - updated to include SDRAM setup

diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h
index 9bcfed8..48937d2 100644
--- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h
+++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h
@@ -179,6 +179,12 @@
 void vAssertCalled( const char * pcFile, unsigned long ulLine );

 #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ );

 

+/* If configTASK_RETURN_ADDRESS is not defined then a task that attempts to

+return from its implementing function will end up in a "task exit error"

+function - which contains a call to configASSERT().  However this can give GCC

+some problems when it tries to unwind the stack, as the exit error function has

+nothing to return to.  To avoid this define configTASK_RETURN_ADDRESS to 0.  */

+#define configTASK_RETURN_ADDRESS	NULL

 

 

 /****** Hardware specific settings. *******************************************/

diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c
index c09e405..de18fae 100644
--- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c
+++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c
@@ -176,8 +176,6 @@
 

 int main( void )

 {

-extern void main_lwIP( void );

-

 	/* Configure the hardware ready to run the demo. */

 	prvSetupHardware();

 

diff --git a/FreeRTOS/Demo/Common/include/serial.h b/FreeRTOS/Demo/Common/include/serial.h
index 60410d6..9102402 100644
--- a/FreeRTOS/Demo/Common/include/serial.h
+++ b/FreeRTOS/Demo/Common/include/serial.h
@@ -124,12 +124,12 @@
 	ser115200

 } eBaud;

 

-xComPortHandle xSerialPortInitMinimal( uint32_t ulWantedBaud, UBaseType_t uxQueueLength );

-xComPortHandle xSerialPortInit( eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits, UBaseType_t uxBufferLength );

-void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, uint16_t usStringLength );

-BaseType_t xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, TickType_t xBlockTime );

-BaseType_t xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime );

-BaseType_t xSerialWaitForSemaphore( xComPortHandle xPort );

+xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength );

+xComPortHandle xSerialPortInit( eCOMPort ePort, eBaud eWantedBaud, eParity eWantedParity, eDataBits eWantedDataBits, eStopBits eWantedStopBits, unsigned portBASE_TYPE uxBufferLength );

+void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength );

+signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, TickType_t xBlockTime );

+signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime );

+portBASE_TYPE xSerialWaitForSemaphore( xComPortHandle xPort );

 void vSerialClose( xComPortHandle xPort );

 

 #endif

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/.info b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/.info
index 7b730a0..3aef363 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/.info
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/.info
@@ -4,4 +4,4 @@
 GCC_STRING=4.7-GNURX_v14.01
 VERSION_IDE=
 ACTIVE_CONFIGURATION=HardwareDebug
-E2STUDIO_VERSION=3.0.0.22
+E2STUDIO_VERSION=3.0.1.09
diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/.settings/language.settings.xml b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/.settings/language.settings.xml
index 8951044..f655393 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/.settings/language.settings.xml
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/.settings/language.settings.xml
@@ -4,7 +4,7 @@
 		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">

 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>

 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>

-			<provider class="com.renesas.cdt.common.build.spec.RXGCCBuiltinSpecsDetector" console="false" env-hash="-1879026215548195910" id="RXGCCBuiltinSpecsDetector" keep-relative-paths="false" name="Renesas GCCBuildinCompilerSettings" options-hash="1142094570" parameter="rx-elf-gcc -E -P -v -dD ${INPUTS} -mcpu=rx600 -mlittle-endian-data" prefer-non-shared="true">

+			<provider class="com.renesas.cdt.common.build.spec.RXGCCBuiltinSpecsDetector" console="false" env-hash="982537399514949188" id="RXGCCBuiltinSpecsDetector" keep-relative-paths="false" name="Renesas GCCBuildinCompilerSettings" options-hash="1142094570" parameter="rx-elf-gcc -E -P -v -dD ${INPUTS} -mcpu=rx600 -mlittle-endian-data" prefer-non-shared="true">

 				<language-scope id="org.eclipse.cdt.core.gcc"/>

 				<language-scope id="org.eclipse.cdt.core.g++"/>

 			</provider>

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/RTOSDemo HardwareDebug.launch b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/RTOSDemo HardwareDebug.launch
index 9cc6968..0d3da2e 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/RTOSDemo HardwareDebug.launch
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/RTOSDemo HardwareDebug.launch
@@ -17,6 +17,7 @@
 <stringAttribute key="com.renesas.cdt.core.targetDevice" value="R5F564ML"/>

 <booleanAttribute key="com.renesas.cdt.core.useRemoteTarget" value="true"/>

 <booleanAttribute key="com.renesas.cdt.core.verboseMode" value="false"/>

+<stringAttribute key="com.renesas.cdt.debug.ioview.dsf.registerSelection" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;selectedRegisterList ioFilePath=&quot;C:\DevTools\Renesas\e2_studio\internal\IoFiles\RX\RX64M.sfrx&quot;/&gt;&#13;&#10;"/>

 <stringAttribute key="com.renesas.cdt.debug.realtimemanager.memory.mruRanges" value=""/>

 <stringAttribute key="com.renesas.cdt.launch.dsf.IO_MAP" value="${eclipse_home}..\internal\IoFiles\RX\RX64M.sfrx"/>

 <booleanAttribute key="com.renesas.cdt.launch.dsf.USE_DEFAULT_IO_MAP" value="true"/>

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/FreeRTOSConfig.h b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/FreeRTOSConfig.h
index 56fc25d..3979519 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/FreeRTOSConfig.h
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/FreeRTOSConfig.h
@@ -66,9 +66,6 @@
 #ifndef FREERTOS_CONFIG_H

 #define FREERTOS_CONFIG_H

 

-/* Hardware specifics. */

-#include "iodefine.h"

-

 /* Prevent Renesas headers redefining some stdint.h types. */

 #define __TYPEDEF__	1

 

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/IntQueueTimer.c b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/IntQueueTimer.c
index 0d04d67..7e59944 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/IntQueueTimer.c
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/IntQueueTimer.c
@@ -77,6 +77,10 @@
 #include "IntQueueTimer.h"

 #include "IntQueue.h"

 

+/* Hardware specifics. */

+#include "iodefine.h"

+#include "rskrx64mdef.h"

+

 #define IPR_PERIB_INTB128	128

 #define IPR_PERIB_INTB129	129

 #define IER_PERIB_INTB128	0x10

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/ParTest.c b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/ParTest.c
index ee03988..2ea02df 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/ParTest.c
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/ParTest.c
@@ -75,6 +75,7 @@
 #include "partest.h"

 

 /* Hardware specifics. */

+#include "iodefine.h"

 #include "rskrx64mdef.h"

 

 #define partestNUM_LEDS ( 4 )

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/main.c b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/main.c
index 3746b8d..95e8a8d 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/main.c
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio/src/main.c
@@ -91,6 +91,10 @@
 #include "QueueOverwrite.h"

 #include "EventGroupsDemo.h"

 

+/* Hardware specifics. */

+#include "iodefine.h"

+#include "rskrx64mdef.h"

+

 /* Set option bytes */

 #pragma address OFS0_location = 0xFFFFFF8CUL

 #pragma address OFS1_location = 0xFFFFFF88UL

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/.info b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/.info
index b83e1be..ca59635 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/.info
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/.info
@@ -2,5 +2,5 @@
 VERSION=v2.01.00
 TC_INSTALL=C:\Devtools\Renesas\RX\2_1_0\
 VERSION_IDE=
-E2STUDIO_VERSION=3.0.0.22
 ACTIVE_CONFIGURATION=HardwareDebug
+E2STUDIO_VERSION=3.0.1.09
diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/FreeRTOSConfig.h b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/FreeRTOSConfig.h
index 0599b96..3979519 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/FreeRTOSConfig.h
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/FreeRTOSConfig.h
@@ -66,9 +66,6 @@
 #ifndef FREERTOS_CONFIG_H

 #define FREERTOS_CONFIG_H

 

-/* Hardware specifics. */

-#include "r_cg_iodefine.h"

-

 /* Prevent Renesas headers redefining some stdint.h types. */

 #define __TYPEDEF__	1

 

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/RegisterWriteProtect.c b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/RegisterWriteProtect.c
index d87b251..53a4ab2 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/RegisterWriteProtect.c
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/RegisterWriteProtect.c
@@ -5,7 +5,7 @@
  *      Author: WarnerR

  */

 

-#include "r_cg_iodefine.h"

+#include "../iodefine.h"

 #include "stdint.h"

 

 #define	PRC0_BIT	0x0001

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/cg_src/r_cg_macrodriver.h b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/cg_src/r_cg_macrodriver.h
index 19209ff..bf5e930 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/cg_src/r_cg_macrodriver.h
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/cg_src/r_cg_macrodriver.h
@@ -35,7 +35,7 @@
 /***********************************************************************************************************************

 Includes

 ***********************************************************************************************************************/

-#include "r_cg_iodefine.h"

+#include "../iodefine.h"

 #include <machine.h>

 

 /***********************************************************************************************************************

diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/cg_src/r_cg_iodefine.h b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/iodefine.h
similarity index 100%
rename from FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/cg_src/r_cg_iodefine.h
rename to FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/Renesas_Code/iodefine.h
diff --git a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/main.c b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/main.c
index bceae9c..1617e8b 100644
--- a/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/main.c
+++ b/FreeRTOS/Demo/RX600_RX64M_RSK_Renesas_e2studio/Source/main.c
@@ -138,7 +138,7 @@
 void vApplicationTickHook( void );

 

 /*-----------------------------------------------------------*/

-uint32_t ul1, ul2;

+

 int main( void )

 {

 	/* Configure the hardware ready to run the demo. */

diff --git a/FreeRTOS/Source/portable/GCC/ARM_CA9/port.c b/FreeRTOS/Source/portable/GCC/ARM_CA9/port.c
index 91cb2d7..ca3c915 100644
--- a/FreeRTOS/Source/portable/GCC/ARM_CA9/port.c
+++ b/FreeRTOS/Source/portable/GCC/ARM_CA9/port.c
@@ -176,6 +176,15 @@
 #define portMAX_8_BIT_VALUE							( ( uint8_t ) 0xff )

 #define portBIT_0_SET								( ( uint8_t ) 0x01 )

 

+/* Let the user override the pre-loading of the initial LR with the address of

+prvTaskExitError() in case is messes up unwinding of the stack in the

+debugger. */

+#ifdef configTASK_RETURN_ADDRESS

+	#define portTASK_RETURN_ADDRESS	configTASK_RETURN_ADDRESS

+#else

+	#define portTASK_RETURN_ADDRESS	prvTaskExitError

+#endif

+

 /*-----------------------------------------------------------*/

 

 /*

@@ -184,6 +193,11 @@
  */

 extern void vPortRestoreTaskContext( void );

 

+/*

+ * Used to catch tasks that attempt to return from their implementing function.

+ */

+static void prvTaskExitError( void );

+

 /*-----------------------------------------------------------*/

 

 /* A variable is used to keep track of the critical section nesting.  This

@@ -243,7 +257,7 @@
 	pxTopOfStack--;

 

 	/* Next all the registers other than the stack pointer. */

-	*pxTopOfStack = ( StackType_t ) 0x00000000;	/* R14 */

+	*pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS;	/* R14 */

 	pxTopOfStack--;

 	*pxTopOfStack = ( StackType_t ) 0x12121212;	/* R12 */

 	pxTopOfStack--;

@@ -286,6 +300,20 @@
 }

 /*-----------------------------------------------------------*/

 

+static void prvTaskExitError( void )

+{

+	/* A function that implements a task must not exit or attempt to return to

+	its caller as there is nothing to return to.  If a task wants to exit it

+	should instead call vTaskDelete( NULL ).

+

+	Artificially force an assert() to be triggered if configASSERT() is

+	defined, then stop here so application writers can catch the error. */

+	configASSERT( ulPortInterruptNesting == ~0UL );

+	portDISABLE_INTERRUPTS();

+	for( ;; );

+}

+/*-----------------------------------------------------------*/

+

 BaseType_t xPortStartScheduler( void )

 {

 uint32_t ulAPSR;

@@ -380,7 +408,7 @@
 	ulCriticalNesting++;

 

 	/* This is not the interrupt safe version of the enter critical function so

-	assert() if it is being called from an interrupt context.  Only API 

+	assert() if it is being called from an interrupt context.  Only API

 	functions that end in "FromISR" can be used in an interrupt.  Only assert if

 	the critical nesting count is 1 to protect against recursive calls if the

 	assert function also uses a critical section. */

diff --git a/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S b/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S
index a92da08..1d9368e 100644
--- a/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S
+++ b/FreeRTOS/Source/portable/GCC/ARM_CA9/portASM.S
@@ -120,9 +120,6 @@
 

 .macro portRESTORE_CONTEXT

 

-	/* Switch to system mode. */

-	CPS		#SYS_MODE

-

 	/* Set the SP to point to the stack of the task being restored. */

 	LDR		R0, pxCurrentTCBConst

 	LDR		R1, [R0]

@@ -168,7 +165,7 @@
 

 

 /******************************************************************************

- * SVC handler is used to start the scheduler and yield a task.

+ * SVC handler is used to start the scheduler.

  *****************************************************************************/

 .align 4

 .type FreeRTOS_SWI_Handler, %function

@@ -177,9 +174,16 @@
 	portSAVE_CONTEXT

 	LDR R0, vTaskSwitchContextConst

 	BLX	R0

+	portRESTORE_CONTEXT

 

+

+/******************************************************************************

+ * vPortRestoreTaskContext is used to start the scheduler.

+ *****************************************************************************/

 .type vPortRestoreTaskContext, %function

 vPortRestoreTaskContext:

+	/* Switch to system mode. */

+	CPS		#SYS_MODE

 	portRESTORE_CONTEXT

 

 .align 4

diff --git a/FreeRTOS/Source/portable/GCC/RX600v2/port.c b/FreeRTOS/Source/portable/GCC/RX600v2/port.c
index 093ea85..484e211 100644
--- a/FreeRTOS/Source/portable/GCC/RX600v2/port.c
+++ b/FreeRTOS/Source/portable/GCC/RX600v2/port.c
@@ -74,6 +74,9 @@
 /* Library includes. */

 #include "string.h"

 

+/* Hardware specifics. */

+#include "iodefine.h"

+

 /*-----------------------------------------------------------*/

 

 /* Tasks should start with interrupts enabled and in Supervisor mode, therefore

diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA9/port.c b/FreeRTOS/Source/portable/IAR/ARM_CA9/port.c
index 674aab9..796e714 100644
--- a/FreeRTOS/Source/portable/IAR/ARM_CA9/port.c
+++ b/FreeRTOS/Source/portable/IAR/ARM_CA9/port.c
@@ -166,6 +166,11 @@
  */

 extern void vPortRestoreTaskContext( void );

 

+/*

+ * Used to catch tasks that attempt to return from their implementing function.

+ */

+static void prvTaskExitError( void );

+

 /*-----------------------------------------------------------*/

 

 /* A variable is used to keep track of the critical section nesting.  This

@@ -175,8 +180,8 @@
 automatically be set to 0 when the first task is started. */

 volatile uint32_t ulCriticalNesting = 9999UL;

 

-/* Saved as part of the task context.  If ulPortTaskHasFPUContext is non-zero then

-a floating point context must be saved and restored for the task. */

+/* Saved as part of the task context.  If ulPortTaskHasFPUContext is non-zero

+then a floating point context must be saved and restored for the task. */

 uint32_t ulPortTaskHasFPUContext = pdFALSE;

 

 /* Set to 1 to pend a context switch from an ISR. */

@@ -221,7 +226,7 @@
 	pxTopOfStack--;

 

 	/* Next all the registers other than the stack pointer. */

-	*pxTopOfStack = ( StackType_t ) 0x00000000;	/* R14 */

+	*pxTopOfStack = ( StackType_t ) prvTaskExitError;	/* R14 */

 	pxTopOfStack--;

 	*pxTopOfStack = ( StackType_t ) 0x12121212;	/* R12 */

 	pxTopOfStack--;

@@ -264,6 +269,20 @@
 }

 /*-----------------------------------------------------------*/

 

+static void prvTaskExitError( void )

+{

+	/* A function that implements a task must not exit or attempt to return to

+	its caller as there is nothing to return to.  If a task wants to exit it

+	should instead call vTaskDelete( NULL ).

+

+	Artificially force an assert() to be triggered if configASSERT() is

+	defined, then stop here so application writers can catch the error. */

+	configASSERT( ulPortInterruptNesting == ~0UL );

+	portDISABLE_INTERRUPTS();

+	for( ;; );

+}

+/*-----------------------------------------------------------*/

+

 BaseType_t xPortStartScheduler( void )

 {

 uint32_t ulAPSR;

diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.h b/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.h
index 07be9cb..208b547 100644
--- a/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.h
+++ b/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.h
@@ -97,9 +97,6 @@
 

 portRESTORE_CONTEXT macro

 

-	; Switch to system mode

-	CPS		#SYS_MODE

-

 	; Set the SP to point to the stack of the task being restored.

 	LDR		R0, =pxCurrentTCB

 	LDR		R1, [R0]

diff --git a/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.s b/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.s
index 21df2cf..b05c7ed 100644
--- a/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.s
+++ b/FreeRTOS/Source/portable/IAR/ARM_CA9/portASM.s
@@ -75,7 +75,7 @@
 	INCLUDE portASM.h

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-; SVC handler is used to start the scheduler and yield a task.

+; SVC handler is used to yield a task.

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 FreeRTOS_SWI_Handler

 

@@ -85,10 +85,15 @@
 	portSAVE_CONTEXT

 	LDR R0, =vTaskSwitchContext

 	BLX	R0

-

-vPortRestoreTaskContext

 	portRESTORE_CONTEXT

 

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+; vPortRestoreTaskContext is used to start the scheduler.

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+vPortRestoreTaskContext

+	; Switch to system mode

+	CPS		#SYS_MODE

+	portRESTORE_CONTEXT

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ; PL390 GIC interrupt handler

@@ -167,7 +172,7 @@
 	MOVS	PC, LR

 

 switch_before_exit

-	; A context swtich is to be performed.  Clear the context switch pending

+	; A context switch is to be performed.  Clear the context switch pending

 	; flag.

 	MOV		r0, #0

 	STR		r0, [r1]

diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CA9/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CA9/port.c
index 697cf27..1ac64cc 100644
--- a/FreeRTOS/Source/portable/RVDS/ARM_CA9/port.c
+++ b/FreeRTOS/Source/portable/RVDS/ARM_CA9/port.c
@@ -198,6 +198,11 @@
  */

 extern void vPortRestoreTaskContext( void );

 

+/*

+ * Used to catch tasks that attempt to return from their implementing function.

+ */

+static void prvTaskExitError( void );

+

 /*-----------------------------------------------------------*/

 

 /* A variable is used to keep track of the critical section nesting.  This

@@ -260,7 +265,7 @@
 	pxTopOfStack--;

 

 	/* Next all the registers other than the stack pointer. */

-	*pxTopOfStack = ( StackType_t ) 0x00000000;	/* R14 */

+	*pxTopOfStack = ( StackType_t ) prvTaskExitError;	/* R14 */

 	pxTopOfStack--;

 	*pxTopOfStack = ( StackType_t ) 0x12121212;	/* R12 */

 	pxTopOfStack--;

@@ -303,6 +308,20 @@
 }

 /*-----------------------------------------------------------*/

 

+static void prvTaskExitError( void )

+{

+	/* A function that implements a task must not exit or attempt to return to

+	its caller as there is nothing to return to.  If a task wants to exit it

+	should instead call vTaskDelete( NULL ).

+

+	Artificially force an assert() to be triggered if configASSERT() is

+	defined, then stop here so application writers can catch the error. */

+	configASSERT( ulPortInterruptNesting == ~0UL );

+	portDISABLE_INTERRUPTS();

+	for( ;; );

+}

+/*-----------------------------------------------------------*/

+

 BaseType_t xPortStartScheduler( void )

 {

 uint32_t ulAPSR;

@@ -354,6 +373,16 @@
 	directly.  Increment ulCriticalNesting to keep a count of how many times

 	portENTER_CRITICAL() has been called. */

 	ulCriticalNesting++;

+

+	/* This is not the interrupt safe version of the enter critical function so

+	assert() if it is being called from an interrupt context.  Only API

+	functions that end in "FromISR" can be used in an interrupt.  Only assert if

+	the critical nesting count is 1 to protect against recursive calls if the

+	assert function also uses a critical section. */

+	if( ulCriticalNesting == 1 )

+	{

+		configASSERT( ulPortInterruptNesting == 0 );

+	}

 }

 /*-----------------------------------------------------------*/

 

diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portASM.s b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portASM.s
index aefd3e4..4b0c925 100644
--- a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portASM.s
+++ b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portASM.s
@@ -71,7 +71,7 @@
 

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-; SVC handler is used to start the scheduler and yield a task.

+; SVC handler is used to yield a task.

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 FreeRTOS_SWI_Handler

 

@@ -81,10 +81,15 @@
 	portSAVE_CONTEXT

 	LDR R0, =vTaskSwitchContext

 	BLX	R0

-

-vPortRestoreTaskContext

 	portRESTORE_CONTEXT

 

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+; vPortRestoreTaskContext is used to start the scheduler.

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+vPortRestoreTaskContext

+	; Switch to system mode

+	CPS		#SYS_MODE

+	portRESTORE_CONTEXT

 

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ; PL390 GIC interrupt handler

@@ -132,7 +137,7 @@
 	ADD		sp, sp, r2

 

 	CPSID 	i

-	

+

 	; Write the value read from ICCIAR to ICCEOIR

 	LDR 	r4, =ulICCEOIR

 	STR		r0, [r4]

diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.inc b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.inc
index aa6bdb1..798c3e4 100644
--- a/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.inc
+++ b/FreeRTOS/Source/portable/RVDS/ARM_CA9/portmacro.inc
@@ -104,9 +104,6 @@
 	MACRO

 	portRESTORE_CONTEXT

 

-	; Switch to system mode

-	CPS		#SYS_MODE

-

 	; Set the SP to point to the stack of the task being restored.

 	LDR		R0, =pxCurrentTCB

 	LDR		R1, [R0]

diff --git a/FreeRTOS/Source/portable/Renesas/RX600v2/port.c b/FreeRTOS/Source/portable/Renesas/RX600v2/port.c
index 82234c3..16e8a5c 100644
--- a/FreeRTOS/Source/portable/Renesas/RX600v2/port.c
+++ b/FreeRTOS/Source/portable/Renesas/RX600v2/port.c
@@ -74,6 +74,9 @@
 /* Library includes. */

 #include "string.h"

 

+/* Hardware specifics. */

+#include "iodefine.h"

+

 /*-----------------------------------------------------------*/

 

 /* Tasks should start with interrupts enabled and in Supervisor mode, therefore

diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c
index 7f03fa9..28dafd9 100644
--- a/FreeRTOS/Source/tasks.c
+++ b/FreeRTOS/Source/tasks.c
@@ -3586,24 +3586,32 @@
 

 void vTaskIncrementMutexHeldCount( void )

 {

-	/* If xSemaphoreCreateMutex() is called before any tasks have been created

-	then pxCurrentTCB will be NULL. */

-	if( pxCurrentTCB != NULL )

+	#if ( configUSE_MUTEXES == 1 )

 	{

-		( pxCurrentTCB->uxMutexesHeld )++;

+		/* If xSemaphoreCreateMutex() is called before any tasks have been created

+		then pxCurrentTCB will be NULL. */

+		if( pxCurrentTCB != NULL )

+		{

+			( pxCurrentTCB->uxMutexesHeld )++;

+		}

 	}

+	#endif

 }

 /*-----------------------------------------------------------*/

 

 void vTaskDecrementMutexHeldCount( void )

 {

-	/* If xSemaphoreCreateMutex() is called before any tasks have been created

-	then pxCurrentTCB will be NULL. */

-	if( pxCurrentTCB != NULL )

+	#if ( configUSE_MUTEXES == 1 )

 	{

-		configASSERT( pxCurrentTCB->uxMutexesHeld );

-		( pxCurrentTCB->uxMutexesHeld )--;

+		/* If xSemaphoreCreateMutex() is called before any tasks have been created

+		then pxCurrentTCB will be NULL. */

+		if( pxCurrentTCB != NULL )

+		{

+			configASSERT( pxCurrentTCB->uxMutexesHeld );

+			( pxCurrentTCB->uxMutexesHeld )--;

+		}

 	}

+	#endif

 }

 

 #ifdef FREERTOS_MODULE_TEST