[bootloader] MPU config

This commit is contained in:
M4x1m3
2022-02-26 11:42:03 +01:00
parent 6eabe9acae
commit d16808183b
4 changed files with 25 additions and 7 deletions

View File

@@ -5,7 +5,5 @@
.thumb
.global jump_to_firmware
jump_to_firmware:
dsb 0xF
isb 0xF
msr msp, r0
bx r1

View File

@@ -2,6 +2,7 @@
#include <ion.h>
#include <bootloader/slot.h>
#include <assert.h>
#include <ion/src/device/shared/drivers/board.h>
#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();
}

View File

@@ -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

View File

@@ -9,6 +9,7 @@ namespace Board {
void init();
void bootloaderMPU();
void initFPU();
void initClocks();
void shutdownClocks(bool keepLEDAwake = false);