Skip to content

Commit e911d98

Browse files
0xc0170adbridge
authored andcommitted
retarget: fix microlib for mbed 2
This is as it used to be, reverting the removal. uARM does not have any hook that we could use for mbed sdk init and copy nvic, therefore _open is used that should be sufficient, but not ideal. For more information, visit https://github.com/ARMmbed/mbed-os/pull/2160/files#r76563844.
1 parent 9797c7c commit e911d98

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

platform/mbed_retarget.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,20 @@ static inline int openmode_to_posix(int openmode) {
177177
* */
178178
extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) {
179179
#if defined(__MICROLIB) && (__ARMCC_VERSION>5030000)
180+
#if !defined(MBED_CONF_RTOS_PRESENT)
181+
// valid only for mbed 2
182+
// for ulib, this is invoked after RAM init, prior c++
183+
// used as hook, as post stack/heap is not active there
184+
extern void mbed_copy_nvic(void);
185+
extern void mbed_sdk_init(void);
186+
187+
static int mbed_sdk_inited = 0;
188+
if (!mbed_sdk_inited) {
189+
mbed_copy_nvic();
190+
mbed_sdk_init();
191+
mbed_sdk_inited = 1;
192+
}
193+
#endif
180194
// Before version 5.03, we were using a patched version of microlib with proper names
181195
// This is the workaround that the microlib author suggested us
182196
static int n = 0;

0 commit comments

Comments
 (0)