From 920d0ee53683e59a3dc1cc65e8ab7bcf4f388076 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 22:39:59 +0200 Subject: [PATCH] software: create liblitedram and move sdram init/test code to it. --- litex/soc/integration/builder.py | 1 + litex/soc/software/bios/Makefile | 14 +++++++---- litex/soc/software/common.mak | 1 + litex/soc/software/liblitedram/Makefile | 23 +++++++++++++++++++ .../soc/software/{bios => liblitedram}/lfsr.h | 0 .../software/{bios => liblitedram}/sdram.c | 0 .../software/{bios => liblitedram}/sdram.h | 0 7 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 litex/soc/software/liblitedram/Makefile rename litex/soc/software/{bios => liblitedram}/lfsr.h (100%) rename litex/soc/software/{bios => liblitedram}/sdram.c (100%) rename litex/soc/software/{bios => liblitedram}/sdram.h (100%) diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 79c6b95d3..64dca9d61 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -25,6 +25,7 @@ __all__ = ["soc_software_packages", "soc_directory", soc_software_packages = [ "libcompiler_rt", "libbase", + "liblitedram", "libliteeth", "bios" ] diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index 24d33a504..73d9ed0a2 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -11,7 +11,6 @@ CFLAGS += -DTFTP_SERVER_PORT=$(TFTP_SERVER_PORT) endif OBJECTS = isr.o \ - sdram.o \ sdcard.o \ main.o \ boot-helper.o \ @@ -59,15 +58,20 @@ endif bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) -%.elf: ../libbase/crt0-ctr.o ../libliteeth/libliteeth.a ../libbase/libbase-nofloat.a ../libcompiler_rt/libcompiler_rt.a +%.elf: ../libbase/crt0-ctr.o \ + ../libcompiler_rt/libcompiler_rt.a \ + ../libbase/libbase-nofloat.a \ + ../liblitedram/liblitedram.a \ + ../libliteeth/libliteeth.a $(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \ ../libbase/crt0-ctr.o \ $(OBJECTS) \ - -L../libliteeth \ - -L../libbase \ -L../libcompiler_rt \ + -L../libbase \ + -L../liblitedram \ + -L../libliteeth \ $(BP_LIBS) \ - -lliteeth -lbase-nofloat -lcompiler_rt \ + -lcompiler_rt -lbase-nofloat -llitedram -lliteeth \ $(BP_FLAGS) ifneq ($(OS),Windows_NT) diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index fb97fc480..808915315 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -50,6 +50,7 @@ INCLUDES = -I$(SOC_DIRECTORY)/software/include/base \ -I$(SOC_DIRECTORY)/common \ -I$(BUILDINC_DIRECTORY) \ -I$(CPU_DIRECTORY) \ + -I$(SOC_DIRECTORY)/software/liblitedram \ -I$(SOC_DIRECTORY)/software/libliteeth COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES) CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes diff --git a/litex/soc/software/liblitedram/Makefile b/litex/soc/software/liblitedram/Makefile new file mode 100644 index 000000000..070263252 --- /dev/null +++ b/litex/soc/software/liblitedram/Makefile @@ -0,0 +1,23 @@ +include ../include/generated/variables.mak +include $(SOC_DIRECTORY)/software/common.mak + +OBJECTS=sdram.o + +all: liblitedram.a + +liblitedram.a: $(OBJECTS) + $(AR) crs liblitedram.a $(OBJECTS) + +# pull in dependency info for *existing* .o files +-include $(OBJECTS:.o=.d) + +%.o: $(LIBLITEDRAM_DIRECTORY)/%.c + $(compile) + +%.o: %.S + $(assemble) + +.PHONY: all clean + +clean: + $(RM) $(OBJECTS) liblitedram.a .*~ *~ diff --git a/litex/soc/software/bios/lfsr.h b/litex/soc/software/liblitedram/lfsr.h similarity index 100% rename from litex/soc/software/bios/lfsr.h rename to litex/soc/software/liblitedram/lfsr.h diff --git a/litex/soc/software/bios/sdram.c b/litex/soc/software/liblitedram/sdram.c similarity index 100% rename from litex/soc/software/bios/sdram.c rename to litex/soc/software/liblitedram/sdram.c diff --git a/litex/soc/software/bios/sdram.h b/litex/soc/software/liblitedram/sdram.h similarity index 100% rename from litex/soc/software/bios/sdram.h rename to litex/soc/software/liblitedram/sdram.h