diff --git a/common/Makefile b/common/Makefile index fcfc2a58b..31363fcf4 100644 --- a/common/Makefile +++ b/common/Makefile @@ -35,7 +35,7 @@ XXD := $(PYRUN) $(CFU_ROOT)/scripts/xxd.py LD_DIR := $(BUILD_DIR)/ld GEN_LD_DIR := $(SOC_SOFTWARE_DIR)/include/generated -LDSCRIPT := $(LD_DIR)/linker.ld +LDSCRIPT ?= $(LD_DIR)/linker.ld LDSCRIPTS := $(LDSCRIPT) $(GEN_LD_DIR)/output_format.ld $(GEN_LD_DIR)/regions.ld SRC_DIR := $(BUILD_DIR)/src diff --git a/proj/hps_accel/Makefile b/proj/hps_accel/Makefile index 1467119b6..e3375ff6f 100644 --- a/proj/hps_accel/Makefile +++ b/proj/hps_accel/Makefile @@ -59,6 +59,15 @@ DEFINES += INCLUDE_MODEL_HPS RUN_MENU_ITEMS=1 1 c TEST_MENU_ITEMS=3 q +# Use a custom linker script for this project +export LDSCRIPT +LDSCRIPT = $(PROJ_DIR)/linker.ld + +# Add constants defined in gateware/constants.py to C++ build +BUILD_DIR_EXTRA_DEP = $(BUILD_DIR)/src/gateware_constants.h + +include ../proj.mk + # Customise arguments to Litex: export EXTRA_LITEX_ARGS EXTRA_LITEX_ARGS += --cpu-variant slim+cfu @@ -67,9 +76,5 @@ ifeq '$(TARGET)' 'digilent_arty' EXTRA_LITEX_ARGS += --sys-clk-freq 75000000 endif -# Add constants defined in gateware/constants.py to C++ build -BUILD_DIR_EXTRA_DEP = $(BUILD_DIR)/src/gateware_constants.h -include ../proj.mk - $(BUILD_DIR)/src/gateware_constants.h: $(BUILD_DIR)/src $(PROJ_DIR)/gateware/constants.py $(PYRUN) -m gateware.constants $@ diff --git a/proj/hps_accel/linker.ld b/proj/hps_accel/linker.ld new file mode 100644 index 000000000..e2c891539 --- /dev/null +++ b/proj/hps_accel/linker.ld @@ -0,0 +1,67 @@ +INCLUDE output_format.ld +ENTRY(_start) + +__DYNAMIC = 0; + +INCLUDE regions.ld + + +SECTIONS +{ + .text : + { + _ftext = .; + *(.text.start) + /* Place the ConvPerChannel4x4() and LoadInput() functions sequentially + * to prevent one from evicting the other from the instruction cache. */ + */conv_accel.o(.text.*ConvPerChannel4x4*) + */blocks.o(.text.*LoadInput*) + *(.text .stub .text.* .gnu.linkonce.t.*) + _etext = .; + } > main_ram + /*} > rom */ + + .rodata : + { + . = ALIGN(8); + _frodata = .; + *(.rodata .rodata.* .gnu.linkonce.r.*) + *(.rodata1) + *(.srodata .srodata.*) + . = ALIGN(8); + _erodata = .; + } > main_ram + /*} > rom */ + + .data : AT (ADDR(.rodata) + SIZEOF (.rodata)) + { + . = ALIGN(8); + _fdata = .; + *(.data .data.* .gnu.linkonce.d.*) + *(.data1) + *(.ramtext .ramtext.*) + _gp = ALIGN(16); + *(.sdata .sdata.* .gnu.linkonce.s.* .sdata2 .sdata2.*) + _edata = ALIGN(16); /* Make sure _edata is >= _gp. */ + } > main_ram + /*} > sram */ + + .bss : AT (ADDR(.data) + SIZEOF (.data)) + { + . = ALIGN(16); + _fbss = .; + *(.dynsbss) + *(.sbss .sbss.* .gnu.linkonce.sb.*) + *(.scommon) + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(8); + _ebss = .; + _end = .; + } > main_ram + /*} > sram */ +} + +PROVIDE(_fstack = ORIGIN(main_ram) + LENGTH(main_ram) - 4); +/* PROVIDE(_fstack = ORIGIN(sram) + LENGTH(sram) - 4); */