summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2023-10-04 17:57:45 -0600
committerAlejandro Soto <alejandro@34project.org>2023-10-04 17:57:45 -0600
commit8741aef09939f7775cb66058c59cbc8e321f4372 (patch)
tree153681a1b5bae5609740cbb5b316a90ef6ccffa7
parent8c747160256d1c79fb5ffbad60864e125afd9f20 (diff)
sim: implement flag overrides in environment
Diffstat (limited to '')
-rw-r--r--Makefile4
-rw-r--r--sim/gdbstub.py1
-rwxr-xr-xsim/sim.py13
3 files changed, 12 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 85c6fbc..15b5ed0 100644
--- a/Makefile
+++ b/Makefile
@@ -79,10 +79,10 @@ sim/%: $(SIM_DIR)/sim.py $(TB_SIM_DIR)/%.py exe/$(TOP) $(SIM_OBJ_DIR)/%.bin
$(if $(DISABLE_COV),,$(SIM_OBJ_DIR)/$*.cov)
vmlaunch: $(SIM_DIR)/sim.py $(SIM_DIR)/gdbstub.py exe/$(TOP)
- @$< $(SIM_DIR)/gdbstub.py $(OBJ_DIR)/$(TOP)/V$(TOP) build/u-boot.bin
+ @ENABLE_VIDEO=1 $< $(SIM_DIR)/gdbstub.py $(OBJ_DIR)/$(TOP)/V$(TOP) build/u-boot.bin
demo: $(SIM_DIR)/sim.py $(SIM_DIR)/gdbstub.py exe/$(TOP) $(DEMO_OBJ_DIR)/demo.bin
- @$< $(SIM_DIR)/gdbstub.py $(OBJ_DIR)/$(TOP)/V$(TOP) $(DEMO_OBJ_DIR)/demo.bin
+ @START_HALTED=0 $< $(SIM_DIR)/gdbstub.py $(OBJ_DIR)/$(TOP)/V$(TOP) $(DEMO_OBJ_DIR)/demo.bin
ifndef DISABLE_COV
$(COV_DIR): $(OBJ_DIR)/$(TOP)/cov.info
diff --git a/sim/gdbstub.py b/sim/gdbstub.py
index 3bd078c..88477be 100644
--- a/sim/gdbstub.py
+++ b/sim/gdbstub.py
@@ -6,7 +6,6 @@ loads = {0x0100000: 'build/uImage',
cycles = None
enable_tty = True
-enable_video = True
start_halted = True
sock, client = None, None
diff --git a/sim/sim.py b/sim/sim.py
index e1dbd41..4b3871e 100755
--- a/sim/sim.py
+++ b/sim/sim.py
@@ -214,6 +214,13 @@ def hexdump(base, memory):
def module_get(attr, default=None):
return getattr(module, attr, default) if module else None
+def module_or_env_bool(var):
+ value = os.getenv(var.upper())
+ if value is not None:
+ return bool(int(value))
+
+ return module_get(var, False)
+
COLOR_RESET = '\033[0m'
COLOR_RED = '\033[31;1m'
COLOR_GREEN = '\033[32m'
@@ -367,10 +374,10 @@ cycles = module_get('cycles', 1024)
if cycles is not None:
exec_args.extend(['--cycles', str(cycles)])
-if not module_get('enable_tty', False):
+if not module_or_env_bool('enable_tty'):
exec_args.append('--no-tty')
-if not module_get('enable_video', False):
+if not module_or_env_bool('enable_video'):
exec_args.append('--headless')
for rng in mem_dumps:
@@ -389,7 +396,7 @@ for addr, const in module_get('consts', {}).items():
for addr, filename in module_get('loads', {}).items():
exec_args.extend(['--load', f'{addr},{filename}'])
-if module_get('start_halted', False):
+if module_or_env_bool('start_halted'):
exec_args.append('--start-halted')
sim_end_sock, target_end = socket.socketpair()