Skip to content

AMI driver compilation fails #35

@taraxacum45e9a

Description

@taraxacum45e9a

The SW build failed when executing ./scripts/gen_package.py under AVED/sw/AMI because it failed to build the kernel driver.

Details
$ ./scripts/gen_package.py 
/tmp/AVED/sw/AMI/./scripts/gen_package.py:467: SyntaxWarning: invalid escape sequence '\$'
  SPEC_FILE += [ "%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*\$!!g')" ]
INFO: [GEN_PACKAGE-62] Command line provided: $ /usr/bin/python3 ./scripts/gen_package.py
INFO: [GEN_PACKAGE-63] Parsing command line options
INFO: [GEN_PACKAGE-7] --------------------------------------------------------------------------------------
INFO: [GEN_PACKAGE-7] [2026-05-30, 19:45:09] Starting gen_package.py
INFO: [GEN_PACKAGE-7] --------------------------------------------------------------------------------------
INFO: [GEN_PACKAGE-18] Creating output directory: /tmp/AVED/sw/AMI/output/2026-05-30_19-45-09
INFO: [GEN_PACKAGE-39] *** [2026-05-30, 19:45:09] Starting step: get system info
INFO: [GEN_PACKAGE-5] Get distribution ID from /etc/os-release
INFO: [GEN_PACKAGE-5] Successfully generated: /tmp/AVED/sw/AMI/output/2026-05-30_19-45-09/os-release.log
INFO: [GEN_PACKAGE-16] Current distribution ID: ubuntu
INFO: [GEN_PACKAGE-15] Executing: $ dpkg --print-architecture
INFO: [GEN_PACKAGE-15] Log file: /tmp/AVED/sw/AMI/output/2026-05-30_19-45-09/dpkg_print_architecture.log
INFO: [GEN_PACKAGE-18] System:
INFO: [GEN_PACKAGE-18] 	 - Distribution ID: ubuntu
INFO: [GEN_PACKAGE-18] 	 - Distribution release: 24.04
INFO: [GEN_PACKAGE-18] 	 - Architecture: amd64
INFO: [GEN_PACKAGE-38] ************************** End of step. Elapsed time: 0:00:00


INFO: [GET_VER] *** [2026-05-30, 19:45:09] Starting step: get AMI version
INFO: [GEN_VERSION] Executing: $ ../scripts/getVersion.sh ami
INFO: [GET_VER] Successfully generated: /tmp/AVED/sw/AMI/api/build/ami_version.h
INFO: [GET_VER] ************************** End of step. Elapsed time: 0:00:00


INFO: [GET_VER] *** [2026-05-30, 19:45:09] Starting step: get GCQ version
INFO: [GEN_VERSION] Executing: $ ./getVersion.sh gcq
INFO: [GET_VER] Successfully generated: /tmp/AVED/sw/AMI/driver/gcq-driver/src/gcq_version.h
INFO: [GET_VER] ************************** End of step. Elapsed time: 0:00:00


INFO: [GET_VER] *** [2026-05-30, 19:45:09] Starting step: get AMI Driver version
INFO: [GEN_VERSION] Executing: $ ../scripts/getVersion.sh driver
INFO: [GET_VER] Successfully generated: /tmp/AVED/sw/AMI/driver/ami_driver_version.h
INFO: [GET_VER] ************************** End of step. Elapsed time: 0:00:00


INFO: [BUILD_DRIVER] *** [2026-05-30, 19:45:09] Starting step: driver compilation confidence check
INFO: [BUILD_CHECK_DRIVER] Executing: $ cd driver && make clean && make
ERROR: [BUILD_CHECK_DRIVER] Step driver compilation confidence check failed: Unexpected non-zero return code (2) for command: cd driver && make clean && make

A subsequent manual build of the driver reports the compilation error: fatal error: ami.h: No such file or directory.

Details
$ cd driver && make clean && make

make -C /lib/modules/`uname -r`/build M=/tmp/AVED/sw/AMI/driver clean
make[1]: Entering directory '/usr/src/linux-headers-6.17.0-35-generic'
make[2]: Entering directory '/tmp/AVED/sw/AMI/driver'
make[2]: Leaving directory '/tmp/AVED/sw/AMI/driver'
make[1]: Leaving directory '/usr/src/linux-headers-6.17.0-35-generic'
make -C /lib/modules/`uname -r`/build M=/tmp/AVED/sw/AMI/driver clean
make[1]: Entering directory '/usr/src/linux-headers-6.17.0-35-generic'
make[2]: Entering directory '/tmp/AVED/sw/AMI/driver'
make[2]: Leaving directory '/tmp/AVED/sw/AMI/driver'
make[1]: Leaving directory '/usr/src/linux-headers-6.17.0-35-generic'

Running ../scripts/getVersion.sh
Done

make -C /lib/modules/`uname -r`/build M=/tmp/AVED/sw/AMI/driver modules
make[1]: Entering directory '/usr/src/linux-headers-6.17.0-35-generic'
make[2]: Entering directory '/tmp/AVED/sw/AMI/driver'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
  You are using:           gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
  CC [M]  ami_top.o
In file included from ami_vsec.h:15,
                 from ami_top.h:18,
                 from ami_top.c:29:
ami_pcie.h:13:10: fatal error: ami.h: No such file or directory
   13 | #include <ami.h>
      |          ^~~~~~~
compilation terminated.
make[4]: *** [/usr/src/linux-headers-6.17.0-35-generic/scripts/Makefile.build:287: ami_top.o] Error 1
make[3]: *** [/usr/src/linux-headers-6.17.0-35-generic/Makefile:2016: .] Error 2
make[2]: *** [/usr/src/linux-headers-6.17.0-35-generic/Makefile:248: __sub-make] Error 2
make[2]: Leaving directory '/tmp/AVED/sw/AMI/driver'
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.17.0-35-generic'
make: *** [Makefile:41: all] Error 2

Root Cause & Suggested Fix

This occurs because the driver's Makefile uses the legacy EXTRA_CFLAGS variable to specify include directories. This deprecated variable was completely removed in newer upstream Linux kernels (probably around v6.15), causing the header search paths to be ignored on newer host kernels (like the 6.17 kernel in the logs).

While I understand that AVED officially supports only the GA kernel and does not formally support the HWE kernel, the fix is trivial and low-risk: simply replace EXTRA_CFLAGS with ccflags-y in the driver Makefile to ensure modern Kbuild compatibility.


After fixing the flags above, the build still fails with the error below:

Details
$ make
make -C /lib/modules/`uname -r`/build M=/tmp/AVED/sw/AMI/driver clean
make[1]: Entering directory '/usr/src/linux-headers-6.17.0-35-generic'
make[2]: Entering directory '/tmp/AVED/sw/AMI/driver'
make[2]: Leaving directory '/tmp/AVED/sw/AMI/driver'
make[1]: Leaving directory '/usr/src/linux-headers-6.17.0-35-generic'

Running ../scripts/getVersion.sh
Done

make -C /lib/modules/`uname -r`/build M=/tmp/AVED/sw/AMI/driver modules
make[1]: Entering directory '/usr/src/linux-headers-6.17.0-35-generic'
make[2]: Entering directory '/tmp/AVED/sw/AMI/driver'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
  You are using:           gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
  CC [M]  ami_top.o
  CC [M]  ami_pcie.o
  CC [M]  ami_pci_dbg.o
  CC [M]  ami_vsec.o
  CC [M]  ami_amc_control.o
ami_amc_control.c: In function ‘setup_amc’:
ami_amc_control.c:1817:23: error: implicit declaration of function ‘vzalloc’; did you mean ‘kzalloc’? [-Werror=implicit-function-declaration]
 1817 |         version_buf = vzalloc(sizeof(char) * VERSION_BUF_SIZE);
      |                       ^~~~~~~
      |                       kzalloc
ami_amc_control.c:1817:21: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1817 |         version_buf = vzalloc(sizeof(char) * VERSION_BUF_SIZE);
      |                     ^
ami_amc_control.c:1905:9: error: implicit declaration of function ‘vfree’; did you mean ‘kvfree’? [-Werror=implicit-function-declaration]
 1905 |         vfree(version_buf);
      |         ^~~~~
      |         kvfree
cc1: some warnings being treated as errors
make[4]: *** [/usr/src/linux-headers-6.17.0-35-generic/scripts/Makefile.build:287: ami_amc_control.o] Error 1
make[3]: *** [/usr/src/linux-headers-6.17.0-35-generic/Makefile:2016: .] Error 2
make[2]: *** [/usr/src/linux-headers-6.17.0-35-generic/Makefile:248: __sub-make] Error 2
make[2]: Leaving directory '/tmp/AVED/sw/AMI/driver'
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.17.0-35-generic'
make: *** [Makefile:41: all] Error 2

The build fails because ami_amc_control.c uses vzalloc() and vfree(), but it does not include <linux/vmalloc.h>, where these functions are declared.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions