diff options
-rw-r--r-- | demos/ARMCM3-STM32F103-GCC/board.c | 20 | ||||
-rw-r--r-- | demos/ARMCM3-STM32F103-GCC/main.c | 9 | ||||
-rw-r--r-- | ports/ARMCM3/crt0.s | 32 | ||||
-rw-r--r-- | readme.txt | 4 |
4 files changed, 53 insertions, 12 deletions
diff --git a/demos/ARMCM3-STM32F103-GCC/board.c b/demos/ARMCM3-STM32F103-GCC/board.c index f10269aa6..7bfa42133 100644 --- a/demos/ARMCM3-STM32F103-GCC/board.c +++ b/demos/ARMCM3-STM32F103-GCC/board.c @@ -24,10 +24,11 @@ #include "stm32_serial.h"
/*
- * Hardware initialization goes here.
- * NOTE: Interrupts are still disabled.
+ * Early initialization code.
+ * This initialization is performed just after reset before BSS and DATA
+ * segments initialization.
*/
-void hwinit(void) {
+void hwinit0(void) {
/*
* Clocks and PLL initialization.
@@ -76,6 +77,14 @@ void hwinit(void) { GPIOD->CRL = VAL_GPIODCRL;
GPIOD->CRH = VAL_GPIODCRH;
GPIOD->ODR = VAL_GPIODODR;
+}
+
+/*
+ * Late initialization code.
+ * This initialization is performed after BSS and DATA segments initialization
+ * and before invoking the main() function.
+ */
+void hwinit1(void) {
/*
* NVIC/SCB initialization.
@@ -95,4 +104,9 @@ void hwinit(void) { * Other subsystems initialization.
*/
InitSerial(0x80, 0x80, 0x80);
+
+ /*
+ * ChibiOS/RT initialization.
+ */
+ chSysInit();
}
diff --git a/demos/ARMCM3-STM32F103-GCC/main.c b/demos/ARMCM3-STM32F103-GCC/main.c index 59e7b792a..0df4bc03d 100644 --- a/demos/ARMCM3-STM32F103-GCC/main.c +++ b/demos/ARMCM3-STM32F103-GCC/main.c @@ -39,17 +39,12 @@ static msg_t Thread1(void *arg) { }
/*
- * Entry point, the interrupts are disabled on entry.
+ * Entry point, note, the main() function is already a thread in the system
+ * on entry.
*/
int main(int argc, char **argv) {
/*
- * The main() function becomes a thread here then the interrupts are
- * enabled and ChibiOS/RT goes live.
- */
- chSysInit();
-
- /*
* Creates the blinker thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
diff --git a/ports/ARMCM3/crt0.s b/ports/ARMCM3/crt0.s index 0f2f4667d..b59f0993b 100644 --- a/ports/ARMCM3/crt0.s +++ b/ports/ARMCM3/crt0.s @@ -48,6 +48,10 @@ ResetHandler: // ldr r1, =__process_stack_size__ // sub r0, r0, r1 /* + * Early initialization. + */ + bl hwinit0 + /* * Data initialization. * NOTE: It assumes that the DATA size is a multiple of 4. */ @@ -82,9 +86,9 @@ bloop: msr BASEPRI, r0 cpsie i /* - * Application-provided HW initialization routine. + * Late initialization. */ - bl hwinit + bl hwinit1 /* * main(0, NULL). */ @@ -92,3 +96,27 @@ bloop: mov r1, r0 bl main bl chSysHalt + +/* + * Default early initialization code. It is declared weak in order to be + * replaced by the real initialization code. + * Early initialization is performed just after reset before BSS and DATA + * segments initialization. + */ +.thumb_func +.global hwinit0 +.weak hwinit0 +hwinit0: + bx lr + +/* + * Default late initialization code. It is declared weak in order to be + * replaced by the real initialization code. + * Late initialization is performed after BSS and DATA segments initialization + * and before invoking the main() function. + */ +.thumb_func +.global hwinit1 +.weak hwinit1 +hwinit1: + bx lr diff --git a/readme.txt b/readme.txt index f66459e33..12d951d58 100644 --- a/readme.txt +++ b/readme.txt @@ -75,6 +75,10 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process, *****************************************************************************
*** 0.7.2 ***
+- CHANGE: Modified the CM3 startup file in order to implement an early
+ initializaiton phase: hwinit0, the late initialization phase is now named
+ hwinit1. The demo now initializes the PLL before initializing the BSS and
+ DATA segments, this greatly optimizes the system start up time.
- Modified the STM32 demo makefile to use the latest YAGARTO toolchain as
default (arm-elf-gcc).
|