Skip to content

Commit ea1de8c

Browse files
committed
[NUC472/M453] Remove mbed_sdk_init_forced()
1. With mbed OS 5, mbed_sdk_init() is ensured to call before C++ global object constructor. 2. Refine startup file with GCC_ARM toolchain related to this modification.
1 parent 6c9fda4 commit ea1de8c

File tree

4 files changed

+12
-62
lines changed

4 files changed

+12
-62
lines changed

targets/TARGET_NUVOTON/TARGET_M451/TARGET_NUMAKER_PFM_M453/mbed_overrides.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616

1717
#include "analogin_api.h"
1818

19-
// NOTE: Ensurce mbed_sdk_init() will get called before C++ global object constructor.
20-
#if defined(__CC_ARM) || defined(__GNUC__)
21-
void mbed_sdk_init_forced(void) __attribute__((constructor(101)));
22-
#elif defined(__ICCARM__)
23-
// FIXME: How to achieve it in IAR?
24-
#endif
25-
26-
2719
void mbed_sdk_init(void)
2820
{
2921
// NOTE: Support singleton semantics to be called from other init functions
@@ -75,8 +67,3 @@ void mbed_sdk_init(void)
7567
/* Lock protected registers */
7668
SYS_LockReg();
7769
}
78-
79-
void mbed_sdk_init_forced(void)
80-
{
81-
mbed_sdk_init();
82-
}

targets/TARGET_NUVOTON/TARGET_M451/device/startup_M451Series.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,11 @@ extern uint32_t __bss_start__;
6161
extern uint32_t __bss_end__;
6262

6363
extern void uvisor_init(void);
64-
//#if defined(TOOLCHAIN_GCC_ARM)
65-
//extern void _start(void);
66-
//#endif
67-
extern void software_init_hook(void) __attribute__((weak));
68-
extern void __libc_init_array(void);
69-
extern int main(void);
64+
#if defined(TOOLCHAIN_GCC_ARM)
65+
extern void _start(void);
66+
#else
67+
#error("For GCC toolchain, only support GNU ARM Embedded")
68+
#endif
7069
#endif
7170

7271
/* Default empty handler */
@@ -307,19 +306,8 @@ void Reset_Handler(void)
307306
}
308307
}
309308

310-
//uvisor_init();
309+
_start();
311310

312-
if (software_init_hook) {
313-
/**
314-
* Give control to the RTOS via software_init_hook() which will also call __libc_init_array().
315-
* Assume software_init_hook() is defined in libraries/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h.
316-
*/
317-
software_init_hook();
318-
}
319-
else {
320-
__libc_init_array();
321-
main();
322-
}
323311
#endif
324312

325313
/* Infinite loop */

targets/TARGET_NUVOTON/TARGET_NUC472/TARGET_NUMAKER_PFM_NUC472/mbed_overrides.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
#include "cmsis.h"
1818
#include "analogin_api.h"
1919

20-
// NOTE: Ensurce mbed_sdk_init() will get called before C++ global object constructor.
21-
#if defined(__CC_ARM) || defined(__GNUC__)
22-
void mbed_sdk_init_forced(void) __attribute__((constructor(101)));
23-
#elif defined(__ICCARM__)
24-
// FIXME: How to achieve it in IAR?
25-
#endif
26-
2720
void mbed_sdk_init(void)
2821
{
2922
// NOTE: Support singleton semantics to be called from other init functions
@@ -88,8 +81,3 @@ void mbed_sdk_init(void)
8881
/* Lock protected registers */
8982
SYS_LockReg();
9083
}
91-
92-
void mbed_sdk_init_forced(void)
93-
{
94-
mbed_sdk_init();
95-
}

targets/TARGET_NUVOTON/TARGET_NUC472/device/startup_NUC472_442.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,11 @@ extern uint32_t __bss_extern_start__ WEAK;
6363
extern uint32_t __bss_extern_end__ WEAK;
6464

6565
extern void uvisor_init(void);
66-
//#if defined(TOOLCHAIN_GCC_ARM)
67-
//extern void _start(void);
68-
//#endif
69-
extern void software_init_hook(void) __attribute__((weak));
70-
extern void __libc_init_array(void);
71-
extern int main(void);
66+
#if defined(TOOLCHAIN_GCC_ARM)
67+
extern void _start(void);
68+
#else
69+
#error("For GCC toolchain, only support GNU ARM Embedded")
70+
#endif
7271
#endif
7372

7473
/* Default empty handler */
@@ -476,19 +475,7 @@ void Reset_Handler(void)
476475
}
477476
}
478477

479-
//uvisor_init();
480-
481-
if (software_init_hook) {
482-
/**
483-
* Give control to the RTOS via software_init_hook() which will also call __libc_init_array().
484-
* Assume software_init_hook() is defined in libraries/rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h.
485-
*/
486-
software_init_hook();
487-
}
488-
else {
489-
__libc_init_array();
490-
main();
491-
}
478+
_start();
492479

493480
#endif
494481
/* Infinite loop */

0 commit comments

Comments
 (0)