|Targeted Hardware||phyBOARD-Zeta (phyCORE-i.MX7)|
Customizing a BSP to support a specific application is a common task in designing systems with PHYTEC SoMs. Describing custom hardware, adding packages to your BSP, and adding custom OS services to your BSP are just a few simple examples of customizing a BSP. Yocto enables customization through it's meta-layer scheme. The BSP is described within these layers using recipes. Everything from where Yocto can find the source to how it builds the source and where it is deployed. Customizing a BSP is as simple as adding your own meta-layer. You can find pre-made layers here or you can find instructions on creating your own custom layer below. More specifically, this How To will guide you through adding a package, from an existing recipe, to the standard PHYTEC BSP.
Creating your custom layer
As a reference point, this how-to will begin just before the Quickstart (also called BSP manual) instructs you to execute the 'bitbake <image_name>' command. However, these instructions are relevant for both pre and post build environments.
Start by creating a development directory within $YOCTO_DIR
With your environment variables sourced according to instructions in the respective Quickstart, create your meta layer skeleton and move it to the development directory with the following commands:
The 'yocto-layer create' command will create a meta layer with the name specified after this command. It will automatically prepend the "meta-" string.
Congratulations! You have just created a meta-layer. Now is a good time to add your work to a git repository:
Adding networkd to your BSP in your custom meta-layer
Following the directory structure of the base recipe, create a 'systemd_%.bbappend' file within your new meta-layer. The filename indicated will append any version of the systemd recipe included in your BSP. Add the following content to systemd_%.bbappend:
This recipe will add networkd to your BSP. We can now use networkd to automatically configure our Ethernet ports upon boot. The next sections will describe creating and adding these configuration files to your BSP.
Creating network configuration files
In the same directory as your systemd_%.bbappend file, create a directory for storing your network configuration files.
Within the 'systemd-machine-units' directory, add configuration files that describe the desired network configuration. Some examples can be found below, as well as here.
For dynamic IP
Add the following file '$YOCTO_DIR/development/meta-zeta-networkd/recipes-core/systemd/systemd-machine-units/10-eth0.network':
For static IP
Add the following file '$YOCTO_DIR/development/meta-zeta-networkd/recipes-core/systemd/systemd-machine-units/10-eth1.network':
Default network device
Add the following file to create a default network device configuration. '$YOCTO_DIR/development/meta-zeta-networkd/recipes-core/systemd/systemd-machine-units/90-dhcp-default.network'
Create a recipe to add your configuration files to the target filesystem
In the same directory as your systemd_%.bbappend file, add the following recipe to populate the BSPs filesystem with your network configuration files:
Adding your meta layer to bblayers.conf
Now that you have completed development of your custom meta layer, you will need to add it to the list of layers that Yocto will build. To do this, we must modify the bblayers.conf file. Start by copying the existing configuration files, bblayers.conf.sample and local.conf.sample, from the standard BSP into your meta layer's 'conf' directory:
These configuration files specify which layers will be built (bblayers.conf.sample) and define your local build environment (local.conf.sample).
Add your layer to to bblayers.conf.sample. Following the format of the existing layers, add your meta layer's name to the list of layers. Below is an example of a bblayers.conf.sample file with the meta-zeta-networkd layer added:
You can also add local environment variables to the local.conf.sample file. Now is a good time to check in your code changes and push your files to a remote git repo.
Update the build manifest
The final step before we can build our custom BSP is updating the build manifest to include our custom meta layer git repo. This allows our build to be automated and repeatable. Start by copying the standard BSP's manifest into a new, git managed, directory. In this example, I will use the '/opt/PHYTEC_BSPs/manifests' directory.
Modify the manifest file to include a 'remote' element, to describe your remote repo location, and a 'project' element to describe the local destination for your layer. See the '$YOCTO_DIR/.repo/repo/docs/manifest-format.txt' file for details on the contents of the manifest file.
Now is a good time to check in your code changes and push your files to a remote git repo.
Build your custom BSP
You are now ready to build your custom BSP!
Let's start with a new directory for our custom BSP.
Initialize and sync remote repositories, locally.
Specify your build configuration to set up the build environment.
Be sure to configure your local.conf with any further additions (as described in the Quickstart Guide).
Now start the build.
This How to guide has demonstrated one possible process for adding a package to a standard PHYTEC BSP by using an existing bitbake recipe. Specifically, we have added the networkd package from the systemd recipe and created configuration files that describe how networkd will configure network interfaces.