diff --git a/Firmware/Board/v3/STM32F405RGTx_FLASH.ld b/Firmware/Board/v3/STM32F405RGTx_FLASH.ld index 6a08d185..30acca2c 100644 --- a/Firmware/Board/v3/STM32F405RGTx_FLASH.ld +++ b/Firmware/Board/v3/STM32F405RGTx_FLASH.ld @@ -145,7 +145,7 @@ SECTIONS . = ALIGN(4); _eccmram = .; /* create a global symbol at ccmram end */ - } >CCMRAM AT> FLASH + } >CCMRAM /*AT> FLASH*/ /* Uninitialized data section */ diff --git a/Firmware/Board/v3/Src/main.c b/Firmware/Board/v3/Src/main.c index 32546a48..644799de 100644 --- a/Firmware/Board/v3/Src/main.c +++ b/Firmware/Board/v3/Src/main.c @@ -108,6 +108,14 @@ int main(void) jump_to_builtin_bootloader(); } + /* The bootloader might fail to properly clean up after itself, + so if we're not sure that the system is in a clean state we + just reset it again */ + if(*((unsigned long *)0x2001C000) != 42) { + *((unsigned long *)0x2001C000) = 42; + NVIC_SystemReset(); + } + // This procedure of building a USB serial number should be identical // to the way the STM's built-in USB bootloader does it. This means // that the device will have the same serial number in normal and DFU mode. diff --git a/Firmware/CHANGELOG.md b/Firmware/CHANGELOG.md index 8e46007c..f010930e 100644 --- a/Firmware/CHANGELOG.md +++ b/Firmware/CHANGELOG.md @@ -4,6 +4,7 @@ Please add a note of your changes below this heading if you make a Pull Request. ### Added * **Storing of configuration parameters to Non Volatile Memory** * **USB Bootloader** +* `make erase_config` to erase the configuration with an STLink (the configuration can also be erased from within explore_odrive.py, using `my_odrive.erase_configuration()`) ### Changed * The build is now configured using the `tup.config` file instead of editing source files. Make sure you set your board version correctly. See [here](README.md#configuring-the-build) for details. diff --git a/Firmware/Makefile b/Firmware/Makefile index 0c6316d6..84a28e30 100644 --- a/Firmware/Makefile +++ b/Firmware/Makefile @@ -24,8 +24,12 @@ bmp: all --ex 'attach 1' \ --ex 'load' $(FIRMWARE) +# Erase all configuration from the ODrive +erase_config: + openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c reset\ halt -c flash\ erase_address\ 0x80C0000\ 0x40000 -c reset\ run -c exit + clean: -rm -fR .dep $(BUILD_DIR) -.PHONY: all flash gdb dfu bmp clean +.PHONY: all flash gdb dfu bmp clean erase_config diff --git a/tools/dfuse/DfuDevice.py b/tools/dfuse/DfuDevice.py index 77f40797..9173dcc4 100644 --- a/tools/dfuse/DfuDevice.py +++ b/tools/dfuse/DfuDevice.py @@ -37,7 +37,7 @@ class DfuDevice: self.intf.set_altsetting() def control_msg(self, requestType, request, value, buffer, timeout=None): - return self.dev.ctrl_transfer(requestType, request, value, self.intf.bInterfaceNumber, buffer, timeout=1500) + return self.dev.ctrl_transfer(requestType, request, value, self.intf.bInterfaceNumber, buffer, timeout=timeout) def detach(self, timeout): return self.control_msg(DFU_REQUEST_SEND, DFU_DETACH, timeout, None) @@ -83,12 +83,11 @@ class DfuDevice: status = self.get_status() while (status[1] in states): - timeout = status[2] - if not timeout is None: - timeout = max(timeout, status[2]) + claimed_timeout = status[2] + actual_timeout = int(max(timeout or 0, claimed_timeout)) #print("timeout = %f, claimed = %f" % (timeout, status[2])) #time.sleep(timeout) - status = self.get_status(timeout=timeout) + status = self.get_status(timeout=actual_timeout) return status