Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


ARM Cortex M4 SVC interrupt causes usage fault

I’m trying to write a context switch assembly on STM32F411E but I encounter a usageFault right after I make a second call to the SVC 0 (in my second task) instruction.

Here are some of the status register values after I make a call to SVC 0, in my second task:

CCR = 0x00000218
HFSR = 0x40000000
CFSR = 0x00000000
DFSR = 0x0000000b
BFAR = 0xe000ed38
AFSR = 0x00000000
MMFSR = 0x00000000
MMFAR = 0xe000ed34

Looks like DFSR might provide the biggest clue but I am still not sure what is causing this fault. Has anyone encountered a similar error and can anyone assist me with finding the source of this fault? Why would first call to SVC 0 (in task1) work but the second call to SVC 0 (in task2) fail?

Here’s my context switch code:

***************************************************
* initActivate
*
* Description: context switch routine for tasks
*
* Input:
*
* Output:
*
* Return:
*
* Note:
*
*
***************************************************/
activate:

cpsie i

mrs ip, psr
push {r4, r5, r6, r7, r8, r9, r10, r11, ip, lr}

ldmfd r0!, {r4, r5, r6, r7, r8, r9, r10, r11, ip, lr}

msr control, ip
isb
msr psp, r0

/* jump to user task*/
bx lr


/***************************************************
* SVC_Handler
*
* Description:
*
* Input:
*
* Output:
*
* Return:
*
* Note: supervisor call (handler mode)
*
*
***************************************************/
.thumb_func
SVC_Handler:

mrs r0, psp
stmdb r0!, {r4, r5, r6, r7, r8, r9, r10, r11, ip, lr}

/* load kernel state */
pop {r4, r5, r6, r7, r8, r9, r10, r11, ip, lr}
msr psr_nzcvq, ip

/* back to the thread mode if no other active exception */
bx lr

 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs