diff --git a/bootloader/jump_to_firmware.s b/bootloader/jump_to_firmware.s index c5b54bcd2..25a521713 100644 --- a/bootloader/jump_to_firmware.s +++ b/bootloader/jump_to_firmware.s @@ -5,7 +5,5 @@ .thumb .global jump_to_firmware jump_to_firmware: - dsb 0xF - isb 0xF msr msp, r0 bx r1 diff --git a/bootloader/main.cpp b/bootloader/main.cpp index 119911199..6f4e54237 100644 --- a/bootloader/main.cpp +++ b/bootloader/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "interface.h" @@ -23,10 +24,6 @@ void ion_main(int argc, const char * const argv[]) { } } - /* - KDContext * ctx = KDIonContext::sharedContext(); - ctx->drawString(Bootloader::s_slotA->version(), KDPoint(0, 20)); - - */ + Ion::Device::Board::bootloaderMPU(); Bootloader::s_slotA->boot(); } diff --git a/ion/src/device/n0110/drivers/board.cpp b/ion/src/device/n0110/drivers/board.cpp index 0ed24868c..23579c5a2 100644 --- a/ion/src/device/n0110/drivers/board.cpp +++ b/ion/src/device/n0110/drivers/board.cpp @@ -24,6 +24,28 @@ namespace Board { using namespace Regs; +void bootloaderMPU() { + // 1. Disable the MPU + // 1.1 Memory barrier + Cache::dmb(); + + // 1.3 Disable the MPU and clear the control register + MPU.CTRL()->setENABLE(false); + + MPU.RNR()->setREGION(7); + MPU.RBAR()->setADDR(0x90000000); + MPU.RASR()->setXN(false); + MPU.RASR()->setENABLE(true); + + // 2.3 Enable MPU + MPU.CTRL()->setENABLE(true); + + // 3. Data/instruction synchronisation barriers to ensure that the new MPU configuration is used by subsequent instructions. + Cache::disable(); + Cache::dsb(); + Cache::isb(); +} + void initMPU() { // 1. Disable the MPU // 1.1 Memory barrier diff --git a/ion/src/device/shared/drivers/board.h b/ion/src/device/shared/drivers/board.h index 61b63b2b3..8d1d1bbb6 100644 --- a/ion/src/device/shared/drivers/board.h +++ b/ion/src/device/shared/drivers/board.h @@ -9,6 +9,7 @@ namespace Board { void init(); +void bootloaderMPU(); void initFPU(); void initClocks(); void shutdownClocks(bool keepLEDAwake = false);