Skip to content

Commit e8d67ac

Browse files
Laurent MEUNIERc1728p9
authored andcommitted
INIT: uARM no rtos: Align pre-main initialization steps between TCs
In uARM, the library's hook _platform_post_stackheap_init does not seem to exist and I couldnot find a documentation describing the initialisation flow. All we know is that _open is called after RAM init and before the C++ init, so this is a working placeholder. This is maybe not acceptable so a uARM lib expert may propose a better hook to fullfil the requirement. At least this is a workign setup. This series should solve issue reported here: STM32 (At least F401) breaks if Tickers are activated in a global object #2115
1 parent f50e23a commit e8d67ac

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

platform/retarget.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,21 @@ static inline int openmode_to_posix(int openmode) {
149149
return posix;
150150
}
151151

152+
extern "C" WEAK void mbed_sdk_init(void);
153+
extern "C" WEAK void mbed_sdk_init(void) {
154+
}
155+
152156
extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) {
153157
#if defined(__MICROLIB) && (__ARMCC_VERSION>5030000)
154158
// Before version 5.03, we were using a patched version of microlib with proper names
155159
// This is the workaround that the microlib author suggested us
156160
static int n = 0;
161+
static int mbed_sdk_inited = 0;
162+
if (!mbed_sdk_inited) {
163+
mbed_sdk_inited = 1;
164+
mbed_sdk_init();
165+
}
157166
if (!std::strcmp(name, ":tt")) return n++;
158-
159167
#else
160168
/* Use the posix convention that stdin,out,err are filehandles 0,1,2.
161169
*/
@@ -516,10 +524,6 @@ extern "C" WEAK void mbed_main(void);
516524
extern "C" WEAK void mbed_main(void) {
517525
}
518526

519-
extern "C" WEAK void mbed_sdk_init(void);
520-
extern "C" WEAK void mbed_sdk_init(void) {
521-
}
522-
523527
#if defined(TOOLCHAIN_ARM)
524528
extern "C" int $Super$$main(void);
525529

0 commit comments

Comments
 (0)