소스 검색

Fix bugs for CubeIDE

Youngbin Kim 2 년 전
부모
커밋
a99ab5f194

+ 3 - 1
Core/Inc/ImC/imc_kernel.h

@@ -3,6 +3,8 @@
 
 #define imcUSE_IMC_KERNEL 1
 
+#define imcSTM32_CUBE_IDE 1
+
 #define imcMAX_NUM_TASKS 5
 #define imcSTACK_SIZE (1024)
 
@@ -21,4 +23,4 @@ void imcInit();
 
 osThreadId_t imcOsThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
 
-#endif
+#endif

+ 4 - 10
Core/Src/main.c

@@ -107,7 +107,7 @@ SRAM_HandleTypeDef hsram4;
 
 /* Definitions for taskEPS */
 osThreadId_t taskEPSHandle;
-uint32_t taskEPSBuffer[ 256 ];
+uint32_t taskEPSBuffer[ imcSTACK_SIZE ];
 osStaticThreadDef_t taskEPSControlBlock;
 const osThreadAttr_t taskEPS_attributes = {
   .name = "taskEPS",
@@ -119,7 +119,7 @@ const osThreadAttr_t taskEPS_attributes = {
 };
 /* Definitions for taskSnap */
 osThreadId_t taskSnapHandle;
-uint32_t taskSnapBuffer[ 512 ];
+uint32_t taskSnapBuffer[ imcSTACK_SIZE ];
 osStaticThreadDef_t taskSnapControlBlock;
 const osThreadAttr_t taskSnap_attributes = {
   .name = "taskSnap",
@@ -1555,9 +1555,7 @@ void taskAIRunner(void *argument)
 void taskImcTest(void *argument) {
   int i = 0;
   while(1) {
-    for(int j=0; j<10000000; j++) {
-      __asm(" nop");
-    }
+    osDelay(1000);
     printf("i=%d\r\n", i++);
     imcREQUEST_CHECKPOINT();
   }
@@ -1568,12 +1566,8 @@ void taskImcTest_2(void *argument)
   int i = 0;
   while (1)
   {
-    for (int j = 0; j < 5000000; j++)
-    {
-      __asm(" nop");
-    }
+    osDelay(2000);
     printf("\tj=%d\r\n", i++);
-    imcREQUEST_CHECKPOINT();
   }
 }
 

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

@@ -882,6 +882,12 @@ uint8_t ucSVCNumber;
 					"										\n");
 
 				/* imc */
+				#if (imcSTM32_CUBE_IDE == 1)
+				__asm volatile(
+					"	push {r7}	\n"
+					"	ldr r7, [sp, #20]"
+				);
+				#endif
 				__asm volatile(
 					"	mrs r1, psplim									\n" /* r2 = PSPLIM. */
 					"	stmdb r0!, {r4-r11}			\n"				/* Save the core registers. */
@@ -893,6 +899,7 @@ uint8_t ucSVCNumber;
 					"	str r0, [r2]						\n" /* Save the new top of stack into the first member of the TCB. */
 					"										\n"
 					"	stmdb sp!, {lr}				\n"
+					"	push {r0}							\n"
 					"	mov r0, lr				\n"
 					"	mov r1, %0 							\n"
 					"	msr basepri, r1						\n"
@@ -901,11 +908,25 @@ uint8_t ucSVCNumber;
 
 					"	bl xTaskCheckpointCurrentTask		\n"
 
+					"	pop {r0}								\n"
+					"	add r0, #8								\n"
+					"	ldmia r0!, {r4-r11}				\n" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY)
+					);
+
+//				#if (imcSTM32_CUBE_IDE == 1)
+//					__asm volatile(
+////						"	pop {r7}	\n"
+//						"	add sp, #4	\n"
+//					);
+//				#endif
+
+				__asm volatile(
 					"	mov r0, #0							\n"
 					"	msr basepri, r0						\n"
 					"	ldmia sp!, {lr}				\n"
+					"	add sp, #4	\n"
 					"	bx lr 					\n"
-					"pxCurrentTCBConst3: .word pxCurrentTCB				\n" ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY));
+					"pxCurrentTCBConst3: .word pxCurrentTCB				\n" );
 			}
 			break;
 		#endif /* imcUSE_IMC_KERNEL */
@@ -1192,4 +1213,4 @@ BaseType_t xReturn;
 
 	return xReturn;
 }
-/*-----------------------------------------------------------*/
+/*-----------------------------------------------------------*/

+ 2 - 2
Middlewares/Third_Party/FreeRTOS/Source/tasks.c

@@ -5362,7 +5362,7 @@ void vRecoverTask(TCB_t *tcb)
 	memcpy(tcb, &xTcbSnapshots[taskNumber][bufferIndex], sizeof(TCB_t));
 
 	// recover stack
-	memcpy((void *)tcb->pxTopOfStack, (void *)xImcTaskStackBuffers[taskNumber][bufferIndex] + prvUNUSED_STACK_SIZE(tcb), prvUSED_STACK_SIZE(tcb));
+	memcpy((void *)(tcb->pxTopOfStack), (void *)((unsigned int)(xImcTaskStackBuffers[taskNumber][bufferIndex]) + (unsigned int)(prvUNUSED_STACK_SIZE(tcb))), prvUSED_STACK_SIZE(tcb));
 
 	__DMB();
 }
@@ -5383,4 +5383,4 @@ osThreadId_t imcOsThreadNew(osThreadFunc_t func, void *argument, const osThreadA
 	return ((osThreadId_t)ret);
 }
 
-#endif // imcUSE_IMC_KERNEL
+#endif // imcUSE_IMC_KERNEL

+ 83 - 0
imc_freertos_app_m33_reset_nvm.launch

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.cubeprog_external_loaders" value="[]"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_certif_path" value=""/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_check_enable" value="false"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_key_path" value=""/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_permission" value="debug_non_secure_L3"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_live_expr" value="true"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_swv" value="false"/>
+    <intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.formatVersion" value="2"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.ip_address_local" value="localhost"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.enabled" value="false"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.value" value=""/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.loadList" value="{&quot;fItems&quot;:[{&quot;fIsFromMainTab&quot;:true,&quot;fPath&quot;:&quot;/Users/ybkim/workspace/imc/imc_m33/imc/utils/nvm_reset.elf&quot;,&quot;fProjectName&quot;:&quot;imc_freertos_app_m33&quot;,&quot;fPerformBuild&quot;:true,&quot;fDownload&quot;:true,&quot;fLoadSymbols&quot;:true}]}"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.override_start_address_mode" value="default"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.remoteCommand" value="target remote"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startServer" value="true"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.divby0" value="true"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="32000000"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_signal_halt" value="false"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_logging" value="false"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_max_halt_delay" value="false"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="0"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="/Users/ybkim/workspace/imc/imc_m33/Debug/st-link_gdbserver_log.txt"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="false"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
+    <booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
+    <stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="cortex_m0"/>
+    <intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/>
+    <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
+    <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
+    <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
+    <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
+    <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
+    <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
+    <intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
+    <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
+    <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
+    <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
+    <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
+    <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
+    <stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
+    <booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
+    <booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
+    <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
+    <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
+    <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
+    <booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
+    <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
+    <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="/Users/ybkim/workspace/imc/imc_m33/imc/utils/nvm_reset.elf"/>
+    <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="imc_freertos_app_m33"/>
+    <booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
+    <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
+    <booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
+    <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+        <listEntry value="/imc_freertos_app_m33"/>
+    </listAttribute>
+    <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+        <listEntry value="4"/>
+    </listAttribute>
+    <stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;"/>
+    <stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
+</launchConfiguration>