From 403355a8edf41745b7ac301337d53e978b489f42 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 22:49:12 +0200 Subject: [PATCH] software: create liblitescard and move sdcard init/test code to it. --- litex/soc/integration/builder.py | 1 + litex/soc/software/bios/Makefile | 15 ++++++------ .../soc/software/bios/commands/cmd_litedram.c | 3 ++- .../software/bios/commands/cmd_litesdcard.c | 3 ++- litex/soc/software/common.mak | 3 ++- litex/soc/software/liblitesdcard/Makefile | 23 +++++++++++++++++++ .../software/{bios => liblitesdcard}/sdcard.c | 0 .../software/{bios => liblitesdcard}/sdcard.h | 0 8 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 litex/soc/software/liblitesdcard/Makefile rename litex/soc/software/{bios => liblitesdcard}/sdcard.c (100%) rename litex/soc/software/{bios => liblitesdcard}/sdcard.h (100%) diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 64dca9d61..496903eb7 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -27,6 +27,7 @@ soc_software_packages = [ "libbase", "liblitedram", "libliteeth", + "liblitesdcard", "bios" ] diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index 73d9ed0a2..a4c39660c 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -11,18 +11,17 @@ CFLAGS += -DTFTP_SERVER_PORT=$(TFTP_SERVER_PORT) endif OBJECTS = isr.o \ - sdcard.o \ - main.o \ boot-helper.o \ boot.o \ helpers.o \ cmd_bios.o \ + cmd_mem.o \ cmd_boot.o \ + cmd_spiflash.o \ cmd_litedram.o \ cmd_liteeth.o \ - cmd_mem.o \ - cmd_litesdcard.o \ - cmd_spiflash.o \ + cmd_litesdcard.o \ + main.o ifneq "$(or $(TERM_NO_COMPLETE),$(TERM_MINI))" "" CFLAGS += -DTERM_NO_COMPLETE @@ -62,7 +61,8 @@ bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) ../libcompiler_rt/libcompiler_rt.a \ ../libbase/libbase-nofloat.a \ ../liblitedram/liblitedram.a \ - ../libliteeth/libliteeth.a + ../libliteeth/libliteeth.a \ + ../liblitesdcard/liblitesdcard.a $(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \ ../libbase/crt0-ctr.o \ $(OBJECTS) \ @@ -70,8 +70,9 @@ bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) -L../libbase \ -L../liblitedram \ -L../libliteeth \ + -L../liblitesdcard \ $(BP_LIBS) \ - -lcompiler_rt -lbase-nofloat -llitedram -lliteeth \ + -lcompiler_rt -lbase-nofloat -llitedram -lliteeth -llitesdcard \ $(BP_FLAGS) ifneq ($(OS),Windows_NT) diff --git a/litex/soc/software/bios/commands/cmd_litedram.c b/litex/soc/software/bios/commands/cmd_litedram.c index dbca41291..0d05b2533 100644 --- a/litex/soc/software/bios/commands/cmd_litedram.c +++ b/litex/soc/software/bios/commands/cmd_litedram.c @@ -5,9 +5,10 @@ #include +#include "sdram.h" + #include "../command.h" #include "../helpers.h" -#include "../sdram.h" /** * Command "sdrrow" diff --git a/litex/soc/software/bios/commands/cmd_litesdcard.c b/litex/soc/software/bios/commands/cmd_litesdcard.c index d9545e07a..63347667d 100644 --- a/litex/soc/software/bios/commands/cmd_litesdcard.c +++ b/litex/soc/software/bios/commands/cmd_litesdcard.c @@ -5,9 +5,10 @@ #include +#include "sdcard.h" + #include "../command.h" #include "../helpers.h" -#include "../sdcard.h" /** * Command "sdclk" diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index 808915315..1431ad552 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -51,7 +51,8 @@ INCLUDES = -I$(SOC_DIRECTORY)/software/include/base \ -I$(BUILDINC_DIRECTORY) \ -I$(CPU_DIRECTORY) \ -I$(SOC_DIRECTORY)/software/liblitedram \ - -I$(SOC_DIRECTORY)/software/libliteeth + -I$(SOC_DIRECTORY)/software/libliteeth \ + -I$(SOC_DIRECTORY)/software/liblitesdcard COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES) CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(SOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding diff --git a/litex/soc/software/liblitesdcard/Makefile b/litex/soc/software/liblitesdcard/Makefile new file mode 100644 index 000000000..7b0c749a7 --- /dev/null +++ b/litex/soc/software/liblitesdcard/Makefile @@ -0,0 +1,23 @@ +include ../include/generated/variables.mak +include $(SOC_DIRECTORY)/software/common.mak + +OBJECTS=sdcard.o + +all: liblitesdcard.a + +liblitesdcard.a: $(OBJECTS) + $(AR) crs liblitesdcard.a $(OBJECTS) + +# pull in dependency info for *existing* .o files +-include $(OBJECTS:.o=.d) + +%.o: $(LIBLITESDCARD_DIRECTORY)/%.c + $(compile) + +%.o: %.S + $(assemble) + +.PHONY: all clean + +clean: + $(RM) $(OBJECTS) liblitesdcard.a .*~ *~ diff --git a/litex/soc/software/bios/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c similarity index 100% rename from litex/soc/software/bios/sdcard.c rename to litex/soc/software/liblitesdcard/sdcard.c diff --git a/litex/soc/software/bios/sdcard.h b/litex/soc/software/liblitesdcard/sdcard.h similarity index 100% rename from litex/soc/software/bios/sdcard.h rename to litex/soc/software/liblitesdcard/sdcard.h