{"id":68728,"date":"2018-12-13T14:41:15","date_gmt":"2018-12-13T14:41:15","guid":{"rendered":"http:\/\/www.sickgaming.net\/blog\/2018\/12\/13\/strategies-for-deploying-embedded-software\/"},"modified":"2018-12-13T14:41:15","modified_gmt":"2018-12-13T14:41:15","slug":"strategies-for-deploying-embedded-software","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2018\/12\/13\/strategies-for-deploying-embedded-software\/","title":{"rendered":"Strategies for Deploying Embedded Software"},"content":{"rendered":"<div><img decoding=\"async\" src=\"http:\/\/www.sickgaming.net\/blog\/wp-content\/uploads\/2018\/12\/strategies-for-deploying-embedded-software.png\" class=\"ff-og-image-inserted\" \/><\/div>\n<p><span><span>While many <\/span><a href=\"https:\/\/events.linuxfoundation.org\/events\/elc-openiot-europe-2018\/\"><span>Embedded Linux Conference<\/span><\/a><span> talks cover emerging technologies, some of the most useful are those that survey the embedded development tools and techniques that are already available. These summaries are not only useful for newcomers but can be a helpful reality check and a source for best practices for more experienced developers.<\/span><\/span><\/p>\n<p><span><span>In \u201c<\/span><span>Strategies for Developing and Deploying your Embedded Applications and Images,\u201d Mirza Krak, an embedded developer at Mender.io, surveys the many options for prepping and deploying software on devices. These range from cross-device development strategies between the desktop and embedded platforms to using IDEs to working with <\/span><span>Yocto\/OE-Core with package managers. Krak, who spoke at this October\u2019s ELC Europe conference in Edinburgh, also covered configuration management tools, network boot utilities, and update solutions such as swupdate and Mender.<\/span><\/span><\/p>\n<h3><span><span>Basic desktop\/embedded cross development<\/span><\/span><\/h3>\n<p><span><span>It\u2019s easier to do your development on a desktop PC rather than directly on an embedded device, said Krak. Even if your device can run the required development software and distributions, you cannot easily integrate all the tools that are available on the desktop. In addition, compile times tend to be very slow. <\/span><\/span><\/p>\n<p><span><span>On the desktop, \u201ceverything is available to you via apt-get install, and there is high availability of trace and debug tools,\u201d said Krak. \u201cYou have a lot more control when doing things like running a binary, and you can build, debug, and test on the same machine so there are usually very short development cycles.\u201d<\/span><\/span><\/p>\n<p><span><span>Eventually, however, you\u2019ll probably need to do some cross-device development. \u201cYou can use some mock hardware to do some basic sanity testing on the desktop, but you are not testing on the hardware where the software will run, which may have some constraints.\u201d<\/span><\/span><\/p>\n<p><span><span>A typical approach for cross-device development is to run Yocto Project or Buildroot on your PC and then cross compile and transfer the binaries to the embedded device. This adds to the complexity because you are compiling the code on one device and you may need to transfer it to multiple devices for testing.<\/span><\/span><\/p>\n<p><span><span>You can use the secure copy (scp) command or transfer data by USB stick. However, \u201cIt\u2019s a lot of manual work and prone to error, and it\u2019s hard to replicate across many devices,\u201d said Krak. \u201cI\u2019m surprised at how many people don\u2019t go beyond this entry point.\u201d <\/span><\/span><\/p>\n<h3><span><span>IDEs and Package Managers<\/span><\/span><\/h3>\n<p><span><span>An easier and more reliable approach is to use an IDE such as Eclipse or Qt Creator, which have plug-ins to cross compile. \u201cIDEs usually have post-build hooks that transfer the binary to the device and run it,\u201d said Krak. \u201cWith Qt Creator, you can launch the debug server on the device and do remote debugging remotely.\u201d<\/span><\/span><\/p>\n<p><span><span>IDEs are great for simpler projects, especially for beginning or casual developers, but they may lack the flexibility required for more complex jobs. Krak generally prefers package managers &#8212; collections of tools for automating the processing of installing, upgrading, configuring, and removing software &#8212; which are much the same as those you\u2019d find on a desktop Linux PC.<\/span><\/span><\/p>\n<p><span><span>\u201cPackage managers give you more sanity checks and controls, and the ability to state dependencies,\u201d said Krak. Package managers for embedded targets include deb, rpm, and opkg, and you can also turn to package utilities like apt, yum, dnf, pacman, zipper, and smart.<\/span><\/span><\/p>\n<p><span><span>\u201cIf you\u2019re compiling your Debian application in a build system you could say \u2018make dpkg\u2019, which will package your binary and any configuration files you might have,\u201d said Krak. \u201cYou can then transfer the binary to your device and install. This is less error prone since you have dependency tracking and upstream and custom package feeds.\u201d<\/span><\/span><\/p>\n<p><span><span>Package managers are useful during prototyping and early development, but you typically won\u2019t make them available to the embedded end user, said Krak. In addition, not all embedded devices support platforms such as Ubuntu or Raspbian that include package managers. <\/span><\/span><\/p>\n<p><span><span>Krak typically works with a Yocto Project\/Open Embedded environment and uses the OE-core Angstrom distribution, which maintains opkg package feeds. \u201cYou can include meta-angstrom in your Yocto build and set DISTRO = \u2018angstrom\u2019 to you get package feeds,\u201d said Krak. \u201cBut there\u2019s a lot more to Angstrom that you may not want, so you may want to create a more customized setup based on Poky or something.\u201d<\/span><\/span><\/p>\n<p><span><span>Yocto generates package feeds when you do an image build, giving you a choice of rpm, deb, or ipk. Yet, \u201cthese are only packages, not a complete package feed,\u201d said Krak. To enable a feed, \u201cthere\u2019s a bitbake package-index command that generates the files. You expose the deploy server where all your packages are to make it available on your device.\u201d<\/span><\/span><\/p>\n<p><span><span>While this process handles the \u201cservice side\u201d package feed, you still need tools on your embedded device. Within Yocto, \u201cthere\u2019s an EXTRA_IMAGE_FEATURES setting you can set to package-management,\u201d said Krak. \u201cThere\u2019s also a recipe in meta-openembedded\/meta-oe called distro-feed-configs.bb. If you include it in your build it will generate the config files needed for your package manager.\u201d<\/span><\/span><\/p>\n<h3><span><span>Config management, network boot, and update solutions<\/span><\/span><\/h3>\n<p><span><span>Krak went on to discuss configuration management tools such as CFEngine, Puppet, Chef, and Ansible. \u201cThese are very common in the enterprise server world if you need to manage a fleet of servers,\u201d said Krak. \u201csome apply workflows to embedded devices. You install a golden image on all your devices, and then set up connectivity and trust between the CM server and device. You can then script the configuration.\u201d<\/span><\/span><\/p>\n<p><span><span>Krak also surveyed solutions for more complex projects in which the application extends beyond a single binary. \u201cYou may be developing a specialized piece of hardware for a very specific use case or perhaps you depend on some custom kernel options,\u201d said Krak. <\/span><\/span><\/p>\n<p><span><span>Network booting is useful here because you can \u201cdeploy all the resources necessary to boot your device,\u201d said Krak. \u201cOn boot, the system fetches the Linux kernel device tree and file system, so you just need to reboot the device to update the software. The setup can be complex, but it has the advantage of being easily extended to boot multiple devices.\u201d<\/span><\/span><\/p>\n<p><span><span>Typical network booting schemes such as PXELINUX and PXE boot use a tftp server setup on a laptop where you put the build artifacts you want to deploy. Alternatively, you can script it using the NFS root file-system.<\/span><\/span><\/p>\n<p><span><span>A final alternative for complex systems is to use an update solution such as Mender, rauc, or swupdate. \u201cYou can use these early in the development process to deploy your builds,\u201d said Krak. \u201cIf you build the same device in production, you can use the same software to test it throughout the development process, which builds confidence. Some use image-based updates, which is nice because your devices are stateless, which simplifies testing. Updaters fit well into development workflow and make it easier to integrate build artifacts. They often have features to avoid bricking devices.\u201d<\/span><\/span><\/p>\n<p><span><span>As a developer for Mender.io, Krak is most familiar with <\/span><a href=\"http:\/\/linuxgizmos.com\/open-source-ota-software-targets-linux-devices\/\"><span>Mender<\/span><\/a><span>, which provides an A\/B image update strategy. \u201cYou have two copies of the OS and you do image-based updates so you always update the whole system,\u201d explained Krak. You can watch the complete\u00a0presentation below.<\/span><\/span><\/p>\n<p>[youtube https:\/\/www.youtube.com\/watch?v=rCDZVjHHC6o]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While many Embedded Linux Conference talks cover emerging technologies, some of the most useful are those that survey the embedded development tools and techniques that are already available. These summaries are not only useful for newcomers but can be a helpful reality check and a source for best practices for more experienced developers. In \u201cStrategies [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":68729,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-68728","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-freebsd-unix"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/68728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=68728"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/68728\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media\/68729"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=68728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=68728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=68728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}