From ecf1ccd25e4641c40a86af7ae70f609a002fba71 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 25 Sep 2019 22:47:40 -0400 Subject: [PATCH 1/8] Add stack_size vars, reduce stack usage --- Firmware/Board/v3/Inc/freertos_vars.h | 2 ++ Firmware/Board/v3/Src/freertos.c | 6 ++++-- Firmware/MotorControl/axis.cpp | 2 +- Firmware/MotorControl/axis.hpp | 1 + Firmware/MotorControl/low_level.cpp | 2 +- Firmware/MotorControl/main.cpp | 11 +++++++++++ Firmware/MotorControl/odrive_main.h | 9 +++++++++ Firmware/communication/communication.cpp | 11 ++++++++++- Firmware/communication/communication.h | 1 + Firmware/communication/interface_can.cpp | 2 +- Firmware/communication/interface_can.hpp | 1 + Firmware/communication/interface_uart.cpp | 3 ++- Firmware/communication/interface_uart.h | 1 + Firmware/communication/interface_usb.cpp | 3 ++- Firmware/communication/interface_usb.h | 1 + 15 files changed, 48 insertions(+), 8 deletions(-) diff --git a/Firmware/Board/v3/Inc/freertos_vars.h b/Firmware/Board/v3/Inc/freertos_vars.h index 6e4c0696..7e86c971 100644 --- a/Firmware/Board/v3/Inc/freertos_vars.h +++ b/Firmware/Board/v3/Inc/freertos_vars.h @@ -11,5 +11,7 @@ extern osSemaphoreId sem_can; extern osThreadId defaultTaskHandle; extern osThreadId usb_irq_thread; +extern const uint32_t stack_size_usb_irq_thread; +extern const uint32_t stack_size_default_task; #endif /* __FREERTOS_H */ \ No newline at end of file diff --git a/Firmware/Board/v3/Src/freertos.c b/Firmware/Board/v3/Src/freertos.c index 5edfd079..42ff9751 100644 --- a/Firmware/Board/v3/Src/freertos.c +++ b/Firmware/Board/v3/Src/freertos.c @@ -89,12 +89,14 @@ osSemaphoreId sem_usb_tx; osSemaphoreId sem_can; osThreadId usb_irq_thread; +const uint32_t stack_size_usb_irq_thread = 1024; // Bytes // Place FreeRTOS heap in core coupled memory for better performance __attribute__((section(".ccmram"))) uint8_t ucHeap[configTOTAL_HEAP_SIZE]; /* USER CODE END Variables */ osThreadId defaultTaskHandle; +const uint32_t stack_size_default_task = 1024; // Bytes /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN FunctionPrototypes */ @@ -150,7 +152,7 @@ void usb_deferred_interrupt_thread(void * ctx) { void init_deferred_interrupts(void) { // Start USB interrupt handler thread - osThreadDef(task_usb_pump, usb_deferred_interrupt_thread, osPriorityAboveNormal, 0, 512); + osThreadDef(task_usb_pump, usb_deferred_interrupt_thread, osPriorityAboveNormal, 0, stack_size_usb_irq_thread / sizeof(StackType_t)); usb_irq_thread = osThreadCreate(osThread(task_usb_pump), NULL); } @@ -206,7 +208,7 @@ void MX_FREERTOS_Init(void) { /* Create the thread(s) */ /* definition and creation of defaultTask */ - osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 256); + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, stack_size_default_task / sizeof(StackType_t)); defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); /* USER CODE BEGIN RTOS_THREADS */ diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index 5f31f0b7..b97cfb98 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -84,7 +84,7 @@ static void run_state_machine_loop_wrapper(void* ctx) { // @brief Starts run_state_machine_loop in a new thread void Axis::start_thread() { - osThreadDef(thread_def, run_state_machine_loop_wrapper, hw_config_.thread_priority, 0, 4 * 512); + osThreadDef(thread_def, run_state_machine_loop_wrapper, hw_config_.thread_priority, 0, stack_size_ / sizeof(StackType_t)); thread_id_ = osThreadCreate(osThread(thread_def), this); thread_id_valid_ = true; } diff --git a/Firmware/MotorControl/axis.hpp b/Firmware/MotorControl/axis.hpp index a52eb858..f9199d8b 100644 --- a/Firmware/MotorControl/axis.hpp +++ b/Firmware/MotorControl/axis.hpp @@ -244,6 +244,7 @@ class Axis { Endstop& max_endstop_; osThreadId thread_id_; + const uint32_t stack_size_ = 1024; // Bytes volatile bool thread_id_valid_ = false; // variables exposed on protocol diff --git a/Firmware/MotorControl/low_level.cpp b/Firmware/MotorControl/low_level.cpp index 23b7c002..866bedc0 100644 --- a/Firmware/MotorControl/low_level.cpp +++ b/Firmware/MotorControl/low_level.cpp @@ -754,7 +754,7 @@ static void analog_polling_thread(void*) { } void start_analog_thread() { - osThreadDef(thread_def, analog_polling_thread, osPriorityLow, 0, 128); + osThreadDef(thread_def, analog_polling_thread, osPriorityLow, 0, 512 / sizeof(StackType_t)); osThreadCreate(osThread(thread_def), NULL); } diff --git a/Firmware/MotorControl/main.cpp b/Firmware/MotorControl/main.cpp index 62d6c47d..43c3e476 100644 --- a/Firmware/MotorControl/main.cpp +++ b/Firmware/MotorControl/main.cpp @@ -195,6 +195,17 @@ void vApplicationIdleHook(void) { system_stats_.min_stack_space_uart = uxTaskGetStackHighWaterMark(uart_thread) * sizeof(StackType_t); system_stats_.min_stack_space_usb_irq = uxTaskGetStackHighWaterMark(usb_irq_thread) * sizeof(StackType_t); system_stats_.min_stack_space_startup = uxTaskGetStackHighWaterMark(defaultTaskHandle) * sizeof(StackType_t); + system_stats_.min_stack_space_can = uxTaskGetStackHighWaterMark(odCAN->thread_id_) * sizeof(StackType_t); + + // Actual usage, in bytes, so we don't have to math + system_stats_.stack_usage_axis0 = axes[0]->stack_size_ - system_stats_.min_stack_space_axis0; + system_stats_.stack_usage_axis1 = axes[1]->stack_size_ - system_stats_.min_stack_space_axis1; + system_stats_.stack_usage_comms = stack_size_comm_thread - system_stats_.min_stack_space_comms; + system_stats_.stack_usage_usb = stack_size_usb_thread - system_stats_.min_stack_space_usb; + system_stats_.stack_usage_uart = stack_size_uart_thread - system_stats_.min_stack_space_uart; + system_stats_.stack_usage_usb_irq = stack_size_usb_irq_thread - system_stats_.min_stack_space_usb_irq; + system_stats_.stack_usage_startup = stack_size_default_task - system_stats_.min_stack_space_startup; + system_stats_.stack_usage_can = odCAN->stack_size_ - system_stats_.min_stack_space_can; } } } diff --git a/Firmware/MotorControl/odrive_main.h b/Firmware/MotorControl/odrive_main.h index 88f4de0c..5b89f8ff 100644 --- a/Firmware/MotorControl/odrive_main.h +++ b/Firmware/MotorControl/odrive_main.h @@ -55,6 +55,15 @@ typedef struct { uint32_t min_stack_space_usb_irq; uint32_t min_stack_space_startup; uint32_t min_stack_space_can; + + uint32_t stack_usage_axis0; + uint32_t stack_usage_axis1; + uint32_t stack_usage_comms; + uint32_t stack_usage_usb; + uint32_t stack_usage_uart; + uint32_t stack_usage_usb_irq; + uint32_t stack_usage_startup; + uint32_t stack_usage_can; } SystemStats_t; extern SystemStats_t system_stats_; diff --git a/Firmware/communication/communication.cpp b/Firmware/communication/communication.cpp index ba494340..8a22508e 100644 --- a/Firmware/communication/communication.cpp +++ b/Firmware/communication/communication.cpp @@ -64,6 +64,7 @@ const uint8_t fw_version_revision = FW_VERSION_REVISION; const uint8_t fw_version_unreleased = FW_VERSION_UNRELEASED; // 0 for official releases, 1 otherwise osThreadId comm_thread; +const uint32_t stack_size_comm_thread = 2048; // Bytes volatile bool endpoint_list_valid = false; static uint32_t test_property = 0; @@ -84,7 +85,7 @@ void init_communication(void) { printf("hi!\r\n"); // Start command handling thread - osThreadDef(task_cmd_parse, communication_task, osPriorityNormal, 0, 8000 /* in 32-bit words */); // TODO: fix stack issues + osThreadDef(task_cmd_parse, communication_task, osPriorityNormal, 0, stack_size_comm_thread / sizeof(StackType_t)); comm_thread = osThreadCreate(osThread(task_cmd_parse), NULL); while (!endpoint_list_valid) @@ -135,6 +136,14 @@ static inline auto make_obj_tree() { make_protocol_ro_property("min_stack_space_can", &system_stats_.min_stack_space_can), make_protocol_ro_property("min_stack_space_usb_irq", &system_stats_.min_stack_space_usb_irq), make_protocol_ro_property("min_stack_space_startup", &system_stats_.min_stack_space_startup), + make_protocol_ro_property("stack_usage_axis0", &system_stats_.stack_usage_axis0), + make_protocol_ro_property("stack_usage_axis1", &system_stats_.stack_usage_axis1), + make_protocol_ro_property("stack_usage_comms", &system_stats_.stack_usage_comms), + make_protocol_ro_property("stack_usage_usb", &system_stats_.stack_usage_usb), + make_protocol_ro_property("stack_usage_uart", &system_stats_.stack_usage_uart), + make_protocol_ro_property("stack_usage_usb_irq", &system_stats_.stack_usage_usb_irq), + make_protocol_ro_property("stack_usage_startup", &system_stats_.stack_usage_startup), + make_protocol_ro_property("stack_usage_can", &system_stats_.stack_usage_can), make_protocol_object("usb", make_protocol_ro_property("rx_cnt", &usb_stats_.rx_cnt), make_protocol_ro_property("tx_cnt", &usb_stats_.tx_cnt), diff --git a/Firmware/communication/communication.h b/Firmware/communication/communication.h index b4bab74b..85519b39 100644 --- a/Firmware/communication/communication.h +++ b/Firmware/communication/communication.h @@ -15,6 +15,7 @@ extern "C" { #include extern osThreadId comm_thread; +extern const uint32_t stack_size_comm_thread; extern const uint8_t hw_version_major; extern const uint8_t hw_version_minor; diff --git a/Firmware/communication/interface_can.cpp b/Firmware/communication/interface_can.cpp index 251dec43..00637597 100644 --- a/Firmware/communication/interface_can.cpp +++ b/Firmware/communication/interface_can.cpp @@ -78,7 +78,7 @@ bool ODriveCAN::start_can_server() { if (status == HAL_OK) status = HAL_CAN_ActivateNotification(handle_, CAN_IT_RX_FIFO0_MSG_PENDING); - osThreadDef(can_server_thread_def, can_server_thread_wrapper, osPriorityNormal, 0, 512); + osThreadDef(can_server_thread_def, can_server_thread_wrapper, osPriorityNormal, 0, stack_size_ / sizeof(StackType_t)); thread_id_ = osThreadCreate(osThread(can_server_thread_def), this); thread_id_valid_ = true; diff --git a/Firmware/communication/interface_can.hpp b/Firmware/communication/interface_can.hpp index dcd06232..7a1e9c9a 100644 --- a/Firmware/communication/interface_can.hpp +++ b/Firmware/communication/interface_can.hpp @@ -54,6 +54,7 @@ class ODriveCAN { // Thread Relevant Data osThreadId thread_id_; + const uint32_t stack_size_ = 1024; // Bytes Error_t error_ = ERROR_NONE; volatile bool thread_id_valid_ = false; diff --git a/Firmware/communication/interface_uart.cpp b/Firmware/communication/interface_uart.cpp index b3141138..dc8a4ce6 100644 --- a/Firmware/communication/interface_uart.cpp +++ b/Firmware/communication/interface_uart.cpp @@ -22,6 +22,7 @@ static uint32_t dma_last_rcv_idx; // static thread_local uint32_t deadline_ms = 0; osThreadId uart_thread; +const uint32_t stack_size_uart_thread = 2048; // Bytes class UART4Sender : public StreamSink { @@ -98,7 +99,7 @@ void start_uart_server() { dma_last_rcv_idx = UART_RX_BUFFER_SIZE - huart4.hdmarx->Instance->NDTR; // Start UART communication thread - osThreadDef(uart_server_thread_def, uart_server_thread, osPriorityNormal, 0, 1024 /* the ascii protocol needs considerable stack space */); + osThreadDef(uart_server_thread_def, uart_server_thread, osPriorityNormal, 0, stack_size_uart_thread / sizeof(StackType_t) /* the ascii protocol needs considerable stack space */); uart_thread = osThreadCreate(osThread(uart_server_thread_def), NULL); } diff --git a/Firmware/communication/interface_uart.h b/Firmware/communication/interface_uart.h index 8ef39ec4..65033a6f 100644 --- a/Firmware/communication/interface_uart.h +++ b/Firmware/communication/interface_uart.h @@ -11,6 +11,7 @@ extern "C" { #include extern osThreadId uart_thread; +extern const uint32_t stack_size_uart_thread; void start_uart_server(void); diff --git a/Firmware/communication/interface_usb.cpp b/Firmware/communication/interface_usb.cpp index 036a8203..7f49c0b5 100644 --- a/Firmware/communication/interface_usb.cpp +++ b/Firmware/communication/interface_usb.cpp @@ -14,6 +14,7 @@ #include osThreadId usb_thread; +const uint32_t stack_size_usb_thread = 2048; // Bytes USBStats_t usb_stats_ = {0}; class USBSender : public PacketSink { @@ -177,6 +178,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, 1024); + osThreadDef(usb_server_thread_def, usb_server_thread, osPriorityNormal, 0, stack_size_usb_thread / sizeof(StackType_t)); usb_thread = osThreadCreate(osThread(usb_server_thread_def), NULL); } diff --git a/Firmware/communication/interface_usb.h b/Firmware/communication/interface_usb.h index 0a5b94ff..c78ecc5d 100644 --- a/Firmware/communication/interface_usb.h +++ b/Firmware/communication/interface_usb.h @@ -12,6 +12,7 @@ extern "C" { #include extern osThreadId usb_thread; +extern const uint32_t stack_size_usb_thread; typedef struct { uint32_t rx_cnt; From e74d626578b0ff7e248196f24a3a41f5198c8522 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 18 Oct 2019 23:55:57 -0400 Subject: [PATCH 2/8] Fix Endstops Homing configuration documentation --- docs/endstops.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/endstops.md b/docs/endstops.md index ca63bd19..0a3be3aa 100644 --- a/docs/endstops.md +++ b/docs/endstops.md @@ -96,9 +96,22 @@ homing_speed | float | 2000.0f ### Performing the Homing Sequence Homing is possible once the ODrive has closed-loop control over the axis. To trigger homing, we must first be in `AXIS_STATE_CLOSED_LOOP_CONTROL`, then call `..controller.home_axis()` This starts the homing sequence, which works as follows: -1. The axis moves towards the `min_endstop` at `homing_speed` -2. The axis presses the `min_endstop` -3. The axis moves away from the `min_endstop` to the home position +1. The axis switches to `INPUT_MODE_VEL_RAMP` +2. The axis ramps up to `homing_speed` in the direction of `min_endstop` +3. The axis presses the `min_endstop` +4. The axis switches to `INPUT_MODE_TRAP_TRAJ` +5. The axis moves to the home position in a controlled manner + +It requires quite a few settings in addition to the endstop settings: + +``` +..controller.config.vel_ramp_rate +..trap_traj.config.vel_limit +..trap_traj.config.accel_limit +..trap_traj.config.decel_limit +``` + +We realize this is a little excessive and we will work towards minimizing the setup, but this works well for smooth and reliable behaviour for now. ### Homing at Startup It is possible to configure the odrive to enter homing immediately after startup. For safety reasons, we require the user to specifically enable closed loop control at startup, even if homing is requested. Thus, to enable homing at startup, the following must be configured: From 0642a69e1a669e986269fd82b1fb15489e27c007 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 24 Oct 2019 16:22:44 +1000 Subject: [PATCH 3/8] AEAT-8800 Adds AEAT-8800 SSI as an encoder using 16bit --- Firmware/MotorControl/encoder.cpp | 12 +++++++++--- Firmware/MotorControl/encoder.hpp | 1 + tools/odrive/enums.py | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Firmware/MotorControl/encoder.cpp b/Firmware/MotorControl/encoder.cpp index 1ede2f47..4c061cc5 100644 --- a/Firmware/MotorControl/encoder.cpp +++ b/Firmware/MotorControl/encoder.cpp @@ -339,7 +339,9 @@ bool Encoder::abs_spi_init() { spi->Init.TIMode = SPI_TIMODE_DISABLE; spi->Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; spi->Init.CRCPolynomial = 10; - + if (config_.mode == MODE_SPI_ABS_AEAT) { + spi->Init.CLKPolarity = SPI_POLARITY_HIGH; + } HAL_SPI_DeInit(spi); HAL_SPI_Init(spi); //stash our configuration @@ -390,7 +392,10 @@ void Encoder::abs_spi_cb() { abs_spi_pos_updated_ = true; } } break; - + case MODE_SPI_ABS_AEAT: { + pos_abs_ = abs_spi_dma_rx_[0]; + abs_spi_pos_updated_ = true; + } break; default: { set_error(ERROR_UNSUPPORTED_ENCODER_MODE); } break; @@ -455,7 +460,8 @@ bool Encoder::update() { } break; case MODE_SPI_ABS_AMS: - case MODE_SPI_ABS_CUI: { + case MODE_SPI_ABS_CUI: + case MODE_SPI_ABS_AEAT: { if (abs_spi_pos_updated_ == false && abs_spi_pos_init_once_) { // Low pass filter the error spi_error_rate_ += current_meas_period * (1.0f - spi_error_rate_); diff --git a/Firmware/MotorControl/encoder.hpp b/Firmware/MotorControl/encoder.hpp index 3e140ca0..76d4fcde 100644 --- a/Firmware/MotorControl/encoder.hpp +++ b/Firmware/MotorControl/encoder.hpp @@ -26,6 +26,7 @@ class Encoder { MODE_SINCOS, MODE_SPI_ABS_CUI = 0x100, MODE_SPI_ABS_AMS = 0x101, + MODE_SPI_ABS_AEAT = 0x102, }; const uint32_t MODE_FLAG_ABS = 0x100; diff --git a/tools/odrive/enums.py b/tools/odrive/enums.py index 08ea6ec0..b9bf4f85 100644 --- a/tools/odrive/enums.py +++ b/tools/odrive/enums.py @@ -84,3 +84,4 @@ ENCODER_MODE_HALL = 0x01 ENCODER_MODE_SINCOS = 0x02 ENCODER_MODE_SPI_ABS_CUI = 0x100 ENCODER_MODE_SPI_ABS_AMS = 0x101 +ENCODER_MODE_SPI_ABS_AEAT = 0x102 From fa0180a6012fb064b88be72cf48e36162edfa8ca Mon Sep 17 00:00:00 2001 From: Paul Guenette Date: Sat, 25 May 2019 21:58:33 +0200 Subject: [PATCH 4/8] Revert "dump_errors() should tell you about unknown errors" This reverts commit 5db152b10385787cb47f8f9dae520e28ccb77dda. --- tools/odrive/utils.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/odrive/utils.py b/tools/odrive/utils.py index 8cbb704a..f5ce0c7f 100755 --- a/tools/odrive/utils.py +++ b/tools/odrive/utils.py @@ -53,12 +53,8 @@ def dump_errors(odrv, clear=False): print(prefix + _VT100Colors['red'] + "Error(s):" + _VT100Colors['default']) errorcodes_tup = [(name, val) for name, val in errorcodes.__dict__.items() if 'ERROR_' in name] for codename, codeval in errorcodes_tup: - if remote_obj.error: - print(" ", end='') - if codeval != 0: - print(codename) - else: - print("UNKNOWN_ERROR!") + if remote_obj.error & codeval != 0: + print(" " + codename) if clear: remote_obj.error = errorcodes.ERROR_NONE else: From 2c9f43c9ff46af72539564e448df1b65b123c939 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 4 Dec 2019 00:09:57 -0500 Subject: [PATCH 5/8] Add safety disarm in the stack overflow hook and increase stack sizes --- Firmware/Board/v3/Src/freertos.c | 4 ++-- Firmware/MotorControl/axis.hpp | 2 +- Firmware/MotorControl/main.cpp | 4 ++++ Firmware/communication/communication.cpp | 2 +- Firmware/communication/interface_uart.cpp | 2 +- Firmware/communication/interface_usb.cpp | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Firmware/Board/v3/Src/freertos.c b/Firmware/Board/v3/Src/freertos.c index 42ff9751..b2d49e55 100644 --- a/Firmware/Board/v3/Src/freertos.c +++ b/Firmware/Board/v3/Src/freertos.c @@ -89,14 +89,14 @@ osSemaphoreId sem_usb_tx; osSemaphoreId sem_can; osThreadId usb_irq_thread; -const uint32_t stack_size_usb_irq_thread = 1024; // Bytes +const uint32_t stack_size_usb_irq_thread = 2048; // Bytes // Place FreeRTOS heap in core coupled memory for better performance __attribute__((section(".ccmram"))) uint8_t ucHeap[configTOTAL_HEAP_SIZE]; /* USER CODE END Variables */ osThreadId defaultTaskHandle; -const uint32_t stack_size_default_task = 1024; // Bytes +const uint32_t stack_size_default_task = 2048; // Bytes /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN FunctionPrototypes */ diff --git a/Firmware/MotorControl/axis.hpp b/Firmware/MotorControl/axis.hpp index f9199d8b..a84e76af 100644 --- a/Firmware/MotorControl/axis.hpp +++ b/Firmware/MotorControl/axis.hpp @@ -244,7 +244,7 @@ class Axis { Endstop& max_endstop_; osThreadId thread_id_; - const uint32_t stack_size_ = 1024; // Bytes + const uint32_t stack_size_ = 2048; // Bytes volatile bool thread_id_valid_ = false; // variables exposed on protocol diff --git a/Firmware/MotorControl/main.cpp b/Firmware/MotorControl/main.cpp index 43c3e476..8650b006 100644 --- a/Firmware/MotorControl/main.cpp +++ b/Firmware/MotorControl/main.cpp @@ -182,6 +182,10 @@ extern "C" int construct_objects(){ extern "C" { int odrive_main(void); void vApplicationStackOverflowHook(xTaskHandle *pxTask, signed portCHAR *pcTaskName) { + for(auto& axis : axes){ + safety_critical_disarm_motor_pwm(axis->motor_); + } + safety_critical_disarm_brake_resistor(); for (;;); // TODO: safe action } void vApplicationIdleHook(void) { diff --git a/Firmware/communication/communication.cpp b/Firmware/communication/communication.cpp index 8a22508e..ac4714db 100644 --- a/Firmware/communication/communication.cpp +++ b/Firmware/communication/communication.cpp @@ -64,7 +64,7 @@ const uint8_t fw_version_revision = FW_VERSION_REVISION; const uint8_t fw_version_unreleased = FW_VERSION_UNRELEASED; // 0 for official releases, 1 otherwise osThreadId comm_thread; -const uint32_t stack_size_comm_thread = 2048; // Bytes +const uint32_t stack_size_comm_thread = 4096; // Bytes volatile bool endpoint_list_valid = false; static uint32_t test_property = 0; diff --git a/Firmware/communication/interface_uart.cpp b/Firmware/communication/interface_uart.cpp index dc8a4ce6..f1bb5e0d 100644 --- a/Firmware/communication/interface_uart.cpp +++ b/Firmware/communication/interface_uart.cpp @@ -22,7 +22,7 @@ static uint32_t dma_last_rcv_idx; // static thread_local uint32_t deadline_ms = 0; osThreadId uart_thread; -const uint32_t stack_size_uart_thread = 2048; // Bytes +const uint32_t stack_size_uart_thread = 4096; // Bytes class UART4Sender : public StreamSink { diff --git a/Firmware/communication/interface_usb.cpp b/Firmware/communication/interface_usb.cpp index 7f49c0b5..c52fe5ca 100644 --- a/Firmware/communication/interface_usb.cpp +++ b/Firmware/communication/interface_usb.cpp @@ -14,7 +14,7 @@ #include osThreadId usb_thread; -const uint32_t stack_size_usb_thread = 2048; // Bytes +const uint32_t stack_size_usb_thread = 4096; // Bytes USBStats_t usb_stats_ = {0}; class USBSender : public PacketSink { From da39c07da6e2016990e322718955eccdfd0f1807 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 4 Dec 2019 00:13:42 -0500 Subject: [PATCH 6/8] Unknown Error if error code is present but not matched in dump_errors --- tools/odrive/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/odrive/utils.py b/tools/odrive/utils.py index f5ce0c7f..2b2901a7 100755 --- a/tools/odrive/utils.py +++ b/tools/odrive/utils.py @@ -50,11 +50,15 @@ def dump_errors(odrv, clear=False): for name, remote_obj, errorcodes in module_decode_map: prefix = ' '*2 + name + ": " if (remote_obj.error != errorcodes.ERROR_NONE): + foundError = False print(prefix + _VT100Colors['red'] + "Error(s):" + _VT100Colors['default']) errorcodes_tup = [(name, val) for name, val in errorcodes.__dict__.items() if 'ERROR_' in name] for codename, codeval in errorcodes_tup: if remote_obj.error & codeval != 0: + foundError = True print(" " + codename) + if not foundError: + print(" " + 'UNKNOWN ERROR!') if clear: remote_obj.error = errorcodes.ERROR_NONE else: From ee9d332fd5cab7bca06b696c8ee35e0dc7aba437 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Fri, 27 Sep 2019 13:00:34 +0200 Subject: [PATCH 7/8] support "unsigned int" type in native protocol This fixes a compile error when using enums with large numerical values. The int type of such enums is unsigned int, which was previously not supported. --- Firmware/fibre/cpp/include/fibre/protocol.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Firmware/fibre/cpp/include/fibre/protocol.hpp b/Firmware/fibre/cpp/include/fibre/protocol.hpp index c1f3cc68..366f46c2 100644 --- a/Firmware/fibre/cpp/include/fibre/protocol.hpp +++ b/Firmware/fibre/cpp/include/fibre/protocol.hpp @@ -398,7 +398,7 @@ bool default_readwrite_endpoint_handler(endpoint_ref_t* value, const uint8_t* in } template -static inline const char* get_default_json_modifier(); +static constexpr inline const char* get_default_json_modifier(); template<> inline constexpr const char* get_default_json_modifier() { @@ -441,6 +441,14 @@ inline constexpr const char* get_default_json_modifier() { return "\"type\":\"uint32\",\"access\":\"rw\""; } template<> +inline constexpr const char* get_default_json_modifier() { + return "\"type\":\"uint32\",\"access\":\"r\""; // TODO: automatically detect size +} +template<> +inline constexpr const char* get_default_json_modifier() { + return "\"type\":\"uint32\",\"access\":\"rw\""; // TODO: automatically detect size +} +template<> inline constexpr const char* get_default_json_modifier() { return "\"type\":\"uint16\",\"access\":\"r\""; } @@ -537,6 +545,11 @@ template<> struct format_traits_t { using type = void; static constexpr const char * fmt = "%lu"; static constexpr const char * fmtp = "%lu"; }; +// TODO: change all overloads to fundamental int type space +template<> struct format_traits_t { using type = void; + static constexpr const char * fmt = "%ud"; + static constexpr const char * fmtp = "%ud"; +}; template<> struct format_traits_t { using type = void; static constexpr const char * fmt = "%hd"; static constexpr const char * fmtp = "%hd"; From 5541df081d1d7a08a1a69d32671924443d457caa Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 22 Dec 2019 16:49:50 -0500 Subject: [PATCH 8/8] Add endstop, estop, and DC Bus over power errors to enums --- tools/odrive/enums.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/odrive/enums.py b/tools/odrive/enums.py index b9bf4f85..310eb7bb 100644 --- a/tools/odrive/enums.py +++ b/tools/odrive/enums.py @@ -29,6 +29,10 @@ class errors: ERROR_CONTROLLER_FAILED = 0x200 ERROR_POS_CTRL_DURING_SENSORLESS = 0x400 ERROR_WATCHDOG_TIMER_EXPIRED = 0x800 + ERROR_MIN_ENDSTOP_PRESSED = 0x1000 + ERROR_MAX_ENDSTOP_PRESSED = 0x2000 + ERROR_ESTOP_REQUESTED = 0x4000 + ERROR_DC_BUS_OVER_POWER = 0x8000 class motor: ERROR_NONE = 0