Skip to content

Commit c6be626

Browse files
authored
Merge pull request #4671 from 0xc0170/fix_uarm_mbed2
retarget: fix microlib for mbed 2
2 parents 9b082ff + 8a9f496 commit c6be626

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)