Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build the agent with yocto zeus: #79

Closed
SimonSimCity opened this issue Jul 8, 2021 · 4 comments
Closed

How to build the agent with yocto zeus: #79

SimonSimCity opened this issue Jul 8, 2021 · 4 comments
Labels
area: yocto There is an issue with Yocto meta-layers

Comments

@SimonSimCity
Copy link

SimonSimCity commented Jul 8, 2021

Since I couldn't find any information about it, I wanted to share how I updated the meta-layer of this repo from warrior to zeus. I can verify these commands by running them in a fresh docker-container only having a couple of modules installed. If you don't have such an image yet, https://github.com/crops/yocto-dockerfiles/tree/master/dockerfiles might be a good starting point.

For this purpose, I assume you are starting off with a fresh project. Create a new folder and run the following commands. They will lead you into the meta-layer where we have to run more commands as follows.

git clone --depth=1 -b zeus git://git.yoctoproject.org/poky
git clone --depth=1 -b zeus git://github.com/openembedded/meta-openembedded.git
git clone --depth=1 -b zeus git://github.com/agherzan/meta-raspberrypi.git
git clone --depth=1 -b zeus git://github.com/sbabic/meta-swupdate.git

mkdir meta-azure-device-update
cd meta-azure-device-update

Download the meta-layer from https://github.com/Azure/iot-hub-device-update/releases/download/0.7.0/meta-azure-device-update.1.zip and extract the files:

wget https://github.com/Azure/iot-hub-device-update/releases/download/0.7.0/meta-azure-device-update.1.zip
unzip meta-azure-device-update.zip
rm meta-azure-device-update.zip

Before we come to the zeus-warrior related changes, there are a couple of git-related settings you have to change so the recipes are pointing to existing git repositories and branches:

sed -i 's/ADUC_GIT_BRANCH ?= "master"/ADUC_GIT_BRANCH ?= "main"/g' recipes-azure-device-update/azure-device-update/azure-device-update_git.bb
sed -i 's+ADUC_SRC_URI ?= "git://github.com/Azure/adu-private-preview;branch=${ADUC_GIT_BRANCH}"+ADUC_SRC_URI ?= "git://github.com/Azure/iot-hub-device-update;branch=${ADUC_GIT_BRANCH}"+g' recipes-azure-device-update/azure-device-update/azure-device-update_git.bb
sed -i 's+SRC_URI = "gitsm://github.com/microsoft/GSL.git;branch=master"+SRC_URI = "gitsm://github.com/microsoft/GSL.git;branch=main"+g' recipes-msft-gsl/msft-gsl/msft-gsl_git.bb

Now to the changes needed to get it to build on zeus:

# Update the compatibility layer
sed -i 's/warrior/zeus/g' conf/layer.conf

# Adjust the bitbake files according to the new sanity checks https://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html#migration-3.0-sanity-checks
sed -i 's/^DEPENDS_${PN}/DEPENDS/g' recipes-azure-device-update/adu-agent-service/adu-agent-service.bb

# Don't know why this was missing ... it's referenced in the swupdates files all over and should be along.
cat >>recipes-support/swupdate/swupdate_%.bbappend <<EOL

DEPENDS_append += " mtd-utils"
EOL

After updating the meta-files, you go one level up, initialize the yocto-build-env and add the layers by running these commands:

cd ..

source poky/oe-init-build-env

bitbake-layers add-layer ../meta-openembedded/meta-oe
bitbake-layers add-layer ../meta-openembedded/meta-python
bitbake-layers add-layer ../meta-openembedded/meta-networking
bitbake-layers add-layer ../meta-openembedded/meta-multimedia
bitbake-layers add-layer ../meta-raspberrypi
bitbake-layers add-layer ../meta-swupdate
bitbake-layers add-layer ../meta-azure-device-update

I added the following settings to the build/conf/local.conf:

cat >>conf/local.conf <<EOL

MACHINE = "raspberrypi3"

SDIMG_ROOTFS_TYPE = "ext4"
ENABLE_UART = "1"
RPI_USE_U_BOOT = "1"
PREFERRED_PROVIDER_virtual/bootloader = "u-boot"
DISTRO_FEATURES_append = " systemd virtualization"
VIRTUAL-RUNTIME_init_manager = "systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
VIRTUAL-RUNTIME_initscripts = ""

IMAGE_INSTALL_append = " adu-agent-service"

ADUC_PRIVATE_KEY = "/home/yocto/project/priv.pem"
ADUC_PRIVATE_KEY_PASSWORD = "/home/yocto/project/priv.pass"

EOL

The files referenced in the last two lines are needed for swupdate and can be generated by using the following command:

echo "TestPassword" > priv.pass
openssl genrsa -aes256 -passout file:priv.pass -out priv.pem

Now you should be able to build by running bitbake core-image-base 🎉

Hope this is helpful to someone. In case anything of what I did was stupid, please tell me! I'm not yet very familiar with yocto but open for improvements, which I'll update right away.

It would also be nice if @microsoftopensource would put this into a separate repository so the community can at least add patches for the individual yocto-releases - even though there aren't any plans to do so yet (#56 (comment)).

@Voxel07
Copy link

Voxel07 commented Jul 19, 2021

To stay in the spirit of yocto and keep things separated, I added a new target to build against.
You can then place everything that belongs to device update into this target. This has the benefit, that you can still build your base target without having to modify your local.conf.

require recipes-config/images/your-base-image

DESCRIPTION = ""
LICENSE = ""

CORE_IMAGE_EXTRA_INSTALL += " \
    azure-device-update   \
    adu-agent-service \
"

@SimonSimCity
Copy link
Author

@Voxel07 Thanks for the hint - I only mentioned azure-device-update as dependency in my code, updated now to adu-agent-service which includes the former and adds a daemonized service.

@SimonSimCity
Copy link
Author

SimonSimCity commented Aug 24, 2021

For everyone bumping in here: I created a repository containing a branch for each version of yocto I got the meta-layer running on. Some of them, like the zeus one also contain some useful additions and bugfixes: https://github.com/munit-solutions/meta-azure-device-update/tree/zeus

@eshashah-msft eshashah-msft added the area: yocto There is an issue with Yocto meta-layers label Jul 19, 2022
@eshashah-msft
Copy link
Contributor

Hi @SimonSimCity, we currently support honister and have our latest Yocto layers published here: https://github.com/Azure/iot-hub-device-update-yocto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: yocto There is an issue with Yocto meta-layers
Projects
None yet
Development

No branches or pull requests

3 participants