Jump to content
  • 0

zmodlib development on Eclypse Z7 without SDK


bpwilliams

Question

I am trying to run the ZmodADC1410 demo directly on Ubuntu with a Petalinux built kernel running on the Eclypse Z7 board. I have successfully run the demo using SDK but want to do development directly on the device.

When I try to build the project natively I get errors, in part:

zmod.cpp:(.text+0x22): undefined reference to `fnInitZmod(unsigned int, int, void*, void*)'
zmod.cpp:(.text+0x32): undefined reference to `fnInitDMA(unsigned int, dma_direction, int)'
zmod.cpp:(.text+0x44): undefined reference to `fnInitFlash(unsigned int, unsigned short)'

All other errors are similar in that they are looking for 'fnSOMETHING()' type definitions.

Is there a file or library specifically in the sysroot files or somewhere else I am missing?

I can see the device in /sys/class/uio and the dma device.

 

Thanks!

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Hello,

What branch have you used after cloning the repository on github ? Please tell us the location you used for cloning the Zmod libraries. Also, be sure that you are cloning the submodules, as zmodlib is a submodule on git.

Also, be sure you are defining LINUX_APP in your project.

As Ionel mentioned, the fnInitZmod is declared in zmodlib\zmod\reg.h and defined in zmodlib/zmod/linux/reg/reg.c.

Please check that the mentioned files are visible under selected branch.

For more details please read https://digilent.com/reference/zmod/zmodbaselibraryuserguide

Link to comment
Share on other sites

  • 0
Posted (edited)

I am using the master branch of zmodlib and I've also tried the one that came with the first ZmodADC1410 demo.

I am going into the subfolders and compiling dependencies such as reg.c, dma.c, etc. using commands similar to:

gcc -DLINUX_APP reg.c -c -luio

For some of these files I had to add the #include <stdbool.h> header to compile it.

For cpp files zmod.cpp and zmodadc1410.cpp I am using:

gcc -std=c++11 -DLINUX_APP zmodadc1410.cpp -c -luio

I am then trying to link to the main.cpp for the ZmodADC1410_Demo_Linux using linking command:
gcc -std=c++11 -DLINUX_APP main.cpp -o main -I "../../zmodlib/" -I "../../zmodlib/Zmod/" -I "../../zmodlib/Zmod/linux/" -I "../../zmodlib/Zmod/linux/dma/" -I "../../zmodlib/Zmod/linux/flash/" -I "../../zmodlib/Zmod/linux/reg/" -I "../../zmodlib/ZmodADC1410/" ../../zmodlib/Zmod/linux/reg/reg.o ../../zmodlib/Zmod/linux/flash/flash.o ../../zmodlib/Zmod/linux/dma/dma.o ../../zmodlib/Zmod/linux/dma/libaxidma.o ../../zmodlib/Zmod/linux/utils.o ../../zmodlib/ZmodADC1410/zmodadc1410.o ../../zmodlib/Zmod/zmod.o -luio -lstdc++

I also uploaded an image depciting the directory structure. I'm not super competent in building/linking things so hopefully I am just doing it incorrectly. Thanks for you help.

 

build_command.png

Edited by bpwilliams
img bad
Link to comment
Share on other sites

  • 0

We only supported the build through the Xilinx tools.
Still, I am guessing that you should be able to build using native gcc compiler, having a proper makefile or build command. This might be a difficult task if you are a beginner.
Taking a look on the screen caption you sent, it seems that the source files (.c) from zmodlib/Zmod/linux/reg, zmodlib/Zmod/linux/flash/, zmodlib/Zmod/linux/dma are never compiled. They are not mentioned in your command line, you only add .o files.

Link to comment
Share on other sites

  • 0

Made some progress, I used g++ (was using gcc before) to compile all the source files:
g++ -std=c++11 -Wall -DLINUX_APP reg.c -c

Then my final linking command was
g++ -std=c++11 -DLINUX_APP main.cpp -o main -I "../../zmodlib/" -I "../../zmodlib/Zmod/" -I "../../zmodlib/Zmod/linux/" -I "../../zmodlib/Zmod/linux/dma/" -I "../../zmodlib/Zmod/linux/flash/" -I "../../zmodlib/Zmod/linux/reg/" -I "../../zmodlib/ZmodADC1410/" ../../zmodlib/Zmod/linux/reg/reg.o ../../zmodlib/Zmod/linux/flash/flash.o ../../zmodlib/Zmod/linux/dma/dma.o ../../zmodlib/Zmod/linux/dma/libaxidma.o ../../zmodlib/Zmod/linux/utils.o ../../zmodlib/ZmodADC1410/zmodadc1410.o ../../zmodlib/Zmod/zmod.o -luio -lstdc++

 

However, not currently seeing my linux dma device. I will summarize my steps completely once I resolve that issue.

Link to comment
Share on other sites

  • 0

Most probably you will encounter issues due to the Xilinx internal libraries which you aren't linking and Xilinx SDK does.

Anyway is a good opportunity for you to learn a lot and enjoy at least stages success. Good luck, and I wish you to enjoy the final success.

Link to comment
Share on other sites

  • 0

Got it working! Here's my cheat sheet to replicate.

Install PetaLinux 2019.1, my install directory is in /home/bw/Xilinx/petalinux-v2019.1

*** You will also need Vivado 2019.1 and SDK 2019.1 if you want to run baremetal or modify the actual hardware project (do additional/different stuff on the FPGA).
*** To collect data with the ADC in Linux using the demo setup, I think you just need Petalinux 2019.1

Get Ubuntu and Format SD Card (just do steps 2, 5, and 6 in link):
https://medium.com/developments-and-implementations-on-zynq-7000-ap/install-ubuntu-16-04-lts-on-zynq-zc702-using-petalinux-2016-4-e1da902eaff7

Get the Digilent Demo for the Eclypse Z7 Zmod ADC 1410:
git clone --recursive https://github.com/Digilent/Eclypse-Z7 -b zmod_adc/master

Source your Petalinux:
source /home/bw/Xilinx/petalinux-v2019.1/settings.sh

The libuio.git build links do not work in this Eclypse-Z7 petalinux project. My workaround is to go into Eclypse-Z7/os/project-spec/meta-user/recipes-apps
and delete the 'libuio' folder. Then later you can install libuio manually in the Ubuntu OS running on the Eclypse Z7.

From Eclypse-Z7/os/ directory run (change to your appropriate directory, probably not "bw"!):

petalinux-config --get-hw-description=/home/bw/Documents/fpga/Eclypse-Z7/hw/hw_handoff/
***In this menu set the rootfs to run from SD card

petalinux-config -c kernel
***In this menu goto device drivers-->userspace I/O-->select (*) all Xilinx UIO options
***also              device drivers-->IRQ chipset-->the Xilinx option (not 100% sure you need this)
***save the file by entering on save option, quick keys MAY be unreliable

petalinux-build

petalinux-package --boot --force --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot

Copy image.ub, boot.bin, and system.dtb from images folder into boot parition on SD card.
You also need a uEnv.txt (given below at end of this).

You should now also have Ubuntu as a rootfs on the SD card, copy the 'ZmodADC1410_Demo_Linux' and the 'zmodlib' folders into a folder onto the rootfs partion, I put mine into
/home/ubuntu/RH

Move ZmodADC1410 demo app from Eclypse-Z7-SW folder onto Eclypse Z7 Ubuntu rootfs

add LINUX_APP to compile
for example:
    
    g++ -std=c++11 -Wall -DLINUX_APP dma.c -c

You need to compile all the .c files within the subfolders of zmodlib
many files require adding #include <stdbool.h>, those needing it will give you an error about "bool" this or that
Some may require libuio.h which I got from:
git clone --recursive https://github.com/Digilent/libuio checkout
you can then ``make" these files to build a library to put with outher library files in /lib/ for example
you can also put libuio.h into /usr/include

list of files to compile: dma.c, libaxidma.c, flash.dma, reg.dma, utils.c, zmod.cpp, zmodadc1410.cpp

Finally, go to the directory holding main.cpp, for me its /home/ubuntu/RH/ZmodADC1410_Demo_Linux/src/

Link/compile main.cpp

g++ -std=c++11 -DLINUX_APP main.cpp -o main -I "../../zmodlib/" -I "../../zmodlib/Zmod/" -I "../../zmodlib/Zmod/linux/" -I "../../zmodlib/Zmod/linux/dma/" -I "../../zmodlib/Zmod/linux/flash/" -I "../../zmodlib/Zmod/linux/reg/" -I "../../zmodlib/ZmodADC1410/" ../../zmodlib/Zmod/linux/reg/reg.o ../../zmodlib/Zmod/linux/flash/flash.o ../../zmodlib/Zmod/linux/dma/dma.o ../../zmodlib/Zmod/linux/dma/libaxidma.o ../../zmodlib/Zmod/linux/utils.o ../../zmodlib/ZmodADC1410/zmodadc1410.o ../../zmodlib/Zmod/zmod.o -luio

You can now run it with: sudo ./main

Won't run without sudo, some permission issue with axidma. (perhaps someone knows how to fix?)

###################################  uEnv.txt ###################################################
# Eclypse boot configuration
#VARIABLES

#Zmod configuratio to use: adc, dac, adc-dac
zmod=system

fdn=0
bit_addr=0x10000000
dtb_addr=0x11000000
img_addr=0x11400000
img_name=image.ub
dtb_name=system.dtb

####### To evaluate before use
eval_variables=\
setenv bit_name zm-${zmod}.bit; \
setenv dtb_name zm-${zmod}.dtb; \
setenv bootargs console=ttyPS0,115200 earlyprintk cma=25M uio_pdrv_genirq.of_id=generic-uio root=/dev/mmcblk0p2 rw rootwait;


####### To run
mmc_fpga=load mmc 0:1 $bit_addr $bit_name && fpga loadb $fdn $bit_addr $filesize;
mmc_dtb=load mmc 0:1 $dtb_addr $dtb_name
#mmc_boot=load mmc 0:1 $img_addr $img_name && bootm $img_addr:kernel@1 - $img_addr:fdt@system-top.dtb $bootargs;
mmc_boot=load mmc 0:1 $img_addr $img_name && bootm $img_addr:kernel@1 - $dtb_addr $bootargs;


####### Entry point
uenvcmd=run eval_variables && run mmc_fpga && run mmc_dtb && run mmc_boot;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...