{"id":593,"date":"2014-06-25T09:00:21","date_gmt":"2014-06-25T07:00:21","guid":{"rendered":"http:\/\/www.thelins.se\/johan\/blog\/?p=593"},"modified":"2014-06-22T23:14:38","modified_gmt":"2014-06-22T21:14:38","slug":"yocto-part-iii-a-custom-meta-layer","status":"publish","type":"post","link":"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-iii-a-custom-meta-layer\/","title":{"rendered":"Yocto part III &#8211; a custom meta layer"},"content":{"rendered":"<p>In this part of the series (previous: <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-i-baseline-boot-time\/\">i<\/a>, <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-ii-baseline-image-size\">ii<\/a>) we will have a look at setting up our own meta layer, so that we can make changes without having to fork the Yocto recipes.<\/p>\n<p>The easiest way to create a layer is to use the <a href=\"http:\/\/www.yoctoproject.org\/docs\/current\/dev-manual\/dev-manual.html#creating-a-general-layer-using-the-yocto-layer-script\">yocto-layer<\/a> tool. To fully understand what a layer consists of, I recommend looking at the instructions for <a href=\"http:\/\/www.yoctoproject.org\/docs\/current\/dev-manual\/dev-manual.html#creating-your-own-layer\">creating a layer manually<\/a> as well. So, long story short:<\/p>\n<p><code> cd ..<br \/>\nyocto-layer create diet<br \/>\n<\/code><\/p>\n<p>The name, meta-diet, comes from my goal with this series &#8211; to create a minimal fast booting image. Only time will tell how well that goes.<\/p>\n<p>The yocto-layer create command produces an MIT-licensed layer. The MIT license is a weak copyleft, so you can choose to close it. I&#8217;ll leave it open for your enjoyment. Also, remember to change the README file. It contains a few references to xxxx and yyyy, which would be you and your project.<\/p>\n<p>As we don&#8217;t want the layer to be a part of the layers provided by the Yocto project, we need to separate it out. To do this, change the directory so that you stand in the meta-diet directory and run:<\/p>\n<p><code> git init<br \/>\n<\/code><\/p>\n<p>Now you are free to do what you like. I suggest making a commit of what is there and perhaps add a remote so that you can push your changes somewhere.<\/p>\n<p>An empty layer is only so much fun, so lets start by adding a recipe for your core-image-minimal, enhanced with systemd-analyze. First, let&#8217;s create a directory for the recipe:<\/p>\n<p><code> mkdir -p\u00a0recipes-diet\/images<br \/>\n<\/code><\/p>\n<p>In that directory, create the\u00a0diet-image.bb file using your favorite, non-emacs, editor. Put the following code in it. This means that we use the core-image-minimal as base, and add systemd-analyze to what we want to install onto the image.<\/p>\n<p><code>require recipes-core\/images\/core-image-minimal.bb<br \/>\n<\/code><\/p>\n<p><code>IMAGE_INSTALL += \"systemd-analyze\"<\/code><\/p>\n<p>As copying code from a blog post is boring, I&#8217;ve put the layer on <a href=\"https:\/\/github.com\/e8johan\/meta-diet\">github as meta-diet<\/a>. For this installment, use the part-iii tag.<\/p>\n<p>To build the diet image, change directory to the build directory and edit the conf\/bblayers.conf file. Simply add the new layer to the BBLAYERS variable. Now you can bitbake the new image as simple as:<\/p>\n<p><code>bitbake diet-image<\/code><\/p>\n<p>So, this installment got us nowhere feature wise, but now we have everything in place to start experimenting!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this part of the series (previous: i, ii) we will have a look at setting up our own meta layer, so that we can make changes without having to fork the Yocto recipes. The easiest way to create a layer is to use the yocto-layer tool. To fully understand what a layer consists of, &hellip; <a href=\"https:\/\/www.thelins.se\/johan\/blog\/2014\/06\/yocto-part-iii-a-custom-meta-layer\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Yocto part III &#8211; a custom meta layer<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-593","post","type-post","status-publish","format-standard","hentry","category-yocto"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/comments?post=593"}],"version-history":[{"count":6,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/593\/revisions"}],"predecessor-version":[{"id":608,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/posts\/593\/revisions\/608"}],"wp:attachment":[{"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/media?parent=593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/categories?post=593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thelins.se\/johan\/blog\/wp-json\/wp\/v2\/tags?post=593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}