Author Topic: error compiling kernel  (Read 4012 times)

cam1965

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
    • http://
error compiling kernel
« on: February 25, 2020, 05:42:54 am »
When compiling a kernel in cosmo I've got this error in the attached picture.
The header file is in https://github.com/gemian/cosmo-linux-kerne.../helio-dvfsrc.h
Please, can someone help me ?

Thank you all.
« Last Edit: March 13, 2020, 12:00:28 pm by cam1965 »

shuntcap

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
error compiling kernel
« Reply #1 on: March 12, 2020, 05:23:50 am »
Quote from: cam1965
When compiling a kernel in cosmo I've got this error in the attached picture.
The header file is in https://github.com/gemian/cosmo-linux-kerne.../helio-dvfsrc.h
Please, can someone help me ?

Thank you all.
Your build is most likely including the wrong mtk_dvfsrc_reg.h (there are multiples) which then includes the wrong mtk_dvfsrc_reg_mt6771.h and then defines DVFSRC_LEVEL incorrectly.  The kernel sources don't build out of the box, as you discovered.  My guess is you had to add a pile of -I include directives to get the kernel to build, or you created a bunch of symlinks to required headers in a directory already specified with a -I directive in the default build.  I assume MediaTek's build environment presents a boatload of -I directives to the make process, but our sources lack this.

I modified drivers/devfreq/helio-dvfsrc.c to force it to pull in the correct header (specifically the last one) from the same directory as helio-dvfsrc.c itself:
#include "drivers/devfreq/helio-dvfsrc.h"
#include "drivers/devfreq/helio-dvfsrc-opp.h"
#include "drivers/devfreq/mtk_dvfsrc_reg.h"

Note the change from an angled path <....h> in the original source to a quoted path "....h".

There are four mtk_dvfsrc_reg.h in the kernel sources:
./drivers/devfreq/mtk_dvfsrc_reg.h
./drivers/misc/mediatek/base/power/include/mtk_dvfsrc_reg.h
./drivers/misc/mediatek/base/power/include/spm_v3/mtk_dvfsrc_reg.h
./drivers/misc/mediatek/base/power/include/spm_v4/mtk_dvfsrc_reg.h

You want to make sure helio-dvfsrc.c includes the top one, which using a quoted #include will accomplish.  You probably have a -I directive to drivers/misc/mediatek/base/power/include/spm_v4, which includes a different mtk_dvfsrc_reg_mt6771.h, which in turn #define's a different DVFSRC_LEVEL macro than the *other* mtk_dvfsrc_reg_mt6771.h in the source tree (yep, there are two), causing your build to fail as the preprocessor expands the wrong DVRSRC_LEVEL macro into something it can't process.

cam1965

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
    • http://
error compiling kernel
« Reply #2 on: March 12, 2020, 12:22:43 pm »
Quote from: shuntcap
Quote from: cam1965
When compiling a kernel in cosmo I've got this error in the attached picture.
The header file is in https://github.com/gemian/cosmo-linux-kerne.../helio-dvfsrc.h
Please, can someone help me ?

Thank you all.
Your build is most likely including the wrong mtk_dvfsrc_reg.h (there are multiples) which then includes the wrong mtk_dvfsrc_reg_mt6771.h and then defines DVFSRC_LEVEL incorrectly.  The kernel sources don't build out of the box, as you discovered.  My guess is you had to add a pile of -I include directives to get the kernel to build, or you created a bunch of symlinks to required headers in a directory already specified with a -I directive in the default build.  I assume MediaTek's build environment presents a boatload of -I directives to the make process, but our sources lack this.

I modified drivers/devfreq/helio-dvfsrc.c to force it to pull in the correct header (specifically the last one) from the same directory as helio-dvfsrc.c itself:
#include "drivers/devfreq/helio-dvfsrc.h"
#include "drivers/devfreq/helio-dvfsrc-opp.h"
#include "drivers/devfreq/mtk_dvfsrc_reg.h"

Note the change from an angled path <....h> in the original source to a quoted path "....h".

There are four mtk_dvfsrc_reg.h in the kernel sources:
./drivers/devfreq/mtk_dvfsrc_reg.h
./drivers/misc/mediatek/base/power/include/mtk_dvfsrc_reg.h
./drivers/misc/mediatek/base/power/include/spm_v3/mtk_dvfsrc_reg.h
./drivers/misc/mediatek/base/power/include/spm_v4/mtk_dvfsrc_reg.h

You want to make sure helio-dvfsrc.c includes the top one, which using a quoted #include will accomplish.  You probably have a -I directive to drivers/misc/mediatek/base/power/include/spm_v4, which includes a different mtk_dvfsrc_reg_mt6771.h, which in turn #define's a different DVFSRC_LEVEL macro than the *other* mtk_dvfsrc_reg_mt6771.h in the source tree (yep, there are two), causing your build to fail as the preprocessor expands the wrong DVRSRC_LEVEL macro into something it can't process.

You are correct.
I've copied the missing files in the correct directory, changed <file > for " file " , changed the correct location of some files . Changed some files also ( error messages ) . But after this the kernel was compiled correctly. I've compiled it in my Mac with linux successfully ( gcc 6 ). In Cosmo , with gcc-7 correctly , excepting that  no Image.gz-dtb was generated (dtc_overlay exec format error) --->  https://www.oesf.org/forum/index.php?showtopic=36159.
When compiling inside Cosmo with gcc 8 a lot of errors appears ( truncate errors ). After changing many , many files ( like strncpy for strlcpy, strncat for strlcat , memcpy in some files , etc ) the kernel was compiled successfully. But after concatenating  initrd and Image.gz-dtb to a boot image kernel, it didn't boot correctly ( kernel panic ).
Well, that is it .  I've also found on the internet a kernel 4 with some sources of gps, fmradio, wlan. After a lot of changes  and the final compilation, some undeclared message  errors has appeared  at the end. I am sure the sources I 've got are not appropriated for the cosmo.
But thanks again for the  tip you told me about forcing the modules  in the kernel .
Thank you so much .
Sorry about my English ( I'm from Brazil ).