Browse Source

Implementation of basic checkpoint functions

Youngbin Kim 2 years ago
parent
commit
16a17362ab

+ 18 - 3
Core/Src/main.c

@@ -115,7 +115,7 @@ const osThreadAttr_t taskEPS_attributes = {
   .stack_size = sizeof(taskEPSBuffer),
   .cb_mem = &taskEPSControlBlock,
   .cb_size = sizeof(taskEPSControlBlock),
-  .priority = (osPriority_t) osPriorityNormal,
+  .priority = (osPriority_t) osPriorityRealtime,
 };
 /* Definitions for taskSnap */
 osThreadId_t taskSnapHandle;
@@ -168,6 +168,7 @@ void taskEPSRunner(void *argument);
 void taskSnapRunner(void *argument);
 void taskAIRunner(void *argument);
 void taskImcTest(void *argument);
+void taskImcTest_2(void *argument);
 
 /* USER CODE BEGIN PFP */
 /* USER CODE END PFP */
@@ -300,6 +301,7 @@ int main(void)
   #if (imcUSE_IMC_KERNEL == 1)
   // taskSnapHandle = imcOsThreadNew(taskSnapRunner, NULL, &taskSnap_attributes);
   taskSnapHandle = imcOsThreadNew(taskImcTest, NULL, &taskSnap_attributes);
+  taskEPSHandle = imcOsThreadNew(taskImcTest_2, NULL, &taskEPS_attributes);
   #else
   // taskSnapHandle = osThreadNew(taskSnapRunner, NULL, &taskSnap_attributes);
   #endif
@@ -1553,15 +1555,28 @@ void taskAIRunner(void *argument)
 void taskImcTest(void *argument) {
   int i = 0;
   while(1) {
-    for(int j=0; j<100000000; j++) {
+    for(int j=0; j<10000000; j++) {
       __asm(" nop");
     }
-    osDelay(1000000);
     printf("i=%d\r\n", i++);
     imcREQUEST_CHECKPOINT();
   }
 }
 
+void taskImcTest_2(void *argument)
+{
+  int i = 0;
+  while (1)
+  {
+    for (int j = 0; j < 5000000; j++)
+    {
+      __asm(" nop");
+    }
+    printf("\tj=%d\r\n", i++);
+    imcREQUEST_CHECKPOINT();
+  }
+}
+
 /**
   * @brief  Period elapsed callback in non blocking mode
   * @note   This function is called  when TIM2 interrupt took place, inside

+ 10 - 2
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/port.c

@@ -34,6 +34,9 @@
 #include "FreeRTOS.h"
 #include "task.h"
 
+/* imc */
+#include "ImC/imc_kernel.h"
+
 /* MPU wrappers includes. */
 #include "mpu_wrappers.h"
 
@@ -877,10 +880,15 @@ uint8_t ucSVCNumber;
 						"	vstmdbeq r0!, {s16-s31}				\n"
 					#endif /* configENABLE_FPU */
 					"										\n");
+
 				/* imc */
 				__asm volatile(
-					"	stmdb r0!, {r4-r11, r14}			\n" /* Save the core registers. */
+					"	mrs r1, psplim									\n" /* r2 = PSPLIM. */
+					"	stmdb r0!, {r4-r11}			\n"				/* Save the core registers. */
+					"	stmdb r0!, {r14}			\n"				/* Save the core registers. */
+					"	stmdb r0!, {r1}			\n"				/* Save the core registers. */
 				);
+
 				__asm volatile(
 					"	str r0, [r2]						\n" /* Save the new top of stack into the first member of the TCB. */
 					"										\n"
@@ -897,7 +905,7 @@ uint8_t ucSVCNumber;
 					"	msr basepri, r0						\n"
 					"	ldmia sp!, {lr}				\n"
 					"	bx lr 					\n"
-					"pxCurrentTCBConst3: .word pxCurrentTCB				\n"
+					"pxCurrentTCBConst3: .word pxCurrentTCB				\n" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY));
 			}
 			break;
 		#endif /* imcUSE_IMC_KERNEL */

+ 3 - 0
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c

@@ -35,6 +35,9 @@
 /* Portasm includes. */
 #include "portasm.h"
 
+/* imc */
+#include "ImC/imc_kernel.h"
+
 /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE is needed to be defined only for the
  * header files. */
 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE

BIN
imc/utils/nvm_reset.elf


+ 4 - 1
imc/utils/program_binary.sh

@@ -1,4 +1,7 @@
 PROJECT_ROOT_DIR="/home/ybkim/workspace/imc/imc_freertos_app_m33"
-BIN_DIR="${PROJECT_ROOT_DIR}/imc_freeRTOS"
+BIN_DIR="${PROJECT_ROOT_DIR}/build/imc_freeRTOS"
+NVM_RESET_DIR="${PROJECT_ROOT_DIR}/imc/utils/nvm_reset.elf"
 OPENOCD_SCRIPT_DIR="${PROJECT_ROOT_DIR}/imc_freertos_app_m33.cfg"
+/home/ybkim/opt/xpack-openocd-0.11.0-4/bin/openocd -f ${OPENOCD_SCRIPT_DIR} -c "program ${NVM_RESET_DIR}" -c reset -c resume -c exit
+sleep 5
 /home/ybkim/opt/xpack-openocd-0.11.0-4/bin/openocd -f ${OPENOCD_SCRIPT_DIR} -c "program ${BIN_DIR}" -c reset -c resume -c exit

+ 3 - 3
imc_freertos_app_m33.cfg

@@ -25,9 +25,9 @@ set CLOCK_FREQ 8000
 # Reset configuration
 # use hardware reset, connect under reset
 # connect_assert_srst needed if low power mode application running (WFI...)
-reset_config srst_only srst_nogate connect_assert_srst
-set CONNECT_UNDER_RESET 1
-set CORE_RESET 0
+# reset_config srst_only srst_nogate connect_assert_srst
+# set CONNECT_UNDER_RESET 1
+# set CORE_RESET 0
 
 # ACCESS PORT NUMBER
 set AP_NUM 0