how to add a third party library as a package in Yocto build - embedded

I have a library that is not famous and there is no package available for this library https://github.com/dailab/libsml normally I install this library on my device by doing make install
How can I add this library as a package in my distribution of Linux. Just like i can add python or any other recipe in my local.conf
My local.conf looks like this
MACHINE ?= "phyboard-regor-am335x-1"
DISTRO ?= "yogurt"
# The following line disables the autostart of the phytec-qtdemo by
# default, but you can start the demo anytime using
# $ systemctl start phytec-qtdemo.service
#SYSTEMD_AUTO_ENABLE_pn-phytec-qtdemo = "disable"
# That are the default values of bitbake. Adapt these to your workspace and
# host preferences.
#DL_DIR = "${TOPDIR}/downloads"
#SSTATE_DIR = "${TOPDIR}/sstate-cache"
# License Handling
# - Uncomment for i.MX6 proprietary GPU libraries
#LICENSE_FLAGS_WHITELIST += "license-nxp_v14-june-2016_imx-gpu-viv"
# - Uncomment for Freescale i.MX6 legacy VPU firmware blobs
#LICENSE_FLAGS_WHITELIST += "license-freescale_v6-february-2015_firmware-imx"
# You can disable and enable FSTYPES as you wish. e.g. 'ext4'.
# This is ordering dependend. IMAGE_FSTYPES += "tar.gz" IMAGE_FSTYPES_append_mx6 = " sdcard ubifs" IMAGE_FSTYPES_append_ti33x
= " sdcard ubifs" IMAGE_FSTYPES_append_rk3288 = " sdcard"
#IMAGE_FSTYPES_append_ti33x = " emmc" DEPLOY_DIR = "${TOPDIR}/deploy"
# Select configuration UI for linux and barebox recipe. The openembedded
# default is 'menuconfig', 'nconfig' has more features.
#KCONFIG_CONFIG_COMMAND = "menuconfig" KCONFIG_CONFIG_COMMAND = "nconfig"
# Turn on debugging options of the kernel
# This is currently only supported for the TI kernel v4.4 DEBUG_BUILD_pn-linux-ti = "1"
# The default package class of the distro yogurt is 'package_ipk'. The first
# value is used as the package manager to build the image and sdk. To build
# also tar packages use
#PACKAGE_CLASSES = "package_ipk package_tar"
# Variable IMAGE_ROOTFS_EXTRA_SPACE from poky/meta/conf/documentation.conf:
# Defines additional free disk space created in the image in Kbytes. By
# default, this variable is set to '0'.
# This example line adds an additional 512 MiB of free space to the root
# filesystem:
#IMAGE_ROOTFS_EXTRA_SPACE = "524288"
# See http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#ref-features-image
# "Through these variables, you can add several different predefined
# packages such as development utilities or packages with debug information
# needed to investigate application problems or profile applications EXTRA_IMAGE_FEATURES = ""
# - "Makes an image suitable for development (e.g. allows root logins without
# passwords and enables post-installation logging)" EXTRA_IMAGE_FEATURES += "debug-tweaks"
# - "Installs debug symbol packages for all packages installed in a given
# image."
#EXTRA_IMAGE_FEATURES += "dbg-pkgs"
# - "Installs debugging tools such as strace and gdb."
#EXTRA_IMAGE_FEATURES += "tools-debug"
#python-netserver for python cgi IMAGE_INSTALL_append = "mc nano openvpn apache2 dhcp-server lora-gateway lora-pkt-fwd spitools python avro-c python-kafka ntp python-netserver iptables"
#SDKMACHINE ?= "x86_64"
OE_TERMINAL = "auto" PATCHRESOLVE = "noop" BB_DISKMON_DIRS = "\
STOPTASKS,${TMPDIR},1G,100K \
STOPTASKS,${DL_DIR},1G,100K \
STOPTASKS,${SSTATE_DIR},1G,100K \
ABORT,${TMPDIR},100M,1K \
ABORT,${DL_DIR},100M,1K \
ABORT,${SSTATE_DIR},100M,1K"
CONF_VERSION = "1"
And my bblayers.conf looks like this:
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
OEROOT := "/home/enilyser/sources/poky"
BBLAYERS ?= " \
${OEROOT}/meta \
${OEROOT}/meta-poky \
${OEROOT}/../meta-phytec \
${OEROOT}/../meta-yogurt \
${OEROOT}/../meta-cloud-services-master/meta-openstack \
${OEROOT}/../meta-openembedded/meta-oe \
${OEROOT}/../meta-openembedded/meta-networking \
${OEROOT}/../meta-openembedded/meta-python \
${OEROOT}/../meta-openembedded/meta-multimedia \
${OEROOT}/../meta-qt5 \
${OEROOT}/../meta-openembedded/meta-ruby \
${OEROOT}/../meta-openembedded/meta-webserver \
${OEROOT}/../meta-lora-net-master \
${OEROOT}/../meta-lorawan-master \
"

You can use devtool to add the recipe if you are no 2.4+ version of yocto release
devtool add libsml https://github.com/dailab/libsml
it will create a recipe template
workspace/recipes/libsml/libsml_git.bb
this is nearly what you need but sometimes you have to tweak it a bit to ensure cross compiling.
in this case it builds and runs the tests, obviously when cross building we can build the tests but we can run them on build machine, so you have to disable that. you can do so in recipe or via a patch. e.g. via recipe you will change do_configure function to something like this
do_configure () {
# Specify any needed configure commands here
sed -i -e "s##./test##g" ${S}/test/Makefile
}
may be change do_install as well so it can install the files you need on target
do_install () {
install -d ${D}${libdir} ${D}${includedir}
install -m 0644 ${B}/sml/lib/libsml.* ${D}${libdir}
rm -rf ${D}${libdir}/libsml.o
cp -R --no-dereference --preserve=mode,links ${S}/sml/include/* ${D}${includedir}
install -D -m 0644 sml.pc ${D}${libdir}/pkgconfig/sml.pc
}
to build and see if all is ok
devtool build libsml
if all builds you can then apply the recipe to a layer of your choice ( say meta-oe )
devtool finish libsml meta-oe -f
Thats it, now you should see the recipe in meta-oe layer, you can try to build it
bitbake libsml

Related

s2e-block: dirty sectors on close:11104 Terminating node id 0 (instance slot 0)

I tried to test OpenVSwitch using S2E. I wrote the OpenVSwitch installation script in bootstrap.sh. The image in the qemu virtual machine is the same as the image in the host machine, so the executable file compiled in the host machine should also be executed in the virtual machine. So after I installed OpenVSwitch and started ovsdb-server and ovs-vsctl, ovs-vswitchd should be able to execute successfully, but I got the following error:
18 [State 0] BaseInstructions: Killing state 0
18 [State 0] Terminating state: State was terminated by opcode
message: "bootstrap terminated"
status: 0x0
18 [State 0] TestCaseGenerator: generating test case at address 0x40717d
18 [State 0] TestCaseGenerator: All states were terminated
qemu-system-x86_64: terminating on signal 15 from pid 42128 (/home/lz/s2e/install/bin/qemu-system-x86_64)
s2e-block: dirty sectors on close:11104
Terminating node id 0 (instance slot 0)
bootstrap.sh and the installation script ovs-install.sh are as follows:
bootstrap.sh
#!/bin/bash
#
# This file was automatically generated by s2e-env at 2022-09-29 14:22:53.271106
#
# This bootstrap script is used to control the execution of the target program
# in an S2E guest VM.
#
# When you run launch-s2e.sh, the guest VM calls s2eget to fetch and execute
# this bootstrap script. This bootstrap script and the S2E config file
# determine how the target program is analyzed.
#
set -x
mkdir -p guest-tools32
TARGET_TOOLS32_ROOT=guest-tools32
mkdir -p guest-tools64
TARGET_TOOLS64_ROOT=guest-tools64
# 64-bit tools take priority on 64-bit architectures
TARGET_TOOLS_ROOT=${TARGET_TOOLS64_ROOT}
# To save the hassle of rebuilding guest images every time you update S2E's guest tools,
# the first thing that we do is get the latest versions of the guest tools.
function update_common_tools {
local OUR_S2ECMD
OUR_S2ECMD=${S2ECMD}
# First, download the common tools
for TOOL in ${COMMON_TOOLS}; do
${OUR_S2ECMD} get ${TARGET_TOOLS_ROOT}/${TOOL}
if [ ! -f ${TOOL} ]; then
${OUR_S2ECMD} kill 0 "Could not get ${TOOL} from the host. Make sure that guest tools are installed properly."
exit 1
fi
chmod +x ${TOOL}
done
}
function update_target_tools {
for TOOL in $(target_tools); do
${S2ECMD} get ${TOOL} ${TOOL}
chmod +x ${TOOL}
done
}
function prepare_target {
# Make sure that the target is executable
chmod +x "$1"
}
function get_ramdisk_root {
echo '/tmp/'
}
function copy_file {
SOURCE="$1"
DEST="$2"
cp ${SOURCE} ${DEST}
}
# This prepares the symbolic file inputs.
# This function takes as input a seed file name and makes its content symbolic according to the symranges file.
# It is up to the host to prepare all the required symbolic files. The bootstrap file does not make files
# symbolic on its own.
function download_symbolic_file {
SYMBOLIC_FILE="$1"
RAMDISK_ROOT="$(get_ramdisk_root)"
${S2ECMD} get "${SYMBOLIC_FILE}"
if [ ! -f "${SYMBOLIC_FILE}" ]; then
${S2ECMD} kill 1 "Could not fetch symbolic file ${SYMBOLIC_FILE} from host"
fi
copy_file "${SYMBOLIC_FILE}" "${RAMDISK_ROOT}"
SYMRANGES_FILE="${SYMBOLIC_FILE}.symranges"
${S2ECMD} get "${SYMRANGES_FILE}" > /dev/null
# Make the file symbolic
if [ -f "${SYMRANGES_FILE}" ]; then
export S2E_SYMFILE_RANGES="${SYMRANGES_FILE}"
fi
# The symbolic file will be split into symbolic variables of up to 4k bytes each.
${S2ECMD} symbfile 4096 "${RAMDISK_ROOT}${SYMBOLIC_FILE}" > /dev/null
}
function download_symbolic_files {
for f in "$#"; do
download_symbolic_file "${f}"
done
}
# This function executes the target program given in arguments.
#
# There are two versions of this function:
# - without seed support
# - with seed support (-s argument when creating projects with s2e_env)
function execute {
local TARGET
TARGET="$1"
shift
execute_target "${TARGET}" "$#"
}
###############################################################################
# This section contains target-specific code
function make_seeds_symbolic {
echo 1
}
# This function executes the target program.
# You can customize it if your program needs special invocation,
# custom symbolic arguments, etc.
function execute_target {
local TARGET
TARGET="$1"
shift
#wo tian jia de
sudo ./install_ovs.sh
S2E_SO="${TARGET_TOOLS64_ROOT}/s2e.so"
# ovs-vswitchd is dynamically linked, so s2e.so has been preloaded to
# provide symbolic arguments to the target if required. You can do so by
# using the ``S2E_SYM_ARGS`` environment variable as required
S2E_SYM_ARGS="" LD_PRELOAD="${S2E_SO}" "${TARGET}" "$#" > /dev/null 2> /dev/null
}
# Nothing more to initialize on Linux
function target_init {
# Start the LinuxMonitor kernel module
sudo modprobe s2e
}
# Returns Linux-specific tools
function target_tools {
echo "${TARGET_TOOLS32_ROOT}/s2e.so" "${TARGET_TOOLS64_ROOT}/s2e.so"
}
S2ECMD=./s2ecmd
COMMON_TOOLS="s2ecmd"
###############################################################################
update_common_tools
update_target_tools
# Don't print crashes in the syslog. This prevents unnecessary forking in the
# kernel
sudo sysctl -w debug.exception-trace=0
# Prevent core dumps from being created. This prevents unnecessary forking in
# the kernel
ulimit -c 0
# Ensure that /tmp is mounted in memory (if you built the image using s2e-env
# then this should already be the case. But better to be safe than sorry!)
if ! mount | grep "/tmp type tmpfs"; then
sudo mount -t tmpfs -osize=10m tmpfs /tmp
fi
# Need to disable swap, otherwise there will be forced concretization if the
# system swaps out symbolic data to disk.
sudo swapoff -a
target_init
# Download the target file to analyze
${S2ECMD} get "ovs-vswitchd"
#wo tian jia de
#${S2ECMD} get "ovsdb-server"
#${S2ECMD} get "ovs-vsctl"
${S2ECMD} get "openvswitch-3.0.0.tar.gz"
${S2ECMD} get "install_ovs.sh"
download_symbolic_files
# Run the analysis
TARGET_PATH='./ovs-vswitchd'
prepare_target "${TARGET_PATH}"
#wo tian jia de
#prepare_target "./ovsdb-server"
#prepare_target "./ovs-vsctl"
prepare_target "openvswitch-3.0.0.tar.gz"
prepare_target "install_ovs.sh"
execute "${TARGET_PATH}" --pidfile --detach --log-file
ovs-install.sh
#!/bin/bash
tar zxvf openvswitch-3.0.0.tar.gz
cd openvswitch-3.0.0
./configure
make -j4
sudo make install
export PATH=$PATH:/usr/local/share/openvswitch/scripts
sudo mkdir -p /usr/local/etc/openvswitch
sudo ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
#/usr/local/share/openvswitch/scripts/ovs-ctl --no-ovs-vswitchd start
sudo ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --pidfile --detach
sudo ovs-vsctl --no-wait init
#sudo ovs-vswitchd --pidfile --detach
Does anybody can tell me how to fix this? Or is OpenVSwitch simply not testable by S2E?

Generate new proto

I have a <Podspec file name>.podspec equivalent to the standard GRPC one.
I don't know how to run the script in here that generates new .pbobjc.h/.pbobjc.m files for each .proto file.
Does anyone know what command I should run in the command line to trigger generating these new files per the script in the .podspec file?
Here is some more context for the script in the .podspec:
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
# You can run this command manually if you later change your protos and need to regenerate.
# Alternatively, you can advance the version of this podspec and run `pod update`.
s.prepare_command = <<-CMD
mkdir -p #{dir}
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--objc_out="Pods/LndRpc" \
--grpc_out="Pods/LndRpc" \
-I $GOPATH/src \
-I $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
-I "Pods/!ProtoCompiler" \
-I "." \
./*.proto
CMD
# The --objc_out plugin generates a pair of .pbobjc.h/.pbobjc.m files for each .proto file.
s.subspec 'Messages' do |ms|
ms.source_files = "#{dir}/*.pbobjc.{h,m}"
ms.header_mappings_dir = dir
ms.requires_arc = false
# The generated files depend on the protobuf runtime.
ms.dependency 'Protobuf'
end
# The --objcgrpc_out plugin generates a pair of .pbrpc.h/.pbrpc.m files for each .proto file with
# a service defined.
s.subspec 'Services' do |ss|
ss.source_files = "#{dir}/*.pbrpc.{h,m}"
ss.header_mappings_dir = dir
ss.requires_arc = true
# The generated files depend on the gRPC runtime, and on the files generated by `--objc_out`.
ss.dependency 'gRPC-ProtoRPC'
ss.dependency "#{s.name}/Messages"
end

cmake thinks variable is a directory

I'm trying to install the trilinos package using the suggested cmake route. I dont have any experience with cmake, but there's a sample bash script that I found. When I try to execute this script I get the error
CMake Error: The source directory "/home/USER/code/packages/trilinos_build/MPI_EXEC:FILEPATH=/usr/bin/pkg/mpiexec" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
I checked the cmake doc and I'm pretty sure the syntax is correct, what am I missing?
#!/bin/bash
# Set this to the root of your Trilinos source directory.
TRILINOS_PATH=../trilinos_source
TRILINOS_BUILD_PATH=./
#
# You can invoke this shell script with additional command-line
# arguments. They will be passed directly to CMake.
#
EXTRA_ARGS=$#
#
# Each invocation of CMake caches the values of build options in a
# CMakeCache.txt file. If you run CMake again without deleting the
# CMakeCache.txt file, CMake won't notice any build options that have
# changed, because it found their original values in the cache file.
# Deleting the CMakeCache.txt file before invoking CMake will insure
# that CMake learns about any build options you may have changed.
# Experience will teach you when you may omit this step.
#
rm -f CMakeCache.txt
#
# Enable all primary stable Trilinos packages.
#
cmake \
-D CMAKE_INSTALL_PREFIX:FILEPATH="${TRILINOS_BUILD_PATH}/mpi" \
-D CMAKE_BUILD_TYPE:STRING=RELEASE \
-D Trilinos_ENABLE_TESTS:BOOL=OFF \
-D Trilinos_ENABLE_ALL_PACKAGES:BOOL=OFF \
-D TPL_ENABLE_MPI:BOOL=ON \
-D MPI_EXEC:FILEPATH="/usr/bin/pkg/mpiexec" \
$EXTRA_ARGS \
$TRILINOS_PATH
I have similar problems with cmake, it is because of the white enters between the last line and $EXTRA_ARGS \ . just remove the empty lines and the error will go away.
so your file should be like this:
#!/bin/bash
# Set this to the root of your Trilinos source directory.
TRILINOS_PATH=../trilinos_source
TRILINOS_BUILD_PATH=./
#
# You can invoke this shell script with additional command-line
# arguments. They will be passed directly to CMake.
#
EXTRA_ARGS=$#
#
# Each invocation of CMake caches the values of build options in a
# CMakeCache.txt file. If you run CMake again without deleting the
# CMakeCache.txt file, CMake won't notice any build options that have
# changed, because it found their original values in the cache file.
# Deleting the CMakeCache.txt file before invoking CMake will insure
# that CMake learns about any build options you may have changed.
# Experience will teach you when you may omit this step.
#
rm -f CMakeCache.txt
#
# Enable all primary stable Trilinos packages.
#
cmake \
-D CMAKE_INSTALL_PREFIX:FILEPATH="${TRILINOS_BUILD_PATH}/mpi" \
-D CMAKE_BUILD_TYPE:STRING=RELEASE \
-D Trilinos_ENABLE_TESTS:BOOL=OFF \
-D Trilinos_ENABLE_ALL_PACKAGES:BOOL=OFF \
-D TPL_ENABLE_MPI:BOOL=ON \
-D MPI_EXEC:FILEPATH="/usr/bin/pkg/mpiexec" \
$EXTRA_ARGS \
$TRILINOS_PATH
Also if you comment any line by # between the -D options the same error will show. after cmake\ all lines must be continuous.
hope itll help!

build yocto image with apache2

I have been using QorIQ-SDK-V1.5 to build image for p1020rdb. However, there's no apache in the image which is what I need. But I also noticed that there's recipe in meta-webserver for apache, and I could build it separately by "bitbake -b" option. So my question is: How do I add the apache objects to image at build time?
Thanks in advance.
Add apache2 object to image at building time.
clone meta webserver from git
$ git clone git://git.openembedded.org/meta-openembedded
copy meta webserver your yocto home
$ cp -R meta-openembedded/meta-webserver {your-yocto-home}
edit bblayers.conf
$ cd {your-build-home}
$ vi conf/bblayers.conf
BBLAYERS ?= " \
{your-yocto-home}/meta \
{your-yocto-home}/meta-poky \
{your-yocto-home}/meta-yocto-bsp \
{your-yocto-home}/meta-webserver \
"
edit local.conf and add this line
$ vi conf/local.conf
IMAGE_INSTALL_append = " apache2"
bitbake core-image-minimal
$ bitbake core-image-minimal
You can find layers and recipes for Open Embedded in this link. Clone the layer directory or add the recipe if the layer is already present in your Yocto.
meta-webserver layer can be found meta-webserver layer. Apache recipe from Apache recipe
After adding a recipe to your poky dir, you need to append the package to install it your image.

finding apache build options

I need to rebuild an apache server, but the original source is no longer available. Is there any way ( command line switch to httpd? ) to get the build options which were originally used?
Try -V which "Print the version and build parameters of httpd, and then exit."
httpd -V
Also, you can see the options for httpd via:
httpd -h
I found previous configure options in the build directory of apache root.
I'm a Centos 5/6 user.
Apache ver. is 2.2.27.
apachedir/build/config.nice
#! /bin/sh
#
# Created by configure
"./configure" \
"--prefix=/usr/local/apache2" \
"--enable-so" \
"--enable-mods-shared=most" \
"--enable-ssl" \
"--with-mpm=worker" \
"--enable-cgi" \
"$#"
I re-compiled apache 2.4.3 recently and change the MPM from worker to prefork, what you have to do if you still keep your original compiled directory without ran "make distclean" (if you ran "make clean" it still OK). You can use the SAME configure option to re-configure by exec ./config.status or you can find and copy './configure' from ./config.status (yes, all the original options that you used to run configure still there).
Here is part of my config.status...
if $ac_cs_silent; then
exec 6>/dev/null
ac_configure_extra_args="$ac_configure_extra_args --silent"
fi
if $ac_cs_recheck; then
set X /bin/sh **'./configure' '--enable-file-cache' '--enable-cache' '--enable-disk-cache' '--enable-mem-cache' '--enable-deflate' '--enable-expires' '--enable-headers' '--enable-usertrack' '--enable-cgi' '--enable-vhost-alias' '--enable-rewrite' '--enable-so' '--with-apr=/usr/local/apache/' '--with-apr-util=/usr/local/apache/' '--prefix=/usr/local/apache' '--with-mpm=worker' '--with-mysql=/var/lib/mysql' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--enable-mods-shared=most' '--enable-ssl' 'CFLAGS=-Wall -O3 -ffast-math -frename-registers -mtune=corei7-avx' '--enable-modules=all' '--enable-proxy' '--enable-proxy-fcgi'** $ac_configure_extra_args --no-create --no-recursion
shift
$as_echo "running CONFIG_SHELL=/bin/sh $*" >&6
CONFIG_SHELL='/bin/sh'
export CONFIG_SHELL
exec "$#"
fi