Hi,
I am trying to build the IgH EtherLab EtherCat Master external Kernel modules with the TorizonCore Builder to be integrated into the image to be deployed to a Verdin imx8mp. This fails due to a not TCB-compatible build process of the kernel modules.
Here are my steps:
Creating directory and in there getting TCB as described
Cloning the sources of the external kernel modules into the subdirectory ethercat
Building the kernel modules: torizoncore-builder kernel build_module ethercat/
This fails with Makefile "ethercat/Makefile" does not exist because the Makefile for building the kernel modules must be generated by a preceding ./bootstrap and a ./configure command which furthermore sets needed env vars like paths to the Linux kernel source.
As far as I know the matching linux kernel sources and compilers are include in the TorizonCore Builder.
Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!
Did you like my answer?
Hello,
To integrate the IgH EtherLab EtherCat Master external kernel modules with the TorizonCore Builder (TCB) and deploy them to a Verdin iMX8MP module, you’ll need to adapt the build process to accommodate the unique requirements of compiling these modules, specifically the need to run ./bootstrap and ./configure before the actual make command. Here’s a step-by-step guide to achieve this:
Prepare the Environment: Ensure you have the latest version of TorizonCore Builder installed and that you’ve cloned the IgH EtherCat sources into the ethercat directory as described.
Modify the Build Process: Since the standard TCB workflow expects a Makefile to be present and doesn’t directly support pre-make configuration steps like running ./bootstrap and ./configure, you’ll need to perform these steps outside of TCB and then adjust the environment to make it compatible with TCB.
Run ./bootstrap and ./configure Manually:
Before invoking TCB, navigate to the ethercat directory and run ./bootstrap and ./configure. This might require installing dependencies or setting up a build environment that mimics the target environment (e.g., cross-compilation tools and kernel headers for the Verdin iMX8MP).
Ensure that the ./configure script is correctly pointed to the kernel sources and compiler that TCB will use. You may need to specify the path to the kernel headers and the cross-compiler prefix. These paths should match the environment TCB uses, which typically involves the kernel headers for the specific TorizonCore version you’re targeting and the ARM cross-compilation toolchain.
Adjust the tcbuild.yaml File: After running the pre-make steps, ensure your tcbuild.yaml is correctly pointing to the modified source directory where the Makefile now exists. If necessary, adjust the source-dir path to point to the correct location within the ethercat directory where the Makefile is located after the configuration steps.
Build the Kernel Module with TCB:
Now, run the TCB command to build the kernel module. If the previous steps were successful, TCB should be able to find the Makefile and compile the module.
If the build process requires environment variables set by the ./configure script, you might need to export these variables before running TCB or modify the TCB command to include them
Please, also check if these links can help you solve your problem:
Problem is, that running ./configure outside of the TCB results in a Makefile containing paths for compiler and linux sources totally different from the inside of the TCB with its bind mounted docker volumes.
I tried to correct the paths in the Makefile, but this seems not to be enough. The build process results in a mess.
I would recommend the same thing @ToradexAI recommended: manually executing the ./bootstrap and ./configure before handing the building process over to TCB.
As you might imagine, those bootstrap and configure steps are not default for building drivers for the kernel.
You can find out yourself how the ./bootstrap and ./configure should be handled in order to allow TCB to compile the driver successfully.
You could start by understanding how the torizoncore-builder command works (alias torizoncore-builder might help you) and then manually launching the TCB container and manually executing ./bootstrap and ./configure from within TCB’s container to understand how things go down.
Then you just manually do the same from outside the container to test your configuration.
Also, you could create your own Makefile (or customize the existing one) to carry our the preceding bootstrap/configure steps. Then, when you run the TCB, it will make use of your customized Makefile that will correctly perform the bootstrap/configure steps.
Hi Henrique,
thanks for responding.
I succeeded to bootstrap, configure and build the kernel modules inside of the TorizonCore Builder command shell.
But there were some missing tools to be installed in advance (apt-get install) like autoconf and pkgconf.
So I could generate a matching Makefile for building the kernel modules with outside call torizoncore-builder kernel build_module ethercat/.
But this fails with following output:
make: Entering directory '/workdir/ethercat'
(CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh '/workdir/ethercat/autoconf/missing' autoheader)
/workdir/ethercat/autoconf/missing: line 81: autoheader: command not found
WARNING: 'autoheader' is missing on your system.
To avoid this, I now try to build a new TorizonCore Builder Docker image with a custom Dockerfile which uses the torizon/torizoncore-builder:3 as base image and install additional tools.
Please tell me if this could be a viable way.
I will report.
Thanks
Since this driver you are using needs those packages to be built (which are uncommon for building a driver), you will indeed need to customize TorizonCore Builder for your use case.
Thanks Henrique,
I managed to get it running with your help, but its tricky to provide the Linux source code inside of the TCB.
The steps are:
Extend the TorizonCore Builder container by the needed tools with a Dockerfile containing RUN apt-get install tools...
Set the alias for torizoncore-builder to the docker run command with the extended Docker image instead of usually let tcb-env-setup.sh do this
Replace the original Makefile with a fake Makefile in the external kernel modules directory
Start to build the kernel module with torizoncore-builder kernel build_module ethercat
This also install the Linux kernel sources to the storage volume
Interrupt the build to not let the TCB delete the Linux sources after successful build
Linux sources are now in the storage volume
Replace the fake Makefile with the original one in the external kernel modules directory
Start and enter shell interactively into the extended TCB Docker container
Run the needed ./bootstrap and ./configure steps which will find the configured Linux kernel sources
Leave the TCB container
Build the kernel modules by the help of the extended TCB: torizoncore-builder build --set TEZI_IMAGE_NAME=output
So this seems to be a little complex and at the moment I don’t know how to tell our Azure pipeline how to manage all the steps, in particular the interruption of the TCB.
Furthermore some environment variables have to be set (toolchain) to the modules build, which is also not that simple with the TCB.
But at least we found a way to proceed in testing the IgH EtherCat modules.
Hi Henrique,
the time has come to integrate all the steps listed in the post before into an Azure pipeline for having automated build of a TorizonCore image.
In step 4 there is a kind of fake torizoncore-builder build_module command to let the TCB install the linux sources to the mounted storage directory. this is needed, because there are some pre-module-build steps necessary against linux sources before we can call the torizoncore-builder build command.
The problem with the fake command is, that it must be interrupted or it fails itself.
This leads to a unwanted termination of the pipeline process.
So my question is, do we have a chance of getting the correct linux.tar.bz2 matching to our settings in ‘tcbuild.yml’ from anywhere to prepare the kernel module build ?