Sorry for the late answer but I have been watching some tutorials and experimenting a bit.
First of all, thank you for the information.
To give a little update on my current state:
I am working with the files found in the boot code repo.
First thing I did was create a file called my_test_data.c which only contains data (integer, array, etc.) to see if I can relocate them during booting.
Let us look at the two interesting arrays:
1) int normal_arr[] = {0x55555555, 0x55555555, 0x55555555, 0x55555555, 0x55555555, 0x55555555, 0x55555555, 0x55555555};
2) int attribute_arr[] __attribute__ ((section(".my_test_section"))) = {0x66666666, 0x66666666, 0x66666666, 0x66666666, 0x66666666, 0x66666666, 0x66666666, 0x66666666};
The idea is to later on have my additional data in seperate files each with its own attribute.
Then I modified the linker script by adding this line in the MEMORY section:
CUT01 : ORIGIN = 0x1C020000, LENGTH = 0x1000
I also added to the SECTION section: (more than necessary but I wanted to make sure)
.my_test_section :
{
. = ALIGN(4);
KEEP(*(.my_test_section))
_mts_start = .;
*(.text.*)
*(.text)
*(.data.*)
*(.data)
*(.comment)
*(.comment.*)
*(.my_test_section)
*(.my_test_section*)
*(.my_test_section.*)
*(.attribute_arr)
*(.attribute_arr*)
*(.attribute_arr.*)
. = ALIGN(4);
_mts_end = .;
} > CUT01
I also created the map file to get a better understanding of what happens with the data in my_test_data.c (or rather the output file that gets generated from it).
Regarding the two arrays I can see them in the map file:
The normal_arr:
.data.normal_arr
0x000000001a000450 0x20 /.../bootloader/fc/my_test_data.o
0x000000001a000450 normal_arr
The attribute_arr:
.my_test_section
0x000000001c020000 0x20 /.../bootloader/fc/my_test_data.o
0x000000001c020000 attribute_arr
Now as you can see both of them are 36 Bytes which seems to be correct as both arrays are 8 integer.
But for some reason the attribute_arr doesn't end up in L2 at the address I specified (or anywhere else for that matter) but the normal_arr resides in ROM (which makes sense as it's part of the .data section).
I thought that adding the appropriate entries in the linker script and creating data with the section attribute should be enough but somewhere along the line it seems like I have made a mistake or several mistakes.
Maybe someone has done something similar and wants to share their knowledge?
Thank you,
LPLA
First of all, thank you for the information.
To give a little update on my current state:
I am working with the files found in the boot code repo.
First thing I did was create a file called my_test_data.c which only contains data (integer, array, etc.) to see if I can relocate them during booting.
Let us look at the two interesting arrays:
1) int normal_arr[] = {0x55555555, 0x55555555, 0x55555555, 0x55555555, 0x55555555, 0x55555555, 0x55555555, 0x55555555};
2) int attribute_arr[] __attribute__ ((section(".my_test_section"))) = {0x66666666, 0x66666666, 0x66666666, 0x66666666, 0x66666666, 0x66666666, 0x66666666, 0x66666666};
The idea is to later on have my additional data in seperate files each with its own attribute.
Then I modified the linker script by adding this line in the MEMORY section:
CUT01 : ORIGIN = 0x1C020000, LENGTH = 0x1000
I also added to the SECTION section: (more than necessary but I wanted to make sure)
.my_test_section :
{
. = ALIGN(4);
KEEP(*(.my_test_section))
_mts_start = .;
*(.text.*)
*(.text)
*(.data.*)
*(.data)
*(.comment)
*(.comment.*)
*(.my_test_section)
*(.my_test_section*)
*(.my_test_section.*)
*(.attribute_arr)
*(.attribute_arr*)
*(.attribute_arr.*)
. = ALIGN(4);
_mts_end = .;
} > CUT01
I also created the map file to get a better understanding of what happens with the data in my_test_data.c (or rather the output file that gets generated from it).
Regarding the two arrays I can see them in the map file:
The normal_arr:
.data.normal_arr
0x000000001a000450 0x20 /.../bootloader/fc/my_test_data.o
0x000000001a000450 normal_arr
The attribute_arr:
.my_test_section
0x000000001c020000 0x20 /.../bootloader/fc/my_test_data.o
0x000000001c020000 attribute_arr
Now as you can see both of them are 36 Bytes which seems to be correct as both arrays are 8 integer.
But for some reason the attribute_arr doesn't end up in L2 at the address I specified (or anywhere else for that matter) but the normal_arr resides in ROM (which makes sense as it's part of the .data section).
I thought that adding the appropriate entries in the linker script and creating data with the section attribute should be enough but somewhere along the line it seems like I have made a mistake or several mistakes.
Maybe someone has done something similar and wants to share their knowledge?
Thank you,
LPLA