{nemu,npc}: inject mainargs to the bin file
* this removes the dependency of trm.c to keep the mainargs up-to-date
This commit is contained in:
parent
c3ffbc97c3
commit
c52a41181f
5 changed files with 52 additions and 15 deletions
|
@ -8,22 +8,28 @@ AM_SRCS := platform/nemu/trm.c \
|
|||
platform/nemu/mpe.c
|
||||
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
CFLAGS += -I$(AM_HOME)/am/src/platform/nemu/include
|
||||
LDFLAGS += -T $(AM_HOME)/scripts/linker.ld \
|
||||
--defsym=_pmem_start=0x80000000 --defsym=_entry_offset=0x0
|
||||
LDFLAGS += --gc-sections -e _start
|
||||
NEMUFLAGS += -l $(shell dirname $(IMAGE).elf)/nemu-log.txt
|
||||
|
||||
CFLAGS += -DMAINARGS=\"$(mainargs)\"
|
||||
CFLAGS += -I$(AM_HOME)/am/src/platform/nemu/include
|
||||
.PHONY: $(AM_HOME)/am/src/platform/nemu/trm.c
|
||||
MAINARGS_MAX_LEN = 64
|
||||
MAINARGS_PLACEHOLDER = The insert-arg rule in Makefile will insert mainargs here.
|
||||
CFLAGS += -DMAINARGS_MAX_LEN=$(MAINARGS_MAX_LEN) -DMAINARGS_PLACEHOLDER=\""$(MAINARGS_PLACEHOLDER)"\"
|
||||
|
||||
insert-arg: image
|
||||
@python $(AM_HOME)/tools/insert-arg.py $(IMAGE).bin $(MAINARGS_MAX_LEN) "$(MAINARGS_PLACEHOLDER)" "$(mainargs)"
|
||||
|
||||
image: image-dep
|
||||
@$(OBJDUMP) -d $(IMAGE).elf > $(IMAGE).txt
|
||||
@echo + OBJCOPY "->" $(IMAGE_REL).bin
|
||||
@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(IMAGE).elf $(IMAGE).bin
|
||||
|
||||
run: image
|
||||
run: insert-arg
|
||||
$(MAKE) -C $(NEMU_HOME) ISA=$(ISA) run ARGS="$(NEMUFLAGS)" IMG=$(IMAGE).bin
|
||||
|
||||
gdb: image
|
||||
gdb: insert-arg
|
||||
$(MAKE) -C $(NEMU_HOME) ISA=$(ISA) gdb ARGS="$(NEMUFLAGS)" IMG=$(IMAGE).bin
|
||||
|
||||
.PHONY: insert-arg
|
||||
|
|
|
@ -12,10 +12,20 @@ CFLAGS += -fdata-sections -ffunction-sections
|
|||
LDFLAGS += -T $(AM_HOME)/scripts/linker.ld \
|
||||
--defsym=_pmem_start=0x80000000 --defsym=_entry_offset=0x0
|
||||
LDFLAGS += --gc-sections -e _start
|
||||
CFLAGS += -DMAINARGS=\"$(mainargs)\"
|
||||
.PHONY: $(AM_HOME)/am/src/riscv/npc/trm.c
|
||||
|
||||
MAINARGS_MAX_LEN = 64
|
||||
MAINARGS_PLACEHOLDER = The insert-arg rule in Makefile will insert mainargs here.
|
||||
CFLAGS += -DMAINARGS_MAX_LEN=$(MAINARGS_MAX_LEN) -DMAINARGS_PLACEHOLDER=\""$(MAINARGS_PLACEHOLDER)"\"
|
||||
|
||||
insert-arg: image
|
||||
@python $(AM_HOME)/tools/insert-arg.py $(IMAGE).bin $(MAINARGS_MAX_LEN) "$(MAINARGS_PLACEHOLDER)" "$(mainargs)"
|
||||
|
||||
image: image-dep
|
||||
@$(OBJDUMP) -d $(IMAGE).elf > $(IMAGE).txt
|
||||
@echo + OBJCOPY "->" $(IMAGE_REL).bin
|
||||
@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(IMAGE).elf $(IMAGE).bin
|
||||
|
||||
run: insert-arg
|
||||
echo "TODO: add command here to run simulation"
|
||||
|
||||
.PHONY: insert-arg
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue