10 Replies Latest reply on Apr 18, 2015 1:51 PM by IntelAnonymous

    How to change yocto configuration

    IntelAnonymous

      Adding or removing specific packages to the bitbake build process is one thing. However, I noticed that I still have to make several additional adjustments after flashing my custom image.


      Examples:

       

      • I have to change the hostname manually
      • I want to enable SSH access via WLAN therefore I have to edit sshd.socket
      • I want to add "user1" and "userX"
      • I want to password protect root
      • I want to add a script of mine (autostart)
      • [...]

       

      These are just examples.

       

      The main idea is, that I do not want to make all these changes each time manually afterwards but have them already included within my custom image. Flashing and done.

      Additionally I want to keep these changes somehow separated, if possible. Because if Intel releases new Linux source files I

       

      1. do not want to lose my changes
      2. do not want to add them all again to the build tree

       

      Does anyone know where to start?

        • 1. Re: How to change yocto configuration
          nniles

          IntelAnonymous,

           

          For the first part, you can look here for starters: https://wiki.yoctoproject.org/wiki/FAQ:How_do_I_set_or_change_the_root_password

           

          For the last part, I believe that the "Yocto" approach is to create your own layer.  If you want to make major modifications to the default image that comes with the BSP (edison-image), then you will probably want to include a new image as part of that.  It's not difficult, and you can just copy edison-image for starters.

           

          To create a layer, start here: http://www.yoctoproject.org/docs/current/dev-manual/dev-manual.html#creating-a-general-layer-using-the-yocto-layer-script

           

          Folder hierarchy seems to be significant in Yocto, so if you're trying to add to a recipe in your layer, you need to have a .bbappend file with the same name as the original .bb, and located in the same place.

           

          I'll be more specific with an example:

           

          To set a default hostname, you need to override the base-files recipe.  In the Yocto layers, this is found at: /path/to/edison-src/poky/meta/recipes-core/base-files/base-files_3.0.14.bb . There is function in that recipe that creates the /etc/hostname file in the target image, with a default value of openembedded.

           

          So if you make a layer called "local", then you will need to add a single line of text containing hostname = "myEdison" to the file /path/to/meta-local/recipes-core/base-files/base-files_3.0.14.bbappend .

           

          To include your layer, just add the path to it in /path/to/edison-src/build/conf/bblayers.conf .

           

          Hopefully this has given you something to start with.  I think that the rest of what you're trying to do can be figured out from here, and with a few searches on these forums (e.g. for info on how SSH logins are initially restricted).

           

          Thanks,

          • 2. Re: How to change yocto configuration
            IntelAnonymous

            nniles thanks for your response. Your proposed approach (= creating an own layer) seems to be the right one. Again, new stuff to learn, but the yocto documentation and having a look at the intel recipes helps creating an own layer.

            • 3. Re: How to change yocto configuration
              nniles

              IntelAnonymous,

               

              If you set up your own layer (let's assume it's called "local"), you can set up WIFI connectivity and enable SSH by default with these instructions.  If you don't set up your own layer, you can make these changes directly in the edison-distro layer (files under /path/to/edison-src/device-software/meta-edison-distro/).

               

              We have to override the openssh and wpa_supplicant recipes:

              1. mkdir -p /path/to/meta-local/recipes-connectivity/openssh/files

              2. mkdir -p /path/to/meta-local/recipes-connectivity/wpa_supplicant/files

               

              This allows us to provide bitbake with a file to be used in the openssh recipe (and it will override the file provided in the original location):

              3. create a new file /path/to/meta-local/recipes-connectivity/openssh/openssh_%.bbappend with the contents:

              FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

              4. create a new file /path/to/meta-local/recipes-connectivity/openssh/files/sshd.socket with the contents:

              [Unit]

              Conflicts=sshd.service

               

              [Socket]

              ExecStartPre=/bin/mkdir -p /var/run/sshd

              ListenStream=22

              # restrict access to wired access for security reasons

              # comment this line to remove restriction

              # BindToDevice=usb0

              Accept=yes

               

              [Install]

              WantedBy=sockets.target

               

              Again, we need to override a file provided in a recipe.

              5. create a new file /path/to/meta-local/recipes-connectivity/wpa_supplicant/wpa-supplicant_2.1.bbappend with the contents:

              FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

              6. set up WIFI connectivity on your Edison using configure_edison --wifi

              7. create a new file /path/to/meta-local/recipes-connectivity/wpa_supplicant/files/wpa_supplicant.conf-sane and copy the contents from /etc/wpa_supplicant/wpa_supplicant.conf (on your Edison) into it (make sure that there's a network={...} section in it)

               

              The final step is to tell systemd to start wpa_supplicant at boot time.  This is the command that is issued if you run systemctl enable wpa_supplicant on the Edison (if it's not already started).

              8. add the following to your image recipe:

              ROOTFS_POSTPROCESS_COMMAND += "enable_wifi;"

              enable_wifi(){

                ln -s '${IMAGE_ROOTFS}/lib/systemd/system/wpa_supplicant.service' '${IMAGE_ROOTFS}/etc/systemd/system/multi-user.target.wants/wpa_supplicant.service'

              }

               

              This has been an interesting exercise, thanks!

              • 4. Re: How to change yocto configuration
                IntelAnonymous

                I need some help...

                 

                nniles schrieb:

                 

                For the last part, I believe that the "Yocto" approach is to create your own layer.  If you want to make major modifications to the default image that comes with the BSP (edison-image), then you will probably want to include a new image as part of that.  It's not difficult, and you can just copy edison-image for starters.

                 

                [...]

                 

                To include your layer, just add the path to it in /path/to/edison-src/build/conf/bblayers.conf .

                 

                In the best case I would like to keep all the Intel Stuff and just override in my layer specific parts.

                 

                I created my own layer and added it to bblayers.conf. But how do I actually "activate" it? I want that all recipes within my layer are additionally executed but so far all my changes to not appear within the final image even though my recipes are parsed. Or do I really have to create my own image to archieve that?

                • 5. Re: How to change yocto configuration
                  nniles

                  IntelAnonymous,

                   

                  If you just want to add things to the default image, you should be able to get your changes in by creating the following file:

                   

                  /path/to/meta-local/recipes-core/images/edison-image.bbappend

                   

                  Then you can add things with IMAGE_INSTALL += "...", or do the stuff above to set the root password and start wpa_supplicant at boot time.

                   

                  If you want to exclude things that are in edison-image (like audio or Arduino support), then you need to create your own image, I believe.

                   

                  Thanks,

                  • 6. Re: How to change yocto configuration
                    IntelAnonymous

                    nniles schrieb:

                     

                    IntelAnonymous,

                     

                    If you set up your own layer (let's assume it's called "local"), you can set up WIFI connectivity and enable SSH by default with these instructions.  If you don't set up your own layer, you can make these changes directly in the edison-distro layer (files under /path/to/edison-src/device-software/meta-edison-distro/).

                     

                    We have to override the openssh and wpa_supplicant recipes:

                    1. mkdir -p /path/to/meta-local/recipes-connectivity/openssh/files

                    2. mkdir -p /path/to/meta-local/recipes-connectivity/wpa_supplicant/files

                     

                    This allows us to provide bitbake with a file to be used in the openssh recipe (and it will override the file provided in the original location):

                    3. create a new file /path/to/meta-local/recipes-connectivity/openssh/openssh_%.bbappend with the contents:

                    FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

                    4. create a new file /path/to/meta-local/recipes-connectivity/openssh/files/sshd.socket with the contents:

                    [Unit]

                    Conflicts=sshd.service

                     

                    [Socket]

                    ExecStartPre=/bin/mkdir -p /var/run/sshd

                    ListenStream=22

                    # restrict access to wired access for security reasons

                    # comment this line to remove restriction

                    # BindToDevice=usb0

                    Accept=yes

                     

                    [Install]

                    WantedBy=sockets.target

                     

                    This is how i did it. I just want to add that *.bbappend is not sufficient. You have to set the BBFILE_PRIORITY of your layer to a higher priority than the edison layers (In my case: 7).

                    • 7. Re: How to change yocto configuration
                      nniles

                      Interesting.  My local layer is set to priority 6 - but I have also defined a new image in that layer that I am using.

                       

                      Thanks,

                      • 8. Re: How to change yocto configuration
                        IntelAnonymous

                        To be more precisely: It did not work for me when using priority 5, after changing to 7 it worked. So maybe 6 (equal) is also fine. Another question: Do you know whether it is possible to perform root actions in, e.g. "do_install"? E.g. if I create a folder, such as "mkdir /home/myFolder" I get strange root_fs errors.

                        • 9. Re: How to change yocto configuration
                          nniles

                          IntelAnonymous

                           

                          Look down about half the page for do_install, and then at the recipe at the botoom here Styleguide - Openembedded.org for what you're trying to do.

                           

                          It looks like the following is the recommended syntax to create a directory (with 755 as privileges on it):

                          install -m 0755 -d ${D}/home/myFolder

                           

                          Then, to copy a file from the package build directory into that location (with 644 as privileges on it):

                          install -m 0644 ${WORKDIR}/README ${D}/home/myFolder/README

                           

                          Thanks,

                          • 10. Re: How to change yocto configuration
                            IntelAnonymous

                            nniles schrieb:

                             

                            IntelAnonymous

                            It looks like the following is the recommended syntax to create a directory (with 755 as privileges on it):

                            install -m 0755 -d ${D}/home/myFolder

                             

                            Thanks,

                             

                            I am really trying to figure out whats wrong, but "myFolder" is not appearing. I do not know why, but paths like

                             

                            ${D}${datadir}/FooBar

                             

                            are created. Do you know what might be wrong?