diff --git a/ion/src/device/n0100/flash.ld b/ion/src/device/n0100/flash.ld index e5ddcc9e4..80f02b63d 100644 --- a/ion/src/device/n0100/flash.ld +++ b/ion/src/device/n0100/flash.ld @@ -30,7 +30,7 @@ SECTIONS { * We're generating the ISR vector table in code because it's very * convenient: using function pointers, we can easily point to the service * routine for each interrupt. */ - + _isr_start = .; KEEP(*(.isr_vector_table)) } >FLASH diff --git a/ion/src/device/n0101/flash.ld b/ion/src/device/n0101/flash.ld index c396ac067..c75d5c2af 100644 --- a/ion/src/device/n0101/flash.ld +++ b/ion/src/device/n0101/flash.ld @@ -38,7 +38,7 @@ SECTIONS { * We're generating the ISR vector table in code because it's very * convenient: using function pointers, we can easily point to the service * routine for each interrupt. */ - + _isr_start = .; KEEP(*(.isr_vector_table)) } >INTERNAL_FLASH diff --git a/ion/src/device/shared/drivers/reset.cpp b/ion/src/device/shared/drivers/reset.cpp index 924dfd993..e0dfc6010 100644 --- a/ion/src/device/shared/drivers/reset.cpp +++ b/ion/src/device/shared/drivers/reset.cpp @@ -2,6 +2,8 @@ #include #include +extern void * _isr_start; + namespace Ion { namespace Device { namespace Reset { @@ -19,8 +21,8 @@ void jump() { Ion::Device::Cache::disableDCache(); Ion::Device::Cache::disableICache(); - uint32_t * stackPointerAddress = reinterpret_cast(0x08000000); - uint32_t * resetHandlerAddress = reinterpret_cast(0x08000004); + uint32_t * stackPointerAddress = reinterpret_cast(&_isr_start); + uint32_t * resetHandlerAddress = stackPointerAddress + 1; /* Jump to the reset service routine after having reset the stack pointer. * Both addresses are fetched from the base of the Flash memory, just like a diff --git a/ion/src/device/shared/ram.ld b/ion/src/device/shared/ram.ld index 619f1fcd3..1003ee25a 100644 --- a/ion/src/device/shared/ram.ld +++ b/ion/src/device/shared/ram.ld @@ -23,6 +23,7 @@ STACK_SIZE = 32K; SECTIONS { .isr_vector_table ORIGIN(RAM_BUFFER) : { + _isr_start = .; KEEP(*(.isr_vector_table)) } >RAM_BUFFER diff --git a/ion/src/device/shared/usb/dfu.ld b/ion/src/device/shared/usb/dfu.ld index 934772384..66a250f74 100644 --- a/ion/src/device/shared/usb/dfu.ld +++ b/ion/src/device/shared/usb/dfu.ld @@ -25,6 +25,10 @@ MEMORY { RAM_BUFFER (rw) : ORIGIN = EPSILON_STACK_END, LENGTH = 8K } +/* The DFU needs to know to which address it should jump to after a leave + * command. This address is used in Ion::Device::Reset::jump(). */ +_isr_start = 0x08000000; + SECTIONS { .text : { . = ALIGN(4);