From 9d4da737ffd282b01c8c0ea9bf33f8b497aa619b Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Fri, 21 Sep 2018 10:14:50 -0400 Subject: [PATCH] libbase/crt0-lm32.S: Add provisions for loading .data from flash. :100644 100644 e0cd7153 34428845 M litex/soc/software/libbase/crt0-lm32.S --- litex/soc/software/libbase/Makefile | 7 +++++-- litex/soc/software/libbase/crt0-lm32.S | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/litex/soc/software/libbase/Makefile b/litex/soc/software/libbase/Makefile index b7f7d4cb..bf876204 100644 --- a/litex/soc/software/libbase/Makefile +++ b/litex/soc/software/libbase/Makefile @@ -4,7 +4,7 @@ include $(SOC_DIRECTORY)/software/common.mak OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o \ system.o id.o uart.o time.o qsort.o strtod.o spiflash.o strcasecmp.o -all: crt0-$(CPU).o libbase.a libbase-nofloat.a +all: crt0-$(CPU).o crt0-$(CPU)-flash.o libbase.a libbase-nofloat.a libbase.a: $(OBJECTS) vsnprintf.o $(AR) crs libbase.a $(OBJECTS) vsnprintf.o @@ -24,8 +24,11 @@ vsnprintf-nofloat.o: $(LIBBASE_DIRECTORY)/vsnprintf.c %.o: $(LIBBASE_DIRECTORY)/%.S $(assemble) +crt0-$(CPU)-flash.o: $(LIBBASE_DIRECTORY)/crt0-$(CPU).S + $(CC) -c -DFLASH_DATA_SECTION $(CFLAGS) -o $@ $< + .PHONY: all clean clean: - $(RM) $(OBJECTS) crt0-$(CPU).o vsnprintf.o vsnprintf-nofloat.o + $(RM) $(OBJECTS) crt0-$(CPU).o crt0-$(CPU)-flash.o vsnprintf.o vsnprintf-nofloat.o $(RM) libbase.a libbase-nofloat.a .*~ *~ diff --git a/litex/soc/software/libbase/crt0-lm32.S b/litex/soc/software/libbase/crt0-lm32.S index e0cd7153..3b65ba9f 100644 --- a/litex/soc/software/libbase/crt0-lm32.S +++ b/litex/soc/software/libbase/crt0-lm32.S @@ -112,6 +112,25 @@ _crt0: mvhi sp, hi(_fstack) ori sp, sp, lo(_fstack) +#ifdef FLASH_DATA_SECTION + /* Load DATA */ + mvhi r1, hi(_erodata) + ori r1, r1, lo(_erodata) + mvhi r2, hi(_fdata) + ori r2, r2, lo(_fdata) + mvhi r3, hi(_edata) + ori r3, r3, lo(_edata) +.moveDATA: + be r2, r3, .doBSS + lw r4, (r1+0) + sw (r2+0), r4 + /* _edata is aligned to 16 bytes. Use word-xfers. */ + addi r1, r1, 4 + addi r2, r2, 4 + bi .moveDATA +#endif + +.doBSS: /* Clear BSS */ mvhi r1, hi(_fbss) ori r1, r1, lo(_fbss) -- 2.30.2