cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
urianr
Visitor
Visitor
5,121 Views
Registered: ‎01-22-2017

OpenSSL in Petalinux 2016.4

OpenSSL is not a menu item, when one calls

petalinux-config -c rootfs

 

But on the other hand, all files from OpenSSL seem to be in the distribution. There are also menu items referring to

OpenSSL in the config file associated to the rootfs configuration.

 

My questions are,

Why is OpenSSL not in the rootfs config menu?

How can I include OpenSSL in my Petalinux project?

 

BL, Rainer

0 Kudos
14 Replies
shabbirk
Moderator
Moderator
5,098 Views
Registered: ‎12-04-2016

Hi Rainer

 

Why is OpenSSL not in the rootfs config menu?

 

To make boot image minimal, we are just adding only required basic packages to rootfs.

 

How can I include OpenSSL in my Petalinux project?

OpenSSL is part of recipe-connectivity layer. If we want to add openssl package to Zynq/ZynqMP architecture, follow these steps:

1. Go to petalinux installation directcory (Ex:/opt/pkg/petalinux/)

2. Locate this file: /opt/pkg/petalinux/components/yocto/source/aarch64/layers/meta-petalinux/recipes-core/packagegroups/packagegroup-petalinux.bb

3. Add the desired package at the end of ZYNQ_EXTRAS (something like this: openssl \ )

4. save the file

5. bitbake to get the new RPM: MACHINE=zynq-generic bitbake petalinux-image

 

 

Best Regards

Shabbir

0 Kudos
fircrestsk8
Observer
Observer
5,057 Views
Registered: ‎03-14-2016

So you are saying that I would need to make changes to my petalinux install just to include openssl in the rootfs of one of my petalinux projects? That seems pretty hacky to me.

I don't have a lot of experience with 2016.4, but isn't there a way to include openssl using only the rootfs menuconfig? I find it hard to believe that you have to hack the yocto backend in order to do this basic task.
bigbrett
Adventurer
Adventurer
5,030 Views
Registered: ‎07-08-2016

I am also very interested in just getting a minimal linux image with openVPN (and therefore openSSL as a dependency) as the only add-ons, but have been struggling quite a bit.

 

@shabbirk could you please provide more detail on step 3? How do we know that just by listing openSSL as a desired package, that it will be included in the build (how does petalinux find the source?).

 

I would also like to do the same for openVPN. Is this possible? 

 

Any tutorials you have on the subject would be helpful (I have already gone through all of the petalinux documentation, but it seems that this task is beyond the petalinux layer and dives deeper into Yocto builds)

 

Also, Is this really a non-standard task? I would have thought that all of the GNU project stuff would be available? 

Thanks!

Brett

 

0 Kudos
urianr
Visitor
Visitor
4,907 Views
Registered: ‎01-22-2017

Hi Shabbir,

step 1 to 4 are fine. But step 5 is not necessary, because the call "Petalinux-config -c rootfs" does this automatically.

Moreover , step 5 wI'll not work without proper sourcing of the environment and it is nowhere stated how to do it.

 

BR,

Rainer

0 Kudos
shabbirk
Moderator
Moderator
4,904 Views
Registered: ‎12-04-2016

Hi Rainer

 

Yes step 5 wIll  work only after proper sourcing of the environment and here is how you need to do:

cd /opt/pkg/petalinux/components/yocto/source/aarch64/layers/poky

source oe-init-build-env

MACHINE=zynq-generic bitbake petalinux-image (make sure you are in build directory to run this)

 

 

Best Regards

Shabbir

 

0 Kudos
my_sarm
Visitor
Visitor
2,734 Views
Registered: ‎03-21-2017

Hi all,

 

Let’s say that I have followed the Step 1 to 4 written by Shabbirk. I executed already the “petalinux-config -c rootfs”, and activated the openssl library in my project directory.

 

The openssl library’s activation is already done based on the content of my “/build/tmp/sysroots/plnx_arm/usr/lib/openssl/ptest/include/openssl”. The folder contains many header files related to openssl, such as “rand.h”, “pem.h”, sha.h”, etc.

 

Once, I created a file, named as opensapp.c, calling functions provided by openssl, and it can be compiled and targeted to an object file with gcc and its -lcrypto in a common linux OS terminal of my host desktop. With the this approach, I am able to use certain functions related to the header files provided by openssl to run a certain functionality.

 

Then, I tried to make another application, named as myapp.c, using petalinux 2017.1 SDK having the same content of the opensapp.c. I also tried to compile it using petalinux-build, and found some errors. To make and compile an application calling functions provided by openssl, I don’t change the Makefile.

 

My questions are: do I need to change the Makefile to make the compilation of myapp.c works? What should I write in myapp.c to define header files provided in the directory “/build/tmp/sysroots/plnx_arm/usr/lib/openssl/ptest/include/openssl”? For instance, do I need to write include “…/openssl/rand.h” in myapp.c, so it is compilable and executable?

 

Thanks.

Mysarm

0 Kudos
my_sarm
Visitor
Visitor
2,706 Views
Registered: ‎03-21-2017

I mean after I had chosen to add the openssl by executing “petalinux-config -c rootfs” and marking in the options of libs to activate the openssl, I ran the “petalinux-build”.

 

In the “build” directory of my petalinux application, I find a certain file header which I need to use in my application, for instance “evp.h” in following directories:

 

./build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/openssl/1.0.2j-r0/sysroot-destdir/usr/include/openssl/evp.h

./build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/openssl/1.0.2j-r0/sysroot-destdir/usr/lib/openssl/ptest/include/openssl/evp.h

./build/tmp/sysroots/plnx_arm/usr/include/openssl/evp.h

./build/tmp/sysroots/plnx_arm/usr/lib/openssl/ptest/include/openssl/evp.h

./build/tmp/sysroots/x86_64-linux/usr/include/openssl/evp.h

 

Can you tell me, how I should write the “evp.h” in my application file (app.c) if I want to use the header file? How about the Makefile?

 

I have tried to write #include <openssl/evp.h> in my application file, and compile the application, but the compilation results an error, i.e. the openssl/evp.h cannot be found.

 

Then, I changed also the Makefile to:

 

$(APP): $(APP_OBJS)

$(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS) -lcrypto

...

 

The compilation shows also another error. I expect the compilation will be:

gcc app.c -o object_file -lcrypto

I need to execute this since in linux os’s user space it was successful. However, there is also an error during compilation.

 

What should I do to make the application’s compilation successful and I can run the app.c in my petalinux later?

 

Mysarm

0 Kudos
dchang3etagen
Observer
Observer
2,657 Views
Registered: ‎07-03-2018


@shabbirk wrote:

Hi Rainer

 

Yes step 5 wIll  work only after proper sourcing of the environment and here is how you need to do:

cd /opt/pkg/petalinux/components/yocto/source/aarch64/layers/poky

source oe-init-build-env

MACHINE=zynq-generic bitbake petalinux-image (make sure you are in build directory to run this)

 

 

Best Regards

Shabbir

 


Can you provide updates instructions for Petalinux 2018.1?  The folder you reference does not exist.

0 Kudos
vanmierlo
Mentor
Mentor
2,621 Views
Registered: ‎06-10-2008

Beware, OpenSSL in Petalinux 2018.1 is broken, due to a change in the used binutils.

0 Kudos
Quake702
Visitor
Visitor
884 Views
Registered: ‎05-11-2020

Hi,guy

 

do you have solve this issue? I am facing this problem from now, 

i need to use the libcurl which depend on the openssl

 

Best wishes

Quake

0 Kudos
vanmierlo
Mentor
Mentor
877 Views
Registered: ‎06-10-2008

Are you still asking about petalinux 2016.4?

0 Kudos
Quake702
Visitor
Visitor
847 Views
Registered: ‎05-11-2020

Dear vanmierlo:

No,i am using petlinux 2018.3. Some new logs as follow, can you help to give some advice?

alinx@yuyikj:~/work/trunk/demo_prj/build$ find ./ -name *openssl
./tmp/deploy/licenses/openssl-native/generic_openssl
./tmp/deploy/licenses/openssl
./tmp/deploy/licenses/openssl/generic_openssl
./tmp/sysroots/x86_64-linux/usr/include/openssl
./tmp/sysroots/x86_64-linux/usr/bin/openssl
./tmp/sysroots/plnx_arm/pkgdata/runtime/gnutls-openssl
./tmp/sysroots/plnx_arm/pkgdata/runtime/openssl
./tmp/sysroots/plnx_arm/pkgdata/runtime-rprovides/(=3.5.3)/gnutls-openssl
./tmp/sysroots/plnx_arm/pkgdata/runtime-rprovides/gnutls-openssl
./tmp/sysroots/plnx_arm/pkgdata/runtime-rprovides/gnutls-openssl/gnutls-openssl
./tmp/sysroots/plnx_arm/pkgdata/openssl
./tmp/sysroots/plnx_arm/pkgdata/runtime-reverse/openssl
./tmp/sysroots/plnx_arm/usr/share/bash-completion/completions/openssl
./tmp/sysroots/plnx_arm/usr/include/openssl
./tmp/sysroots/plnx_arm/usr/lib/ruby/2.2.0/openssl
./tmp/sysroots/plnx_arm/usr/lib/openssl
./tmp/sysroots/plnx_arm/usr/lib/openssl/ptest/include/openssl
./tmp/sysroots/plnx_arm/usr/lib/openssl/ptest/apps/openssl
./tmp/sysroots/plnx_arm/sysroot-providers/openssl
./tmp/stamps/cortexa9hf-neon-xilinx-linux-gnueabi/openssl
./tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/ruby/2.2.5-r0/sysroot-destdir/us r/lib/ruby/2.2.0/openssl
./tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/openssl
alinx@yuyikj:~/work/trunk/demo_prj/build$ cd ./tmp/sysroots/plnx_arm/usr/lib/ope nssl
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl$ ls
ptest
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl$ ls
ptest
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl$ cd ptest/
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test$ ls
apps config crypto include libssl.a Makefile.org test
certs Configure e_os.h libcrypto.a Makefile run-ptest util
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test$ cd include/
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test/include$ ls
openssl
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test/include$ cd openssl/
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test/include/openssl$ ls
aes.h conf_api.h engine.h objects.h rc4.h symhacks.h
asn1.h conf.h e_os2.h obj_mac.h ripemd.h tls1.h
asn1_mac.h crypto.h err.h ocsp.h rsa.h ts.h
asn1t.h des.h evp.h opensslconf.h safestack.h txt_db.h
bio.h des_old.h hmac.h opensslv.h seed.h ui_compat.h
blowfish.h dh.h idea.h ossl_typ.h sha.h ui.h
bn.h dsa.h krb5_asn.h pem2.h srp.h whrlpool.h
buffer.h dso.h kssl.h pem.h srtp.h x509.h
camellia.h dtls1.h lhash.h pkcs12.h ssl23.h x509v3.h
cast.h ebcdic.h md4.h pkcs7.h ssl2.h x509_vfy.h
cmac.h ecdh.h md5.h pqueue.h ssl3.h
cms.h ecdsa.h mdc2.h rand.h ssl.h
comp.h ec.h modes.h rc2.h stack.h
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test/include/openssl$ cd ..
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test/include$ ls
openssl
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test/include$ cd ..
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test$ ls
apps config crypto include libssl.a Makefile.org test
certs Configure e_os.h libcrypto.a Makefile run-ptest util
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib/openssl/p test$ cd ..
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib$ cd libc
libcanberra-0.30/ libc_pic/
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/lib$ cd ../.. /../
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots$ cd ..
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp$ ls
abi_version deploy sstate-control sysroots-uninative xsctenv
buildstats log stamps work
cache saved_tmpdir sysroots work-shared
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp$ cd ..
alinx@yuyikj:~/work/trunk/demo_prj/build$ ls
bitbake.lock build.log cache config.log downloads sstate-cache
bootgen.bif build.log.old conf config.log.old misc tmp
alinx@yuyikj:~/work/trunk/demo_prj/build$ find ./ -name *curl
./tmp/deploy/licenses/curl
./tmp/sysroots/plnx_arm/pkgdata/runtime/libcurl
./tmp/sysroots/plnx_arm/pkgdata/runtime/curl
./tmp/sysroots/plnx_arm/pkgdata/runtime/gstreamer1.0-plugins-bad-curl
./tmp/sysroots/plnx_arm/pkgdata/curl
./tmp/sysroots/plnx_arm/pkgdata/runtime-rprovides/libcurl
./tmp/sysroots/plnx_arm/pkgdata/runtime-rprovides/libcurl/libcurl
./tmp/sysroots/plnx_arm/pkgdata/runtime-rprovides/(=7.50.1)/libcurl
./tmp/sysroots/plnx_arm/pkgdata/runtime-reverse/curl
./tmp/sysroots/plnx_arm/pkgdata/runtime-reverse/gstreamer1.0-plugins-bad-curl
./tmp/sysroots/plnx_arm/usr/share/bash-completion/completions/curl
./tmp/sysroots/plnx_arm/usr/include/curl
./tmp/sysroots/plnx_arm/sysroot-providers/curl
./tmp/stamps/cortexa9hf-neon-xilinx-linux-gnueabi/curl
./tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/curl
./tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/gstreamer1.0-plugins-bad/1.8.3+g itAUTOINC+8e8b435aff-r0/pkgdata/runtime/gstreamer1.0-plugins-bad-curl
./tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/gstreamer1.0-plugins-bad/1.8.3+g itAUTOINC+8e8b435aff-r0/pkgdata/runtime-reverse/gstreamer1.0-plugins-bad-curl
alinx@yuyikj:~/work/trunk/demo_prj/build$ cd ./tmp/sysroots/plnx_arm/usr/include /curl
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/include/curl$ ls
curlbuild.h curlrules.h easy.h multi.h typecheck-gcc.h
curl.h curlver.h mprintf.h stdcheaders.h
alinx@yuyikj:~/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm/usr/include/curl$ cd -
/home/alinx/work/trunk/demo_prj/build
alinx@yuyikj:~/work/trunk/demo_prj/build$ cd ..
alinx@yuyikj:~/work/trunk/demo_prj$ ls
apps build config.project modules user-dtsi
BOOT.BIN components images project-spec
alinx@yuyikj:~/work/trunk/demo_prj$ petalinux-build -c curltest
[INFO] building curltest
[INFO] sourcing bitbake
INFO: bitbake curltest
Loading cache: 100% |############################################| Time: 0:00:00
Loaded 3262 entries from dependency cache.
Parsing recipes: 100% |##########################################| Time: 0:00:00
Parsing of 2472 .bb files complete (2439 cached, 33 parsed). 3265 targets, 226 s kipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |#######################################| Time: 0:00:01
Checking sstate mirror object availability: 100% |###############| Time: 0:00:03
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: curltest-1.0-r0 do_compile: oe_runmake failed
ERROR: curltest-1.0-r0 do_compile: Function failed: do_compile (log file is loca ted at /home/alinx/work/trunk/demo_prj/build/tmp/work/cortexa9hf-neon-xilinx-lin ux-gnueabi/curltest/1.0-r0/temp/log.do_compile.26488)
ERROR: Logfile of failure stored in: /home/alinx/work/trunk/demo_prj/build/tmp/w ork/cortexa9hf-neon-xilinx-linux-gnueabi/curltest/1.0-r0/temp/log.do_compile.264 88
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: make -j 8 CFLAGS= -O2 -pipe -g -feliminate-unused-debug-types -fdebug-pr efix-map=/home/alinx/work/trunk/demo_prj/build/tmp/work/cortexa9hf-neon-xilinx-l inux-gnueabi/curltest/1.0-r0=/usr/src/debug/curltest/1.0-r0 -fdebug-prefix-map=/ home/alinx/work/trunk/demo_prj/build/tmp/sysroots/x86_64-linux= -fdebug-prefix-m ap=/home/alinx/work/trunk/demo_prj/build/tmp/sysroots/plnx_arm= -c -g LDFLAGS=- Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lpthread -lcurl -lssl
| ERROR: oe_runmake failed
| arm-xilinx-linux-gnueabi-gcc -march=armv7-a -marm -mfpu=neon -mfloat-abi=har d -mcpu=cortex-a9 --sysroot=/home/alinx/work/trunk/demo_prj/build/tmp/sysroots/p lnx_arm -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lpthread -lcurl -lssl -o c urltest curltest.o
| curltest.o: In function `main':
| /usr/src/debug/curltest/1.0-r0/curltest.c:45: undefined reference to `curl_eas y_init'
| /usr/src/debug/curltest/1.0-r0/curltest.c:47: undefined reference to `curl_eas y_setopt'
| /usr/src/debug/curltest/1.0-r0/curltest.c:49: undefined reference to `curl_eas y_setopt'
| /usr/src/debug/curltest/1.0-r0/curltest.c:52: undefined reference to `curl_eas y_perform'
| /usr/src/debug/curltest/1.0-r0/curltest.c:64: undefined reference to `curl_eas y_cleanup'
| /usr/src/debug/curltest/1.0-r0/curltest.c:56: undefined reference to `curl_eas y_strerror'
| collect2: error: ld returned 1 exit status
| make: *** [Makefile:11: curltest] Error 1
| ERROR: Function failed: do_compile (log file is located at /home/alinx/work/tr unk/demo_prj/build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/curltest/1.0-r0 /temp/log.do_compile.26488)
ERROR: Task (/home/alinx/work/trunk/demo_prj/project-spec/meta-user/recipes-apps /curltest/curltest.bb:do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 1197 tasks of which 1196 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
/home/alinx/work/trunk/demo_prj/project-spec/meta-user/recipes-apps/curltest/c urltest.bb:do_compile
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
ERROR: Failed to build curltest
webtalk failed:PetaLinux statistics:extra lines detected:notsent_nofile!
webtalk failed:Failed to get PetaLinux usage statistics!

 

Best wishes

Quake

0 Kudos
vanmierlo
Mentor
Mentor
823 Views
Registered: ‎06-10-2008

So you're not asking about petalinux 2016.4 nor about openssl. Better to start a new thread next time, IMHO.

I think you need to select the 'curl' package to get libcurl. If it's not present in petalinux-config -c rootfs then you will have to add it in a layer. Open project-spec/meta-user/conf/layer.conf and add this line:

IMAGE_INSTALL_append += " curl"
0 Kudos
Quake702
Visitor
Visitor
815 Views
Registered: ‎05-11-2020

Dear vanmierlo:

Firstly, thank's for your reply, sorry to in the old thread ask you the question.

i have tried your advice, and verify the compile procedure, still have the issues, and i have opened one new thread about the issue, here is the link:

https://forums.xilinx.com/t5/Embedded-Linux/how-to-use-libcurl-in-petlinux2018-3-project/td-p/1138683

Can you help to about the problem, thank you very much.

 

Best wishes

Quake

0 Kudos