I have been working with the Yocto Project for over 13 years pretty much since the beginning. I have also developed the Linux Foundation’s first course on the Yocto Project and taught the class may times. What I have learned from the classes I eventually distilled into a book on the subject. Fair enough, I might be a little biased.
Building a Linux distribution from scratch is not a trivial undertaking. It is very much the “secret” sauce of the distribution builders such as RedHat, Ubuntu, SuSe, etc. The difficult and time-consuming part of maintaining a Linux distribution is the dependency handling and keeping up with CVEs and other improvements.
When building a custom Linux distribution for an embedded device, you essentially have two choices:
Top-down means you are taking a distribution and the packages the distribution builder creates and modify it to your requirements. That to some extend alleviates you from the tedious maintenance tasks. But you have to come up with a way to modify the distribution to your requirements: install additional packages, remove packages that you don’t need (without breaking dependencies), build and install packages that are not available from upstream, etc. You are also faced with the problem of creating the distribution for your target architecture: most distributions are built and optimized for x86(_64). Yes, some distros now also provide ARM and aarch64 package feeds but because of the diversity of ARM SoCs you will still need to build the kernel and bootloader for your target.
With bottom-up you are in full control but you are the distribution builder and the burden of maintenance is on you (together with the burden of dependency management, cross-building, etc).
I have done both in the past with different tooling. Now I am using exclusively the Yocto Project as it offers me the best of both worlds: a maintained set of software packages, toolchains for various architectures, and blueprints for various systems (which I don’t use anymore since I have created my own catalog).
In response to @simmania 's questions:
1: I assume Yocto is Debian based? Does it come with a package handler?
No, the Yocto Project is not Debian-based. It is building all software packages from source code. You have a choice of package management systems: rpm, dpkg, and opkg.
2: Does it come with a graphical user interface? Or is it terminal only?
Yes, there is a web-based UI called toaster which allows you to configure and execute builds.
3: Is it wise to go the Yocto route when not having much experience with Linux?
The Yocto Project is only the build system that creates a custom Linux OS stack. The more fundamental question is if it is wise to use Linux for an embedded system project without having much experience with Linux? There are a gazillion reasons why Linux is great for embedded systems which is why it has become the leading OS for embedded applications that require full OS stack capabilities. However, you need to be willing to go through the learning curve regardless on how you build the OS stack for your system. Companies and independent consultants can help you flatten the learning curve and keep you on track with your project. Shameless plug: that is what my company and I do for our customers.
4: Can we install and run Visual Studio Code on the target?
That mostly depends on your target. While the Yocto Project will most likely provide all the dependencies required for VS Code, there is no recipe that can build VS Code. However, downloading VS Code and installing it on a target built with YP can probably be made working. I have not tried it myself.
On-target development is traditionally not common for embedded systems as they often lack the resources to do so. Hence, the YP can build an SDK that allows cross-development on an x86_64 Linux system. That SDK can be integrated with VS Code and others such as Qt Creator. I am doing all my YP development with either one of them (or both dependent on the project).
5: When using OpenCV, does the imshow() function work?
OpenCV is fully supported by YP. It is part of the meta-oe layer.
6: Are USB cameras supported?
Yes, no different from any Linux distro.
7: I would consider cross compilation. Can that be done with short iteration times?
YP always does cross compliation. It creates the toolchain it builds with itself. That is also true when the target is an x86_64 system. How long builds take depends on the size of the target system and the build system you have available. A full initial build may take 30 minutes or more. For subsequent builds only packages that need to be rebuilt (for various reasons) are being built. The Yocto Project (or more precisely the bitbake engine behind it) does a very good job at dependency handling and reusing pre-built artifacts. There is also something that is called a shared state cache (I won’t go into details, there is a lot to it). Using the SDK with the Yocto Project devtool allows you to build the software you are working on on your build system and deploy it to a YP remote target via network, run it as well as debug it.
A quick word on containers: We are using containers on top of YP systems for different reasons. But to run a container you still need a base system. That we build with the YP and include the container tools we need. There are many reasons why doing this. One is that developers can work in a container environment for development on their dev system. The container is then used on the target system (often with a different architecture). Developers can use container tools rather then YP tools. It depends on what you are looking for.