From c5357940ab0108b4102442d07825c44d5be0d22f Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Thu, 13 Jun 2013 02:02:53 +0200 Subject: hwstub: major improvement in the stub and the tools Fix the stub in many way to correctly detect the STMP family and act upon that. Drop some unused commands and bump version. Rewrite the tool to allows scripting in lua and load the register description from an XML file using the regtools. Introduce a new tool to load and run code using the hwstub (either binary format or Rockbox additive scramble format). Also switch to an optimise version of the memcpy/move/set functions to correctly handle alignement issue (like writing a full word/half-word when possible for registers which is crucial) Change-Id: Id1d5cfe0b1b47e8b43900d32c5cd6eafae6414f6 --- utils/hwstub/stmp/Makefile | 87 ++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 53 deletions(-) (limited to 'utils/hwstub/stmp/Makefile') diff --git a/utils/hwstub/stmp/Makefile b/utils/hwstub/stmp/Makefile index ca61fe392d..7fd33c3d9e 100644 --- a/utils/hwstub/stmp/Makefile +++ b/utils/hwstub/stmp/Makefile @@ -1,58 +1,51 @@ -PREFIX?=arm-elf-eabi- -CC=$(PREFIX)gcc -LD=$(PREFIX)gcc -AS=$(PREFIX)gcc -OC=$(PREFIX)objcopy -SBTOOLS=../../sbtools/ +# +# common +# +CC=arm-elf-eabi-gcc +LD=arm-elf-eabi-gcc +AS=arm-elf-eabi-gcc +OC=arm-elf-eabi-objcopy CFLAGS=-W -Wall -Wundef -O -nostdlib -ffreestanding -Wstrict-prototypes -pipe -std=gnu99 -mcpu=arm926ej-s -fomit-frame-pointer -Wno-pointer-sign -Wno-override-init -ffunction-sections -CFLAGS_3700=$(CFLAGS) -DHAVE_STMP3700 ASFLAGS=$(CFLAGS) -D__ASSEMBLER__ -ASFLAGS_3700=$(CFLAGS_3700) -D__ASSEMBLER__ OCFLAGS= -LINKER_FILE=hwemul.lds -LDFLAGS=-lgcc -Os -nostdlib -Tlink.lds -Wl,-Map,hwemul.map -LDFLAGS_3700=-lgcc -Os -nostdlib -Tlink.lds -Wl,-Map,hwemul3700.map +LINKER_FILE=hwstub.lds +TMP_LDS=link.lds +TMP_MAP=hwstub.map +LDFLAGS=-lgcc -Os -nostdlib -T$(TMP_LDS) -Wl,-Map,$(TMP_MAP) SRC_C=$(wildcard *.c) SRC_S=$(wildcard *.S) OBJ_C=$(SRC_C:.c=.o) OBJ_S=$(SRC_S:.S=.o) -OBJ_C_3700=$(SRC_C:.c=.3700.o) -OBJ_S_3700=$(SRC_S:.S=.3700.o) OBJ=$(OBJ_C) $(OBJ_S) -OBJ_3700=$(OBJ_C_3700) $(OBJ_S_3700) OBJ_EXCEPT_CRT0=$(filter-out crt0.o,$(OBJ)) -OBJ_EXCEPT_CRT0_3700=$(filter-out crt0.3700.o,$(OBJ_3700)) DEPS=$(OBJ:.o=.d) -EXEC_ELF=hwemul.elf -EXEC_SB=hwemul.sb -EXEC_ELF_3700=hwemul3700.elf -EXEC_SB_3700=hwemul3700.sb +EXEC_ELF=hwstub.elf +# +# image production +# +TOOLS=../../../tools +SBTOOLS=../../imxtools/sbtools + +# sb (stmp37xx) +EXEC_SB=hwstub.sb ELF2SB=$(SBTOOLS)/elftosb -d -ELF2SB_CMD=-c hwemul.db -ELF2SB_KEY=-z -SBLOADER=$(SBTOOLS)/sbloader -SBLOADER_CMD=0 $(EXEC_SB) -SBLOADER_CMD_3700=0 $(EXEC_SB_3700) +ELF2SB_CMD=-c hwstub.db +ELF2SB_KEY?=-z -TOOLS=../../../../tools/ -SCRAMBLE=$(TOOLS)/scramble +# sb1 (stmp36xx) +EXEC_SB1=hwstub.sb1 +ELF2SB1_CMD=-loadjump $(EXEC_ELF) +ELF2SB1_KEY?= +ELF2SB1=$(SBTOOLS)/elftosb1 -d -EXEC=$(EXEC_SB) $(EXEC_SB_3700) $(EXEC_ELF) $(EXEC_ELF_3700) +EXEC=$(EXEC_ELF) $(EXEC_SB) $(EXEC_SB1) all: $(EXEC) # pull in dependency info for *existing* .o files -include $(DEPS) -%.3700.o: %.c - $(CC) $(CFLAGS_3700) -c -o $@ $< - $(CC) -MM $(CFLAGS_3700) $*.c > $*.d - @cp -f $*.d $*.d.tmp - @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \ - sed -e 's/^ *//' -e 's/$$/:/' >> $*.d - @rm -f $*.d.tmp - %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< $(CC) -MM $(CFLAGS) $*.c > $*.d @@ -61,32 +54,20 @@ all: $(EXEC) sed -e 's/^ *//' -e 's/$$/:/' >> $*.d @rm -f $*.d.tmp -%.3700.o: %.S - $(AS) $(ASFLAGS_3700) -c -o $@ $< - %.o: %.S $(AS) $(ASFLAGS) -c -o $@ $< -link.lds: $(LINKER_FILE) +$(TMP_LDS): $(LINKER_FILE) $(CC) -E -x c - < $< | sed '/#/d' > $@ - -$(EXEC_ELF): $(OBJ) link.lds + +$(EXEC_ELF): $(OBJ) $(TMP_LDS) $(LD) $(LDFLAGS) -o $@ $(OBJ_EXCEPT_CRT0) $(EXEC_SB): $(EXEC_ELF) $(ELF2SB) $(ELF2SB_CMD) $(ELF2SB_KEY) -o $@ -$(EXEC_ELF_3700): $(OBJ_3700) link.lds - $(LD) $(LDFLAGS_3700) -o $@ $(OBJ_EXCEPT_CRT0_3700) - -$(EXEC_SB_3700): $(EXEC_ELF_3700) - $(ELF2SB) $(ELF2SB_CMD) $(ELF2SB_KEY) -o $@ - -sbload: $(EXEC_SB) - $(SBLOADER) $(SBLOADER_CMD) - -sbload3700: $(EXEC_SB_3700) - $(SBLOADER) $(SBLOADER_CMD_3700) +$(EXEC_SB1): $(EXEC_ELF) + $(ELF2SB1) $(ELF2SB1_CMD) $(ELF2SB1_KEY) -o $@ clean: - rm -rf $(OBJ) $(OBJ_3700) $(DEPS) $(EXEC) *.map + rm -rf $(OBJ) $(DEPS) $(EXEC) $(TMP_LDS) $(TMP_MAP) \ No newline at end of file -- cgit v1.2.3