From ee1169dc05e182834a207f483656a44d34d4be91 Mon Sep 17 00:00:00 2001 From: Jeremy Schlatter Date: Sat, 13 Jul 2024 17:40:55 -0700 Subject: [PATCH] lab004/firmware: fix firmware build Fixes two separate issues that were keeping lab004 from working. The first is a minor but important oversight from https://github.com/litex-hub/fpga_101/commit/b36c77a8f004cbdc130e7a492d79499a5025917c: It added a definition for crt0.o but then didn't refer to it anywhere, effectively removing crt0.o from the build. That was likely the cause of https://github.com/litex-hub/fpga_101/issues/12. The second issue I don't understand as well, but seems to be exactly the same as https://github.com/enjoy-digital/litex/pull/1007, from which I copied the fix. --- lab004/firmware/Makefile | 2 +- lab004/firmware/linker.ld | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lab004/firmware/Makefile b/lab004/firmware/Makefile index 577de49..9a0990b 100644 --- a/lab004/firmware/Makefile +++ b/lab004/firmware/Makefile @@ -3,7 +3,7 @@ BUILD_DIR=../build/ include $(BUILD_DIR)/software/include/generated/variables.mak include $(SOC_DIRECTORY)/software/common.mak -OBJECTS=isr.o main.o +OBJECTS=isr.o main.o crt0.o all: firmware.bin diff --git a/lab004/firmware/linker.ld b/lab004/firmware/linker.ld index 36af682..fba8124 100644 --- a/lab004/firmware/linker.ld +++ b/lab004/firmware/linker.ld @@ -10,6 +10,12 @@ SECTIONS .text : { _ftext = .; + /* Make sure crt0 files come first, and they, and the isr */ + /* don't get disposed of by greedy optimisation */ + *crt0*(.text) + KEEP(*crt0*(.text)) + KEEP(*(.text.isr)) + *(.text .stub .text.* .gnu.linkonce.t.*) _etext = .; } > main_ram