• 0
malkauns

PCAM elf on PetaLinux from SD card

Question

Hi all,  I am able to successfully build the PCAM demo project for the Zybo Z7-10 and can verify that it works.  After importing the project into the SDK and letting it build, sdk/pcam_vdma_hdmi/Debug/pcam_vdma_hdmi.elf is generated.  I would like to be able to run this application from with PetaLinux booted from an SD card so that I can control the camera as well as performing other operations within Linux.  If I try to run the generated pcam_vdma_hdmi.elf as it is I get an "Illegal instruction" error message.  What do I have to do to make this work from within a booted PetaLinux?

Edited by malkauns

Share this post


Link to post
Share on other sites

12 answers to this question

Recommended Posts

  • 0

Hi @malkauns,

I have reached out to more experienced embedded linux engineers to see if they would have any input for you. It may be a little bit before you receive a response. The more experience embedded engineers are out of the office this week.

thank you,

Jon

Share this post


Link to post
Share on other sites
  • 0

We have a PCAM demo in the Petalinux-Zybo-Z7-20 project. The PCAM support is not included in the Petalinux-Zybo-Z7-10 project because they were intended for SDSoC and the FPGA in the Z7-10 is too small for SDSoC usage.

We modified the Z7-20 Vivado project to work on the Z7-10 (system.hdf file attached.)

Follow these steps to have PCAM support on the Z7-10.

  1. Git clone  Petalinux-Zybo-Z7-20
  2. Unzip the attached system.hdf file in a folder and include the system.hdf in the unzipped folder itself. Copy & replace the folder contents into project-spec/hw-description of the petalinux project.
  3. Build the image with the petalinux-build command
  4. Follow the PCAM instructions at the bottom of the readme for Petalinux-Zybo-Z7-20

 

FYI, here are the steps to modifying the  Z7-20 Vivado project to work on the Z7-10. A SDSoC license is needed for generating the bitstream.

  1. Download the Zybq-Z7-20-base-linux project from https://github.com/Digilent/Zybo-Z7-20-base-linux and unzip.
  2. Download the Vivado library from https://github.com/Digilent/vivado-library and unzip it in the Zybq-Z7-20-base-linux project, in the \repo\vivado-library folder.
  3. Make sure you have the Zybo Z7 board support files in your Vivado installation. If you don’t have them, download them from https://github.com/Digilent/vivado-boards, unzip the downloaded file, and copy the contents from the \vivado-boards-master\new\board_files folder to your Vivado 2017.4 installation folder (e.g. C:\Xilinx\Vivado\2017.4\data\boards\board_files).
  4. Open Vivado 2017.4, select Tools -> Run Script and run the create_project.tcl script from the \proj folder inside the Zybq-Z7-20-base-linux folder.
  5. Change the target board in Viado, by selecting Settings -> Project Device -> Zybo Z7-10 -> OK. Save the project.
  6. You will need to regenerate the IPs used in this project, due to the board change. Tools -> Report IP Status -> Upgrade Selected.
  7. The Zybo Z7-10 board has one less RGB LED than Zybo Z7-20 boards. Therefore, you will need to do several change to the project:
    • In the Zybo-Z7-Master.xdc file, comment out the lines referring to RGB LED 5:
      #set_property -dict { PACKAGE_PIN Y11   IOSTANDARD LVCMOS33 } [get_ports { pwm_rgb[2] }]; #IO_L18N_T2_13 Sch=led5_r
      #set_property -dict { PACKAGE_PIN T5    IOSTANDARD LVCMOS33 } [get_ports { pwm_rgb[1] }]; #IO_L19P_T3_13 Sch=led5_g
      #set_property -dict { PACKAGE_PIN Y12   IOSTANDARD LVCMOS33 } [get_ports { pwm_rgb[0] }]; #IO_L20P_T3_13 Sch=led5_b
    • In the same XDC file, change the indexes of the lines referring to RGB LED 6, so they look like this:
      set_property -dict { PACKAGE_PIN V16   IOSTANDARD LVCMOS33 } [get_ports { pwm_rgb[2] }]; #IO_L18P_T2_34 Sch=led6_r
      set_property -dict { PACKAGE_PIN F17   IOSTANDARD LVCMOS33 } [get_ports { pwm_rgb[1] }]; #IO_L6N_T0_VREF_35 Sch=led6_g
      set_property -dict { PACKAGE_PIN M17   IOSTANDARD LVCMOS33 } [get_ports { pwm_rgb[0] }]; #IO_L8P_T1_AD10P_35 Sch=led6_b
    • In the project block diagram, double-click on pwm_rgb IP and change the Number of PWMs from 6 to 3. Select OK and save the project.
    • Also in the project block diagram, double click on the output from the pwm_rgb IP (pwm_rgb signal), select Properties and then change the LEFT parameter from 5 to 2. Save the project.
  8. It may have happened that no top-level wrapper was generated for your project. If so, right-click on the system_i block diagram and select Create HDL Wrapper…
  9. Then right-click on the newly-created wrapper and select Set As Top. Save the project.
  10. You can now generate the bitstream and you should not see any issues while doing that.

Share this post


Link to post
Share on other sites
  • 0

Hi Vicentiu,  Thanks for putting in the effort to make this work on the Z7-10.  I really appreciate what you all are doing.  However, I am unable to get the Z7 to boot fully.  It gets stuck at "Starting kernel".  Here are the commands I used to build Petalinux on a fresh install of Ubuntu 16.04 in VirtualBox:

 

sudo apt-get update
sudo apt-get install tofrodos gawk xvfb git libncurses5-dev tftpd zlib1g-dev zlib1g-dev:i386 libssl-dev flex bison chrpath socat autoconf libtool texinfo gcc-multilib libsdl1.2-dev libglib2.0-dev screen pax xterm python diffstat unzip libncurses-dev chrpath socat texinfo gcc-multilib libsdl1.2-dev

sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales #ok.. ok.. ok
sudo apt-get install tftpd-hpa
sudo chmod a+w /var/lib/tftpboot/
sudo mkdir -p /opt/pkg/petalinux
sudo chown $USER /opt/pkg/
sudo chgrp $USER /opt/pkg/
sudo chgrp $USER /opt/pkg/petalinux/
sudo chown $USER /opt/pkg/petalinux/

#download petalinux-v2017.4-final-installer.run

chmod +x petalinux-v2017.4-final-installer.run
./petalinux-v2017.4-final-installer.run /opt/pkg/petalinux

comment out the following line in /opt/pkg/petalinux/components/yocto/source/arm/layers/core/meta/conf/sanity.conf:
INHERIT += "sanity" 

git clone --recursive https://github.com/Digilent/Petalinux-Zybo-Z7-20.git
wget https://forum.digilentinc.com/applications/core/interface/file/attachment.php?id=8742 -O system.hdf
mkdir system.hdf_zip
unzip system.hdf -d system.hdf_zip
cp -r system.hdf_zip/* Petalinux-Zybo-Z7-20/Zybo-Z7-20/project-spec/hw-description/ #i'm assuming this is where to magic is supposed to happen for the Z7-10..
cp system.hdf Petalinux-Zybo-Z7-20/Zybo-Z7-20/project-spec/hw-description/ #..and here
cd Petalinux-Zybo-Z7-20/Zybo-Z7-20/
source /opt/pkg/petalinux/settings.sh
echo "configparams-sdk-launch-timeout 180" > .xsdbrc
petalinux-build
petalinux-package --boot --force --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system_wrapper.bit --u-boot
cd images/linux
cp BOOT.BIN image.ub /run/media/$USER/BOOT/
sudo umount /dev/sdb2
sudo dd if=rootfs.ext4 of=/dev/sdb2
sync
eject /dev/sdb
#insert SD card into Zybo Z7-10, make sure its in SD boot mode and power on
#hangs at "Starting kernel"

 

Please let me know what I need to do to get it fully booting on the Z7-10.

Share this post


Link to post
Share on other sites
  • 0

Are you using minicom to connect to the serial console?

If yes, try connecting with Putty.

We've noticed the same issue with minicom, and terminal output worked fine once we switched to Putty.

Share this post


Link to post
Share on other sites
  • 0

 I'm using Linux and am using this command to view output from the board:

screen /dev/ttyUSB1 115200

Using a BOOT.BIN and image.ub that I have made a while back I can get the board to complete the boot process and make it to the prompt so there must be something that needs tweaking in this project.  Is there some dtsi file that needs editing?  Maybe some boot option is missing.  Are you actually able the get this to boot on the Z7-10?

 

Here's the boot log output where it gets stuck at "Starting kernel ...":



U-Boot 2017.01 (Dec 18 2018 - 09:59:59 -0800)

Model: Zynq Zybo Z7 Development Board
Board: Xilinx Zynq
I2C:   ready
DRAM:  ECC disabled 1 GiB
MMC:   sdhci@e0100000: 0 (SD)
Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   ZYNQ GEM: e000b000, phyaddr 1, interface rgmii-id
SF: Detected s25fl128s_64k with page size 256 Bytes, erase size 64 KiB, total 16 MiB

Warning: ethernet@e000b000 using MAC address from ROM
eth0: ethernet@e000b000
U-BOOT for Zybo Z7
ethernet@e000b000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Hit any key to stop autoboot:  4  3  2  1  0 
Device: sdhci@e0100000
Manufacturer ID: 9f
OEM: 5449
Name: 00000 
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.4 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
reading image.ub
2281992 bytes read in 225 ms (9.7 MiB/s)
## Loading kernel from FIT Image at 10000000 ...
   Using 'conf@2' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel@0' kernel subimage
     Description:  Linux Kernel
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x100000d4
     Data Size:    2249752 Bytes = 2.1 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x00008000
     Entry Point:  0x00008000
     Hash algo:    sha1
     Hash value:   133089f2029c5e4eeeea23f7e95c11a63be240c3
   Verifying Hash Integrity ... sha1+ OK
## Loading fdt from FIT Image at 10000000 ...
   Using 'conf@2' configuration
   Trying 'fdt@0' fdt subimage
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x102255e0
     Data Size:    30947 Bytes = 30.2 KiB
     Architecture: ARM
     Hash algo:    sha1
     Hash value:   399c9df8f6c14fe63d1e25f5d3e1786d61310363
   Verifying Hash Integrity ... sha1+ OK
   Booting using the fdt blob at 0x102255e0
   Loading Kernel Image ... OK
   Loading Device Tree to 07ff5000, end 07fff8e2 ... OK

Starting kernel ...

 

Edited by malkauns
more data

Share this post


Link to post
Share on other sites
  • 0

I ran most of the commands you ran and booted successfully. I'm connecting with TeraTerm from Windows.

I didn't run the following:

Quote

echo "configparams-sdk-launch-timeout 180" > .xsdbrc

and

sudo dd if=rootfs.ext4 of=/dev/sdb2

It looks like you want a rootfs. I booted with initramfs.

if you want rootfs, you'll need to run petalinux-config to change root filesystem type and also change the bootargs. The details are in the "Configure SD rootfs" section of the project.

Make sure you clean the project after switching from initramfs to rootfs (or vice versa). We noticed that if you make the switch and rebuild without cleaning, it will stay stuck in that same place: Starting kernel....

Share this post


Link to post
Share on other sites
  • 0

Hi,

I have a Zybo Zynq-Z7-10 board with PMOD PCam-5C

I tried the steps in the replies:

https://forum.digilentinc.com/topic/17074-pcam-elf-on-petalinux-from-sd-card/?do=findComment&comment=42504

https://forum.digilentinc.com/topic/17074-pcam-elf-on-petalinux-from-sd-card/?do=findComment&comment=42698

I setup as well a microSD card 8G using gParted: first partition 1GB type fat16  and  the second partition 6.80GB type ext4.

After inserting the card in Zybo's slot and switching the jumper to SD  , the effect of switching on is that the board lights on the LED red LD13 PGOOD, the connected HDMI Monitor has not signal.


I have some questions: which resolution has the HDMI output in Petalinux? The bitstream file of Z7-20 Vivado project with the modifications of the diagram and PWM  https://github.com/Digilent/Zybo-Z7-20-base-linux - how does it get inserted in the Petalinux binaries that get on the SD card?

I guess using this command --- petalinux-package --boot --force --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system_wrapper.bit --u-boot  ----  but there is no interdependency set in the previous posts.
Should the project run and the HDMI display connected to the output of the Zynq must run even without the bitstream ?
The microsd card was formated with gParted, is compulsory using of a dedicated tool to write the rootfs, boot.bin files ? or the commands:
 

cp BOOT.BIN image.ub /dev/sdd1/

is enough ?

https://github.com/Digilent/Petalinux-Zybo-Z7-20?_ga=2.177147622.2104787184.1555966017-216103582.1546520870#configure-sd-rootfs

sudo umount /dev/sdd2

sudo dd if=images/linux/rootfs.ext4 of=/dev/sdd2

sync
sudo resize2fs /dev/sdd2

sync

should be enough?

Share this post


Link to post
Share on other sites
  • 0

Hi,

as I mentioned in the previous post as the Zybo-z7-20-base linux was not referenced by the Petalinux project build, so I sourced the hardware description:
petalinux-config --get-hw-description=<PATH-TO-HDF-DIRECTORY>

I did as well the petalinux-config and selected SD card instead of initramfs .

The outcome is that there is some activity of the board afterwards the sd with boot.bin and image.ub are copied on the card and fed into the Zybo: the LED Green is blinking

I tried connected to the serial terminal with screen , but no establishing of the communication is done.

With dmesg -w , the Zybo device seems restarting and the peripherals listed by the dmesg are ftdi and /dev/ttyUSB0 , and it seems disconnected and the serial is enumerated afterwards on the /dev/ttyUSB1 and this restarting of the Zybo board is like continous after 5 or 10 seconds.

Also the HDMI synk to the display is without effect and I can not see the "desktop" of the Petalinux.

I had a post here:

that only the

pipeline_mode_change(vdma_driver, cam, vid, Resolution::R640_480_60_NN,OV5640_cfg::mode_t::MODE_720P_1280_720_60fps); 

 

worked when debugged on ARM the https://github.com/Digilent/Zybo-Z7-20-pcam-5c project .
 

I would be interested if something similar - a setting of the HDMI -dvi2rgb or other display driver could be done when initializing the Programming System - ARM :

something like the following snippet

set video resolution (Resolution::R640_480_60)

into this https://github.com/Digilent/Petalinux-Zybo-Z7-20/blob/master/Zybo-Z7-20/project-spec/hw-description/ps7_init.c file      ??
 

Thanks and regards!

Edited by flying
clarification

Share this post


Link to post
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