[ion] Reset: add a method Reset::coreWhilePlugged implemented

differently for N0100 & N0110
This commit is contained in:
Émilie Feral
2019-06-18 15:26:58 -04:00
parent fbd18dbf7d
commit bf80957b56
9 changed files with 45 additions and 46 deletions

View File

@@ -1,8 +1,7 @@
ion_device_src += $(addprefix ion/src/device/n0100/drivers/, \
board.cpp \
power.cpp \
reset.cpp \
)
ion_device_src += ion/src/device/n0100/usb/stack/device.cpp
LDSCRIPT ?= ion/src/device/n0100/flash.ld

View File

@@ -0,0 +1,18 @@
#include <drivers/reset.h>
#include "config/flash.h"
namespace Ion {
namespace Device {
namespace Reset {
void coreWhilePlugged() {
/* We don't perform a core reset because at this point in time the USB cable
* might be plugged in. Doing a full core reset would result in the device
* entering the ST DFU bootloader. By performing a jump-reset, we mimic the
* core reset without entering ST bootloader.*/
jump(Flash::Config::StartAddress);
}
}
}
}

View File

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

View File

@@ -2,8 +2,7 @@ ion_device_src += $(addprefix ion/src/device/n0110/drivers/, \
board.cpp \
cache.cpp \
power.cpp \
reset.cpp \
)
ion_device_src += ion/src/device/n0110/usb/stack/device.cpp
LDSCRIPT ?= ion/src/device/n0110/flash.ld

View File

@@ -0,0 +1,13 @@
#include <drivers/reset.h>
namespace Ion {
namespace Device {
namespace Reset {
void coreWhilePlugged() {
core();
}
}
}
}

View File

@@ -1,21 +0,0 @@
#include <usb/stack/device.h>
#include <drivers/reset.h>
#include <drivers/config/flash.h>
namespace Ion {
namespace Device {
namespace USB {
void Device::leave(uint32_t leaveAddress) {
if (leaveAddress == Ion::Device::Flash::Config::StartAddress) {
Ion::Device::Reset::core();
} else {
Ion::Device::Reset::jump(leaveAddress);
}
}
}
}
}

View File

@@ -8,6 +8,7 @@ namespace Device {
namespace Reset {
void core();
void coreWhilePlugged();
/* jump takes as parameter the address of the isr vector to jump to: the data at
* jumpIsrVectorAddress must the stack_pointer address, and the data at

View File

@@ -51,7 +51,7 @@ dfu_src += libaxx/src/cxxabi/pure_virtual.cpp
dfu_src += ion/src/device/shared/usb/boot.cpp
dfu_src += ion/src/device/$(MODEL)/drivers/board.cpp
dfu_src += ion/src/device/$(MODEL)/drivers/cache.cpp
dfu_src += ion/src/device/$(MODEL)/usb/stack/device.cpp
dfu_src += ion/src/device/$(MODEL)/drivers/reset.cpp
dfu_src += $(addprefix ion/src/device/shared/drivers/, \
backlight.cpp \
battery.cpp \

View File

@@ -1,4 +1,6 @@
#include "device.h"
#include <drivers/config/flash.h>
#include <drivers/reset.h>
#include <regs/regs.h>
namespace Ion {
@@ -89,6 +91,14 @@ void Device::detach() {
OTG.DCTL()->setSDIS(true);
}
void Device::leave(uint32_t leaveAddress) {
if (leaveAddress == Ion::Device::Flash::Config::StartAddress) {
Ion::Device::Reset::coreWhilePlugged();
} else {
Ion::Device::Reset::jump(leaveAddress);
}
}
bool Device::processSetupInRequest(SetupPacket * request, uint8_t * transferBuffer, uint16_t * transferBufferLength, uint16_t transferBufferMaxLength) {
// Device only handles standard requests.
if (request->requestType() != SetupPacket::RequestType::Standard) {