Přeskočit na hlavní obsah

deploying binaries from a Yocto server using ssh port forwarding and devtool

I haven't been able to find anything on the internet regarding this topic, so here you go..

Our setup at work is:

  • A Yocto buildserver setup nicely with sstate cache and all the bells and whistles (don't ask me, I didn't do it),

  • an embedded device designed on top of the Raspberry Compute Module 3, connected to local wifi network and running an ssh server,

  • my laptop, connected to the same local network.

Now there's a basic Qt5 application that I didn't develop, but ported to CMake. I managed to make it build on the buildserver and now I'd like to deploy this build on the embedded device. I really don't want to build the whole custom image everytime I make a change on the Qt app.

There's many tutorials online on SSH Port Forwarding (tunneling), but none of them were for this specific usecase and none of them quite worked for me. Thankfully I have a linux wizard colleague that has networking experience whose wisdom I'll share with you.

First, you need to forward the port on the embedded device, from your machine, run:

$ ssh -L 10000:localhost:22 root@<local_embedded_device_ip>

This forwards the port 22 on the device to port 10000 on your machine.

Now, open another terminal on your machine and run:

$ ssh -R 10000:localhost:10000 <username>@<buildserver_ip_or_url>

This forwards the port 10000 on buildserver to the port 10000 on your machine.

Now, on the buildserver, you may run:

$ ssh root@localhost -p 10000

To connect to the embedded device, or deploy like this:

$ devtool deploy-target <recipe> root@localhost -P 10000 # Careful, it's capital -P !

You should see INFO: Successfully deployed line as output from bitbake. You can confirm by stat-ing the deployed binary on the embedded device, there should be a recent Change:.

You may be required to change some settings in the /etc/sshd_config for either the embedded device or buildserver. I am not sure exactly which ones, but AllowAgentForwarding yes might be necessary on the embedded device.

And there you go, that's how you deploy to a device on the local network using devtool and SSH Port Forwarding.

If you need any help with Yocto, Linux or Embedded Programming, feel free to email me or catch me on Mastodon. If you'd like to hire me for any of these things, you can, I'm a freelancer.