diff --git a/ion/src/device/device.cpp b/ion/src/device/device.cpp index 475dec13a..4c5d515cd 100644 --- a/ion/src/device/device.cpp +++ b/ion/src/device/device.cpp @@ -103,7 +103,6 @@ void coreReset() { } void jumpReset() { - shutdown(); uint32_t * stackPointerAddress = reinterpret_cast(0x08000000); uint32_t * resetHandlerAddress = reinterpret_cast(0x08000004); set_msp(*stackPointerAddress); diff --git a/ion/src/device/usb/Makefile b/ion/src/device/usb/Makefile index a26bc2931..72e714f72 100644 --- a/ion/src/device/usb/Makefile +++ b/ion/src/device/usb/Makefile @@ -45,6 +45,7 @@ dfu_objs += ion/src/device/usb/boot.o dfu_objs += ion/src/device/keyboard.o dfu_objs += ion/src/device/device.o dfu_objs += ion/src/device/usb.o +dfu_objs += ion/src/device/set_msp.o ion/src/device/usb/dfu.elf: LDFLAGS = --gc-sections -T ion/src/device/usb/dfu.ld ion/src/device/usb/dfu.elf: $(usb_objs) $(dfu_objs) diff --git a/ion/src/device/usb/calculator.cpp b/ion/src/device/usb/calculator.cpp index 5615112fd..88a6415d6 100644 --- a/ion/src/device/usb/calculator.cpp +++ b/ion/src/device/usb/calculator.cpp @@ -2,12 +2,13 @@ #include "../regs/regs.h" #include "../keyboard.h" #include +#include "../device.h" namespace Ion { namespace USB { namespace Device { -bool Calculator::PollAndReset(bool exitWithKeyboard) { +void Calculator::PollAndReset(bool exitWithKeyboard) { char serialNumber[Ion::SerialNumberLength+1]; Ion::getSerialNumber(serialNumber); Calculator c(serialNumber); @@ -28,7 +29,14 @@ bool Calculator::PollAndReset(bool exitWithKeyboard) { if (!c.isSoftDisconnected()) { c.detach(); } - return c.resetOnDisconnect(); + if (c.resetOnDisconnect()) { + /* We don't perform a core reset because at this point in time the USB cable + * is most likely plugged in. Doing a full core reset would be the clean + * thing to do but would therefore result in the device entering the ROMed + * DFU bootloader, which we want to avoid. By performing a jump-reset, we + * will enter the newly flashed firmware. */ + Ion::Device::jumpReset(); + } } Descriptor * Calculator::descriptor(uint8_t type, uint8_t index) { diff --git a/ion/src/device/usb/calculator.h b/ion/src/device/usb/calculator.h index a0eb4559b..29a541ddd 100644 --- a/ion/src/device/usb/calculator.h +++ b/ion/src/device/usb/calculator.h @@ -24,7 +24,7 @@ namespace Device { class Calculator : public Device { public: - static bool PollAndReset(bool exitWithKeyboard); // Return true if reset is needed + static void PollAndReset(bool exitWithKeyboard); // Return true if reset is needed Calculator(const char * serialNumber) : Device(&m_dfuInterface), m_deviceDescriptor( diff --git a/ion/src/device/usb/dfu_relocated.cpp b/ion/src/device/usb/dfu_relocated.cpp index 4e1ba2933..8e2966c18 100644 --- a/ion/src/device/usb/dfu_relocated.cpp +++ b/ion/src/device/usb/dfu_relocated.cpp @@ -1,7 +1,6 @@ #include #include #include -#include "../device.h" extern char _stack_end; extern char _dfu_bootloader_flash_start; @@ -10,7 +9,7 @@ extern char _dfu_bootloader_flash_end; namespace Ion { namespace USB { -typedef bool (*PollFunctionPointer)(bool exitWithKeyboard); +typedef void (*PollFunctionPointer)(bool exitWithKeyboard); void DFU() { @@ -62,14 +61,7 @@ void DFU() { * add-symbol-file ion/src/device/usb/dfu.elf 0x20038000 */ - if (dfu_bootloader_entry(true)) { - /* We don't perform a core reset because at this point in time the USB cable - * is most likely plugged in. Doing a full core reset would be the clean - * thing to do but would therefore result in the device entering the ROMed - * DFU bootloader, which we want to avoid. By performing a jump-reset, we - * will enter the newly flashed firmware. */ - Ion::Device::jumpReset(); - } + dfu_bootloader_entry(true); /* 5- That's all. The DFU bootloader on the stack is now dead code that will * be overwritten when the stack grows. */ diff --git a/ion/src/device/usb/dfu_xip.cpp b/ion/src/device/usb/dfu_xip.cpp index fadfcd65c..ad2ef68bb 100644 --- a/ion/src/device/usb/dfu_xip.cpp +++ b/ion/src/device/usb/dfu_xip.cpp @@ -5,9 +5,7 @@ namespace Ion { namespace USB { void DFU() { - if (Ion::USB::Device::Calculator::PollAndReset(true)) { - Ion::Device::jumpReset(); - } + Ion::USB::Device::Calculator::PollAndReset(true); } }