mbed SDK library sources

Fork of mbed-src by mbed official

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Dec 24 21:15:05 2013 +0000
Parent:
66:64ad953ee6c3
Child:
68:41613245dfd7
Commit message:
Synchronized with git revision 82aa7b7f2b67dfdef90373b703bb8b2f33ea4e57

Full URL: https://github.com/mbedmicro/mbed/commit/82aa7b7f2b67dfdef90373b703bb8b2f33ea4e57/

1. Provide the required __end__ symbol
2. Call software_init_hook() if present, which in turn starts the RTOS

The fix was applied for all targets with a TOOLCHAIN_GCC_CR folder,
but it only works with LPC1768 and LPC4088 because of incomplete or
missing support for GCC_CR and/or the RTOS for the other targets.
Tested by running RTOS_1, RTOS_2 and RTOS_3 with LPC1768 and LPC4088.

Changed in this revision

targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_CR/LPC11U24.ld Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_CR/startup_LPC11xx.cpp Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_NXP/TARGET_LPC11XX_11CXX/TOOLCHAIN_GCC_CR/startup_LPC11xx.cpp Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_NXP/TARGET_LPC176X/TOOLCHAIN_GCC_CR/LPC1768.ld Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_NXP/TARGET_LPC176X/TOOLCHAIN_GCC_CR/startup_LPC17xx.cpp Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_NXP/TARGET_LPC408X/TOOLCHAIN_GCC_CR/LPC407x_8x.ld Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_NXP/TARGET_LPC408X/TOOLCHAIN_GCC_CR/startup_lpc407x_8x.cpp Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_NXP/TARGET_LPC43XX/TOOLCHAIN_GCC_CR/startup_LPC43xx.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_CR/LPC11U24.ld	Fri Dec 20 15:00:06 2013 +0000
+++ b/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_CR/LPC11U24.ld	Tue Dec 24 21:15:05 2013 +0000
@@ -145,6 +145,7 @@
         . = ALIGN(4) ;
         _ebss = .;
         PROVIDE(end = .);
+        __end__ = .;
     } > RamLoc8
     
     PROVIDE(_pvHeapStart = .);
--- a/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_CR/startup_LPC11xx.cpp	Fri Dec 20 15:00:06 2013 +0000
+++ b/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_CR/startup_LPC11xx.cpp	Tue Dec 24 21:15:05 2013 +0000
@@ -9,7 +9,7 @@
      void ResetISR            (void);
 WEAK void NMI_Handler         (void);
 WEAK void HardFault_Handler   (void);
-WEAK void SVCall_Handler      (void);
+WEAK void SVC_Handler         (void);
 WEAK void PendSV_Handler      (void);
 WEAK void SysTick_Handler     (void);
 WEAK void IntDefaultHandler   (void);
@@ -57,7 +57,7 @@
     0,
     0,
     0,
-    SVCall_Handler,
+    SVC_Handler,
     0,
     0,
     PendSV_Handler,
@@ -113,6 +113,8 @@
 extern unsigned int __data_section_table_end;
 extern unsigned int __bss_section_table_end;
 
+extern "C" void software_init_hook(void) __attribute__((weak));
+
 AFTER_VECTORS void ResetISR(void) {
     unsigned int LoadAddr, ExeAddr, SectionLen;
     unsigned int *SectionTableAddr;
@@ -134,14 +136,18 @@
     }
     
     SystemInit();
-    __libc_init_array();
-    main();
+    if (software_init_hook) // give control to the RTOS
+        software_init_hook(); // this will also call __libc_init_array
+    else {
+        __libc_init_array();
+        main();
+    }
     while (1) {;}
 }
 
 AFTER_VECTORS void NMI_Handler      (void) {while(1){}}
 AFTER_VECTORS void HardFault_Handler(void) {while(1){}}
-AFTER_VECTORS void SVCall_Handler   (void) {while(1){}}
+AFTER_VECTORS void SVC_Handler      (void) {while(1){}}
 AFTER_VECTORS void PendSV_Handler   (void) {while(1){}}
 AFTER_VECTORS void SysTick_Handler  (void) {while(1){}}
 AFTER_VECTORS void IntDefaultHandler(void) {while(1){}}
--- a/targets/cmsis/TARGET_NXP/TARGET_LPC11XX_11CXX/TOOLCHAIN_GCC_CR/startup_LPC11xx.cpp	Fri Dec 20 15:00:06 2013 +0000
+++ b/targets/cmsis/TARGET_NXP/TARGET_LPC11XX_11CXX/TOOLCHAIN_GCC_CR/startup_LPC11xx.cpp	Tue Dec 24 21:15:05 2013 +0000
@@ -9,7 +9,7 @@
      void ResetISR            (void);
 WEAK void NMI_Handler         (void);
 WEAK void HardFault_Handler   (void);
-WEAK void SVCall_Handler      (void);
+WEAK void SVC_Handler         (void);
 WEAK void PendSV_Handler      (void);
 WEAK void SysTick_Handler     (void);
 WEAK void IntDefaultHandler   (void);
@@ -57,7 +57,7 @@
     0,
     0,
     0,
-    SVCall_Handler,
+    SVC_Handler,
     0,
     0,
     PendSV_Handler,
@@ -113,6 +113,8 @@
 extern unsigned int __data_section_table_end;
 extern unsigned int __bss_section_table_end;
 
+extern "C" void software_init_hook(void) __attribute__((weak));
+
 AFTER_VECTORS void ResetISR(void) {
     unsigned int LoadAddr, ExeAddr, SectionLen;
     unsigned int *SectionTableAddr;
@@ -134,14 +136,18 @@
     }
     
     SystemInit();
-    __libc_init_array();
-    main();
+    if (software_init_hook) // give control to the RTOS
+        software_init_hook(); // this will also call __libc_init_array
+    else {
+        __libc_init_array();
+        main();
+    }
     while (1) {;}
 }
 
 AFTER_VECTORS void NMI_Handler      (void) {while(1){}}
 AFTER_VECTORS void HardFault_Handler(void) {while(1){}}
-AFTER_VECTORS void SVCall_Handler   (void) {while(1){}}
+AFTER_VECTORS void SVC_Handler   (void) {while(1){}}
 AFTER_VECTORS void PendSV_Handler   (void) {while(1){}}
 AFTER_VECTORS void SysTick_Handler  (void) {while(1){}}
 AFTER_VECTORS void IntDefaultHandler(void) {while(1){}}
--- a/targets/cmsis/TARGET_NXP/TARGET_LPC176X/TOOLCHAIN_GCC_CR/LPC1768.ld	Fri Dec 20 15:00:06 2013 +0000
+++ b/targets/cmsis/TARGET_NXP/TARGET_LPC176X/TOOLCHAIN_GCC_CR/LPC1768.ld	Tue Dec 24 21:15:05 2013 +0000
@@ -146,6 +146,7 @@
         . = ALIGN(4) ;
         _ebss = .;
         PROVIDE(end = .);
+        __end__ = .;
     } > RamLoc32
     
     PROVIDE(_pvHeapStart = .);
--- a/targets/cmsis/TARGET_NXP/TARGET_LPC176X/TOOLCHAIN_GCC_CR/startup_LPC17xx.cpp	Fri Dec 20 15:00:06 2013 +0000
+++ b/targets/cmsis/TARGET_NXP/TARGET_LPC176X/TOOLCHAIN_GCC_CR/startup_LPC17xx.cpp	Tue Dec 24 21:15:05 2013 +0000
@@ -22,7 +22,7 @@
 WEAK void MemManage_Handler (void);
 WEAK void BusFault_Handler  (void);
 WEAK void UsageFault_Handler(void);
-WEAK void SVCall_Handler    (void);
+WEAK void SVC_Handler       (void);
 WEAK void DebugMon_Handler  (void);
 WEAK void PendSV_Handler    (void);
 WEAK void SysTick_Handler   (void);
@@ -75,7 +75,7 @@
     0,
     0,
     0,
-    SVCall_Handler,
+    SVC_Handler,
     DebugMon_Handler,
     0,
     PendSV_Handler,
@@ -130,6 +130,8 @@
     for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = 0;
 }
 
+extern "C" void software_init_hook(void) __attribute__((weak));
+
 AFTER_VECTORS void ResetISR(void) {
     unsigned int LoadAddr, ExeAddr, SectionLen;
     unsigned int *SectionTableAddr;
@@ -149,8 +151,12 @@
     }
     
     SystemInit();
-    __libc_init_array();
-    main();
+    if (software_init_hook) // give control to the RTOS
+        software_init_hook(); // this will also call __libc_init_array
+    else {
+        __libc_init_array();
+        main();
+    }
     while (1) {;}
 }
 
@@ -159,7 +165,7 @@
 AFTER_VECTORS void MemManage_Handler (void) {}
 AFTER_VECTORS void BusFault_Handler  (void) {}
 AFTER_VECTORS void UsageFault_Handler(void) {}
-AFTER_VECTORS void SVCall_Handler    (void) {}
+AFTER_VECTORS void SVC_Handler       (void) {}
 AFTER_VECTORS void DebugMon_Handler  (void) {}
 AFTER_VECTORS void PendSV_Handler    (void) {}
 AFTER_VECTORS void SysTick_Handler   (void) {}
--- a/targets/cmsis/TARGET_NXP/TARGET_LPC408X/TOOLCHAIN_GCC_CR/LPC407x_8x.ld	Fri Dec 20 15:00:06 2013 +0000
+++ b/targets/cmsis/TARGET_NXP/TARGET_LPC408X/TOOLCHAIN_GCC_CR/LPC407x_8x.ld	Tue Dec 24 21:15:05 2013 +0000
@@ -156,6 +156,7 @@
         . = ALIGN(4) ;
         _ebss = .;
         PROVIDE(end = .);
+        __end__ = .;
     } > RamLoc64
         
     /* NOINIT section for RamPeriph32 */
--- a/targets/cmsis/TARGET_NXP/TARGET_LPC408X/TOOLCHAIN_GCC_CR/startup_lpc407x_8x.cpp	Fri Dec 20 15:00:06 2013 +0000
+++ b/targets/cmsis/TARGET_NXP/TARGET_LPC408X/TOOLCHAIN_GCC_CR/startup_lpc407x_8x.cpp	Tue Dec 24 21:15:05 2013 +0000
@@ -259,6 +259,9 @@
 // Sets up a simple runtime environment and initializes the C/C++
 // library.
 //*****************************************************************************
+
+extern "C" void software_init_hook(void) __attribute__((weak));
+
 __attribute__ ((section(".after_vectors")))
 void
 ResetISR(void) {
@@ -319,21 +322,23 @@
 //#ifdef __USE_CMSIS
 	SystemInit();
 //#endif
-
+  if (software_init_hook) // give control to the RTOS
+    software_init_hook(); // this will also call __libc_init_array
+  else {
 #if defined (__cplusplus)
-	//
-	// Call C++ library initialisation
-	//
-	__libc_init_array();
+    //
+    // Call C++ library initialisation
+    //
+    __libc_init_array();
 #endif
 
 #if defined (__REDLIB__)
-	// Call the Redlib library, which in turn calls main()
-	__main() ;
+    // Call the Redlib library, which in turn calls main()
+    __main() ;
 #else
-	main();
+    main();
 #endif
-
+  }
 	//
 	// main() shouldn't return, but if it does, we'll just enter an infinite loop 
 	//
--- a/targets/cmsis/TARGET_NXP/TARGET_LPC43XX/TOOLCHAIN_GCC_CR/startup_LPC43xx.cpp	Fri Dec 20 15:00:06 2013 +0000
+++ b/targets/cmsis/TARGET_NXP/TARGET_LPC43XX/TOOLCHAIN_GCC_CR/startup_LPC43xx.cpp	Tue Dec 24 21:15:05 2013 +0000
@@ -312,6 +312,9 @@
 // library.
 //
 // *****************************************************************************
+
+extern "C" void software_init_hook(void) __attribute__((weak));
+
 void
 ResetISR(void) {
 
@@ -342,20 +345,23 @@
 		bss_init(ExeAddr, SectionLen);
 	}
 
-	#if defined(__cplusplus)
-	//
-	// Call C++ library initialisation
-	//
-	__libc_init_array();
-	#endif
+  if (software_init_hook) // give control to the RTOS
+    software_init_hook(); // this will also call __libc_init_array
+  else {
+    #if defined(__cplusplus)
+    //
+    // Call C++ library initialisation
+    //
+    __libc_init_array();
+    #endif
 
-	#if defined(__REDLIB__)
-	// Call the Redlib library, which in turn calls main()
-	__main();
-	#else
-	main();
-	#endif
-
+    #if defined(__REDLIB__)
+    // Call the Redlib library, which in turn calls main()
+    __main();
+    #else
+    main();
+    #endif
+  }
 	//
 	// main() shouldn't return, but if it does, we'll just enter an infinite loop
 	//