Skip to content

Commit 646f614

Browse files
committed
Fix start_new_application compile error on Cortex-M23
With "mov r2, #0", compile OK with GCC_ARM, but failed with ARMC6. With "ldr r2, =0", compile OK with ARMC6, but failed with GCC_ARM. Finally, with "movw r2, #0"/"movt r2, #0", compile OK with both ARMC6 and GCC_ARM.
1 parent b3f17a9 commit 646f614

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

platform/mbed_application.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,13 @@ __asm static void start_new_application(void *sp, void *pc)
117117

118118
void start_new_application(void *sp, void *pc)
119119
{
120-
#if defined(__CORTEX_M23)
121120
__asm volatile (
122-
"ldr r2, =0 \n"
123-
"msr control, r2 \n" // Switch to main stack
124-
"mov sp, %0 \n"
125-
"msr primask, r2 \n" // Enable interrupts
126-
"bx %1 \n"
127-
:
128-
: "l" (sp), "l" (pc)
129-
: "r2", "cc", "memory"
130-
);
121+
#if defined(__CORTEX_M23)
122+
"movw r2, #0 \n"
123+
"movt r2, #0 \n"
131124
#else
132-
__asm volatile (
133125
"mov r2, #0 \n"
126+
#endif
134127
"msr control, r2 \n" // Switch to main stack
135128
"mov sp, %0 \n"
136129
"msr primask, r2 \n" // Enable interrupts
@@ -139,7 +132,6 @@ void start_new_application(void *sp, void *pc)
139132
: "l" (sp), "l" (pc)
140133
: "r2", "cc", "memory"
141134
);
142-
#endif
143135
}
144136

145137
#else

0 commit comments

Comments
 (0)