From 0b5d0ab87cf0a7cdc05e2892843ef9cbe89a7ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20N=C3=B3brega?= Date: Thu, 21 Dec 2023 21:32:14 +0000 Subject: [PATCH 1/2] fix(pc_emul): Allow configurable pc-emul settings; Update README. - Update Ethernet info in README. - Move ethernet CONSOLE_CMD to sw_build.mk (this allows it to be used in pc_emul). - Change order of the `software/Makefile` includes and settings to allow for more flexibility in pc_emul configuration via sw_build.mk --- README.md | 8 ++++--- scripts/iob_soc_utils.py | 18 +++------------- software/sw_build.mk | 3 --- submodules/LIB/software/Makefile | 36 +++++++++++++++++--------------- 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 65a694c78..92ef2766e 100644 --- a/README.md +++ b/README.md @@ -292,8 +292,10 @@ These values will select which network interface and which python environment to For example, you can add the following to your `~/.bashrc`: ```Bash -# IOb-SoC console network interface +# IOb-SoC console network interface (loopback interfacce) export RMAC_ADDR=000000000000 -# IOb-SoC console python interperter with `CAP_NET_RAW` capability. -export IOB_CONSOLE_PYTHON_ENV=python +# Custom IOb-SoC console python interperter with `CAP_NET_RAW` capability. +export IOB_CONSOLE_PYTHON_ENV=/opt/pyeth3/bin/python ``` + +You could also set those variables in the `config_build.mk` file of the build directory. diff --git a/scripts/iob_soc_utils.py b/scripts/iob_soc_utils.py index 3fd439f41..9b5a800d8 100755 --- a/scripts/iob_soc_utils.py +++ b/scripts/iob_soc_utils.py @@ -232,28 +232,16 @@ def post_setup_iob_soc(python_module, num_extmem_connections): with open(python_module.build_dir + "/hardware/fpga/fpga_build.mk", "w") as file: file.writelines(contents) - # Set variables in sim_build.mk + # Set variables in sw_build.mk if ethernet_macro: - with open( - python_module.build_dir + "/hardware/simulation/sim_build.mk", "r" - ) as file: + with open(python_module.build_dir + "/software/sw_build.mk", "r") as file: contents = file.readlines() contents.insert(0, "\n") # Set custom ethernet CONSOLE_CMD contents.insert( 0, - 'CONSOLE_CMD=rm -f soc2cnsl cnsl2soc; $(IOB_CONSOLE_PYTHON_ENV) $(PYTHON_DIR)/console_ethernet.py -L -c $(PYTHON_DIR)/console.py -m "$(RMAC_ADDR)"\n', + 'CONSOLE_CMD ?=rm -f soc2cnsl cnsl2soc; $(IOB_CONSOLE_PYTHON_ENV) $(PYTHON_DIR)/console_ethernet.py -L -c $(PYTHON_DIR)/console.py -m "$(RMAC_ADDR)"\n', ) - contents.insert(0, "#Lines below were auto generated by iob_soc_utils.py\n") - with open( - python_module.build_dir + "/hardware/simulation/sim_build.mk", "w" - ) as file: - file.writelines(contents) - - # Set variables in sw_build.mk - if ethernet_macro: - with open(python_module.build_dir + "/software/sw_build.mk", "r") as file: - contents = file.readlines() contents.insert( 0, """ diff --git a/software/sw_build.mk b/software/sw_build.mk index cf9b9c3db..88c5e5b53 100644 --- a/software/sw_build.mk +++ b/software/sw_build.mk @@ -67,9 +67,6 @@ iob_soc_boot: ######################################### # Local pc-emul makefile settings for custom pc emulation targets. -# Include directory with iob_soc_system.h -EMUL_INCLUDE+=-I. -Isrc - # SOURCES EMUL_SRC+=src/iob_soc_firmware.c EMUL_SRC+=src/printf.c diff --git a/submodules/LIB/software/Makefile b/submodules/LIB/software/Makefile index c5d951268..928a297be 100644 --- a/submodules/LIB/software/Makefile +++ b/submodules/LIB/software/Makefile @@ -5,6 +5,18 @@ include ../config_build.mk +######################################### +# General settings # +######################################### + +PYTHON_DIR = ../scripts + +# include local build segment +# all previously defined variables can be overwritten in this file +ifneq ($(wildcard sw_build.mk),) +include sw_build.mk +endif + ######################################### # Embedded settings # ######################################### @@ -32,26 +44,16 @@ INCLUDES ?=-I. -Isrc ######################################### # compiler flags -EMUL_CFLAGS=-Os -std=gnu99 -Wl,--strip-debug +EMUL_CFLAGS ?=-Os -std=gnu99 -Wl,--strip-debug -CONSOLE_CMD=rm -f soc2cnsl cnsl2soc; ../scripts/console.py -L +CONSOLE_CMD ?=rm -f soc2cnsl cnsl2soc; ../scripts/console.py -L -EMUL_INCLUDES=-I. -Isrc +EMUL_INCLUDES ?=-I. -Isrc EMUL_HDR+=$(wildcard src/*_emul.h) EMUL_SRC+=$(wildcard src/*_emul.c) -######################################### -# General settings # -######################################### - -# include local build segment -# all previously defined variables can be overwritten in this file -ifneq ($(wildcard sw_build.mk),) -include sw_build.mk -endif - ######################################### # Embedded targets # ######################################### @@ -84,15 +86,15 @@ build_emul: fw_emul @echo "build" #board client command -BOARD_GRAB_CMD=../scripts/board_client.py grab 300 +BOARD_GRAB_CMD ?=../scripts/board_client.py grab 300 -run_emul: build_emul +test.log: build_emul $(BOARD_GRAB_CMD) -s './fw_emul' -c '$(CONSOLE_CMD)' -test_emul: run_emul +run_emul: test.log test "$$(cat test.log)" = "Test passed!" -.PHONY: build_emul run_emul test_emul +.PHONY: build_emul run_emul ######################################### # General targets # From 9642fa5eea792dc3cb810d4a38159bfd2fd35285 Mon Sep 17 00:00:00 2001 From: arturum1 <34355224+arturum1@users.noreply.github.com> Date: Fri, 22 Dec 2023 06:09:25 +0000 Subject: [PATCH 2/2] Update pc-emul-test in Makefile Makefile in build_dir no longer has target pc-emul-test. Now, the pc-emul-run target compares the generated test.log file. This way it is consistent with the sim-run and fpga-run targets. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5e60deaff..fbdc7cdc8 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ pc-emul-run: nix-shell --run 'make clean setup && make -C ../$(CORE)_V*/ pc-emul-run' pc-emul-test: - nix-shell --run 'make clean setup && make -C ../$(CORE)_V*/ pc-emul-test' + nix-shell --run 'make clean setup && make -C ../$(CORE)_V*/ pc-emul-run' sim-run: nix-shell --run 'make clean setup INIT_MEM=$(INIT_MEM) USE_EXTMEM=$(USE_EXTMEM) && make -C ../$(CORE)_V*/ fw-build'