How to include tools/commands in yocto image recipe? - embedded-linux

I have a question regarding including different tools into Yocto image recipe. Currently I am building image recipe for my Avenger96 board. I have created a base image and it runs fine on the device. But when I try to do sgdisk after booting it says -sh: sgdisk: command not found. I understand that these commands are not available by default and need to install it.
But I am not sure how to do it given my board is not connected to internet. Can I include these commands/tools in image recipe? I want to use some other commands like ufw, etc but I have same issue with them too.
Can someone please let me know how to do this?
Your help will be much appreciated.
Thanks in advance.
P.S: I am using Ubuntu 20.04 with Yocto as build system.

sgdisk is present under recipe: meta/recipes-devtools/fdisk/gptdisk_xx.bb
For xx it depends on your poky version.
For dunfell this is the recipe here.
ufw is present in meta-openembedded/meta-networking/recipes-connectivity/ufw
So, make sure meta-openembedded/meta-networking is present in your bblayers.conf and to include both of them add the following line to local.conf or to your custom image file:
IMAGE_INSTALL_append = " gptfdisk ufw"
If you still do not find sgdisk try gptdisk-sgdisk.
If you want to add any recipe in the future, try to look for it in the official yocto git repositories in this link.
It is not recommended to add tools manually into the board, unless you are in the development process and you need to gain time, so here are some ideas for you:
Create an image for development that includes all dev features (gcc, g++, cmake, ..etc)
Include git and other fetching tools
Clone the tool's source code and compile it in the board
Or: bitbake the recipe with Yocto and copy the output binary directly to the image via ssh or other ways.

Related

how to add wirinigPi library on buildroot?

How to add wiringpi in Buildroot image ?
I followed the same steps as described here: How to add an out-of-tree package to buildroot? The download of the git archive functions correctly but the compilation of the library doesn't work. I tried to change the "sh build" command in the .mk file using an absolute path to where the archive was extracted (in output/build).
I also tried to change the build.sh included in WiringPi archive with absolute paths everytime cd was used beacause the make command used with buildroot wasn't executed in the same directory Can you help me write a correct .mk file that will compile wiringpi for my buildroot image using this git: https://github.com/WiringPi/WiringPi ?
WiringPi is/was already in buildroot packages, however, the whole library was deprecated by the author at some point. Due to this and apparently also because the WiringPi's author deleted all sources (according to this), it was moved to buildroot's legacy packages. However, that deprecation post is now removed by the WiringPi author (which is why the first link points to internet archives), so it could be that the sources are also restored and the WiringPi package from the legacy config works or could be made working with small modifications.
TLDR; Even if you could get it working, you should use something else.

Installing an RPM in Yocto

So I have a Yocto build and I need to install this 3rd party RPM. I've created a recipe for it using the link to the source RPM. Problem is when implementing the do_install() function.
I need to install it, and it's installed via rpm --install rpm_package, and then I need to enable the service.
For the service I know I have to inherit systemd in my recipe file, but for the installation I'm still confused.
The install command only creates directories and copies files over.
Any help is appreciated.
Indeed do_install only create install directories in your /tmp/work/cortex[...]/my_recipe_name/ directory
Normally if you bitbake your image which include your recipe you should have a warning like:
Files/directories were installed but not shipped in any package
So, after the installation you need to "package them" in order to be in your final linux image, to do so use FILES_$PN like below for instance:
FILES_${PN}_append = " /usr/sbin/"
where /usr/bin is the directory which contain what you want to "install" in your image.
Then the package will be shipped in your final image.
For the service, indeed inherit systemd is mandatory + you have to add in do_install
install -Dm0644 ${WORKDIR}/my_script.service ${D}${systemd_system_unitdir}/my_script.service
and at the end of your .bbfile
SYSTEMD_SERVICE_${PN} = "my_script.service"
You can install packages at runtime with rpm, but it is not recommended for production builds, as that is the whole idea behind Yocto which is creating a custom distribution with all your needs integrated.
In order to use rpm command in runtime you need to configure it to fetch the sources from the right location. And the right location is generally a Yocto build, because it is compatible with your board's architecture and system (Otherwise, you need to handle that manually).
You can link the Yocto build rpm files to the board's rpm command using smart, for more info check first the official Yocto documentation here.
Also, you can check more example here and here.
IMPORTANT
I do not recommend creating a systemd/sysvinit service to install an rpm/deb/ipk/tar package.
The idea is, if you install a package with rpm it means that it is already supported by Yocto and has a recipe. So, simply:
IMAGE_INSTALL_append = " package"

confusion between u-boot.elf and u-boot

Installed Vivado 2018.2
Clone u-boot git clone https://github.com/Xilinx/u-boot-xlnx.git
change directory to u-boot-xlnx
source /opt/Xilinx/Vivado/2018.2/settings64.sh
export CROSS_COMPILE=aarch64-linux-gnu-
export ARCH=aarch64
make avnet_ultra96_rev1_defconfig
make
Both u-boot and u-boot.elf appear at the directory, what they are?
I want to build a boot.bin from fsbl.elf, xxxx.bit and u-boot.elf with SDK, which file shall I use?
I search the issue on web but get difference answer, someone recommends that rename the u-boot to u-boot.elf and apply it, other says use the u-boot.elf directly.
Your answer is welcome, thanks a lot.

How to add X11 desktop environment in yocto configuration?

I tried to build the BSP for v3msk (linux based embedded system) on Ubuntu 18.04 following the link:
https://elinux.org/R-Car/Boards/Yocto-Gen3-ADAS#Building_the_BSP_for_Renesas_ADAS_boards
I used Yocto v3.21.0
The local.conf I used is available here https://pastebin.com/UyBGzQ2J
I tried adding x11 to distro features.
DISTRO_FEATURES_append = " x11"
I ran
bitbake core-image-x11
and I expect it to build yocto images with X11.
I got error :
ERROR: Nothing PROVIDES 'core-image-x11'
core-image-x11 was skipped: missing required distro feature 'x11' (not in
DISTRO_FEATURES)
What could be missing in local.conf?
Nothing PROVIDES 'core-image-x11'
means you don't have image file with this name in the meta layers list of your build/conf/bblayers.conf file.
try to execute command:
find source| grep images| grep x11
to see if you have any layer containing images related to x11. add discovered layer to the build/conf/bblayers.conf file then retry your command:
bitbake core-image-x11

How to edit the kernel files using yocto recipe

I am using yocto krogoth branch and compiling kernel image. Now i want to change some data in the middle of the this drivers/tty/serial/imx.c.
using yocto recipe without git patches. could you please give me some inputs.
Patching with quilt is the way to go:
https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#using-a-quilt-workflow

Resources