From 04ca9ab1137d43bb6936934fbb749820bf7ffadd Mon Sep 17 00:00:00 2001
From: brian <brian@crocoll.ch>
Date: Sat, 6 Jan 2024 15:57:08 +0100
Subject: [PATCH] Working user stack no errors

---
 assembleur.s           | 1 +
 mpu_user_console_etu.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/assembleur.s b/assembleur.s
index 74272b4..ac36678 100644
--- a/assembleur.s
+++ b/assembleur.s
@@ -12,6 +12,7 @@
 
 switch_to_user_mode:
 	ldr r0, =user_stack
+	add r0, r0, #2048
 	msr PSP, r0
 	mov r1, #3
 	msr CONTROL, r1
diff --git a/mpu_user_console_etu.c b/mpu_user_console_etu.c
index 759dc1f..b946221 100644
--- a/mpu_user_console_etu.c
+++ b/mpu_user_console_etu.c
@@ -80,6 +80,7 @@ int main(void) {
 	MPU->RBAR = 0x00000000;
 	MPU->RASR = RO | BTEX_NORMAL_NOT_SHAREABLE | SET_SIZE_512KB | REGION_ENABLE;
 
+
 	// Region 1 (SRAM1)
 	MPU->RNR = 1;
 	MPU->RBAR = 0x10000000;
@@ -119,7 +120,7 @@ int main(void) {
 	switch_to_user_mode();					// to be implemented
 
 	// testing memory accesses in user mode:
-	test_user_mode();		// to be removed after checking
+	//test_user_mode();		// to be removed after checking
 
 	while (1) {
 		exec_user_read_write();
-- 
GitLab