...
The sample code encompasses operations associated with the NN model, along with preprocessing and postprocessing related to the NN model. We need to cross-compile this code into an application that can execute on c3v C3V Linux. Additionally, we should utilize it along with the generated NB file.
Table of Contents |
---|
1. Building
1.1. Linux
...
Terminal Cross Compile
When compiling NN-related applications, it is necessary to include SDK's headers and libraries.
...
Code Block |
---|
BIN=sampleApp VIVANTE_SDK_DIR=Path to VIVANTE SDK directory TOOLCHAIN=Path to toolchain directory VIVANTE_SDK_INC=$(VIVANTE_SDK_DIR)/include VIVANTE_SDK_LIB=$(VIVANTE_SDK_DIR)/lib CROSS_COMPILE=$(TOOLCHAIN)/aarch64-none-linux-gnu- CC=$(CROSS_COMPILE)gcc CXX=$(CROSS_COMPILE)g++ CFLAGS=-Wall -O3 INCLUDE += -I$(VIVANTE_SDK_INC) -I$(VIVANTE_SDK_INC)/HAL -I$(VIVANTE_SDK_INC)/ovxlib LIBS += -L$(VIVANTE_SDK_LIB) -L./ -L$(STD_LOG_INC) LIBS += -lOpenVX -lOpenVXU -lOpenVX -lCLC -lVSC -lGAL -ljpeg -lovxlib -lm LIBS += -lNNArchPerf -lArchModelSw LIBS += -lstdc++ -ldl -lpthread -lgcc_s CFLAGS += $(INCLUDE) -fPIC SRCS=${wildcard *.c} SRCS+=${wildcard *.cpp} OBJS=$(addsuffix .o, $(basename $(SRCS))) .SUFFIXES: .hpp .cpp .c .cpp.o: $(CXX) $(CFLAGS) -std=c++11 -c $< .c.o: $(CC) $(CFLAGS) -c $< all: $(BIN) $(BIN): $(OBJS) $(CC) $(CFLAGS) $(LFLAGS) $(OBJS) -o $@ $(LIBS) rm -rf *.o clean: rm -rf *.o rm -rf $(BIN) $(LIB) rm -rf *~ |
1.2. Vivante IDE Cross Compile
Environment Preparations
C3V toolchain
toolchain\crossgcc\gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu
C3V OVXLIB files
...
Import
...
Project
select File->import:
...
select "General->Existing Projects into Workspace":
...
select the checkbox of the project and the checkbox of "copy project into workspace". Then press "Finish" to import the project.
...
Setting
This step sets the cross-compiler as the C3V toolchain and the library search path as the C3V OVXLIB folder. In the IDE main window, select "Project->Properties". Select "Tool Chain Editor" in the pop-up window. In "Current toolchain", select "Cross Gcc with openVX":
...
Choose "Settings" and select "Cross Settings", please configure the Prefix and Path of the C3V toolchain. configure the C3V OVXLIB search path. Then press "OK".
...
Build
Right-click on the model project in the Project Explorer pane, and select Build Project. The build results will appear in the Console pane.
...
After building success, the binary file is in the folder "Project/Debug/"
2. Running on the C3V Linux
Copy the application into C3V Linux and running:
...