Commit 62dd78e4 authored by Dimitris Lampridis's avatar Dimitris Lampridis

Merge branch '33-makefile-for-firmware-does-not-work-with-gcc-version-11-2' into 'master'

Resolve "makefile for firmware does not work with gcc version 11.2"

Closes #33

See merge request be-cem-edl/common/mockturtle!28
parents d27a3c6f e490b771
......@@ -27,13 +27,9 @@ software_build:
EDL_CI_SW_PATHS: software
test_fw_build:
stage: build
image: gitlab-registry.cern.ch/be-cem-edl/evergreen/gitlab-ci/build-fec-sw:latest
script:
- make -C tests/firmware
artifacts:
paths:
- tests/firmware/**/*.bin
extends: .build_urv_fw
variables:
EDL_CI_FW_PATHS: tests/firmware
trtl-project-creator:
interruptible: true
......
......@@ -38,10 +38,8 @@ RT_GIT_VERSION = 0x$(shell git rev-parse --short=8 HEAD || echo "0") # empty if
AUTOCONF = $(src)/$(BUILDDIR)/include/generated/autoconf.h
CROSS_COMPILE_TARGET ?= riscv32-elf-
# FIXME the mult/div is broken, for the time being remove it completely
# -march=rv32im should be the future option
CFLAGS += -D__TRTL_FIRMWARE__
CFLAGS += -mabi=ilp32 -march=rv32im -ffunction-sections -fdata-sections
CFLAGS ?= -mabi=ilp32 -march=rv32im
ASFLAGS ?= -mabi=ilp32 -march=rv32im_zicsr
CXXFLAGS += -fno-rtti -fno-exceptions
LDFLAGS += -lgcc -lc -Wl,--gc-sections
TRTL_LD_DIR ?= $(src)
......@@ -74,7 +72,7 @@ STRIP = $(CROSS_COMPILE_TARGET)strip
MEM_INIT_GEN = $(GEN_CORES)/tools/mem_init_gen.py
CFLAGS += -Wall -D__TRTL_FIRMWARE__ -DARCH=urv
CFLAGS += -Wall -D__TRTL_FIRMWARE__ -DARCH=urv -ffunction-sections -fdata-sections
CFLAGS += -I.
CFLAGS += -I$(BUILDDIR)/include
CFLAGS += -I$(TRTL_FW)
......@@ -178,7 +176,7 @@ $(BUILDDIR)/%.o: %.cpp
$(POSTCOMPILE)
$(BUILDDIR)/%.o: %.S
${CC} $(DEPFLAGS) $(CFLAGS) $(LDFLAGS) -c $< -o $@
${CC} $(DEPFLAGS) $(ASFLAGS) $(LDFLAGS) -c $< -o $@
$(POSTCOMPILE)
clean:
......
......@@ -760,7 +760,15 @@ static inline uint32_t trtl_get_runtime_cycles()
static inline void __smem_atomic_op(volatile int *p, int x,
enum trtl_smem_modifier type)
{
#pragma GCC diagnostic push
/* The way SMEM atomic operations are implemented, it looks like we are trying
to access way beyond the allocated size of p (TRTL_SMEM_TYPE_TO_RANGE here will
add some multiple of TRTL_SMEM_SIZE). GCC -Wall will catch this but in this particular
case it's a false alarm, the Mock Turtle HDL will use the extra address bits to determine
the operation to perform on 'p' */
#pragma GCC diagnostic ignored "-Warray-bounds"
*(volatile int *)(p + (TRTL_SMEM_TYPE_TO_RANGE(type) >> 2)) = x;
#pragma GCC diagnostic pop
}
......
......@@ -2,6 +2,11 @@
#
# SPDX-License-Identifier: LGPL-2.1-or-later
.module_cleanup: &module_cleanup
- rmmod mockturtle-$CARD-demo || true
- rmmod mockturtle || true
- rmmod $CARD-fmc-carrier || true
test_on_hw:
stage: validate
parallel:
......@@ -23,6 +28,7 @@ test_on_hw:
_BASE_DEST: $CI_PROJECT_DIR/$EDL_CI_EOS_OUTPUT_DIR
_BITSTREAM_DEST: $_BASE_DEST/bitstreams
_SW_DEST: $_BASE_DEST/software
_FW_DEST: $_BASE_DEST/firmware
rules:
- if: $CARD == "spec"
variables:
......@@ -37,19 +43,21 @@ test_on_hw:
MODULE: "FMC-SVEC"
_BITSTREAM_NAME: "svec-mt_demo.bin"
before_script:
- *module_cleanup
- export PATH=$PATH:/acc/local/share/ht_tools/L867/git/latest
- rmmod mockturtle-demo-$CARD || true
- rmmod mockturtle || true
- rmmod $CARD-fmc-carrier || true
- sh /usr/local/drivers/scripts/${CARD}_fmc_carrier_install.sh
- export TMP_DIR=$(mktemp -d)
- mkdir -p $TMP_DIR/usr/lib/modules
- cp -r /usr/local/lib/modules/$(uname -r) $TMP_DIR/usr/lib/modules
- find $TMP_DIR/usr/lib/modules -name mockturtle*.ko -delete
- tar xvf $_SW_DEST/mockturtle-software-L867.tar.xz -C $TMP_DIR/
- tar xvf $_SW_DEST/mockturtle-software-L867${CI_COMMIT_TAG:+-$CI_COMMIT_TAG}.tar.xz -C $TMP_DIR/
- tar xvf $_FW_DEST/mockturtle-firmware${CI_COMMIT_TAG:+-$CI_COMMIT_TAG}.tar.xz -C $TMP_DIR/
- export MODPROBE_ROOT=$TMP_DIR/usr
- depmod -b $MODPROBE_ROOT
- export FIRMWARE_PATH=$TMP_DIR/bitstreams
- modprobe -d $MODPROBE_ROOT -v htvic
- modprobe -d $MODPROBE_ROOT -v i2c-mux
- modprobe -d $MODPROBE_ROOT -v i2c-ocores
- export FIRMWARE_PATH=$TMP_DIR/lib/firmware
- mkdir -p $FIRMWARE_PATH
- tar xf $_BITSTREAM_DEST/${CARD}_mt_demo${CI_COMMIT_TAG:+-$CI_COMMIT_TAG}.tar.xz -C $FIRMWARE_PATH
- ln -sf $FIRMWARE_PATH/${CARD}_mt_demo.bin $FIRMWARE_PATH/$_BITSTREAM_NAME
......@@ -68,7 +76,7 @@ test_on_hw:
- source /usr/local/drivers/scripts/environment.sh && card_slot_fpga_configure $BUS $SLOT mt_demo
- modprobe -d $MODPROBE_ROOT mockturtle
- modprobe -d $MODPROBE_ROOT mockturtle-${CARD}-demo
- export MT_NODE=$(ls -d /sys/bus/platform/devices/id\:$VID$PID.*/mock-turtle.* | cut -d '.' -f 4)
- export MT_NODE=$(ls -l /sys/bus/platform/devices/mock-turtle.* | grep $DEVID/$FPGAID/id:$VID$PID | cut -d '.' -f 2)
- export LD_LIBRARY_PATH=$TMP_DIR/usr/local/lib
- source /acc/local/share/python/acc-py/base/pro/setup.sh
- acc-py venv $TMP_DIR/venv
......@@ -80,7 +88,9 @@ test_on_hw:
- tail -n +1 /sys/kernel/debug/$DEVID/$FPGAID/build_info
- $TMP_DIR/usr/local/bin/lsmockturtle
- cd tests
- pytest --id $MT_NODE --junitxml=./pytest.xml
- pytest --id $MT_NODE --fw-path $FIRMWARE_PATH --junitxml=./pytest.xml
after_script:
- *module_cleanup
artifacts:
when: always
paths:
......
......@@ -8,11 +8,23 @@ import PyMockTurtle
import pytest
import time
class FirmwareLocator:
@staticmethod
def get_path(fw):
_dir_name, _file_name = os.path.split(fw)
_module_path = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
if pytest.fw_path:
return os.path.join(pytest.fw_path, _file_name)
return os.path.join(_module_path, _dir_name, _file_name)
@pytest.fixture(scope="module")
def fw_locator():
return FirmwareLocator
@pytest.fixture(scope="module")
def devid():
return pytest.dev_id
def build_default_cfg():
config = PyMockTurtle.TrtlConfig()
config.signature = PyMockTurtle.TrtlConfig.TRTL_CONFIG_ROM_SIGNATURE
......@@ -64,10 +76,6 @@ def trtl_shm(devid):
dev = PyMockTurtle.TrtlDevice(devid)
return dev.shm
@pytest.fixture(scope="module")
def trtl_firmware_dir():
return os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
@pytest.fixture(scope="module", params=[2**x for x in range(5)])
def trtl_msg(request):
"""This provides a list of test messages. Each test message contains
......@@ -95,7 +103,9 @@ def trtl_version_exp():
def pytest_addoption(parser):
parser.addoption("--id", type=lambda x: int(x, 0),
required=True, help="Mockturtle identifier")
parser.addoption("--fw-path", default=None,
help="Path to test firmware. Defaults to source locations.")
def pytest_configure(config):
pytest.dev_id = config.getoption("--id")
pytest.fw_path = config.getoption("--fw-path")
......@@ -9,8 +9,8 @@ import PyMockTurtle
import time
@pytest.fixture
def firmware_file_config(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir, "firmware/config_rom/fw-config-rom.bin")
def firmware_file_config(fw_locator):
return fw_locator.get_path("firmware/config_rom/fw-config-rom.bin")
class TestConfig(object):
......
......@@ -12,18 +12,16 @@ import time
import PyMockTurtle
@pytest.fixture
def firmware_file_loop(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir, "firmware/cpu-loop/fw-loop.bin")
def firmware_file_loop(fw_locator):
return fw_locator.get_path("firmware/cpu-loop/fw-loop.bin")
@pytest.fixture
def firmware_binary_byte_addressing(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir,
"firmware/cpu-byte-addressing/fw-byte-addressing.bin")
def firmware_binary_byte_addressing(fw_locator):
return fw_locator.get_path("firmware/cpu-byte-addressing/fw-byte-addressing.bin")
@pytest.fixture
def firmware_binary_notification(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir,
"firmware/cpu-notify/fw-notify.bin")
def firmware_binary_notification(fw_locator):
return fw_locator.get_path("firmware/cpu-notify/fw-notify.bin")
class TestCPU(object):
confirm = 'OK\r\n'
......
......@@ -12,24 +12,20 @@ import multiprocessing
import errno
@pytest.fixture
def trtl_binary_hmq_purge(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir,
"firmware/hmq-purge/fw-hmq-purge.bin")
def trtl_binary_hmq_purge(fw_locator):
return fw_locator.get_path("firmware/hmq-purge/fw-hmq-purge.bin")
@pytest.fixture
def trtl_binary_hmq_async_send(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir,
"firmware/hmq-async-send/fw-hmq-async-send.bin")
def trtl_binary_hmq_async_send(fw_locator):
return fw_locator.get_path("firmware/hmq-async-send/fw-hmq-async-send.bin")
@pytest.fixture
def trtl_binary_hmq_async_recv(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir,
"firmware/hmq-async-recv/fw-hmq-async-recv.bin")
def trtl_binary_hmq_async_recv(fw_locator):
return fw_locator.get_path("firmware/hmq-async-recv/fw-hmq-async-recv.bin")
@pytest.fixture
def trtl_binary_hmq_sync(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir,
"firmware/hmq-sync/fw-hmq-sync.bin")
def trtl_binary_hmq_sync(fw_locator):
return fw_locator.get_path("firmware/hmq-sync/fw-hmq-sync.bin")
def do_sync_mult(q, hmq, msg):
......
......@@ -10,9 +10,8 @@ import random
import time
@pytest.fixture
def trtl_binary_frm(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir,
"firmware/rt-frm/fw-rt-frm.bin")
def trtl_binary_frm(fw_locator):
return fw_locator.get_path("firmware/rt-frm/fw-rt-frm.bin")
class TestFirmwareFramework(object):
......
......@@ -10,8 +10,8 @@ import stat
import time
@pytest.fixture
def firmware_file_serial(trtl_firmware_dir):
return os.path.join(trtl_firmware_dir, "firmware/serial/fw-serial.bin")
def firmware_file_serial(fw_locator):
return fw_locator.get_path("firmware/serial/fw-serial.bin")
def firmware_output():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment