diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2021-10-26 00:04:44 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2021-10-26 00:04:44 -0600 |
commit | dbbe83bd8882fe18e26f6305a1f425145bfea8db (patch) | |
tree | a18e100a31ec6330fd906b4f82820703b3894f26 /src/kern/panic.c | |
parent | 04da2a442392c5bf3dcf4ca4611f42af7b35e596 (diff) | |
download | stm32l4-dbbe83bd8882fe18e26f6305a1f425145bfea8db.tar.gz stm32l4-dbbe83bd8882fe18e26f6305a1f425145bfea8db.tar.bz2 stm32l4-dbbe83bd8882fe18e26f6305a1f425145bfea8db.zip |
Fixed annoying bug with bootup when compiling with new GCC.
The problem was the BSS segment was not aligned with size 4,
thus the routine to clear the BSS segment was infinite looping,
clobbering everything in it's wake until it ran off the memory edge and
caused a hard fault.
This commit does a couple of things.
1. Fixes the alignment issue in the linker script
2. Panics if the bss/data segments are not aligned properly
3. Makes the logging the _first_ thing to initialize. Much easier to
debug that way!
Diffstat (limited to 'src/kern/panic.c')
-rw-r--r-- | src/kern/panic.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/kern/panic.c b/src/kern/panic.c index de1d143..e005bcc 100644 --- a/src/kern/panic.c +++ b/src/kern/panic.c @@ -15,30 +15,26 @@ _Noreturn void panic(const char* fmt, ...) uint32_t base[0]; disable_all_interrupts(); - if (get_system_init_level() > INIT_LEVEL_2) { - va_list l; - va_start(l, fmt); + va_list l; + va_start(l, fmt); - kerr_logf("** Kernel Panic! **\n"); - kerr_vlogf(fmt, l); - kerr_logf("** Stack:\n"); + kerr_logf("** Kernel Panic! **\n"); + kerr_vlogf(fmt, l); + kerr_logf("** Stack:\n"); - int i = 0; - for (; i < 20 && &base[i] != (void*)STACK_TOP; ++ i) { - kerr_logf(" (%p) %p\n", &base[i], base[i]); - } + int i = 0; + for (; i < 20 && &base[i] != (void*)STACK_TOP; ++ i) { + kerr_logf(" (%p) %p\n", &base[i], base[i]); + } + + set_system_clock_MHz(4); /* reduce power usage while we do nothing. */ + gpio_reserved_pin_t pin3 = get_sysled(); - set_system_clock_MHz(4); /* reduce power usage while we do nothing. */ - for(;;); - } else { - set_system_clock_MHz(4); /* reduce power usage while we do nothing. */ - gpio_reserved_pin_t pin3 = get_sysled(); - for (;;) { - set_gpio_pin_high(pin3); - delay(100000); - set_gpio_pin_low(pin3); - delay(100000); - } + for (;;) { + set_gpio_pin_high(pin3); + delay(100000); + set_gpio_pin_low(pin3); + delay(100000); } } #endif |