Specifying Custom Kernel headers

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Specifying Custom Kernel headers

Paulo Matos

Hello,

I am running into trouble building a cross-compiler from a sample for rpi3 using armv7l (arm32) with crosstool-ng 1.24.0
It looks straightforward, however doing:

$ ct-ng armv7-rpi2-linux-gnueabihf
$ ct-ng build

generates a toolchain that compiles just fine but then using qemu-arm-static to emulate it causes a 'kernel too old' message.
So, I noticed that my kernel is 4.15.0-66-generic (ubuntu 18.04) and ct-ng uses by default kernel headers from 4.20.  I changes the config to enable backwards compatibility to 4.15.0.
CT_LINUX_V_4_20=y
...
CT_GLIBC_KERNEL_VERSION_CHOSEN=y
CT_GLIBC_MIN_KERNEL_VERSION="4.15.0"
CT_GLIBC_MIN_KERNEL="4.15.0"

Then I rebuild and qemu works but the result is strange.
 cat listdir.c
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>

int main(void)
{
    struct dirent *de;
    DIR *dr = opendir("/");
    errno = 0;
    while ((de = readdir(dr)) != NULL)
            printf("%s\n", de->d_name);
    if (errno == EOVERFLOW)
      perror("");
    closedir(dr);
    return 0;
}

When compiled:
$ armv7-rpi2-linux-gnueabihf-gcc -static -o listdir listdir.c
$ qemu-arm-static -L /home/pmatos/x-tools/armv7-rpi2-linux-gnueabihf/armv7-rpi2-linux-gnueabihf/sysroot/ ./listdir               
Value too large for defined data type

I assume this is still related to kernel headers. Possibly I need to use the kernel headers for my exact kernel version. Is there a way to do this?

If I do:
$ ct-ng armv7-rpi2-linux-gnueabihf
$ ct-ng menuconfig

In Operating System -> Source of linux the only available option is Released tarball.

Am I correct in saying this is due to the kernel headers version difference? Any hints on how to solve this?

Kind regards,

Paulo Matos