Verified Commit e924ecee authored by Rahix's avatar Rahix
Browse files

fix(api): Reset FPU before loading a new payload

Without resetting the FPU we get spurious failures in Pycardium.  These
manifest in many different forms, ranging from HardFaults and triggered
assertions to "syntax errors" in loaded scripts while said script does
not contain any.

These failures stem from the FPU still containing state from the last
loaded payload and thus sometimes corrupting stack locations where the
previous payload had floating point state.

Closes #72.

Signed-off-by: Rahix's avatarRahix <>
parent 1e7b2265
......@@ -45,9 +45,22 @@ static uintptr_t core1_initial_ivt[] = {
__attribute__((naked)) void __core1_reset(void)
__asm volatile("mov sp, %0\n\t"
: /* No Outputs */
: "r"(core1_initial_ivt[0]));
/* Reset stack to MSP and set it to 0x20080000 */
__asm volatile(
"mov r0, #0\n\t"
"msr control, r0\n\t"
"mov sp, %0\n\t"
: /* No Outputs */
: "r"(core1_initial_ivt[0])
: "r0");
/* Reset FPU */
SCB->CPACR = 0x00000000;
FPU->FPDSCR = 0x00000000;
FPU->FPCCR = 0x00000000;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment