Cross compile GCC and GDB with Yocto - gcc

Is there any way to cross compile gcc and gdb using the bitbake command in YOCTO project?

If I get you correctly you want to add gcc and gdb to the image.
The easiest and cleanest solution I know is to enable them via EXTRA_IMAGE_FEATURES.
Typically, you configure this variable in your local.conf file, which is found in the Build Directory. Although you can use this variable from within a recipe, best practices dictate that you do not. [1]
EXTRA_IMAGE_FEATURES = "tools-sdk tools-debug"
[1] http://www.yoctoproject.org/docs/2.1/ref-manual/ref-manual.html#var-EXTRA_IMAGE_FEATURES

To create the image-based SDK, For example, run this:
$ bitbake core-image-full-cmdline -c populate_sdk
With that, the SDK is created based on the core-image-full-cmdline image.
After it is done, the binary script can be found at /build/tmp/deploy/sdk/poky-eglibc-x86_64-core-image-full-cmdline-armv5te-toolchain-1.6.sh
To create generic SDK, use meta-toolchain
$ bitbake meta-toolchain
Find how to set up Qt here

Related

Execute binaries / tests on host that are built by non-host toolchain

Scenario:
We would like to build our sources by an external / hermetic toolchain so all includes, libs and tools from the host are ignored
To do so, a new toolchain is introduced to Bazel-Configuration. >>> working well
Using -Wl,-rpath=$ORIGIN/%{runtime_library_search_directories}/... the relative path from the binary to the libs that should be loaded on runtime gets defined >>> works quite well
When doing bazel run the Binary is executed but the host's LD is being used
To get rid of this a wrapper (written in Bash) is injected using --run_under. >>> dirty workaround
Problem:
--run_under could only be used once. We also need this option to execute tests within a specific environment and so this option is not the way of choice for us. IMHO it's also a bit dirty workaround.
We also tried to use -Wl,--dynamic-linker=<<PATH_TO_LD>>. But we were not able to get neither a relative nor an absolute path to LD when linking the executable.
Questions:
Is there ...
... any way to get the absolute/relative path to LD when linking?
... any other way of running a binary on Host using a toolchain?
... a possibility to do sandboxing/chroot so the correct LD of the toolchain is being used automatically?
Sidenotes:
Bazel 1.1.0 is used
the toolchain is GCC8 build from sources
the host is an Ubuntu 18.04.1 image running in docker

How can I build Yocto image to using build script?

I need to compile some of program in Yocto and this program compile by build script.
Build script doing make(using MakeFile).
As we know, if we don't using bitbake, Yocto need SDK tools. But I can't using SDK tools. So I have to build by recipe.
It is too complicate to using cmake or oe_runmake(for me).
You have to use oe_runmake as it will handle cross-compilation and other stuff for you. You can use devtool to help you create recipe. If makefile is done correctly, recipe is straightforward.

Quick rebuild of device tree only with Yocto/bitbake?

So, each time I modify the device tree I typically change the dts in a custom recipe and rebuild the image. The rebuild takes a long time since it rebuilds the entire kernel, and then the image needs to be built and finally deployed to the target device.
Is there any trick that I'm missing that rebuilds only the device tree?
UPDATE:
I've marked g0hl1n's answer as the correct one, since it is the answer to my question. However, I found it to be very cumbersome to work with the kernel in Yocto: strange, long paths and risk of files being overwritten on each rebuild, source of kernel in tmp/work-shared while the kernel is being built in tmp/work.
Instead I've moved the kernel development out of Yocto. Yocto has good tools for creating an SDK (see populate_sdk task) and with that it's easy to setup an environment for kernel development with quick rebuilds and manual (or scripted) deployments. Once the work is done the changes can be moved to a recipe using git diff.
The instructions on the following page was very helpful: http://jumpnowtek.com/beaglebone/Working-on-the-BeagleBone-kernel.html
AFAIK there are two different ways of doing this.
The kernel way: Using the scripts provided by the kernel
Change to your kernel source directory (<build dir>/tmp/work/<machine>/<kernel-name>/<kernel-version>/git/)
Execute the device-tree-compiler: ./scripts/dtc/dtc -I dts -O dtb -o ./devicetree.dtb path/to/devicetree.dts
The bitbake way: Using the kernel's deploy job
Call $ bitbake <kernel-name> -f -c deploy
The generated device-tree-blob then can be found in <build dir>/tmp/work/<machine>/<kernel-name>/<kernel-version>/build/arch/arm/boot/dts/)
At least for me both versions worked in a quick test.
UPDATE:
I just came over a third version of building the dtb with yocto on the net.
That one uses yocto's devshell of the kernel build.
For more information see the original authors page at https://splefty.blogspot.co.at/2015/09/compiling-device-tree-using-yocto.html.
For me using bitbake to regenerate the device tree worked in the following way:
Command: $ bitbake <kernel-name> -f -c compile
Example: $ bitbake linux-fslc -f -c compile
Tested using yocto sumo.

Building a Linux kernel using Travis CI

How can I build a Linux kernel in Travis CI. I have added script: make menuconfig to my Travis config and it doesn't work and says
No output has been received in the last 10 minutes
How can I fix this?
Link to GitHub repo : https://github.com/ProjectPolyester/tegra_kernel and submit fixes in PRs if possible
Travis monitors your build process and if there is no output for about 10 minutes, it assumes that your process is stuck somewhere for unknown reasons, and then kills it.
Solution in your case :
You need to provide with the actual build command.
make menuconfig
actually just allows you to configure the kernel. It doesn't really starts the kernel build process. So there is no output of this command.
Also, the kernel should already be configured or you can download the appropriate .config file if its available some where online. And then there will be no need to execute:
make menuconfig
The build command
It can be simply
make
or something like
make -j3 modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOCALVERSION=-$SOURCE_VERSION
The second one is actually to perform cross compilation.
You also need to set all the prerequisites like downloading the header file etc
You may want to take a look at this script , it crosscompiles the modules only, not the entire kernel.
If you want to use the old config for a new kernel, you can use make olddefconfig. Here is my example how to compile and boot a new kernel in travis: https://github.com/avagin/criu/blob/linux-next/scripts/travis/kexec.sh#L54
I know that this is an old thread but I was recently able to get Travis CI working on building a Linux kernel
https://github.com/GlassROM-devices/android_kernel_oneplus_msm8994/commit/6ed484812bbd4a25c3b22e730b7489eaaf668da1
GCC fix is for toolchains compiled on Debian unstable, arch, gentoo, etc. These toolchains will fail to compile on Ubuntu so you'll have to use the GCC fix for these toolchains
And you really want to upgrade GCC before you even try building a kernel. Travis CI has a very old GCC that will fail if you try to compile the kernel
In my commit I'm building it with GCC 8 linaro built by myself

Compiling and embedding lua into a C++ application

For portability reasons, I'd like to compile lua from source when I compile my C++ code. I use lua to read input file.
If I understand correctly, lua's readme mentions that it's possible to do that through src/Makefile. I can't really read it that well. Has anyone figured out how to do it?
is it possible to have it in one command? gcc ....
bonus: how to put it in cmake ?
Lua has a makefile that needs your target platform to build to so you will need to specify make [target platform].
But that is right in the beginning of the readme.
You could try to call the make command from inside your build process.
Cheers
[UPDATE based on the comments]
If you use:
make a PLAT=[target platform]
on the command line in the src directory it will only build the liblua.a library for the target platform then you will just need to copy that file to wherever you need and link against it.

Resources