[ion] DFU leave instruction triggers a core reset on N0101 and a soft

reset on N0100 (to avoid booting on ST bootloader as the device is
plugged)
This commit is contained in:
Émilie Feral
2019-03-21 14:23:51 +01:00
parent c298c17af8
commit 478d49b416
7 changed files with 43 additions and 7 deletions

View File

@@ -2,4 +2,6 @@ ion_device_src += $(addprefix ion/src/device/n0100/drivers/, \
board.cpp \
)
ion_device_src += ion/src/device/n0101/usb/stack/device.cpp
LDSCRIPT ?= ion/src/device/n0100/flash.ld

View File

@@ -0,0 +1,20 @@
#include <usb/stack/device.h>
#include <drivers/reset.h>
namespace Ion {
namespace Device {
namespace USB {
void Device::leave() {
/* 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::Reset::jump();
}
}
}
}

View File

@@ -3,4 +3,6 @@ ion_device_src += $(addprefix ion/src/device/n0101/drivers/, \
cache.cpp \
)
ion_device_src += ion/src/device/n0101/usb/stack/device.cpp
LDSCRIPT ?= ion/src/device/n0101/flash.ld

View File

@@ -0,0 +1,16 @@
#include <usb/stack/device.h>
#include <drivers/reset.h>
namespace Ion {
namespace Device {
namespace USB {
void Device::leave() {
Ion::Device::Reset::core();
}
}
}
}

View File

@@ -48,6 +48,7 @@ dfu_src += liba/src/memcpy.c
dfu_src += libaxx/src/cxxabi/pure_virtual.cpp
dfu_src += ion/src/device/shared/usb/boot.cpp
dfu_src += ion/src/device/$(MODEL)/drivers/cache.cpp
dfu_src += ion/src/device/$(MODEL)/usb/stack/device.cpp
dfu_src += $(addprefix ion/src/device/shared/drivers/, \
base64.cpp \
external_flash.cpp \

View File

@@ -1,7 +1,6 @@
#include "calculator.h"
#include <ion/usb.h>
#include <drivers/keyboard.h>
#include <drivers/reset.h>
#include <drivers/serial_number.h>
namespace Ion {
@@ -30,12 +29,7 @@ void Calculator::PollAndReset(bool exitWithKeyboard) {
c.detach();
}
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::Reset::jump();
c.leave();
}
}

View File

@@ -23,6 +23,7 @@ public:
void poll();
bool isSoftDisconnected() const;
void detach();
void leave();
bool resetOnDisconnect() { return m_resetOnDisconnect; }
void setResetOnDisconnect(bool reset) { m_resetOnDisconnect = reset; }
protected: