6 Replies Latest reply on Jun 28, 2017 8:58 AM by Kanna_NTN

    Joule ref-os-iot : How do I build and Flash the Kernel Image Independently?

    Kanna_NTN

      Hi all,

           I successfully compiled and flashed the ref-os-iot yocto build for Intel Joule.

       

           However, I have certain logics unexplained. I will explain what i attempted to figure out.

       

      1. How to generate a UEFI configuration file (/boot/EFI/bootx64.efi) file from the Kernel Image (bzImage) generated?
        • I notice that a run.do_uefiapp yocto script embeds Kernel Image and other files using objcopy.
        • But, I cannot find those files (machine.txt, cmdline, etc.) in the Yocto build.
        • Also, any references which explains UEFI booting process would be welcome
      2. How WIC generates Bootable Images from the Generated Rootfs?
        • I read some articles on how WIC uses the kickstart file (refosiot.wks) to generate the final image full-image-intel-5xx-64.wic.xz.
        • Exactly which options are to be used with wic to generate the Image remains a puzzle to me
      3. Why the full-image-intel-5xx-64.wic.xz Image generated is always a live booting Image?
        • full-image-intel-5xx-64.wic which we flash in the bootable USB / SD card always prompts to install in the EMMC, or performs a live boot.
        • I understand that the rootfs is compressed as squashfs in the Image generated.
        • I cannot figure out what to change in the configuration to generate an actual Image which i can flash and run in the SD card / USB drive.

       

      P.S:

                I have attached the above referred run.do_uefiapp python script file, and refosiot.wks WIC Kickstart file.

                I beleive you won't require the 1.2G full-image-intel-5xx-64.wic.xz

        • 1. Re: Joule ref-os-iot : How do I build and Flash the Kernel Image Independently?
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi Kanna,
           
          Thanks for your interest in the Intel® Joule Platform.
           
          Those are very good questions that I would like to investigate a little bit more and as soon as I have useful information I’ll let you know.
           
          I’ll appreciate your patience during the meantime.
           
          Regards,
          -Yermi A.
           

          • 2. Re: Joule ref-os-iot : How do I build and Flash the Kernel Image Independently?
            Kanna_NTN

            Hi Yermi,

                 Thanks for your interest in this topic. Is there any update on this query?

                

                 TIA.

             

            regards,

                 Kannan M.

            • 3. Re: Joule ref-os-iot : How do I build and Flash the Kernel Image Independently?
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hi Kannan,
               
              At this moment we are still working on your query, I would like to let you know that as soon as I have any updates I’ll let you know.
               
              Regards,
              -Yermi A.  
               

              • 4. Re: Joule ref-os-iot : How do I build and Flash the Kernel Image Independently?
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                Hi Kannan,

                Thank you for your patience. We would like to update you with the following information:

                1. How to generate a UEFI configuration file (/boot/EFI/bootx64.efi) file from the Kernel Image (bzImage) generated?
                  • bootx64.efi is generated during build via the do_uefiapp function. One can call the function via bitbake like so:
                bitbake -f -c uefiapp full-image
                    • Next, the xboot64.efi can be copied to the boot partition. See steps below.
                  • For iterative kernel development, the above method is quite time consuming and it's faster to compile the kernel in devshell and then copy the generated bzImage via objcopy on device: 
                    • Kernel compilation:
                bitbake -c devshell virtual/kernel
                make -j8
                # Kernel build dir is printed in the first line of make
                scp <KERNEL BUILD DIR>/arch/x86/bzImage root@<device ip>:/tmp/
                
                    • On device:
                # mount efi partition so xboot64.efi can be updated
                mkdir /tmp/boot_part
                mount /dev/mmcblk1p1 /tmp/boot_part
                objcopy --remove-section .linux /tmp/boot_part/EFI/BOOT/bootx64.efi /tmp/bootx64-tmp.efi
                objcopy --add-section .linux=/tmp/bzImage --change-section-vma .linux=0x40000 /tmp/bootx64-tmp.efi /tmp/bootx64-new.efi
                # replace the bootx64.efi with the new file
                cp /tmp/bootx64-new.efi /tmp/boot_part/EFI/BOOT/bootx64.efi
                umount /tmp/boot_part
                reboot
                

                 

                  • Kernel command line is built from pieces. e.g. meta-ref-os-iot/meta-5xx/conf/machine/intel-5xx-64.conf:
                APPEND_append = " console=ttyS2,115200 video=efifb maxcpus=4 reboot=efi kmemleak=off net.ifnames=0"
                

                 

                  • Device boot process/flow is as follows: BIOS -> bootx64.efi -> kernel -> ramdisk -> user space (systemd/init) 
                    • bootx64.efi has kernel, kernel command line and ramdisk embedded in it

                 

                     2. How WIC generates Bootable Images from the Generated Rootfs? 

                  • Ref-OS-IoT uses intel-refkit as base and WIC generation is done in that layer. WIC itself is part of meta-openempedded layers and is something that comes from yocto/oe.
                  • .wks file is this: intel-iot-refkit/meta-refkit/wic/refkit-directdisk.wks.in

                 

                     3. Why the full-image-intel-5xx-64.wic.xz Image generated is always a live booting Image? 

                  • This is how the development team has decided to implement this feature. It's similar to Ubuntu, you can try and install it in case you are interested in.
                  • rootfs is not using squashfs. The wic image is an uncompressed image (three partitions stitched into one), but wic.xz is a compressed image.
                  • I cannot figure out what to change in the configuration to generate an actual Image which I can flash and run in the SD card / USB drive.
                    • Remove the installer and you'll have a booting image without any prompts during boot. Remove/comment out this line (meta-ref-os-iot/meta-5xx/conf/local.conf.sample):
                PACKAGE_INSTALL_append_pn-refkit-initramfs = " initramfs-framework-installer"
                


                Hope this information helps.

                Regards,
                -Yermi A.

                • 5. Re: Joule ref-os-iot : How do I build and Flash the Kernel Image Independently?
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hi Kanna,

                  I would like to know if you have any other questions.

                  Regards,
                  -Yermi A.

                  • 6. Re: Joule ref-os-iot : How do I build and Flash the Kernel Image Independently?
                    Kanna_NTN

                    Hi Yermi,

                         Thanks for your reply. The steps mentioned were useful.