diff options
author | Palmer Dabbelt <palmer@sifive.com> | 2018-12-13 18:45:09 -0800 |
---|---|---|
committer | Palmer Dabbelt <palmer@sifive.com> | 2018-12-13 18:45:09 -0800 |
commit | 2077ff04a25b4393d9b88cd0ee69db3f8eb40276 (patch) | |
tree | be7b0dcc478fc97978a7efccce04a17557a37b22 | |
parent | 0c3b3d75eadffb9ab1d85e811cac55d54ac9d3ca (diff) |
Add support for generating coreip hex files via elf2hex
This just calls elf2hex on the compiled elf files, producing a hex file
that can be fed into RTL simulation.
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Makefile | 32 | ||||
-rw-r--r-- | bsp/coreip-e31-arty/settings.mk | 3 | ||||
-rw-r--r-- | bsp/coreip-s51-arty/settings.mk | 3 | ||||
-rw-r--r-- | bsp/coreip-s51/settings.mk | 3 | ||||
m--------- | scripts/elf2hex | 0 |
6 files changed, 37 insertions, 7 deletions
diff --git a/.gitmodules b/.gitmodules index 68ab3b2..060615c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "freedom-mee"] path = freedom-mee url = https://github.com/sifive/freedom-mee.git +[submodule "scripts/elf2hex"] + path = scripts/elf2hex + url = ../elf2hex @@ -192,16 +192,41 @@ mee_install: mee $(MAKE) -C $(MEE_SOURCE_PATH) install ############################################################# +# This Section is for elf2hex Compliation +############################################################# +scripts/elf2hex/build/Makefile: scripts/elf2hex/configure + @rm -rf $(dir $@) + @mkdir -p $(dir $@) + cd $(dir $@); \ + $(abspath $<) \ + --prefix=$(abspath $(dir $<))/install \ + --target=$(CROSS_COMPILE) + +scripts/elf2hex/install/bin/$(CROSS_COMPILE)-elf2hex: scripts/elf2hex/build/Makefile + $(MAKE) -C $(dir $<) install + touch -c $@ + +.PHONY: clean-elf2hex +clean-elf2hex: + rm -rf scripts/elf2hex/build scripts/elf2hex/install +clean: clean-elf2hex + +############################################################# # This Section is for Software Compilation ############################################################# PROGRAM_ELF = software/$(PROGRAM)/$(PROGRAM) +PROGRAM_HEX = software/$(PROGRAM)/$(PROGRAM).hex ifeq ($(BSP),mee) .PHONY: software software: $(PROGRAM_ELF) +ifneq ($(COREIP_MEM_WIDTH),) +software: $(PROGRAM_HEX) +endif + $(PROGRAM_ELF): \ - $(shell find $(abspath $(dir $(PROGRAM_ELF))) -type f) \ + $(addprefix software/$(PROGRAM)/,$(shell git -C software/$(PROGRAM) ls-files)) \ $(MEE_BSP_PATH)/install/lib/libmee.a \ $(MEE_BSP_PATH)/install/lib/libmee-gloss.a \ $(MEE_BSP_PATH)/mee.lds @@ -214,6 +239,11 @@ $(PROGRAM_ELF): \ LDLIBS="-Wl,--start-group -lc -lmee -lmee-gloss -Wl,--end-group" touch -c $@ +$(PROGRAM_HEX): \ + scripts/elf2hex/install/bin/$(CROSS_COMPILE)-elf2hex \ + $(PROGRAM_ELF) + $< --output $@ --input $(PROGRAM_ELF) --bit-width $(COREIP_MEM_WIDTH) + .PHONY: clean-software clean-software: $(MAKE) -C $(dir $(PROGRAM_ELF)) clean diff --git a/bsp/coreip-e31-arty/settings.mk b/bsp/coreip-e31-arty/settings.mk index eacecc3..3017c12 100644 --- a/bsp/coreip-e31-arty/settings.mk +++ b/bsp/coreip-e31-arty/settings.mk @@ -1,4 +1,3 @@ -#write_config_file - RISCV_ARCH=rv32imac RISCV_ABI=ilp32 +COREIP_HEX_WIDTH=32 diff --git a/bsp/coreip-s51-arty/settings.mk b/bsp/coreip-s51-arty/settings.mk index 31aca11..433aab1 100644 --- a/bsp/coreip-s51-arty/settings.mk +++ b/bsp/coreip-s51-arty/settings.mk @@ -1,4 +1,3 @@ -#write_config_file - RISCV_ARCH=rv64imac RISCV_ABI=lp64 +COREIP_HEX_WIDTH=32 diff --git a/bsp/coreip-s51/settings.mk b/bsp/coreip-s51/settings.mk index 31aca11..002e8cd 100644 --- a/bsp/coreip-s51/settings.mk +++ b/bsp/coreip-s51/settings.mk @@ -1,4 +1,3 @@ -#write_config_file - RISCV_ARCH=rv64imac RISCV_ABI=lp64 +COREIP_MEM_WIDTH=32 diff --git a/scripts/elf2hex b/scripts/elf2hex new file mode 160000 +Subproject 6b1d0f078e153755ee1bee1b2c9b0a05b322145 |