Skip to content

Commit

Permalink
Add DTS file
Browse files Browse the repository at this point in the history
When you build using the command make ENABLE_SYSTEM=1 -j$(nproc),
the default target in the Makefile is invoked. At this stage, the
Device Tree Blob (DTB) should already be built before executing
rv32emu. Therefore, system.mk is included before the all target
in the Makefile.
  • Loading branch information
ChinYikMing committed Nov 4, 2024
1 parent 0915b75 commit e2bb7f0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
19 changes: 2 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ CFLAGS += $(CFLAGS_NO_CET)

OBJS_EXT :=

ifeq ($(call has, SYSTEM), 1)
OBJS_EXT += system.o
endif

# Integer Multiplication and Division instructions
ENABLE_EXT_M ?= 1
$(call set-feature, EXT_M)
Expand Down Expand Up @@ -214,8 +210,9 @@ $(OUT)/emulate.o: CFLAGS += -foptimize-sibling-calls -fomit-frame-pointer -fno-s
include mk/external.mk
include mk/artifact.mk
include mk/wasm.mk
include mk/system.mk

all: config $(BIN)
all: config $(BUILD_DTB) $(BIN)

OBJS := \
map.o \
Expand All @@ -242,18 +239,6 @@ ifeq ($(call has, GDBSTUB), 1)
$(OBJS): $(GDBSTUB_LIB)
endif

# Peripherals for system emulation
ifeq ($(call has, SYSTEM), 1)
DEV_OUT := $(OUT)/devices
DEV_SRC := src/devices
$(DEV_OUT)/%.o: $(DEV_SRC)/%.c $(deps_emcc)
$(Q)mkdir -p $(DEV_OUT)
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) $(CFLAGS_emcc) -c -MMD -MF $@.d $<
DEV_OBJS := $(patsubst $(DEV_SRC)/%.c, $(DEV_OUT)/%.o, $(wildcard $(DEV_SRC)/*.c))
deps += $(DEV_OBJS:%.o=%.o.d)
endif

$(OUT)/%.o: src/%.c $(deps_emcc)
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) $(CFLAGS_emcc) -c -MMD -MF $@.d $<
Expand Down
Binary file modified build/minimal.dtb
Binary file not shown.
20 changes: 20 additions & 0 deletions mk/system.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Peripherals for system emulation
ifeq ($(call has, SYSTEM), 1)
DEV_OUT := $(OUT)/devices
DEV_SRC := src/devices

DTC ?= dtc
$(OUT)/minimal.dtb: $(DEV_SRC)/minimal.dts
$(VECHO) " DTC\t$@\n"
$(Q)$(DTC) $^ -o $@
BUILD_DTB := $(OUT)/minimal.dtb

$(DEV_OUT)/%.o: $(DEV_SRC)/%.c $(deps_emcc)
$(Q)mkdir -p $(DEV_OUT)
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) $(CFLAGS_emcc) -c -MMD -MF $@.d $<
DEV_OBJS := $(patsubst $(DEV_SRC)/%.c, $(DEV_OUT)/%.o, $(wildcard $(DEV_SRC)/*.c))
deps += $(DEV_OBJS:%.o=%.o.d)

OBJS_EXT += system.o
endif
2 changes: 1 addition & 1 deletion src/riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#if RV32_HAS(SYSTEM)
#include "devices/plic.h"
#include "devices/uart.h"
#endif /* RV32_HAS(EXT_SYSTEM) */
#endif /* RV32_HAS(SYSTEM) */

#if RV32_HAS(EXT_F)
#define float16_t softfloat_float16_t
Expand Down

0 comments on commit e2bb7f0

Please sign in to comment.