mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[ion] Add the ability to perform a jump-reset
This commit is contained in:
@@ -34,7 +34,7 @@ const char * patchLevel();
|
||||
const char * fccId();
|
||||
|
||||
/* CAUTION: This is a complete reset! */
|
||||
void reset();
|
||||
void reset(bool jump = false);
|
||||
|
||||
// CRC32 : non xor-ed, non reversed, direct, polynomial 4C11DB7
|
||||
// Only accepts whole 32bit values
|
||||
|
||||
@@ -23,6 +23,7 @@ objs += $(addprefix ion/src/device/, \
|
||||
led.o\
|
||||
power.o\
|
||||
sd_card.o\
|
||||
set_msp.o \
|
||||
swd.o \
|
||||
usb.o \
|
||||
wakeup.o \
|
||||
|
||||
@@ -14,6 +14,7 @@ extern "C" {
|
||||
#include "swd.h"
|
||||
#include "usb.h"
|
||||
#include "bench/bench.h"
|
||||
#include "set_msp.h"
|
||||
|
||||
#define USE_SD_CARD 0
|
||||
|
||||
@@ -65,10 +66,28 @@ uint32_t Ion::random() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Ion::reset() {
|
||||
static void coreReset() {
|
||||
// Perform a full core reset
|
||||
CM4.AIRCR()->requestReset();
|
||||
}
|
||||
|
||||
static void jumpReset() {
|
||||
Ion::Device::shutdown();
|
||||
uint32_t * stackPointerAddress = reinterpret_cast<uint32_t *>(0x08000000);
|
||||
uint32_t * resetHandlerAddress = reinterpret_cast<uint32_t *>(0x08000004);
|
||||
set_msp(*stackPointerAddress);
|
||||
void (*ResetHandler)(void) = (void (*)())(*resetHandlerAddress);
|
||||
ResetHandler();
|
||||
}
|
||||
|
||||
void Ion::reset(bool jump) {
|
||||
if (jump) {
|
||||
jumpReset();
|
||||
} else {
|
||||
coreReset();
|
||||
}
|
||||
}
|
||||
|
||||
static inline char hex(uint8_t d) {
|
||||
if (d > 9) {
|
||||
return 'A'+d-10;
|
||||
|
||||
8
ion/src/device/set_msp.h
Normal file
8
ion/src/device/set_msp.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef ION_DEVICE_SETMSP_H
|
||||
#define ION_DEVICE_SETMSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" void set_msp(uint32_t address);
|
||||
|
||||
#endif
|
||||
10
ion/src/device/set_msp.s
Normal file
10
ion/src/device/set_msp.s
Normal file
@@ -0,0 +1,10 @@
|
||||
.syntax unified
|
||||
|
||||
.section .text
|
||||
.align 2
|
||||
.thumb
|
||||
.global set_msp
|
||||
set_msp:
|
||||
msr msp, r0
|
||||
bx lr
|
||||
.type set_msp, function
|
||||
Reference in New Issue
Block a user