Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker poc #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Kconfig.zephyr
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ config LINKER_SORT_BY_ALIGNMENT
in decreasing size of symbols. This helps to minimize
padding between symbols.

config VECT_REGION
bool "vector table specific allocation"
default n
help
used to specify a specific memory region for the vector table.
this can be used to split the memories region for code and vector
table.

endmenu

menu "Compiler Options"
Expand Down
19 changes: 19 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,25 @@ config FLASH_BASE_ADDRESS
normally set by the board's defconfig file and the user should generally
avoid modifying it via the menu configuration.

config VECT_BASE_ADDRESS
hex "physical memory address"
default 0
depends on VECT_REGION
help
This option specifies address of the memory region to define for the
vector table.
If unsure, leave at the default value 0.

config VECT_SIZE
hex "vector table size"
default 0
depends on VECT_REGION
help
This option specifies the size of the memory region to reseved for
the vector table. This value suould be higher tthan the vector table
size.
If unsure, leave at the default value 0.

endif # ARM || ARC || NIOS2 || X86

if ARCH_HAS_TRUSTED_EXECUTION
Expand Down
4 changes: 2 additions & 2 deletions boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
model = "STMicroelectronics STM32MP157-DK2 board";
compatible = "st,stm32mp157c-dk2", "st,stm32mp15";
chosen {
zephyr,flash = &retram;
zephyr,sram = &mcusram;
zephyr,flash = &mcusramcode;
zephyr,sram = &mcusramdata;
};
};
3 changes: 3 additions & 0 deletions boards/arm/stm32mp157c_dk2/stm32mp157c_dk2_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ CONFIG_CLOCK_CONTROL=y
CONFIG_CONSOLE=y
CONFIG_RAM_CONSOLE=y
CONFIG_RAM_CONSOLE_BUFFER_SIZE=1024

CONFIG_VECT_REGION=y
CONFIG_VECT_SIZE=0x300
28 changes: 24 additions & 4 deletions dts/arm/st/mp1/stm32mp157.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,35 @@
};
};

retram: memory0@0 {
vecttab: memory0@0 {
device_type = "memory";
compatible = "mmio-sram";
reg = <0x00000000 DT_SIZE_K(64)>;
reg = <0x00000000 0x300>;
};
mcusram: memory1@10000000 {
retram: memory1@300 {
device_type = "memory";
compatible = "mmio-sram";
reg = <0x10000000 DT_SIZE_K(256)>;
reg = <0x00000300 0xFD00>;
};
mcusramcode: memory2@10000000 {
device_type = "memory";
compatible = "mmio-sram";
reg = <0x10000000 0x30000>;
};
mcusramdata: memory3@10030000 {
device_type = "memory";
compatible = "mmio-sram";
reg = <0x10030000 0x10000>;
};
mcusram3: memory4@10040000 {
device_type = "memory";
compatible = "mmio-sram";
reg = <0x10040000 0x10000>;
};
mcusram4: memory5@10050000 {
device_type = "memory";
compatible = "mmio-sram";
reg = <0x10050000 0x10000>;
};

soc {
Expand Down
30 changes: 29 additions & 1 deletion include/arch/arm/cortex_m/scripts/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@

/* physical address of RAM */
#ifdef CONFIG_XIP
#ifdef CONFIG_VECT_REGION
#define VECT_REGION VECT
#endif
#define ROMABLE_REGION FLASH
#define RAMABLE_REGION SRAM
#else
#ifdef CONFIG_VECT_REGION
#define VECT_REGION VECT
#endif
#define ROMABLE_REGION SRAM
#define RAMABLE_REGION SRAM
#endif
Expand All @@ -40,6 +46,11 @@
#define SKIP_TO_KINETIS_FLASH_CONFIG
#endif

#ifdef CONFIG_VECT_REGION
#define VECT_ADDR CONFIG_VECT_BASE_ADDRESS
#define VECT_SIZE CONFIG_VECT_SIZE
#endif

#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)
#ifdef CONFIG_TI_CCFG_PRESENT
#define CCFG_SIZE 88
Expand Down Expand Up @@ -89,6 +100,9 @@ _region_min_align = 4;

MEMORY
{
#ifdef CONFIG_VECT_REGION
VECT (rx) : ORIGIN = VECT_ADDR, LENGTH = VECT_SIZE
#endif
FLASH (rx) : ORIGIN = ROM_ADDR, LENGTH = ROM_SIZE
#ifdef CONFIG_TI_CCFG_PRESENT
FLASH_CCFG (rwx): ORIGIN = CCFG_ADDR, LENGTH = CCFG_SIZE
Expand Down Expand Up @@ -123,9 +137,12 @@ SECTIONS
*(.iplt)
}

#ifdef CONFIG_VECT_REGION
GROUP_START(VECT_REGION)
#else
GROUP_START(ROMABLE_REGION)

_image_rom_start = ROM_ADDR;
#endif

SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
{
Expand Down Expand Up @@ -172,7 +189,18 @@ SECTIONS
KEEP(*(".kinetis_flash_config.*"))

_vector_end = .;

#ifdef CONFIG_VECT_REGION
} GROUP_LINK_IN(VECT_REGION)

GROUP_END(VECT_REGION)

GROUP_START(ROMABLE_REGION)

_image_rom_start = ROM_ADDR;
#else
} GROUP_LINK_IN(ROMABLE_REGION)
#endif

#ifdef CONFIG_CODE_DATA_RELOCATION

Expand Down