diff options
| author | Alejandro Soto <alejandro@34project.org> | 2023-10-04 17:57:45 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2023-10-04 17:57:45 -0600 |
| commit | 8741aef09939f7775cb66058c59cbc8e321f4372 (patch) | |
| tree | 153681a1b5bae5609740cbb5b316a90ef6ccffa7 | |
| parent | 8c747160256d1c79fb5ffbad60864e125afd9f20 (diff) | |
sim: implement flag overrides in environment
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | sim/gdbstub.py | 1 | ||||
| -rwxr-xr-x | sim/sim.py | 13 |
3 files changed, 12 insertions, 6 deletions
@@ -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 @@ -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() |
