aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2021-10-26 01:50:09 -0600
committerJosh Rahm <joshuarahm@gmail.com>2021-10-26 01:53:55 -0600
commit969c054e5b1aee7fb034667f09240216ea0c6abf (patch)
tree3b0062d62ac4dac4f65d1b3395d015331ff5f18a /src
parent23acf071a670719336eafd18d33cdd0e0f02775c (diff)
downloadstm32l4-969c054e5b1aee7fb034667f09240216ea0c6abf.tar.gz
stm32l4-969c054e5b1aee7fb034667f09240216ea0c6abf.tar.bz2
stm32l4-969c054e5b1aee7fb034667f09240216ea0c6abf.zip
Fix Init Level Logging.
The linker script was broken because the init_boundaries were showing the incorrect value. It's fixed now. Unfortunately there's a bizarre bug where if I add another klogf() statement in the run_init_routines() function, I lose _all_ logging. I have no idea what is causing this! The only thing I can think of in an honsest-to-god complier bug. It probably has to do with some bizarre-o optimizations GCC is doing. In the time being I had to shuffle the finishing routines logging to the init() function directly ... unfortunate.
Diffstat (limited to 'src')
-rw-r--r--src/kern/init.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/kern/init.c b/src/kern/init.c
index 288e851..247c44f 100644
--- a/src/kern/init.c
+++ b/src/kern/init.c
@@ -5,7 +5,7 @@
#include "arch/stm32l4xxx/peripherals/system.h"
#include "kern/log.h"
-static _no_init init_level_t initlevel;
+static volatile _no_init init_level_t initlevel;
init_level_t get_system_init_level()
{
@@ -43,6 +43,8 @@ init2()
volatile uint32_t init_data_values_ptr = (uint32_t) &INIT_DATA_VALUES;
volatile uint32_t data_segment_start_ptr = (uint32_t) &DATA_SEGMENT_START;
volatile uint32_t data_segment_stop_ptr = (uint32_t) &DATA_SEGMENT_STOP;
+
+ klogf("Copy data segments from flash ... \n");
klogf(" .data ...\n");
klogf(" set (%p - %p)\n", &DATA_SEGMENT_START, &DATA_SEGMENT_STOP);
@@ -55,8 +57,6 @@ init2()
if (init_data_values_ptr & 3) {
panic("init data values pointer not aligned with sizeof(uint32_t)!\n");
}
-
- klogf("Copy data segments from flash ... \n");
/* Next, we'll copy the data sections from flash to ram. */
uint32_t* src;
@@ -107,28 +107,26 @@ void run_init_routines()
&INIT_7_END,
};
- initialize_logging();
-
void (**initfn)();
+ klogf("Init routines at (%p - %p)\n",
+ &INIT_ROUTINES_FLASH_START,
+ &INIT_ROUTINES_FLASH_STOP);
+
/* Enable a higher clock speed. This is the first thing we do
* beacuse it will boost the boot up time. */
set_system_clock_MHz(80);
- klogf("Init Level 0 ...\n");
+ klogf("[Init Level 0]\n");
for (initfn = &INIT_ROUTINES_FLASH_START; initfn < &INIT_ROUTINES_FLASH_STOP;
++initfn) {
while (initfn >= init_boundaries[initlevel] && initlevel < INIT_LEVEL_7) {
++initlevel;
- klogf("Init Level %d ...\n", initlevel);
+ klogf("[Init Level %d]\n", initlevel);
}
(*initfn)();
}
-
- while (initlevel < INIT_LEVEL_7) {
- ++initlevel;
- }
}
/*
@@ -137,11 +135,16 @@ void run_init_routines()
*/
_Noreturn void on_reset()
{
-
+ initialize_logging();
initlevel = INIT_LEVEL_0;
run_init_routines();
+ while (initlevel < INIT_LEVEL_7) {
+ ++initlevel;
+ klogf("[Init Level %d]\n", initlevel);
+ }
+
/* Jump to main. */
main();