diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-05-13 15:20:08 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-22 03:31:56 +0000 |
commit | 288e1a5d8ea9be1e15829067969cc786d725a4a4 (patch) | |
tree | fef788b8b875b8fef2760bb5e04f6a0896f67ead /common/main.c | |
parent | 092918a531ec535a12db6bdf01af3d1b782630f5 (diff) | |
download | chrome-ec-288e1a5d8ea9be1e15829067969cc786d725a4a4.tar.gz |
cortex-m: Clean up MPU logic
Add error checking for failures and use IS_ENABLED combined with helper
functions for readability.
BRANCH=none
BUG=b:155229277, b:156501835
TEST=Compile and flash "rollback" test on dragonclaw with region 0
On console: "runtest"
=> Reboots with "Data access violation, mfar = 8020000"
=> PASS
TEST=Compile and flash "rollback" test on dragonclaw with region 1
On console: "runtest"
=> Memory is successfully read
=> FAIL
TEST=Compile and flash "rollback" test on dragontalon with region 0
On console: "runtest"
=> Reboots with "Data access violation, mfar = 80c0000"
=> PASS
TEST=Compile and flash "rollback" on dragontalon with region 1
On console: "runtest"
=> Reboots with "Data access violation, mfar = 80e0000"
=> PASS
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I0f8d149c8c5c568241457a6779079c65eb38ce32
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2200199
Commit-Queue: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common/main.c')
-rw-r--r-- | common/main.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/common/main.c b/common/main.c index c62b835bfd..9b505c756c 100644 --- a/common/main.c +++ b/common/main.c @@ -40,6 +40,8 @@ test_mockable __keep int main(void) { + int mpu_pre_init_rv = EC_SUCCESS; + if (IS_ENABLED(CONFIG_PRESERVE_LOGS)) { /* * Initialize tx buffer head and tail. This needs to be done @@ -73,7 +75,7 @@ test_mockable __keep int main(void) #endif #ifdef CONFIG_MPU - mpu_pre_init(); + mpu_pre_init_rv = mpu_pre_init(); #endif gpio_pre_init(); @@ -133,6 +135,10 @@ test_mockable __keep int main(void) /* Initialize UART. Console output functions may now be used. */ uart_init(); + /* We wait to report the failure until here where we have console. */ + if (mpu_pre_init_rv != EC_SUCCESS) + panic("MPU init failed\n"); + /* be less verbose if we boot for USB resume to meet spec timings */ if (!(system_get_reset_flags() & EC_RESET_FLAG_USB_RESUME)) { if (system_jumped_to_this_image()) { |