12 Replies Latest reply on Oct 24, 2016 1:14 PM by Intel Corporation

    Compiling kernel modules

    shmkv

      Hi,

      I need to modify the code of the kernel driver (hsu/mfd_core for work with RS485). I learned how to make changes to the kernel, but Bitbake reloads source codes and compiles whole kernel anew.  After that I have to create an image and reflash it. It is too long. Is there a possibility of separating the module from the image and its compilation as .ko? Can I read anything about it?

        • 1. Re: Compiling kernel modules
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello shmkv,
           
          I will try to help you with this. To make a module of a driver you will have to make changes to the kernel while building it. You will have to modify the Linux kernel config file and on the specific driver you need, change its option to "m".
           
          Could you please share with us the steps you have taken so far?
          We will be waiting for your response.
          -Peter.

          • 2. Re: Compiling kernel modules
            shmkv

            Hello Peter,

            I do a kernel cleanup:

            bitbake -f -c clean virtual/kernel

            after that I run compiling the kernel:

            bitbake -f -c compile virtual/kernel

            Before compiling the build script reloads the source code, and I am forced to replace the necessary files. I know what I'm doing wrong, but I don't know how to make a compile locally.

            /.setup.sh --mode=devenv

            command doesn't work (build environment 20160606)

            • 3. Re: Compiling kernel modules
              shmkv

              You will have to modify the Linux kernel config file and on the specific driver you need, change its option to "m"

              I need to replace in file i386_edison_defconfig "y" to"m" for the desired option (CONFIG_SERIAL_MFD_HSU=m)?

              And can I then compile this module separately? If so, how do I do that?

              • 4. Re: Compiling kernel modules
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                Hi shmkv,

                Yes, in order to create a module of a kernel driver, you have to use the option 'm' on the kernel configuration. When you finish building the image I'd suggest you to search for the modules using the command find -name mfd_core*. 

                Also, the user @dbaba has a thread very similar to yours in which he compiles a kernel driver into a module. I suggest you to check it out, I believe it would be of much help for you. It can be found in https://communities.intel.com/message/422223#422223.

                I hope this helps.
                -Peter.

                • 5. Re: Compiling kernel modules
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hello shmkv,

                  Do you have any updates about this?

                  -Peter.

                  • 6. Re: Compiling kernel modules
                    shmkv

                    Hello Peter,

                    I changed the configuration of the kernel, but when building having problems with unresolved symbols. Now I'm trying to understand the reason. I'll post more information later. I also do not understand how to build kernel modules separately. I found a similar topic (kernel headers), but I have the same problem with the version of the kernel.

                    • 7. Re: Compiling kernel modules
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      Thanks for the update shmkv, please do keep us updated. 

                      Have you checked the thread I posted above? It explains how to create a kernel module I thought it might be of help for you.

                      -Peter.

                      • 8. Re: Compiling kernel modules
                        shmkv

                        Hello Peter,

                        Yes, I have read the thread. I do about the same thing.

                        It explains how to create a kernel module I thought it might be of help for you.

                        Yes, it explains how to create a module. I will have a lot of iterations correction code->compiling module->testing. I would like to find the most convenient and fastest way to do this.

                         

                        I  have still problems with kernel compilation. I am trying to understand what a hsu_register_board_info. See build console:

                        You can also run generated qemu images with a command like 'runqemu qemux86'

                        test@test-VirtualBox:~/iot-devkit-yp-poky-edison-20160606/build_edison$ bitbake virtual/kernel -c configure -f -v

                        WARNING: Host distribution "Ubuntu-16.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.

                        Loading cache: 100% |###########################################| ETA:  00:00:00

                        Loaded 2238 entries from dependency cache.

                        WARNING: No recipes available for:

                          /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/../poky/meta-intel-iot-devkit/recipes-kernel/linux/linux-yocto-quark_3.8.bbappend

                        NOTE: selecting linux-externalsrc to satisfy virtual/kernel due to PREFERRED_PROVIDERS

                        NOTE: Resolving any missing task queue dependencies

                        NOTE: selecting pseudo-native to satisfy virtual/fakeroot-native due to PREFERRED_PROVIDERS

                        NOTE: selecting binutils-cross-i586 to satisfy virtual/i586-poky-linux-binutils due to PREFERRED_PROVIDERS

                        NOTE: selecting gcc-cross-i586 to satisfy virtual/i586-poky-linux-gcc due to PREFERRED_PROVIDERS

                        NOTE: selecting gcc-runtime to satisfy virtual/i586-poky-linux-compilerlibs due to PREFERRED_PROVIDERS

                        NOTE: selecting glibc to satisfy virtual/libc due to PREFERRED_PROVIDERS

                        NOTE: selecting linux-externalsrc to satisfy runtime kernel-base due to PREFERRED_PROVIDER_virtual/kernel = linux-externalsrc

                        NOTE: selecting linux-externalsrc to satisfy runtime kernel-image due to PREFERRED_PROVIDER_virtual/kernel = linux-externalsrc

                        NOTE: selecting glibc to satisfy runtime libsegfault due to PREFERRED_PROVIDER_virtual/libc = glibc

                        NOTE: selecting glibc to satisfy runtime glibc-dev due to PREFERRED_PROVIDER_virtual/libc = glibc

                        NOTE: selecting glibc to satisfy runtime glibc due to PREFERRED_PROVIDER_virtual/libc = glibc

                        NOTE: selecting glibc to satisfy virtual/i586-poky-linux-libc-for-gcc due to PREFERRED_PROVIDERS

                        NOTE: selecting linux-libc-headers to satisfy linux-libc-headers due to PREFERRED_PROVIDERS

                        NOTE: selecting gcc-cross-i586 to satisfy virtual/i586-poky-linux-g++ due to PREFERRED_PROVIDERS

                        NOTE: selecting libgcc to satisfy libgcc due to PREFERRED_PROVIDERS

                        NOTE: selecting gcc-cross-initial-i586 to satisfy virtual/i586-poky-linux-gcc-initial due to PREFERRED_PROVIDERS

                        NOTE: selecting glibc-initial to satisfy virtual/i586-poky-linux-libc-initial due to PREFERRED_PROVIDERS

                        NOTE: selecting linux-libc-headers to satisfy runtime linux-libc-headers-dev due to PREFERRED_PROVIDER_linux-libc-headers = linux-libc-headers

                        NOTE: selecting libgcc to satisfy runtime libgcc due to PREFERRED_PROVIDER_libgcc = libgcc

                         

                        Build Configuration:

                        BB_VERSION        = "1.24.0"

                        BUILD_SYS         = "i686-linux"

                        NATIVELSBSTRING   = "Ubuntu-16.04"

                        TARGET_SYS        = "i586-poky-linux"

                        MACHINE           = "edison"

                        DISTRO            = "poky-edison"

                        DISTRO_VERSION    = "1.7.3"

                        TUNE_FEATURES     = "m32 core2"

                        TARGET_FPU        = ""

                        meta          

                        meta-intel-arduino

                        meta-intel-edison-bsp

                        meta-intel-edison-distro

                        meta-intel-iot-devkit

                        meta-intel-iot-middleware

                        meta-java     

                        meta-oic      

                        meta-filesystems

                        meta-networking

                        meta-oe       

                        meta-python   

                        meta-ruby     

                        meta-webserver

                        meta-yocto    

                        meta-yocto-bsp    = "<unknown>:<unknown>"

                         

                        NOTE: Preparing runqueue

                        NOTE: Marking Active Tasks

                        NOTE: Pruned 1262 inactive tasks, 253 left

                        NOTE: Assign Weightings

                        NOTE: Compute totals (have 1 endpoint(s))

                        NOTE: Invalidate task do_configure, /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/../poky/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/linux-externalsrc.bb

                        NOTE: Tainting hash to force rebuild of task /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/../poky/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/linux-externalsrc.bb, do_configure

                        WARNING: /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/../poky/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/linux-externalsrc.bb.do_configure is tainted from a forced run

                        NOTE: Executing SetScene Tasks

                        NOTE: Executing RunQueue Tasks

                        +

                        cd /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0

                        + do_configure

                        + cp /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/../poky/linux-kernel/arch/x86/configs/i386_edison_defconfig /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/.config

                         

                        + sed -i s/.*CONFIG_USB_SERIAL is not set.*/CONFIG_USB_SERIAL=y/ /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/.config

                         

                        + sed -i s/.*CONFIG_USB_SERIAL_FTDI_SIO.*/CONFIG_USB_SERIAL_FTDI_SIO=m/ /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/.config

                         

                        + sed -i s/.*CONFIG_USB_USBNET.*/CONFIG_USB_USBNET=y/ /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/.config

                         

                        + sed -i s/.*CONFIG_USB_RTL8150.*/CONFIG_USB_RTL8150=m/ /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/.config

                         

                        + sed -i s/.*CONFIG_USB_RTL8152.*/CONFIG_USB_RTL8152=m/ /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/.config

                         

                        + sed -i s/.*CONFIG_USB_GSPCA_OV534 is not set.*/CONFIG_USB_GSPCA_OV534=m/ /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/.config

                         

                        + sed -i s/.*CONFIG_USB_GSPCA_OV534_9 is not set.*/CONFIG_USB_GSPCA_OV534_9=m/ /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/.config

                         

                        + ret=0

                        + trap  0

                        + exit 0

                         

                        NOTE: Checking autotools environment for common misconfiguration

                        NOTE: linux-externalsrc: md5 checksum matched for file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7

                        NOTE: Tasks Summary: Attempted 253 tasks of which 252 didn't need to be rerun and all succeeded.

                         

                        Summary: There were 3 WARNING messages shown.

                        test@test-VirtualBox:~/iot-devkit-yp-poky-edison-20160606/build_edison$ bitbake edison-image

                        WARNING: Host distribution "Ubuntu-16.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.

                        Loading cache: 100% |###########################################| ETA:  00:00:00

                        Loaded 2238 entries from dependency cache.

                        WARNING: No recipes available for:

                          /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/../poky/meta-intel-iot-devkit/recipes-kernel/linux/linux-yocto-quark_3.8.bbappend

                        NOTE: Resolving any missing task queue dependencies

                        NOTE: multiple providers are available for jpeg (jpeg, libjpeg-turbo)

                        NOTE: consider defining a PREFERRED_PROVIDER entry to match jpeg

                        NOTE: multiple providers are available for runtime java2-runtime (cacao, jamvm, openjdk-8-jre, openjdk-7-jre, openjdk-6-jre)

                        NOTE: consider defining a PREFERRED_PROVIDER entry to match java2-runtime

                        NOTE: multiple providers are available for virtual/java-native (cacao-native, jamvm-native)

                        NOTE: consider defining a PREFERRED_PROVIDER entry to match virtual/java-native

                        NOTE: multiple providers are available for jpeg-native (jpeg-native, libjpeg-turbo-native)

                        NOTE: consider defining a PREFERRED_PROVIDER entry to match jpeg-native

                        NOTE: multiple providers are available for runtime java2-vm (openjdk-7-jre, openjdk-6-jre)

                        NOTE: consider defining a PREFERRED_PROVIDER entry to match java2-vm

                        NOTE: multiple providers are available for virtual/java-initial-native (cacao-initial-native, jamvm-initial-native)

                        NOTE: consider defining a PREFERRED_PROVIDER entry to match virtual/java-initial-native

                         

                        Build Configuration:

                        BB_VERSION        = "1.24.0"

                        BUILD_SYS         = "i686-linux"

                        NATIVELSBSTRING   = "Ubuntu-16.04"

                        TARGET_SYS        = "i586-poky-linux"

                        MACHINE           = "edison"

                        DISTRO            = "poky-edison"

                        DISTRO_VERSION    = "1.7.3"

                        TUNE_FEATURES     = "m32 core2"

                        TARGET_FPU        = ""

                        meta          

                        meta-intel-arduino

                        meta-intel-edison-bsp

                        meta-intel-edison-distro

                        meta-intel-iot-devkit

                        meta-intel-iot-middleware

                        meta-java     

                        meta-oic      

                        meta-filesystems

                        meta-networking

                        meta-oe       

                        meta-python   

                        meta-ruby     

                        meta-webserver

                        meta-yocto    

                        meta-yocto-bsp    = "<unknown>:<unknown>"

                         

                        NOTE: Preparing runqueue

                        WARNING: /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/../poky/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/linux-externalsrc.bb.do_configure is tainted from a forced run

                        NOTE: Executing SetScene Tasks

                        NOTE: Executing RunQueue Tasks

                        NOTE: validating kernel config, see log.do_kernel_configcheck for details

                        ERROR: Function failed: do_compile (log file is located at /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/temp/log.do_compile.3041)

                        ERROR: Logfile of failure stored in: /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/temp/log.do_compile.3041

                        Log data follows:

                        | DEBUG: Executing shell function do_compile

                        | NOTE: make -j 2 bzImage CC=i586-poky-linux-gcc  LD=i586-poky-linux-ld.bfd

                        |   GEN     /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/Makefile

                        | scripts/kconfig/conf --silentoldconfig Kconfig

                        | #

                        | # configuration written to .config

                        | #

                        | make[2]: Nothing to be done for 'all'.

                        |   GEN     /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/linux-externalsrc-1.0/Makefile

                        |   CHK     include/generated/uapi/linux/version.h

                        |   CHK     include/generated/utsrelease.h

                        |   CC      scripts/mod/devicetable-offsets.s

                        |   GEN     scripts/mod/devicetable-offsets.h

                        |   HOSTCC  scripts/mod/file2alias.o

                        |   HOSTLD  scripts/mod/modpost

                        | make[2]: Nothing to be done for 'relocs'.

                        |   Using /home/test/iot-devkit-yp-poky-edison-20160606/poky/linux-kernel as source for kernel

                        |   CALL    /home/test/iot-devkit-yp-poky-edison-20160606/poky/linux-kernel/scripts/checksyscalls.sh

                        |   CHK     include/generated/compile.h

                        |   PASYMS  arch/x86/realmode/rm/pasyms.h

                        |   LDS     arch/x86/realmode/rm/realmode.lds

                        |   LD      arch/x86/realmode/rm/realmode.elf

                        |   RELOCS  arch/x86/realmode/rm/realmode.relocs

                        |   OBJCOPY arch/x86/realmode/rm/realmode.bin

                        |   AS      arch/x86/realmode/rmpiggy.o

                        |   LD      arch/x86/realmode/built-in.o

                        |   VDSOSYM arch/x86/vdso/vdso32-int80-syms.lds

                        |   VDSOSYM arch/x86/vdso/vdso32-sysenter-syms.lds

                        |   VDSOSYM arch/x86/vdso/vdso32-syms.lds

                        |   LD      arch/x86/vdso/built-in.o

                        |   LD      arch/x86/built-in.o

                        | WARNING: arch/x86/built-in.o(.text+0x3581e): Section mismatch in reference from the function penwell_arch_setup() to the function .init.text:mfld_calibrate_tsc()

                        | The function penwell_arch_setup() references

                        | the function __init mfld_calibrate_tsc().

                        | This is often because penwell_arch_setup lacks a __init

                        | annotation or the annotation of mfld_calibrate_tsc is wrong.

                        |

                        |   LD      drivers/tty/serial/built-in.o

                        |   LD      drivers/tty/built-in.o

                        |   LD      drivers/built-in.o

                        |   LINK    vmlinux

                        |   LD      vmlinux.o

                        |   MODPOST vmlinux.o

                        | WARNING: vmlinux.o(.text+0x347f3): Section mismatch in reference from the function intel_scu_devices_create() to the function .init.text:i2c_register_board_info()

                        | The function intel_scu_devices_create() references

                        | the function __init i2c_register_board_info().

                        | This is often because intel_scu_devices_create lacks a __init

                        | annotation or the annotation of i2c_register_board_info is wrong.

                        |

                        | WARNING: vmlinux.o(.text+0x35dce): Section mismatch in reference from the function penwell_arch_setup() to the function .init.text:mfld_calibrate_tsc()

                        | The function penwell_arch_setup() references

                        | the function __init mfld_calibrate_tsc().

                        | This is often because penwell_arch_setup lacks a __init

                        | annotation or the annotation of mfld_calibrate_tsc is wrong.

                        |

                        |   GEN     .version

                        |   CHK     include/generated/compile.h

                        |   UPD     include/generated/compile.h

                        |   CC      init/version.o

                        |   LD      init/built-in.o

                        | arch/x86/built-in.o: In function `hsu_dev_platform_data':

                        | /home/test/iot-devkit-yp-poky-edison-20160606/poky/linux-kernel/arch/x86/platform/intel-mid/device_libs/platform_hsu.c:434: undefined reference to `hsu_register_board_info'

                        | /home/test/iot-devkit-yp-poky-edison-20160606/poky/linux-kernel/Makefile:785: recipe for target 'vmlinux' failed

                        | make[1]: *** [vmlinux] Error 1

                        | Makefile:130: recipe for target 'sub-make' failed

                        | make: *** [sub-make] Error 2

                        | ERROR: oe_runmake failed

                        | WARNING: exit code 1 from a shell command.

                        | ERROR: Function failed: do_compile (log file is located at /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/tmp/work/edison-poky-linux/linux-externalsrc/1.0-r2/temp/log.do_compile.3041)

                        ERROR: Task 80 (/home/test/iot-devkit-yp-poky-edison-20160606/build_edison/../poky/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/linux-externalsrc.bb, do_compile) failed with exit code '1'

                        NOTE: Tasks Summary: Attempted 5512 tasks of which 5510 didn't need to be rerun and 1 failed.

                        No currently running tasks (5512 of 5585)

                         

                        Summary: 1 task failed:

                          /home/test/iot-devkit-yp-poky-edison-20160606/build_edison/../poky/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/linux-externalsrc.bb, do_compile

                        Summary: There were 3 WARNING messages shown.

                        Summary: There was 1 ERROR message shown, returning a non-zero exit code.

                        • 9. Re: Compiling kernel modules
                          Intel Corporation
                          This message was posted on behalf of Intel Corporation

                          The first thing that caught my eye was the following line:

                          "WARNING: Host distribution "Ubuntu-16.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution."

                          This tells me that you are using Ubuntu 16 and as it is stated in that line you might experience unexpected issues. So, if possible, I would suggest you to install an Ubuntu distribution that is compatible with the BSP. You can check the supported Linux distributions in section 1.3.1 of Yocto's Mega Manual (http://www.yoctoproject.org/docs/1.7.3/mega-manual/mega-manual.html).

                          Have you been able to build the standard image? Or do you also have this issue when trying to build it?

                          Let me know.
                          -Peter.

                          • 10. Re: Compiling kernel modules
                            shmkv

                            Hi Peter

                            Have you been able to build the standard image? Or do you also have this issue when trying to build it?

                            Yes, standard image is well being built. Moreover, I added the modules in the kernel without any problems, but problems arise when using CONFIG_SERIAL_MFD_HSU=m.

                            I will try to use ubuntu 14. I didn't think that it can significantly affect the build process.

                            • 11. Re: Compiling kernel modules
                              Intel Corporation
                              This message was posted on behalf of Intel Corporation

                              I understand. Please do try with Ubuntu 14 and let us know how it goes.
                               
                              We'll be waiting for your response.
                              -Peter.

                              • 12. Re: Compiling kernel modules
                                Intel Corporation
                                This message was posted on behalf of Intel Corporation

                                Hello shmkv,

                                Do you have any updates about this?

                                -Peter.