From 2f36e68b79ed914b4316cb2427e17df4e38c44bc Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Tue, 29 Jan 2019 22:25:51 -0500 Subject: [PATCH 1/3] double stack space for usb server thread --- Firmware/communication/interface_usb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/communication/interface_usb.cpp b/Firmware/communication/interface_usb.cpp index cd44c907..036a8203 100644 --- a/Firmware/communication/interface_usb.cpp +++ b/Firmware/communication/interface_usb.cpp @@ -177,6 +177,6 @@ void usb_rx_process_packet(uint8_t *buf, uint32_t len, uint8_t endpoint_pair) { void start_usb_server() { // Start USB communication thread - osThreadDef(usb_server_thread_def, usb_server_thread, osPriorityNormal, 0, 512); + osThreadDef(usb_server_thread_def, usb_server_thread, osPriorityNormal, 0, 1024); usb_thread = osThreadCreate(osThread(usb_server_thread_def), NULL); } From add0dd954cda6e93a7268df05a138f90df4b9156 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Tue, 29 Jan 2019 22:28:42 -0500 Subject: [PATCH 2/3] increase comms stack size again --- Firmware/communication/communication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/communication/communication.cpp b/Firmware/communication/communication.cpp index 625a3cf7..aaff052d 100644 --- a/Firmware/communication/communication.cpp +++ b/Firmware/communication/communication.cpp @@ -84,7 +84,7 @@ void init_communication(void) { printf("hi!\r\n"); // Start command handling thread - osThreadDef(task_cmd_parse, communication_task, osPriorityNormal, 0, 6000 /* in 32-bit words */); // TODO: fix stack issues + osThreadDef(task_cmd_parse, communication_task, osPriorityNormal, 0, 8000 /* in 32-bit words */); // TODO: fix stack issues comm_thread = osThreadCreate(osThread(task_cmd_parse), NULL); while (!endpoint_list_valid) From 301d0d807ee29e0886c21a958e8357dc55d3d373 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Tue, 29 Jan 2019 22:31:17 -0500 Subject: [PATCH 3/3] make stack overflows debuggable Now if you break on vApplicationStackOverflowHook in a debugger, you can see which thread overflowed. --- Firmware/MotorControl/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/MotorControl/main.cpp b/Firmware/MotorControl/main.cpp index 4146850c..709381e4 100644 --- a/Firmware/MotorControl/main.cpp +++ b/Firmware/MotorControl/main.cpp @@ -97,7 +97,7 @@ void enter_dfu_mode() { extern "C" { int odrive_main(void); -void vApplicationStackOverflowHook(void) { +void vApplicationStackOverflowHook(xTaskHandle *pxTask, signed portCHAR *pcTaskName) { for (;;); // TODO: safe action } void vApplicationIdleHook(void) {