In this short demo we will discuss how to build a baremetal and Linux application targeting the RFDC driver from the git sources (ie without SDK or Petalinux)
Building Libmetal:
The libmetal library can be downloaded from here. However, in this demo I will be using the libmetal that is delivered with embeddedsw here
Code Block | ||||
---|---|---|---|---|
| ||||
git clone https://github.com/Xilinx/embeddedsw
cd embeddedsw
git checkout xilinx-v2018.3 |
Libmetal dependencies:
The libmetal needs the libsysfs. If the user is on Ubuntu, then they can just use the command below:
Code Block | ||||
---|---|---|---|---|
| ||||
sudo apt-get install libsysfs-dev |
Users, can also build this from git sources:
Code Block | ||||
---|---|---|---|---|
| ||||
git clone https://github.com/Distrotech/sysfsutils
autoreconfig -f -i
configure
make |
Copy the toolchain.cmake into embeddedsw/ThirdParty/sw_services/libmetal/src/libmetal/cmake/platforms
Code Block | ||||
---|---|---|---|---|
| ||||
cd embeddedsw/ThirdParty/sw_services/libmetal/src/libmetal
mkdir build_libm
cd build_libm
cmake .. –DCMAKE_INCLUDE_PATH=<path to sysfsutils> -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/toolchain.cmake |
For example:
Tip | ||
---|---|---|
| ||
Note: if using the Ubuntu, and the libsysfs is installed. then you would not need the -DCMAKE_INCLUDE_PATH |
To build, use the make:
Building baremetal RFDC driver:
Open the baremetal makefile at embeddedsw\XilinxProcessorIPLib\drivers\rfdc\src
Note, there are two makefiles here; MakeFile and MakeFile.Linux
Make the changes below to the make file to add the Library, and Include paths:
Code Block | ||||
---|---|---|---|---|
| ||||
COMPILER=
ARCHIVER=
CP=cp
COMPILER_FLAGS=
EXTRA_COMPILER_FLAGS=
LIB=libxil.a
RELEASEDIR=.
INCLUDEDIR=../../../../ThirdParty/sw_services/libmetal/src/libmetal/build_libm/lib/include
INCLUDES=-I./. -I${INCLUDEDIR}
INCLUDEFILES=xrfdc_hw.h xrfdc.h xrfdc_mts.h
LIBSOURCES=*.c
OUTS = *.o
libs:
echo "Compiling rfdc"
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES) -D __BAREMETAL__
$(ARCHIVER) -r ${RELEASEDIR}/${LIB} $(OUTS)
make clean
include:
${CP} ${INCLUDEFILES} ${INCLUDEDIR}
clean:
rm -rf ${OUTS} |
User can pass the make parameters as shown below.
Note: the libxil.a will need to be copied manually into the same location as we built the libmetal.a file above. This is the archived library of all the other compiled driver .o files in the BSP:
This can be found here psu_cortexa53_0\lib
User will also need all the header files in the include folder. In SDK these are populated using the HSI API to read the IP used. It then finds the matching driver (from the MLD file). It then populates the
Include folder in the BSP with the header files for the drivers.
Building Linux RFDC driver:
Open the baremetal makefile at embeddedsw\XilinxProcessorIPLib\drivers\rfdc\src
Note, there are two makefiles here; MakeFile and MakeFile.Linux
Users can rename, the MakeFile to MakeFile.BareMetal, and rename the MakeFile.Linux to MakeFile.
Make the changes below to the make file to add the Library, and Include paths:
Code Block | ||||
---|---|---|---|---|
| ||||
APP = rfdc
LIBSOURCES=*.c
OUTS = *.o
NAME := rfdc
MAJOR = 1
MINOR = 1
VERSION = $(MAJOR).$(MINOR)
LD_LIBRARY_PATH = /home/stephenm/cases/rfdc-standalone/libmetal/build_libm/lib
LD_INCLUDE_PATH = /home/stephenm/cases/rfdc-standalone/libmetal/build_libm/lib/include /home/stephenm/cases/rfdc-standalone/sysfsutils
all: lib$(NAME).so
lib$(NAME).so.$(VERSION): $(OUTS)
$(CC) $(LDFLAGS) $(OUTS) -shared -Wl,-soname,lib$(NAME).so.$(MAJOR) -o lib$(NAME).so.$(VERSION) -L$(LD_LIBRARY_PATH) -lmetal
lib$(NAME).so: lib$(NAME).so.$(VERSION)
rm -f lib$(NAME).so.$(MAJOR) lib$(NAME).so
ln -s lib$(NAME).so.$(VERSION) lib$(NAME).so.$(MAJOR)
ln -s lib$(NAME).so.$(MAJOR) lib$(NAME).so
%.o: %.c
$(CC) $(CFLAGS) -c -fPIC -I$(LD_INCLUDE_PATH) $(LIBSOURCES)
clean:
rm -rf *.o *.so *.so.* |
Then just call this make file: