UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
2,323 Views
Registered: ‎11-10-2017

Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

Hello ,

 

I am trying to pack a led tutorial that i made in XSDK after exporting the bitstream. The code is working when i flash it via JTAG using SDK on the ultrazed board. 

 

I followed : https://www.xilinx.com/support/documentation/sw_manuals/xilinx2017_1/ug1144-petalinux-tools-reference-guide.pdf

pg 50 on how to include the pre-build app in the petalinux package. When i did this, app is present in my /usr/bin folder but does not execute correctly.

 

Error i get :

root@mprjLin:/usr/bin# gpiodemo
[   31.471371] gpiodemo[2138]: undefined instruction: pc=00000000000009b4
[   31.477855] Code: d280001b d280001c d280001d d280001e (d5384240)
Illegal instruction
root@mprjLin:/usr/bin#
root@mprjLin:/usr/bin# ./gpiodemo
[   40.873941] gpiodemo[2140]: undefined instruction: pc=00000000000009b4
[   40.880418] Code: d280001b d280001c d280001d d280001e (d5384240)
Illegal instruction
root@mprjLin:/usr/bin#

The SDK generated it as .elf file which i changed when placing in petalinux apps folder.

 

Please let me know how to resolve this.

 

 

0 Kudos
1 Solution

Accepted Solutions
Explorer
Explorer
2,874 Views
Registered: ‎10-19-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

@vish.bh30, I will need to see the build error log to diagnose the problem.

 

You should be able to follow the directions here

http://www.wiki.xilinx.com/Linux+GPIO+Driver

 

once you get PetaLinux to build. These direction are pretty comprehensive. The --get-hw-description does a lot of the work for you. It reads where the address of the gpio is from the hardware design file, adding it to the device tree (this eliminates the need for xparameters.h), then Xilinx's GPIO drivers (in the link) are able to link to it that way, which allows you to open some files and read and write to them to trigger the GPIO (write to certain addresses where the GPIO actually is, which is automated by Xilinx software).

 

PetaLinux should be able to build with some basic gpios. If I cannot figure out your failures, you should open an SR.

View solution in original post

0 Kudos
11 Replies
Explorer
Explorer
2,316 Views
Registered: ‎10-19-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

Do it the "Yocto" way. The SDK is a nuisance imho for Linux development. I have had trouble with every GUI Xilinx has made.

 

petalinux-create -t apps -n <appname>--enable

 

Go to <project-root>/project-spec/meta-user/receipes-apps/<appname>/files/<appname>.c and edit that file. If you need to include other files in the project, then add them to the Makefile in <project-root>/project-spec/meta-user/receipes-apps/<appname>/files/ as well as <project-root>/project-spec/meta-user/receipes-apps/<appname>/<appname>.bbappend.

 

It makes life so much easier.

 

You can try to build that application only:

petalinux-build -c <appname>

 

0 Kudos
Adventurer
Adventurer
2,307 Views
Registered: ‎11-10-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

HI @jackfrye11

 

I am using my custom HDF that i created in vivado. If i add the application and add the gpio code , xparameters.h file is not getting detected for some reason even after i added the hdf via  --get-hw-description. Keep getting build error. That was the whole point i switched back to include pre-built app.

 

Not sure how to make a BSP in SDK so that i can use that in petalinux. 

0 Kudos
Explorer
Explorer
2,299 Views
Registered: ‎10-19-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

There are a couple of ways to hack at this.

 

/dev/mem

1. You can simply copy your xparameters.h to your app and include it, referencing any macros or constants that correspond to absolute addresses. You should see that these addresses are somewhere on the AXI bus (I am assuming this is for ZYNQ)

axibus.PNG

You can open the /dev/mem device, specifying the base address from xparameters as the physical address offset and just write to the GPIO way.

 

Device Driver

2. You can also add a device node to your device tree with an address property and use a platform device to parse out those properties, creating a device node somewhere such that you can use read/write or mmap to write to the physical address. This is probably the more stylistically acceptable way to go, but also much harder. Also note that in an ideal scenario, PetaLinux would be able to parse your peripheral from the hdf. I would check out the device tree and see if it isn't already in there because it very well may be. If it is, I would see if they don't already have a driver that will do this for you. If they have a device driver for writing to GPIO, you are pretty much set, you just need to open it and probably write to the device file to access the GPIO registers.

0 Kudos
Explorer
Explorer
2,280 Views
Registered: ‎10-19-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution
Try the test procedure of this guy and build off of that
http://www.wiki.xilinx.com/Linux+GPIO+Driver
0 Kudos
Explorer
Explorer
2,875 Views
Registered: ‎10-19-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

@vish.bh30, I will need to see the build error log to diagnose the problem.

 

You should be able to follow the directions here

http://www.wiki.xilinx.com/Linux+GPIO+Driver

 

once you get PetaLinux to build. These direction are pretty comprehensive. The --get-hw-description does a lot of the work for you. It reads where the address of the gpio is from the hardware design file, adding it to the device tree (this eliminates the need for xparameters.h), then Xilinx's GPIO drivers (in the link) are able to link to it that way, which allows you to open some files and read and write to them to trigger the GPIO (write to certain addresses where the GPIO actually is, which is automated by Xilinx software).

 

PetaLinux should be able to build with some basic gpios. If I cannot figure out your failures, you should open an SR.

View solution in original post

0 Kudos
Adventurer
Adventurer
2,170 Views
Registered: ‎11-10-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

hey @jackfrye11

 

Got the GPIO tutorial working after i created a script having commands from : http://www.wiki.xilinx.com/Linux+GPIO+Driver  (section : Using the GPIO driver from User Space)

 

The only trouble i have now is auto running it , may be for a different thread.

0 Kudos
Explorer
Explorer
2,164 Views
Registered: ‎10-19-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

That is great. If you can, I suggest you post the code here for future reference in case others search this issue. As far as automating it, you can always look at trying to get CRON on your distro. I am sure there are OpenEmbedded layers out there you might be able to leverage.

0 Kudos
Adventurer
Adventurer
2,144 Views
Registered: ‎11-10-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

Hello @jackfrye11

 

I used these tutorials to create the script :

 

https://www.beyond-circuits.com/wordpress/2016/08/gpio-with-zynq-and-petalinux/

 

http://www.wiki.xilinx.com/Linux+GPIO+Driver (Using the GPIO driver from User Space)

 

As given in the above tutorials i had to first search for the correct gpio-led section under /sys/class/gpio.

 

Script : led.sh

 

#!/bin/sh

echo -n 901 > /sys/class/gpio/export
echo -n 902 > /sys/class/gpio/export

echo out 901 > /sys/class/gpio/gpio901/direction
echo out 902 > /sys/class/gpio/gpio902/direction

echo 1 > /sys/class/gpio/gpio901/value
echo 1 > /sys/class/gpio/gpio902/value

I created a simple c program and called this script by :

 

#include "stdio.h"
#include "unistd.h"
#include "stdlib.h"

#define script_name "led.sh"


int main()
{
 ......

 system(led.sh);

 .....

 return 0;
}

 

hope this helps others ! 

 

regards

 

V

 

0 Kudos
Adventurer
Adventurer
2,142 Views
Registered: ‎11-10-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

@jackfrye11

 

the problem with auto run right now i am having is I need to run the file soon after auto-login. For this the workaround i found was to modify the S99rmnologin.sh file under /etc/rc5.d/ ... but i want these settings to take place at the time of build generation so that i do not have to modify the files manually.

 

I already used  INITSCRIPT and INITPARAMS in the application bb file as :

 

INITSCRIPT_NAME = "ledTut.sh"

# INITSCRIPT_PARAMS = "start 99 S ."

INITSCRIPT_PARAMS = "start 99 5 ."
0 Kudos
Explorer
Explorer
1,469 Views
Registered: ‎10-19-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution
Not sure about that one. My guess is that the best way to do it is write a .bbappend file that is able to build your script into the startup routine but I am not sure exactly how that would be done. That's more of a Yocto question than a PetaLinux one. If there is a Yocto forum, you might be able to get answers there too.
0 Kudos
Adventurer
Adventurer
1,459 Views
Registered: ‎11-10-2017

Re: Packaging and executing prebuilt app via Petalinux for SD boot

Jump to solution

hey @jackfrye11

 

Thanks mate ! Yes got it

 

this is what i did eventually :

 

app.bb file 

do_install {

         install -d ${D}${sysconfdir}/rc5.d

         install -m 0755 ${S}/myapp.sh ${D}${sysconfdir}/rc5.d/S99xmyapp.sh

}

this created a S99xmyapp.sh service /routine which would run at very end .. hence able to start my app at login / auto-run

 

thanks for all the help and guidance ! 

 

Please mark this thread as closed.

 

regards ,

 

0 Kudos