This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-AM62P-LP: Ethercat build error in new kernel build

Part Number: SK-AM62P-LP


Tool/software:

Hi experts,


I followed these steps which is there in ti page

https://software-dl.ti.com/processor-sdk-linux-rt/esd/AM62PX/10_00_07_04/exports/docs/linux/Foundational_Components_Kernel_Users_Guide.html#id19

i followed the kernel image and kernel modules installation. 

current kernel
Linux am62pxx-evm 6.6.32-rt32-g04a9ad081f0f-dirty #1 SMP PREEMPT_RT Tue Oct 29 16:47:42 IST 2024 aarch64 GNU/Linux

I thing we are missing the linux headers for this kernel version.

But what i tried is, copied the old linux header(linux-headers-6.6.32-k3-rt) to updated kernel name in /usr/src

linux-headers-6.6.32-rt32-g04a9ad081f0f-dirty

Can you please help us to build ethercat with these this is our last blocker from the target

error while building the ethercat 

[64316.553416] ec_master: version magic '6.6.32-k3-rt SMP preempt_rt mod_unload aarch64' should be '6.6.32-rt32-g04a9ad081f0f-dirty SMP preempt_rt mod_unload aarch64'


------error from ethercat installation------
ERROR: could not insert 'ec_master': Exec format error  failed


 we rebuild the ethercat and its successfully rebuild and ethercat.ko file also created but the problem is since I deleted the lib/modules for old kernel and paste the new kernel modules. while building ethercat it automatically creating the folder of old kernel name and pasting the ethercat folder into it. so after that i manually copy that folder inside the new kernel but even if its not working.

Let me tell you one thing we not giving any path where to install ethercat but i should automatically take the current kernel.

Can you tell me the steps where i can build the kernel image with same old kernel name or if anything else.
I am thing there are even if some dependencies are there with the old kernel and new.

One last thing to add on we are using the same old linux-header(/usr/src/linux**) while ethercat install its taking the old header and building it.


This is the previous thread for some information why we build kernel.(+) SK-AM62P-LP: Error while docker run - Processors forum - Processors - TI E2E support forums

Regards,
Debashis

  • Hi Debashis,

    Can you explain the how you built the Acontis EtherCAT Master? I want to see if I can follow the same steps to see if I can generate the same issue. This will help me with troubleshooting this issue.

    Like you already mentioned, I think it has to do with the naming of the Kernel version (6.6.32-k3-rt vs 6.6.32-rt32-g04a9ad081f0f-dirty). The dirty keyword indicates that the Linux Git working tree has uncommitted changes. The modules are therefore installed in /lib/modules/6.6.<x>-dirty/, and the version of the running Linux kernel must match this.

    Since your rebuilt Kernel has the "dirty" suffix attached to it, it indicates you have made changes in Kernel source code and built the Kernel based on those changes. You can either revert those changes or commit those changes and rebuild the Kernel and check if the Kernel version name gets rid of the "dirty" suffix. You can check if you made uncommited changes with "git status".

    Although this should get rid of the "dirty" I believe the "-g04a9ad081f0f-" would still show as long as you are building the Kernel from the TI Linux SDK. Alternatively, I was wondering if you could rename the /lib/modules/6.6.32-rt32-g04a9ad081f0f-dirty/ to /lib/modules/6.6.32-k3-rt? This is probably not the proper way to handle the Kernel module versioning but I think worth a try.

    -Daolin

  • Hi Daolin,
    We are using Igh Ethercat master.
    This is link you can check for installation steps https://gitlab.com/etherlab.org/ethercat/-/blob/stable-1.5/INSTALL.md?ref_type=heads

    Only in this line we are doing some modification for enable or disable some functionality. 

    ./configure --enable-sii-assign --disable-8139too --enable-hrtimer --enable-generic --disable-eoe

    Although this should get rid of the "dirty" I believe the "-g04a9ad081f0f-" would still show as long as you are building the Kernel from the TI Linux SDK. Alternatively,

    Yes you are correct now its showing some thing like

    Linux am62pxx-evm 6.6.32-rt32-g66c58b6a4a36 #1 SMP PREEMPT_RT Fri Nov 1 10:57:25 IST 2024 aarch64 GNU/Linux



    I was wondering if you could rename the /lib/modules/6.6.32-rt32-g04a9ad081f0f-dirty/ to /lib/modules/6.6.32-k3-rt? This is probably not the proper way to handle the Kernel module versioning but I think worth a try.

    When i rename it its showing some error to the path where we rename the modules(can't open that folder). But one thing after i rename this i have give one more addon to ethercat in ./config --with-linux-dir to /usr/src/linux-header path otherwise its showing error cannot find the linux headers.

    depmod: ERROR: could not open directory /lib/modules/6.6.32-rt32-g66c58b6a4a36: No such file or directory
    depmod: FATAL: could not search modules: No such file or directory



    After that i again modify the name of kernel to previous one and build the ethercat i got the same error as previous.


    Regards,
    Debashis

  • Hi Daolin,

    After add on this command, I realized that  something we have to do with the linux header because i have copied the old linux headers and rename with new linux header which is might causing this error.

    command
    ./configure ...... --with-linux-dir=/lib/modules/$(uname -r)/build --with-module-dir=/lib/modules/$(uname -r)

    tree command which creates the old kernel name and installing ethercat.

    root@am62pxx-evm:/home/ethercat/sncn_installer# tree /lib/modules/6.6.32-k3-rt/
    /lib/modules/6.6.32-k3-rt/
    -- lib
        -- modules
            -- 6.6.32-rt32-g66c58b6a4a36
                |-- devices
                |   -- ec_generic.ko
                |-- examples
                |   -- mini
                |       -- ec_mini.ko
                -- master
                    -- ec_master.ko
    
    8 directories, 3 files


    Can you give me some clarity in it.

    Regards,
    Debashis

  • Hi Daolin,

    I went through the makefile of linux source code and build the linux headers.
    After that, I try to build ethercat its showing error in ./configure only




    root@am62pxx-evm:/home/ethercat# ./configure --enable-sii-assign --disable-8139too --enable-hrtimer --enable-generic --disable-eoe
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for a race-free mkdir -p... /usr/bin/mkdir -p
    checking for gawk... no
    checking for mawk... mawk
    checking whether make sets $(MAKE)... yes
    checking whether make supports nested variables... yes
    checking whether make supports nested variables... (cached) yes
    checking for a sed that does not truncate output... /usr/bin/sed
    checking for pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    checking whether make supports the include directive... yes (GNU style)
    checking for gcc... gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether the compiler supports GNU C... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to enable C11 features... none needed
    checking whether gcc understands -c and -o together... yes
    checking dependency style of gcc... gcc3
    checking for ar... ar
    checking the archiver (ar) interface... ar
    checking for g++... g++
    checking whether the compiler supports GNU C++... yes
    checking whether g++ accepts -g... yes
    checking for g++ option to enable C++11 features... none needed
    checking dependency style of g++... gcc3
    checking build system type... aarch64-unknown-linux-gnu
    checking host system type... aarch64-unknown-linux-gnu
    checking how to print strings... printf
    checking for a sed that does not truncate output... (cached) /usr/bin/sed
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for fgrep... /usr/bin/grep -F
    checking for ld used by gcc... /usr/bin/ld
    checking if the linker (/usr/bin/ld) is GNU ld... yes
    checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
    checking the name lister (/usr/bin/nm -B) interface... BSD nm
    checking whether ln -s works... yes
    checking the maximum length of command line arguments... 1572864
    checking how to convert aarch64-unknown-linux-gnu file names to aarch64-unknown-linux-gnu format... func_convert_file_noop
    checking how to convert aarch64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
    checking for /usr/bin/ld option to reload object files... -r
    checking for file... file
    checking for objdump... objdump
    checking how to recognize dependent libraries... pass_all
    checking for dlltool... no
    checking how to associate runtime and link libraries... printf %s\n
    checking for archiver @FILE support... @
    checking for strip... strip
    checking for ranlib... ranlib
    checking command to parse /usr/bin/nm -B output from gcc object... ok
    checking for sysroot... no
    checking for a working dd... /usr/bin/dd
    checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
    checking for mt... mt
    checking if mt is a manifest tool... no
    checking for stdio.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for strings.h... yes
    checking for sys/stat.h... yes
    checking for sys/types.h... yes
    checking for unistd.h... yes
    checking for dlfcn.h... yes
    checking for objdir... .libs
    checking if gcc supports -fno-rtti -fno-exceptions... no
    checking for gcc option to produce PIC... -fPIC -DPIC
    checking if gcc PIC flag -fPIC -DPIC works... yes
    checking if gcc static flag -static works... yes
    checking if gcc supports -c -o file.o... yes
    checking if gcc supports -c -o file.o... (cached) yes
    checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
    checking whether -lc should be explicitly linked in... no
    checking dynamic linker characteristics... GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    checking whether stripping libraries is possible... yes
    checking if libtool supports shared libraries... yes
    checking whether to build shared libraries... yes
    checking whether to build static libraries... yes
    checking how to run the C++ preprocessor... g++ -E
    checking for ld used by g++... /usr/bin/ld
    checking if the linker (/usr/bin/ld) is GNU ld... yes
    checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
    checking for g++ option to produce PIC... -fPIC -DPIC
    checking if g++ PIC flag -fPIC -DPIC works... yes
    checking if g++ static flag -static works... yes
    checking if g++ supports -c -o file.o... yes
    checking if g++ supports -c -o file.o... (cached) yes
    checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
    checking dynamic linker characteristics... (cached) GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    checking whether to build kernel modules... yes
    checking for Linux kernel sources... 
    configure: error: Failed to extract Linux kernel version!
    .



    Regards,
    Debashis

  • Hi Debashis,

    copied the old linux header(linux-headers-6.6.32-k3-rt) to updated kernel name in /usr/src

    You stated that "6.6.32-k3-rt" is the "old linux header". Where did this "6.6.32-k3-rt" originate from? Was it generated from building the Linux Kernel from the TI SDK? 

    command
    ./configure ...... --with-linux-dir=/lib/modules/$(uname -r)/build --with-module-dir=/lib/modules/$(uname -r)

    Are you running this command on a Linux host PC? Why have you chose to configure --with-linux-dir and --with-module-dir with /lib/modules/..? If this is on a host PC, the contents of /lib/modules would be different from the /lib/modules on your DUT (SK-AM62P-LP).

    Instead you should point --with-linux-dir to the <TI SDK install path>/board-support/<TI Linux Kernel directory> of your installed TI SDK.

    Additionally, --with-modules-dir should point to where the kernel modules that will be built should be installed. One option is to make your own directory and point to that directory so that modules will be installed there. Afterwards you just need to remember to install these modules on the SD card of your DUT if you are using an SD card.

    -Daolin

  • Hi Daolin,
    For your information let me tell you that i am building the ethercat in SK-AM62P-LP not in my host system.
    I only build the kernel with some configuration flag to make docker work.

    this is default kernel come with Trixi sdk "6.6.32-k3-rt"  in this kernel ethercat building as well as working perfectly.
    As you said above i did a commit and again build the kernel with some updated flag(updated kernel 6.6.32-rt32-g66c58b6a4a36) and dump in sd card.


    The steps I followed:

    /*After the respective changes for kernel related flags*/ 
    
    make ARCH=arm64 CROSS_COMPILE="$CROSS_COMPILE_64" defconfig ti_arm64_prune.config ti_rt.config
    
    make ARCH=arm64 CROSS_COMPILE="$CROSS_COMPILE_64" Image
    
    make ARCH=arm64 CROSS_COMPILE="$CROSS_COMPILE_64" modules
    
    sudo cp arch/arm64/boot/Image /media/rootfs/boot
    
    sudo make ARCH=arm64 INSTALL_MOD_PATH=/media/rootfs modules_install



    After copying the image and modules we required linux-header for the updated kernel. so for that I compared the files with an existing Linux header folder and copied the same structure from the Linux RT SDK to the SD card.

    files and folders which are copied ti sdk for new kernel headers:
    Makefile  Module.symvers  arch  scripts  .config

    And the include folder will generate with this command
    sudo make ARCH=arm64 INSTALL_HDR_PATH=/media/rootfs/usr/src/linux-headers-6.6.32-rt32-g66c58b6a4a36 headers_install



    Regards,
    Debashis

  • Hi Debashis,

    For your information let me tell you that i am building the ethercat in SK-AM62P-LP not in my host system.

    Are you able to try building in your host system instead? I think building directly in your DUT might have caused some conflict resulting the EtherCAT build issue you are seeing. It is more standard to build Kernel modules in your host development system and then copy/install them into your SD card of your DUT. This would include building the EtherCAT modules from IgH.

    this is default kernel come with Trixi sdk "6.6.32-k3-rt"  in this kernel ethercat building as well as working perfectly.

    What is "Trixi sdk"? This was working perfectly on the same DUT? I don't think "6.6.32-k3-rt" is Linux Kernel version name showing up on our TI SDK 10.0 default images. As I mentioned before, our TI SDK Linux kernels will follow "6.6.32-6.6.32-rt32-g04a9ad081f0f" format on SDK 10.0.

    -Daolin

  • Hi Daolin,

    What is "Trixi sdk"? This was working perfectly on the same DUT? I don't think "6.6.32-k3-rt" is Linux Kernel version name showing up on our TI SDK 10.0 default images. As I mentioned before, our TI SDK Linux kernels will follow "6.6.32-6.6.32-rt32-g04a9ad081f0f" format on SDK 10.0.

    This is the default sdk given by ti: 

    Version: 10.00.07.04

    tisdk-debian-trixie-rt-am62pxx-evm.wic.xz   link PROCESSOR-SDK-LINUX-RT-AM62P Software development kit (SDK) | TI.com


    "6.6.32-rt32-g04a9ad081f0f"  this name you can see only after building the kernel and dumping but you will not see this name with default sdk kernel.
    default kernel name is "6.6.32-k3-rt" 

    But i don't know how to build the ethercat in host system can you guide me how to do it. Till now we are doing that in target system only.

    Or else tell me if I am missing any steps for new kernel build if its possible because in default kernel ethercat is working but docker is not working there.

    And can you please tell what is DUT?


    Regards,
    Debashis

  • Hi Debashis,

    But i don't know how to build the ethercat in host system can you guide me how to do it. Till now we are doing that in target system only.

    I'll see if I can run through the steps you shared before on the target system tomorrow and see if after rebuilding the kernel I can see the same issue. I plan on responding with an update tomorrow.

    And can you please tell what is DUT?

    DUT= device under test or the target system

    -Daolin

  • Hi Debashis,

    The instructions provided in https://gitlab.com/etherlab.org/ethercat/-/blob/stable-1.5/INSTALL.md?ref_type=heads#building-and-installing Documentation explains steps for building the EtherCAT master on a host development system and then installing the fully built software onto the target system.

    What specific steps did you take to successfully build on the target system directly?

    But i don't know how to build the ethercat in host system can you guide me how to do it. Till now we are doing that in target system only.

    The EtherCAT Master is an application specific program and we at TI cannot provide professional guidance on how to build and install an application-specific software. Moreover, the IgH EtherCAT Master is an open source software that TI does not provide direct support on, we support mainly TI hardware and in terms of Linux, TI-specific Linux drivers/Kernel.

    There are some online sources on how to build a Linux application on a host development system. For example, page 43 of https://bootlin.com/doc/training/embedded-linux-beagleplay/embedded-linux-beagleplay-labs.pdf runs through an example build of a Third-party Linux application including how to set up the options of the ./configure file.

    Back when I first tested out IgH, I used the following steps on an SK-AM62x; however, this may or may not work for you since I used an older kernel version.

    FROM HOST DEVELOPMENT PC
    Download the "ethercat-stable-1.6" branch
    Using master branch could result in some WARNINGS when building modules
    
    $sudo apt-get install autoconf
    $sudo apt-get install libtool
    $autoupdate
    
    $./bootstrap (Bootlin: similar to autoreconf to create configure and Makefile.in)
    
    ./configure --sysconfdir=/opt/etherlab --prefix=/opt/etherlab --with-linux-dir=<SDK install path>/board-support/ti-linux-kernel/ --with-module-dir=/opt/etherlab/ouput --enable-8139too=no --enable-eoe=no CC=<SDK install where this compiler can be found>/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc --host=aarch64-none-linux-gnu 
    
    $sudo su
    
    #export PATH=<PATH to cross-compiler toolchain>:$PATH
    //You can use the same toolchain as used for "CROSS_COMPILEE_64" in https://software-dl.ti.com/processor-sdk-linux-rt/esd/AM62PX/10_00_07_04/exports/docs/linux/Foundational_Components_Kernel_Users_Guide.html#compiler
    
    #make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- modules
    
    Highly not recommended to run "make install" as it installs in host pc's /opt directory! Additionally, doesn't actually install the ethercat modules into /opt/etherlab/output
    
    Instead, follow the below steps
    1.After building the Image and modules from the SDK, install these to an SD already flashed with a default image
    	To install modules: sudo make ARCH=arm64 INSTALL_MOD_PATH=/media/<host PC user name>/root modules_install
    2.Make sure that the modules that were installed have the same name as the original (kernel version) name from the default image --> otherwise installing the IgH modules will not work

    -Daolin

  • Hi Daolin,

    I wanted to update you and also ask for your suggestion. I managed to resolve the issue about 30 minutes ago but thank you for your response.

    we have build the kernel(ti kernel with the changed flag) in target system directly and install the modules. after then  i just rename the updated kernel to "Image" in /boot/ directory then i reboot the system.

    Currently, I have successfully installed EtherCAT on Debian with the updated kernel. However, when I run an Ubuntu 22 Docker container, I copy the updated lib/modules and linux-headers into it and try to install EtherCAT again inside the container. Now, I'm seeing an error indicating a GCC version mismatch—the Linux headers were built with GCC 14.0, while the Docker container(ubuntu 22) is using GCC 11.

    I think there are two ways to resolve this:

    1. Upgrade the GCC version in the Ubuntu Docker container(ubuntu 22) to 14.0.2.
    2. Just run the make command only on the Linux headers inside the Docker container so that the headers are build with the Docker environment.

    Currently I am trying to build gcc 14 from source code inside docker because gcc14 package is not given by ubuntu 22.

    Which approach would you recommend resolving this issue?

    Regards,
    Debashis

  • Hi Daolin,

    we have successfully install the ethercat inside docker

    Just run the make command only on the Linux headers inside the Docker container so that the headers are build with the Docker environment

    We followed this option since it's easier. However, Option 1 would also be possible by installing all the required dependencies as we did on Debian.

    I want to thank Daolin and your team for helping me complete this issue.

    Best regards,
    Debashis