Merge pull request #106 from cr1901/data-crt0

libbase/crt0-lm32.S: Add provisions for loading .data from flash.
This commit is contained in:
Tim Ansell 2018-09-22 15:21:35 +01:00 committed by GitHub
commit 1c1d87f845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -4,7 +4,7 @@ include $(SOC_DIRECTORY)/software/common.mak
OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o \ 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 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 libbase.a: $(OBJECTS) vsnprintf.o
$(AR) crs 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 %.o: $(LIBBASE_DIRECTORY)/%.S
$(assemble) $(assemble)
crt0-$(CPU)-flash.o: $(LIBBASE_DIRECTORY)/crt0-$(CPU).S
$(CC) -c -DFLASH_DATA_SECTION $(CFLAGS) -o $@ $<
.PHONY: all clean .PHONY: all clean
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 .*~ *~ $(RM) libbase.a libbase-nofloat.a .*~ *~

View File

@ -112,6 +112,25 @@ _crt0:
mvhi sp, hi(_fstack) mvhi sp, hi(_fstack)
ori sp, sp, lo(_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 */ /* Clear BSS */
mvhi r1, hi(_fbss) mvhi r1, hi(_fbss)
ori r1, r1, lo(_fbss) ori r1, r1, lo(_fbss)