robseb / LinuxVSCppFPGA

C++ examples for accessing FPGA Soft-IP and Hard-IP with embedded Linux for Intel (ALTERA) SoC-FPGAs (Cyclone V)
MIT License
7 stars 1 forks source link

GetStarted C++ #4

Closed rokzitko closed 2 years ago

rokzitko commented 2 years ago

This is more a question rather than an issue. I'm trying to compile GetStarted without Visual Studio. The example works perfectly well in remote-debugging mode of Visual Studio, but when I try to compile it manually on board, I get a segmentation fault in alt_gpio_init(). It might be due to command line flags that I am using.

The Makefile is:

TARGET = main

# ALT_DEVICE_FAMILY ?= soc_cv_av HWLIBS_ROOT = Linux_alt_lib/altera_hps/hwlib

CROSS_COMPILE = arm-linux-gnueabihf-

CPPFLAGS = -g -Wall -D$(ALT_DEVICE_FAMILY) -I$(HWLIBS_ROOT)/include/$(ALT_DEVICE_FAMILY) -I$(HWLIBS_ROOT)/include/ -I.. -Wformat=0 -std=c++11 CCFLAGS = -g -Wall -D$(ALT_DEVICE_FAMILY) -I$(HWLIBS_ROOT)/include/$(ALT_DEVICE_FAMILY) -I$(HWLIBS_ROOT)/include/ -I.. -Wformat=0 LDFLAGS = -g -Wall -lpthread CXX = $(CROSS_COMPILE)g++ CC = $(CROSS_COMPILE)gcc ARCH= arm

CFILES = $(wildcard *.c) OBJECTS = $(CFILES:.c=.o)

build: $(TARGET) $(TARGET): main.o $(OBJECTS) $(CXX) $(LDFLAGS) $^ -o $@ %.o : %.cc $(CXX) $(CPPFLAGS) -c $< -o $@ %.o : %.c $(CC) $(CCFLAGS) -c $< -o $@

.PHONY: clean clean: rm -f $(TARGET) .a .o *~

I compile main.cpp and alt_generalpurpose_io.c

rokzitko commented 2 years ago

I think I figured out this one. One should not use hps.h included in Linux_alt_lib/altera_hps/hwlib, but the one in /usr/include/socal, and define LINUX_TASK_MODE. It works now.