diff --git a/Firmware/.vscode/c_cpp_properties.json b/Firmware/.vscode/c_cpp_properties.json index b337bc20..de6eb463 100644 --- a/Firmware/.vscode/c_cpp_properties.json +++ b/Firmware/.vscode/c_cpp_properties.json @@ -5,17 +5,17 @@ "includePath": [ "${workspaceRoot}", "${workspaceRoot}/MotorControl", - "${workspaceRoot}/Board/v3.3/Inc", - "${workspaceRoot}/Board/v3.3/Drivers/CMSIS/Include", - "${workspaceRoot}/Board/v3.3/Drivers/CMSIS/Device/ST/STM32F4xx/Include", - "${workspaceRoot}/Board/v3.3/Drivers/DRV8301", - "${workspaceRoot}/Board/v3.3/Drivers/STM32F4xx_HAL_Driver/Inc", - "${workspaceRoot}/Board/v3.3/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy", - "${workspaceRoot}/Board/v3.3/Middlewares/ST/STM32_USB_Device_Library/Core/Inc", - "${workspaceRoot}/Board/v3.3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc", - "${workspaceRoot}/Board/v3.3/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS", - "${workspaceRoot}/Board/v3.3/Middlewares/Third_Party/FreeRTOS/Source/include", - "${workspaceRoot}/Board/v3.3/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F", + "${workspaceRoot}/Drivers/DRV8301", + "${workspaceRoot}/Board/v3/Inc", + "${workspaceRoot}/Board/v3/Drivers/CMSIS/Include", + "${workspaceRoot}/Board/v3/Drivers/CMSIS/Device/ST/STM32F4xx/Include", + "${workspaceRoot}/Board/v3/Drivers/STM32F4xx_HAL_Driver/Inc", + "${workspaceRoot}/Board/v3/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy", + "${workspaceRoot}/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Core/Inc", + "${workspaceRoot}/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc", + "${workspaceRoot}/Board/v3/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS", + "${workspaceRoot}/Board/v3/Middlewares/Third_Party/FreeRTOS/Source/include", + "${workspaceRoot}/Board/v3/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F", "c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/arm-none-eabi/include/c++/6.3.1", "c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/arm-none-eabi/include/c++/6.3.1/arm-none-eabi", "c:/program files (x86)/gnu tools arm embedded/6 2017-q1-update/arm-none-eabi/include/c++/6.3.1/backward", @@ -39,79 +39,82 @@ "limitSymbolsToIncludedHeaders": true } }, - { - "name": "Linux", - "includePath": [ - "${workspaceRoot}", - "${workspaceRoot}/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F", - "${workspaceRoot}/Middlewares/Third_Party/FreeRTOS/Source/include", - "${workspaceRoot}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS", - "${workspaceRoot}/Drivers/DRV8301", - "${workspaceRoot}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc", - "${workspaceRoot}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc", - "${workspaceRoot}/Drivers/STM32F4xx_HAL_Driver/Inc", - "${workspaceRoot}/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy", - "${workspaceRoot}/Drivers/CMSIS/Device/ST/STM32F4xx/Include", - "${workspaceRoot}/Drivers/CMSIS/Include", - "${workspaceRoot}/Inc", - "${workspaceRoot}/MotorControl", - "/usr/lib/gcc/arm-none-eabi/4.9.3/include", - "/usr/lib/arm-none-eabi/include" - ], - "defines": [ + { + "name": "Linux", + "includePath": [ + "${workspaceRoot}", + "${workspaceRoot}/MotorControl", + "${workspaceRoot}/Drivers/DRV8301", + "${workspaceRoot}/Board/v3/Inc", + "${workspaceRoot}/Board/v3/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F", + "${workspaceRoot}/Board/v3/Middlewares/Third_Party/FreeRTOS/Source/include", + "${workspaceRoot}/Board/v3/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS", + "${workspaceRoot}/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Core/Inc", + "${workspaceRoot}/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc", + "${workspaceRoot}/Board/v3/Drivers/STM32F4xx_HAL_Driver/Inc", + "${workspaceRoot}/Board/v3/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy", + "${workspaceRoot}/Board/v3/Drivers/CMSIS/Device/ST/STM32F4xx/Include", + "${workspaceRoot}/Board/v3/Drivers/CMSIS/Include", + "/usr/lib/gcc/arm-none-eabi/4.9.3/include", + "/usr/lib/arm-none-eabi/include" + ], + "defines": [ "STM32F405xx", "USE_HAL_DRIVER", "__weak=\"__attribute__((weak))\"", "__packed=\"__attribute__((__packed__))\"", "__GNUC__" - ], - "intelliSenseMode": "clang-x64", - "browse": { - "path": [ + ], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ "${workspaceRoot}", - "/usr/lib/gcc/arm-none-eabi/4.9.3/include", - "/usr/lib/arm-none-eabi/include" - ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" - } - }, - { - "name": "Mac", - "includePath": [ - "${workspaceRoot}", - "${workspaceRoot}/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F", - "${workspaceRoot}/Middlewares/Third_Party/FreeRTOS/Source/include", - "${workspaceRoot}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS", - "${workspaceRoot}/Drivers/DRV8301", - "${workspaceRoot}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc", - "${workspaceRoot}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc", - "${workspaceRoot}/Drivers/STM32F4xx_HAL_Driver/Inc", - "${workspaceRoot}/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy", - "${workspaceRoot}/Drivers/CMSIS/Device/ST/STM32F4xx/Include", - "${workspaceRoot}/Drivers/CMSIS/Include", - "${workspaceRoot}/Inc", - "${workspaceRoot}/MotorControl", - "/usr/local/Caskroom/gcc-arm-embedded/6-2017-q2-update/gcc-arm-none-eabi-6-2017-q2-update/arm-none-eabi/include", - "/usr/local/Caskroom/gcc-arm-embedded/6-2017-q2-update/gcc-arm-none-eabi-6-2017-q2-update/arm-none-eabi/include/c++/6.3.1", - "/usr/local/Caskroom/gcc-arm-embedded/6-2017-q2-update/gcc-arm-none-eabi-6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/arm-none-eabi", - "/usr/local/Caskroom/gcc-arm-embedded/6-2017-q2-update/gcc-arm-none-eabi-6-2017-q2-update/lib/gcc/arm-none-eabi/6.3.1/include" - ], - "defines": [ + "/usr/lib/gcc/arm-none-eabi/4.9.3/include", + "/usr/lib/arm-none-eabi/include" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + }, + "compilerPath": "arm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -specs=nosys.specs -specs=nano.specs -u _printf_float -u _scanf_float", + "cStandard": "c11", + "cppStandard": "c++14" + }, + { + "name": "Mac", + "includePath": [ + "${workspaceRoot}", + "${workspaceRoot}/MotorControl", + "${workspaceRoot}/Drivers/DRV8301", + "${workspaceRoot}/Board/v3/Inc", + "${workspaceRoot}/Board/v3/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F", + "${workspaceRoot}/Board/v3/Middlewares/Third_Party/FreeRTOS/Source/include", + "${workspaceRoot}/Board/v3/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS", + "${workspaceRoot}/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Core/Inc", + "${workspaceRoot}/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc", + "${workspaceRoot}/Board/v3/Drivers/STM32F4xx_HAL_Driver/Inc", + "${workspaceRoot}/Board/v3/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy", + "${workspaceRoot}/Board/v3/Drivers/CMSIS/Device/ST/STM32F4xx/Include", + "${workspaceRoot}/Board/v3/Drivers/CMSIS/Include", + "/usr/local/Caskroom/gcc-arm-embedded/6-2017-q2-update/gcc-arm-none-eabi-6-2017-q2-update/arm-none-eabi/include", + "/usr/local/Caskroom/gcc-arm-embedded/6-2017-q2-update/gcc-arm-none-eabi-6-2017-q2-update/arm-none-eabi/include/c++/6.3.1", + "/usr/local/Caskroom/gcc-arm-embedded/6-2017-q2-update/gcc-arm-none-eabi-6-2017-q2-update/arm-none-eabi/include/c++/6.3.1/arm-none-eabi", + "/usr/local/Caskroom/gcc-arm-embedded/6-2017-q2-update/gcc-arm-none-eabi-6-2017-q2-update/lib/gcc/arm-none-eabi/6.3.1/include" + ], + "defines": [ "STM32F405xx", "USE_HAL_DRIVER", "__weak=\"__attribute__((weak))\"", "__packed=\"__attribute__((__packed__))\"", "__GNUC__" - ], - "intelliSenseMode": "clang-x64", - "browse": { - "path": [ + ], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ "${workspaceRoot}", "/usr/local/Caskroom/gcc-arm-embedded/" - ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" } } ], diff --git a/Firmware/.vscode/launch.json b/Firmware/.vscode/launch.json index 06d37018..71e7db4c 100644 --- a/Firmware/.vscode/launch.json +++ b/Firmware/.vscode/launch.json @@ -17,5 +17,19 @@ ], "cwd": "${workspaceRoot}" }, + { + // For the Cortex-Debug extension + "type": "cortex-debug", + "servertype": "openocd", + "request": "launch", + "name": "Debug ODrive - FreeRTOS", + "executable": "${workspaceRoot}/build/ODriveFirmware.elf", + "rtos": "FreeRTOS", + "configFiles": [ + "interface/stlink-v2.cfg", + "target/stm32f4x_stlink.cfg", + ], + "cwd": "${workspaceRoot}" + }, ] } \ No newline at end of file diff --git a/Firmware/Board/v3/0001-display-correct-ODrive-version-in-USB-descriptor.patch b/Firmware/Board/v3/0001-display-correct-ODrive-version-in-USB-descriptor.patch index f57298b0..0b031242 100644 --- a/Firmware/Board/v3/0001-display-correct-ODrive-version-in-USB-descriptor.patch +++ b/Firmware/Board/v3/0001-display-correct-ODrive-version-in-USB-descriptor.patch @@ -14,7 +14,7 @@ index 94dc49b..37b4302 100644 @@ -96,7 +96,9 @@ #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "ODrive Robotics" - #define USBD_PID_FS 0x0D33 + #define USBD_PID_FS 0x0D32 -#define USBD_PRODUCT_STRING_FS "ODrive v3.3" +#define USBD_PRODUCT_XSTR(s) USBD_PRODUCT_STR(s) +#define USBD_PRODUCT_STR(s) #s diff --git a/Firmware/Board/v3/Odrive.ioc b/Firmware/Board/v3/Odrive.ioc index aea71bef..583cb7f7 100644 --- a/Firmware/Board/v3/Odrive.ioc +++ b/Firmware/Board/v3/Odrive.ioc @@ -599,7 +599,7 @@ USB_DEVICE.APP_TX_DATA_SIZE-CDC_FS=64 USB_DEVICE.CLASS_NAME_FS=CDC USB_DEVICE.IPParameters=VirtualMode-CDC_FS,VirtualModeFS,CLASS_NAME_FS,MANUFACTURER_STRING-CDC_FS,PRODUCT_STRING_CDC_FS,VID-CDC_FS,PID_CDC_FS,SERIALNUMBER_STRING_CDC_FS,APP_RX_DATA_SIZE-CDC_FS,APP_TX_DATA_SIZE-CDC_FS USB_DEVICE.MANUFACTURER_STRING-CDC_FS=ODrive Robotics -USB_DEVICE.PID_CDC_FS=0x0D33 +USB_DEVICE.PID_CDC_FS=0x0D32 USB_DEVICE.PRODUCT_STRING_CDC_FS=ODrive v3.3 USB_DEVICE.SERIALNUMBER_STRING_CDC_FS=000000000001 USB_DEVICE.VID-CDC_FS=0x1209 diff --git a/Firmware/Board/v3/Src/freertos.c b/Firmware/Board/v3/Src/freertos.c index 9439fd97..f370b539 100644 --- a/Firmware/Board/v3/Src/freertos.c +++ b/Firmware/Board/v3/Src/freertos.c @@ -166,7 +166,7 @@ void StartDefaultTask(void const * argument) thread_cmd_parse = osThreadCreate(osThread(task_cmd_parse), NULL); // Start USB interrupt handler thread - osThreadDef(task_usb_pump, usb_update_thread, osPriorityNormal, 0, 512); + osThreadDef(task_usb_pump, usb_update_thread, osPriorityAboveNormal, 0, 512); thread_usb_pump = osThreadCreate(osThread(task_usb_pump), NULL); //If we get to here, then the default task is done. diff --git a/Firmware/Board/v3/Src/usbd_desc.c b/Firmware/Board/v3/Src/usbd_desc.c index 37b43026..e812a013 100644 --- a/Firmware/Board/v3/Src/usbd_desc.c +++ b/Firmware/Board/v3/Src/usbd_desc.c @@ -95,7 +95,7 @@ #define USBD_VID 0x1209 #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "ODrive Robotics" -#define USBD_PID_FS 0x0D33 +#define USBD_PID_FS 0x0D32 #define USBD_PRODUCT_XSTR(s) USBD_PRODUCT_STR(s) #define USBD_PRODUCT_STR(s) #s #define USBD_PRODUCT_STRING_FS ODrive version HW_VERSION_MAJOR.HW_VERSION_MINOR diff --git a/Firmware/CHANGELOG.md b/Firmware/CHANGELOG.md index 9b9e3486..cb3b5b00 100644 --- a/Firmware/CHANGELOG.md +++ b/Firmware/CHANGELOG.md @@ -2,13 +2,14 @@ Please add a note of your changes below this heading if you make a Pull Request. ### Added - * `make write_otp` command to burn the board version onto the ODrive's one-time programmable memory. If you have an ODrive v3.4 or older, you should run this once for a better firmware update user experience in the future. Run the command without any options for more details. Once set, the board version is exposed through the `board_version_[...]` properties. - * bake Git-derived firmware version into firmware binary. The firmware version is exposed through the `fw_version_[...]` properties. +* `make write_otp` command to burn the board version onto the ODrive's one-time programmable memory. If you have an ODrive v3.4 or older, you can run this once for a better firmware update user experience in the future. Run the command without any options for more details. Once set, the board version is exposed through the `board_version_[...]` properties. +* bake Git-derived firmware version into firmware binary. The firmware version is exposed through the `fw_version_[...]` properties. ### Changed - * The DFU script now verifies the flash after writing - +* The DFU script now verifies the flash after writing +* Set thread priority of USB pump thread above protocol thread ### Fixed +* Enums now transported with correct underlying type on native protocol # Releases diff --git a/Firmware/FreeRTOS-openocd.c b/Firmware/FreeRTOS-openocd.c new file mode 100644 index 00000000..81a3ab77 --- /dev/null +++ b/Firmware/FreeRTOS-openocd.c @@ -0,0 +1,20 @@ +/* + * Since at least FreeRTOS V7.5.3 uxTopUsedPriority is no longer + * present in the kernel, so it has to be supplied by other means for + * OpenOCD's threads awareness. + * + * Add this file to your project, and, if you're using --gc-sections, + * ``--undefined=uxTopUsedPriority'' (or + * ``-Wl,--undefined=uxTopUsedPriority'' when using gcc for final + * linking) to your LDFLAGS; same with all the other symbols you need. + */ + +#include "FreeRTOS.h" + +#ifdef __GNUC__ +#define USED __attribute__((used)) +#else +#define USED +#endif + +const int USED uxTopUsedPriority = configMAX_PRIORITIES - 1; diff --git a/Firmware/MotorControl/commands.cpp b/Firmware/MotorControl/commands.cpp index 296d97e5..c7a8ce95 100644 --- a/Firmware/MotorControl/commands.cpp +++ b/Firmware/MotorControl/commands.cpp @@ -26,6 +26,8 @@ #include #include +#include + #define UART_TX_BUFFER_SIZE 64 /* Private defines -----------------------------------------------------------*/ @@ -152,6 +154,7 @@ const Endpoint endpoints[] = { Endpoint::make_object("config"), Endpoint::make_property("brake_resistance", &brake_resistance), Endpoint::close_tree(), + Endpoint::make_property("user_config_loaded", const_cast(&user_config_loaded)), Endpoint::make_object("axis0"), Endpoint::make_object("config"), Endpoint::make_property("enable_control_at_start", &axis_configs[0].enable_control_at_start), @@ -160,7 +163,7 @@ const Endpoint endpoints[] = { Endpoint::close_tree(), Endpoint::make_object("motor0"), Endpoint::make_object("config"), - Endpoint::make_property("control_mode", reinterpret_cast(&motors[0].control_mode)), + Endpoint::make_property("control_mode", reinterpret_cast*>(&motors[0].control_mode)), Endpoint::make_property("counts_per_step", &motors[0].counts_per_step), Endpoint::make_property("pole_pairs", &motors[0].pole_pairs), Endpoint::make_property("pos_gain", &motors[0].pos_gain), @@ -171,10 +174,10 @@ const Endpoint endpoints[] = { Endpoint::make_property("resistance_calib_max_voltage", &motors[0].resistance_calib_max_voltage), Endpoint::make_property("phase_inductance", &motors[0].phase_inductance), Endpoint::make_property("phase_resistance", &motors[0].phase_resistance), - Endpoint::make_property("motor_type", reinterpret_cast(&motors[0].motor_type)), - Endpoint::make_property("rotor_mode", reinterpret_cast(&motors[0].rotor_mode)), + Endpoint::make_property("motor_type", reinterpret_cast*>(&motors[0].motor_type)), + Endpoint::make_property("rotor_mode", reinterpret_cast*>(&motors[0].rotor_mode)), Endpoint::close_tree(), - Endpoint::make_property("error", reinterpret_cast(&motors[0].error)), + Endpoint::make_property("error", reinterpret_cast*>(&motors[0].error)), Endpoint::make_property("pos_setpoint", &motors[0].pos_setpoint), Endpoint::make_property("vel_setpoint", &motors[0].vel_setpoint), Endpoint::make_property("vel_integrator_current", &motors[0].vel_integrator_current), @@ -202,7 +205,7 @@ const Endpoint endpoints[] = { Endpoint::make_property("Ibus", const_cast(&motors[0].current_control.Ibus)), Endpoint::close_tree(), Endpoint::make_object("gate_driver"), - Endpoint::make_property("drv_fault", reinterpret_cast(&motors[0].drv_fault)), + Endpoint::make_property("drv_fault", reinterpret_cast*>(&motors[0].drv_fault)), Endpoint::make_property("status_reg_1", (&motors[0].gate_driver_regs.Stat_Reg_1_Value)), Endpoint::make_property("status_reg_2", (&motors[0].gate_driver_regs.Stat_Reg_2_Value)), Endpoint::make_property("ctrl_reg_1", (&motors[0].gate_driver_regs.Ctrl_Reg_1_Value)), @@ -260,7 +263,7 @@ const Endpoint endpoints[] = { Endpoint::close_tree(), Endpoint::make_object("motor1"), Endpoint::make_object("config"), - Endpoint::make_property("control_mode", reinterpret_cast(&motors[1].control_mode)), + Endpoint::make_property("control_mode", reinterpret_cast*>(&motors[1].control_mode)), Endpoint::make_property("counts_per_step", &motors[1].counts_per_step), Endpoint::make_property("pole_pairs", &motors[1].pole_pairs), Endpoint::make_property("pos_gain", &motors[1].pos_gain), @@ -271,10 +274,10 @@ const Endpoint endpoints[] = { Endpoint::make_property("resistance_calib_max_voltage", &motors[1].resistance_calib_max_voltage), Endpoint::make_property("phase_inductance", &motors[1].phase_inductance), Endpoint::make_property("phase_resistance", &motors[1].phase_resistance), - Endpoint::make_property("motor_type", reinterpret_cast(&motors[1].motor_type)), - Endpoint::make_property("rotor_mode", reinterpret_cast(&motors[1].rotor_mode)), + Endpoint::make_property("motor_type", reinterpret_cast*>(&motors[1].motor_type)), + Endpoint::make_property("rotor_mode", reinterpret_cast*>(&motors[1].rotor_mode)), Endpoint::close_tree(), - Endpoint::make_property("error", reinterpret_cast(&motors[1].error)), + Endpoint::make_property("error", reinterpret_cast*>(&motors[1].error)), Endpoint::make_property("pos_setpoint", &motors[1].pos_setpoint), Endpoint::make_property("vel_setpoint", &motors[1].vel_setpoint), Endpoint::make_property("vel_integrator_current", &motors[1].vel_integrator_current), @@ -302,7 +305,7 @@ const Endpoint endpoints[] = { Endpoint::make_property("Ibus", const_cast(&motors[1].current_control.Ibus)), Endpoint::close_tree(), Endpoint::make_object("gate_driver"), - Endpoint::make_property("drv_fault", reinterpret_cast(&motors[1].drv_fault)), + Endpoint::make_property("drv_fault", reinterpret_cast*>(&motors[1].drv_fault)), Endpoint::make_property("status_reg_1", (&motors[1].gate_driver_regs.Stat_Reg_1_Value)), Endpoint::make_property("status_reg_2", (&motors[1].gate_driver_regs.Stat_Reg_2_Value)), Endpoint::make_property("ctrl_reg_1", (&motors[1].gate_driver_regs.Ctrl_Reg_1_Value)), diff --git a/Firmware/MotorControl/config.cpp b/Firmware/MotorControl/config.cpp index f860381e..abbb915d 100644 --- a/Firmware/MotorControl/config.cpp +++ b/Firmware/MotorControl/config.cpp @@ -212,6 +212,7 @@ void get_motor_config(const Motor_t* motor, MotorConfig_t* config) { config->encoder_motor_dir = motor->encoder.motor_dir; } +bool user_config_loaded = false; void init_configuration(void) { MotorConfig_t motor_config[2]; @@ -230,11 +231,11 @@ void init_configuration(void) { // Default config coming from flashed Motor_t return; } else { + user_config_loaded = true; //printf("load config successful\r\n"); osDelay(5); + set_motor_config(&motor_config[0], &motors[0]); + set_motor_config(&motor_config[1], &motors[1]); } - - set_motor_config(&motor_config[0], &motors[0]); - set_motor_config(&motor_config[1], &motors[1]); } void save_configuration(void) { diff --git a/Firmware/MotorControl/config.h b/Firmware/MotorControl/config.h index 57fafcca..69191451 100644 --- a/Firmware/MotorControl/config.h +++ b/Firmware/MotorControl/config.h @@ -5,6 +5,7 @@ extern "C" { #endif +extern bool user_config_loaded; void init_configuration(void); void save_configuration(void); void erase_configuration(void); diff --git a/Firmware/README.md b/Firmware/README.md index ad9cbf2c..2d2c32b7 100644 --- a/Firmware/README.md +++ b/Firmware/README.md @@ -110,6 +110,7 @@ If you have multiple ODrives connected, you should specify which one to upgrade. iSerial 3 306A396A3235 ``` * The last column is the serial number you're looking for. You can unplug selected devices to track down the one you want to update. +* If you only get `iSerial 3`, then you can try to substitute `sudo lsusb` in place of `lsusb`. * Run `make dfu SERIAL_NUMBER=385F324D3037`, where `385F324D3037` is the targeted serial number. __Warning:__ Currently it is advised that you only do this to flash @@ -118,7 +119,7 @@ the device during upgrade. Otherwise, if something goes wrong, you need an exter programmer to recover the device. This will be fixed in the future. ### Flashing the firmware (external Programmer) -* **Make sure you have [configured the parameters first](#configuring-parameters)** +* **Make sure you have [configured the build first](#configuring-the-build)** * Connect `GND`, `SWD`, and `SWC` on connector J2 to the programmer. Note: Always plug in `GND` first! * You need to power the board by only **ONE** of the following: VCC(3.3v), 5V, or the main power connection (the DC bus). The USB port (J1) does not power the board. * Run `make flash` in the `Firmware` directory. diff --git a/Firmware/Tupfile.lua b/Firmware/Tupfile.lua index 26b4308e..0b5b263b 100644 --- a/Firmware/Tupfile.lua +++ b/Firmware/Tupfile.lua @@ -85,6 +85,7 @@ LDFLAGS += '-T'..boarddir..'/STM32F405RGTx_FLASH.ld' LDFLAGS += '-L'..boarddir..'/Drivers/CMSIS/Lib' -- lib dir LDFLAGS += '-lc -lm -lnosys -larm_cortexM4lf_math' -- libs LDFLAGS += '-mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -specs=nosys.specs -specs=nano.specs -u _printf_float -u _scanf_float -Wl,--cref -Wl,--gc-sections' +LDFLAGS += '-Wl,--undefined=uxTopUsedPriority' -- common flags for ASM, C and C++ @@ -138,7 +139,8 @@ build{ 'MotorControl/axis.cpp', 'MotorControl/commands.cpp', 'MotorControl/protocol.cpp', - 'MotorControl/config.cpp' + 'MotorControl/config.cpp', + 'FreeRTOS-openocd.c' }, includes={ 'Drivers/DRV8301', diff --git a/Firmware/build.sh b/Firmware/build.sh index 26718282..811a4ab7 100755 --- a/Firmware/build.sh +++ b/Firmware/build.sh @@ -18,6 +18,6 @@ bash -xe ./tup_build.sh # Deploy if ! [ -z ${DEPLOY+x} ]; then mkdir -p deploy - cp build/ODriveFirmware.elf deploy/ODriveFirmware-"$DEPLOY".elf - cp build/ODriveFirmware.hex deploy/ODriveFirmware-"$DEPLOY".hex + cp build/ODriveFirmware.elf deploy/ODriveFirmware_"$DEPLOY".elf + cp build/ODriveFirmware.hex deploy/ODriveFirmware_"$DEPLOY".hex fi diff --git a/Firmware/tup.config.default b/Firmware/tup.config.default index 740e1dde..be0515fc 100644 --- a/Firmware/tup.config.default +++ b/Firmware/tup.config.default @@ -1,6 +1,6 @@ # Copy this file to tup.config and adapt it to your needs # make sure this fits your board -#CONFIG_BOARD_VERSION=v3.3 +#CONFIG_BOARD_VERSION=v3.4-24V CONFIG_USB_PROTOCOL=native CONFIG_UART_PROTOCOL=ascii CONFIG_STEP_DIR=n