14 Replies Latest reply on Dec 1, 2014 2:12 AM by mhahn

    [SOLVED] Best way to clean, rebuild kernel

    mjstanis

      Hi everyone,

       

      I've seen a variety of posts on the best way to incrementally build Yocto without clearing all your cache and work directories.  However, I've found that when I modify the kernel in the following ways:

       

      - Add a patch

      - Change a menuconfig option

      - Edit a kernel source file

       

      And rebuild using the methods I found, the changes don't seem to make it into the kernel.  The only foolproof way I have right now is to delete my directories and rebuild from scratch, which is painful.

       

      What is the proper sequence of commands to clean and rebuild only the kernel and deploy it to an SD card?

       

      Thanks!

      Matt

        • 1. Re: Best way to clean, rebuild kernel
          CMata_Intel

          Hi Matt;

           

          A recommended way to do it is as the BSP guide and the Yocto Website says.

          I don't know if you already have checked these links, but it could be helpful:

               https://communities.intel.com/thread/48499

               http://www.malinov.com/Home/sergey-s-blog/intelgalileo-buildinglinuximage > In this one you could check the changes made in the image and the configuration of the kernel after that.

           

          Regards;

          CMata

          • 2. Re: Best way to clean, rebuild kernel
            mjstanis

            Hi CMata,

             

            Thanks for the links.  I have built Sergey's image before, so I understand his method for adding patches and then compiling.  I've also looked at the BSP and based on what I can find, it points to making menuconfig changes, which I describe below.

             

            I should also correct myself and say that I can get menuconfig changes to compile in using the following commands on a build directory where I've already compiled a full SD image before (Note: I'm using the IoT DevKit now):

            source iot-devkit-init-build-env

            bitbake linux-yocto-quark -c menuconfig

            bitbake iot-devkit-prof-dev-image (or whatever your image is)

             

            My issue is once I compile a full image, say I want to either add a patch file or edit the kernel source.  Once I edit a file, I want to run a command that will rebuild the kernel with my changes without rebuilding my whole image.

             

            The Yocto guide briefly mentions this in Section 4.1.2.2 of the link you provided:

            Rebuild the kernel image with your changes: Rebuilding the kernel image applies your changes.

             

            The first question is, what is the command used to rebuild the kernel image?

             

            Also, I'm currently editing kernel files in meta-intel-iot-devkit/build/tmp/work/quark-poky-linux/linux-yocto-quark/3.8-r0/linux before I rebuild.

             

            Is that the correct kernel source directory to edit files?

             

            Thanks!

            Matt

            • 3. Re: Best way to clean, rebuild kernel
              mhahn

              did you run a "bitbake -c cleansstate linux-yocto"?

              • 4. Re: Best way to clean, rebuild kernel
                mhahn

                ... or whatever your kernel is called

                • 5. Re: Best way to clean, rebuild kernel
                  mjstanis

                  Hi mhahn,

                   

                  I believe I tried that before, but just to be safe I went through the procedure again.  With a fully built image, I went back to the build/ directory and did the following:

                   

                  1. bitbake -c cleansstate linux-yocto-quark
                  2. bitbake -c menuconfig linux-yocto-quark
                  3. Edited config, saved
                  4. Edited a kernel source .c file, adding a printk() to a location I know would show up at boot
                  5. bitbake iot-devkit-prof-dev-image

                   

                  I copied the resulting files to SD (only bzImage was modified) and booted.

                   

                  The result: I did not find my printk() statement at boot, so it appears that my source change didn't get wrapped into the updated kernel.

                   

                  Any thoughts?

                   

                  Thanks!

                  Matt

                  • 6. Re: Best way to clean, rebuild kernel
                    mhahn

                    What happens if you run "bitbake linux-yocto-quark" after you modified the kernel and prior to bitbaking the image?

                    • 7. Re: Best way to clean, rebuild kernel
                      mjstanis

                      Hi mhahn,

                       

                      I gave that a shot, but no luck.  I also tried to edit the kernel source .c file in meta-intel-iot-devkit/build/tmp/work/quark-poky-linux/linux-yocto-quark/3.8-r0/linux-quark-standard-build instead of meta-intel-iot-devkit/build/tmp/work/quark-poky-linux/linux-yocto-quark/3.8-r0/linux with no luck.

                       

                      Matt

                      • 8. Re: Best way to clean, rebuild kernel
                        CMata_Intel

                        Hi mjstanis;

                         

                        Have you tried editing the local.conf file? You can use BB_NUMBER_THREADS and PARALLEL_MAKE twice your host processor's number of cores. Take a look in the section Configuring the local.conf File in this link

                         

                        Regards;

                        CMata

                        • 9. Re: Best way to clean, rebuild kernel
                          mhahn

                          I don't see how this would flush the cash and trigger a correct new build.

                          • 10. Re: Best way to clean, rebuild kernel
                            AlexT_Intel

                            To rebuild the kernel (and just the kernel) after updating the config or anything in the sources, you better run

                            bitbake -f -c deploy linux-yocto-clanton

                            to compile the kernel and put it into tmp/deploy/image.

                            Put the actual kernel recipe name if you're using other BSP than the standard one (i.e. DevKit's one would be called differently as I can see from the paths you've posted, I haven't tried this one myself).

                             

                            Cleaning sstate or rebuilding the whole image is redundant here and just cause more work (and delay) than necessary.

                             

                            You can find additional hints regarding the kernel development cycle recommended by Yocto team here:

                            http://www.yoctoproject.org/docs/1.6.1/mega-manual/mega-manual.html#modifying-source-code

                            • 11. Re: Best way to clean, rebuild kernel
                              mjstanis

                              Thanks Alex!  After trying the deploy command, I was still missing something, so I took a look at the Yocto link you provided and after following the instructions, I got it to work!

                               

                              Here are instructions for manual source editing that worked for me:

                               

                              1. bitbake linux-yocto-quark -c kernel_configme -f
                              2. bitbake linux-yocto-quark -c menuconfig
                              3. Make any menuconfig changes and save
                              4. Edit a kernel source .c file, adding a printk() to a location I know would show up at boot
                              5. bitbake -f linux-yocto-quark (edited per Alex's comments below)
                              6. bitbake iot-devkit-prof-dev-image (or whatever your image is)


                              I was able to copy the new image to my SD, boot and see my printk() in the dmesg output:


                              [        4.285756] MATT WAS HERE!

                               

                              Thanks guys, looks like I'm all set!
                              Matt

                              1 of 1 people found this helpful
                              • 12. Re: Best way to clean, rebuild kernel
                                AlexT_Intel

                                If you don't need to execute the steps iteratively, then you can compress these three commands

                                1. bitbake linux-yocto-quark -c compile -f
                                2. bitbake linux-yocto-quark -c deploy
                                3. bitbake linux-yocto-quark

                                into just one

                                bitbake -f linux-yocto-quark

                                That will do compile, deploy and IPK package creation and "-f" is to make sure it disregards the sstate cache and actually does that.

                                1 of 1 people found this helpful
                                • 13. Re: Best way to clean, rebuild kernel
                                  mjstanis

                                  Hi Alex,

                                   

                                  Just tested your advice and confirmed the new image works with the compressed command.  I'll update my post above.

                                   

                                  Thanks!

                                  Matt

                                  • 14. Re: [SOLVED] Best way to clean, rebuild kernel
                                    mhahn

                                    in general one can check the available task for a specific recipe by calling

                                    bitbake -c listtasks <recipe name>
                                    

                                    which would list "compile" and "deploy" for

                                    bitbake -c listtasks linux-yocto-quark