Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pc_emul): Allow configurable pc-emul settings; Update README. #689

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
18 changes: 3 additions & 15 deletions scripts/iob_soc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
"""
Expand Down
3 changes: 0 additions & 3 deletions software/sw_build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 19 additions & 17 deletions submodules/LIB/software/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
#########################################
Expand Down Expand Up @@ -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 #
#########################################
Expand Down Expand Up @@ -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 #
Expand Down