aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2021-10-26 00:38:58 -0600
committerJosh Rahm <joshuarahm@gmail.com>2021-10-26 00:38:58 -0600
commit4507bff773fd4cc540c91c6c3696ac3cf9a21b3c (patch)
tree589fb2a21d77913254baaa38cf4528026b0a902b
parentf9b12f748b557994b958115c04fd1591b322248e (diff)
downloadstm32l4-4507bff773fd4cc540c91c6c3696ac3cf9a21b3c.tar.gz
stm32l4-4507bff773fd4cc540c91c6c3696ac3cf9a21b3c.tar.bz2
stm32l4-4507bff773fd4cc540c91c6c3696ac3cf9a21b3c.zip
Removed the requirement for the init data to be aligned.
I don't yet know how to configure the the initscript to align the INIT_DATA_VALUES. Nothing seems to work. But whatever, it seems like things work and it's a very minor performance hit.
-rw-r--r--.vimsource2
-rw-r--r--linker/linker_script.ld4
-rw-r--r--src/kern/init.c24
3 files changed, 17 insertions, 13 deletions
diff --git a/.vimsource b/.vimsource
new file mode 100644
index 0000000..f31eb62
--- /dev/null
+++ b/.vimsource
@@ -0,0 +1,2 @@
+noremap <silent> <S-á>\ :<C-u>call popbuf#toggle("minicom")<cr>
+noremap <silent> <S-á>t :<C-u>call popbuf#toggle("Terminal")<cr>
diff --git a/linker/linker_script.ld b/linker/linker_script.ld
index 1817fbd..83dcca0 100644
--- a/linker/linker_script.ld
+++ b/linker/linker_script.ld
@@ -9,16 +9,18 @@ SECTIONS
{
/* This is where the code goes. */
. = ORIGIN(flash);
- .text : {
+ .text ALIGN(0x100) : {
*(.vectors); /* All .vector sections go here. */
*(.text); /* All .text sections go here. */
} >flash
.data : {
+ . = ALIGN(0x04);
/* Data segment as defined in the flash. */
INIT_DATA_VALUES = LOADADDR(.data);
/* Data segment where it will be in memory. */
+ . = ALIGN(0x04);
DATA_SEGMENT_START = .;
*(.data);
DATA_SEGMENT_STOP = .;
diff --git a/src/kern/init.c b/src/kern/init.c
index 4c2bfcd..b156dd7 100644
--- a/src/kern/init.c
+++ b/src/kern/init.c
@@ -44,17 +44,17 @@ init2()
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(" .data ...\n");
+ klogf(" set (%p - %p)\n", &DATA_SEGMENT_START, &DATA_SEGMENT_STOP);
+ klogf(" from (%p)\n", &INIT_DATA_VALUES);
+
if ((data_segment_start_ptr | data_segment_start_ptr) & 3) {
panic(".data segment not aligned with sizeof(uint32_t)!\n");
}
- if (init_data_values_ptr & 3) {
- panic("init data values pointer not aligned with sizeof(uint32_t)!\n");
- }
-
- if ((bss_start_ptr | bss_end_ptr) & 3) {
- panic(".bss data segment not aligned with sizeof(uint32_t)!\n");
- }
+ // 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");
@@ -62,10 +62,6 @@ init2()
uint32_t* src;
uint32_t* dest;
- klogf(" .data ...\n");
- klogf(" set (%p - %p)\n", &DATA_SEGMENT_START, &DATA_SEGMENT_STOP);
- klogf(" from (%p)\n", &INIT_DATA_VALUES);
-
src = &INIT_DATA_VALUES;
dest = &DATA_SEGMENT_START;
@@ -77,6 +73,10 @@ init2()
klogf(" .bss ...\n");
klogf(" clear (%p - %p)\n", &BSS_START, &BSS_END);
+ if ((bss_start_ptr | bss_end_ptr) & 3) {
+ panic(".bss data segment not aligned with sizeof(uint32_t)!\n");
+ }
+
/* Everything in the BSS segment is set to zero. */
dest = &BSS_START;
@@ -118,7 +118,7 @@ void run_init_routines()
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) {
+ while (initfn >= init_boundaries[initlevel] && initlevel < INIT_LEVEL_7) {
++initlevel;
klogf("Init Level %d ...\n", initlevel);
}