tbsdtv / linux_media

TBS linux open source drivers
https://github.com/tbsdtv/linux_media/wiki
Other
174 stars 81 forks source link

Compilation fails: RockPro64 #322

Closed hartontw closed 1 year ago

hartontw commented 1 year ago

Hello,

I'm following the guide in the wiki. Probably I'm doing something wrong but I'm not able to determine what.

Hardware: RockPro64 Arch: aarch64 OS: DietPi v8.21.1 (Bookworm) Kernel: 6.1.50-current-rockchip64

Workaround (fresh install):

apt install linux-headers-current-rockchip64 patchutils gcc make git
git clone https://github.com/tbsdtv/media_build.git
git clone --depth=1 https://github.com/tbsdtv/linux_media.git -b latest ./media
cd media_build
make dir DIR=../media
make allyesconfig
sed -i -r 's/(^CONFIG.*_RC.*=)./\1n/g' v4l/.config
sed -i -r 's/(^CONFIG.*_IR.*=)./\1n/g' v4l/.config
make -j4

Errors:

./include/linux/minmax.h:36:9: error: expected identifier or '(' before '__builtin_choose_expr'
   36 |         __builtin_choose_expr(__safe_cmp(x, y), \
./include/linux/minmax.h:33:49: error: expected identifier or '(' before ')' token
   33 |                 __cmp(unique_x, unique_y, op); })
Log Error ```shell make -C /home/drivers/media_build/v4l make[1]: Entering directory '/home/drivers/media_build/v4l' make -C firmware prep creating symbolic links... make[2]: Entering directory '/home/drivers/media_build/v4l/firmware' make[2]: Nothing to be done for 'prep'. make[2]: Leaving directory '/home/drivers/media_build/v4l/firmware' make -C firmware make[2]: Entering directory '/home/drivers/media_build/v4l/firmware' make[2]: Nothing to be done for 'default'. make[2]: Leaving directory '/home/drivers/media_build/v4l/firmware' Kernel build directory is /lib/modules/6.1.50-current-rockchip64/build make -C ../linux apply_patches make[2]: Entering directory '/home/drivers/media_build/linux' Syncing with dir ../../media Patches for 6.1.50-current-rockchip64 already applied. make[2]: Leaving directory '/home/drivers/media_build/linux' make -C /lib/modules/6.1.50-current-rockchip64/build M=/home/drivers/media_build/v4l modules make[2]: Entering directory '/usr/src/linux-headers-6.1.50-current-rockchip64' CC [M] /home/drivers/media_build/v4l/rockchip_av1_filmgrain.o CC [M] /home/drivers/media_build/v4l/hantro_h264.o CC [M] /home/drivers/media_build/v4l/hantro_hevc.o CC [M] /home/drivers/media_build/v4l/hantro_mpeg2.o In file included from : /home/drivers/media_build/v4l/compat.h:1076: warning: "untagged_addr" redefined 1076 | #define untagged_addr(addr) (addr) | In file included from ./arch/arm64/include/asm/thread_info.h:17, from ./include/linux/thread_info.h:60, from ./arch/arm64/include/asm/preempt.h:6, from ./include/linux/preempt.h:78, from ./include/linux/smp.h:110, from ./arch/arm64/include/asm/arch_timer.h:18, from ./arch/arm64/include/asm/timex.h:8, from ./include/linux/timex.h:67, from ./include/linux/time32.h:13, from ./include/linux/time.h:60, from ./include/linux/input.h:8, from /home/drivers/media_build/v4l/compat.h:47: ./arch/arm64/include/asm/memory.h:230: note: this is the location of the previous definition 230 | #define untagged_addr(addr) ({ \ | In file included from ./include/linux/kernel.h:26, from ./arch/arm64/include/asm/cpufeature.h:22, from ./arch/arm64/include/asm/hwcap.h:9, from ./arch/arm64/include/asm/arch_timer.h:12: ./include/linux/minmax.h:36:9: error: expected identifier or '(' before '__builtin_choose_expr' 36 | __builtin_choose_expr(__safe_cmp(x, y), \ | ^~~~~~~~~~~~~~~~~~~~~ ./include/linux/minmax.h:45:25: note: in expansion of macro '__careful_cmp' 45 | #define min(x, y) __careful_cmp(x, y, <) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:28: note: in expansion of macro 'min' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ /home/drivers/media_build/v4l/rockchip_av1_filmgrain.c:195:19: note: in expansion of macro 'clamp' 195 | static inline s32 clamp(s32 value, s32 low, s32 high) | ^~~~~ ./include/linux/minmax.h:33:49: error: expected identifier or '(' before ')' token 33 | __cmp(unique_x, unique_y, op); }) | ^ ./include/linux/minmax.h:20:28: note: in definition of macro '__typecheck' 20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) | ^ ./include/linux/minmax.h:36:31: note: in expansion of macro '__safe_cmp' 36 | __builtin_choose_expr(__safe_cmp(x, y), \ | ^~~~~~~~~~ ./include/linux/minmax.h:45:25: note: in expansion of macro '__careful_cmp' 45 | #define min(x, y) __careful_cmp(x, y, <) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:28: note: in expansion of macro 'min' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ ./include/linux/minmax.h:38:17: note: in expansion of macro '__cmp_once' 38 | __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) | ^~~~~~~~~~ ./include/linux/minmax.h:52:25: note: in expansion of macro '__careful_cmp' 52 | #define max(x, y) __careful_cmp(x, y, >) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:45: note: in expansion of macro 'max' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ /home/drivers/media_build/v4l/rockchip_av1_filmgrain.c:195:19: note: in expansion of macro 'clamp' 195 | static inline s32 clamp(s32 value, s32 low, s32 high) | ^~~~~ In file included from ./include/linux/bits.h:5, from ./include/linux/ratelimit_types.h:5, from ./include/linux/printk.h:9, from ./include/asm-generic/bug.h:22, from ./arch/arm64/include/asm/bug.h:26, from ./include/linux/bug.h:5, from ./include/linux/mmdebug.h:5, from /home/drivers/media_build/v4l/config-compat.h:12, from /home/drivers/media_build/v4l/compat.h:10: ./include/linux/minmax.h:33:49: error: expected identifier or '(' before ')' token 33 | __cmp(unique_x, unique_y, op); }) | ^ ./include/linux/const.h:12:55: note: in definition of macro '__is_constexpr' 12 | (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) | ^ ./include/linux/minmax.h:26:39: note: in expansion of macro '__no_side_effects' 26 | (__typecheck(x, y) && __no_side_effects(x, y)) | ^~~~~~~~~~~~~~~~~ ./include/linux/minmax.h:36:31: note: in expansion of macro '__safe_cmp' 36 | __builtin_choose_expr(__safe_cmp(x, y), \ | ^~~~~~~~~~ ./include/linux/minmax.h:45:25: note: in expansion of macro '__careful_cmp' 45 | #define min(x, y) __careful_cmp(x, y, <) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:28: note: in expansion of macro 'min' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ ./include/linux/minmax.h:38:17: note: in expansion of macro '__cmp_once' 38 | __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) | ^~~~~~~~~~ ./include/linux/minmax.h:52:25: note: in expansion of macro '__careful_cmp' 52 | #define max(x, y) __careful_cmp(x, y, >) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:45: note: in expansion of macro 'max' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ /home/drivers/media_build/v4l/rockchip_av1_filmgrain.c:195:19: note: in expansion of macro 'clamp' 195 | static inline s32 clamp(s32 value, s32 low, s32 high) | ^~~~~ ./include/linux/minmax.h:33:49: error: expected identifier or '(' before ')' token 33 | __cmp(unique_x, unique_y, op); }) | ^ ./include/linux/minmax.h:28:27: note: in definition of macro '__cmp' 28 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y)) | ^ ./include/linux/minmax.h:45:25: note: in expansion of macro '__careful_cmp' 45 | #define min(x, y) __careful_cmp(x, y, <) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:28: note: in expansion of macro 'min' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ ./include/linux/minmax.h:38:17: note: in expansion of macro '__cmp_once' 38 | __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) | ^~~~~~~~~~ ./include/linux/minmax.h:52:25: note: in expansion of macro '__careful_cmp' 52 | #define max(x, y) __careful_cmp(x, y, >) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:45: note: in expansion of macro 'max' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ /home/drivers/media_build/v4l/rockchip_av1_filmgrain.c:195:19: note: in expansion of macro 'clamp' 195 | static inline s32 clamp(s32 value, s32 low, s32 high) | ^~~~~ ./include/linux/minmax.h:33:49: error: expected identifier or '(' before ')' token 33 | __cmp(unique_x, unique_y, op); }) | ^ ./include/linux/minmax.h:28:40: note: in definition of macro '__cmp' 28 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y)) | ^ ./include/linux/minmax.h:45:25: note: in expansion of macro '__careful_cmp' 45 | #define min(x, y) __careful_cmp(x, y, <) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:28: note: in expansion of macro 'min' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ ./include/linux/minmax.h:38:17: note: in expansion of macro '__cmp_once' 38 | __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) | ^~~~~~~~~~ ./include/linux/minmax.h:52:25: note: in expansion of macro '__careful_cmp' 52 | #define max(x, y) __careful_cmp(x, y, >) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:45: note: in expansion of macro 'max' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ /home/drivers/media_build/v4l/rockchip_av1_filmgrain.c:195:19: note: in expansion of macro 'clamp' 195 | static inline s32 clamp(s32 value, s32 low, s32 high) | ^~~~~ ./include/linux/minmax.h:33:49: error: expected identifier or '(' before ')' token 33 | __cmp(unique_x, unique_y, op); }) | ^ ./include/linux/minmax.h:38:17: note: in expansion of macro '__cmp_once' 38 | __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) | ^~~~~~~~~~ ./include/linux/minmax.h:45:25: note: in expansion of macro '__careful_cmp' 45 | #define min(x, y) __careful_cmp(x, y, <) | ^~~~~~~~~~~~~ ./include/linux/minmax.h:89:28: note: in expansion of macro 'min' 89 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | ^~~ /home/drivers/media_build/v4l/rockchip_av1_filmgrain.c:195:19: note: in expansion of macro 'clamp' 195 | static inline s32 clamp(s32 value, s32 low, s32 high) | ^~~~~ make[3]: *** [scripts/Makefile.build:250: /home/drivers/media_build/v4l/rockchip_av1_filmgrain.o] Error 1 make[3]: *** Waiting for unfinished jobs.... In file included from : /home/drivers/media_build/v4l/compat.h:1076: warning: "untagged_addr" redefined 1076 | #define untagged_addr(addr) (addr) | In file included from ./arch/arm64/include/asm/thread_info.h:17, from ./include/linux/thread_info.h:60, from ./arch/arm64/include/asm/preempt.h:6, from ./include/linux/preempt.h:78, from ./include/linux/smp.h:110, from ./arch/arm64/include/asm/arch_timer.h:18, from ./arch/arm64/include/asm/timex.h:8, from ./include/linux/timex.h:67, from ./include/linux/time32.h:13, from ./include/linux/time.h:60, from ./include/linux/input.h:8, from /home/drivers/media_build/v4l/compat.h:47: ./arch/arm64/include/asm/memory.h:230: note: this is the location of the previous definition 230 | #define untagged_addr(addr) ({ \ | make[2]: *** [Makefile:2012: /home/drivers/media_build/v4l] Error 2 make[2]: Leaving directory '/usr/src/linux-headers-6.1.50-current-rockchip64' make[1]: *** [Makefile:53: default] Error 2 make[1]: Leaving directory '/home/drivers/media_build/v4l' make: *** [Makefile:26: all] Error 2 ```
crazycat69 commented 1 year ago

https://github.com/tbsdtv/media_build/commit/18a3abecbca0cc57bb46b9bfac959d61367e35b3

hartontw commented 1 year ago

Thanks for the response.

I've repeated the process described with the same result.

I've checked first v4l/versions.txt.

hartontw commented 1 year ago

Hardware: RockPro64 Arch: aarch64 OS: Armbian 23.8 Bookworm

Kernel: 6.1.50-current-rockchip64 Same workaround, same errors.

Kernel: 5.15.93-rockchip64

Error:

/root/media_build/v4l/adv748x-core.c:851:19: error: initialization of 'int (*)(struct i2c_client *)' from incompatible pointer type 'void (*)(struct i2c_client *)' [-Werror=incompatible-pointer-types]
  851 |         .remove = adv748x_remove,
      |                   ^~~~~~~~~~~~~~
Log Error ```shell make -C /root/media_build/v4l make[1]: Entering directory '/root/media_build/v4l' make -C firmware prep creating symbolic links... make[2]: Entering directory '/root/media_build/v4l/firmware' make[2]: Nothing to be done for 'prep'. make[2]: Leaving directory '/root/media_build/v4l/firmware' make -C firmware make[2]: Entering directory '/root/media_build/v4l/firmware' make[2]: Nothing to be done for 'default'. make[2]: Leaving directory '/root/media_build/v4l/firmware' Kernel build directory is /lib/modules/5.15.93-rockchip64/build make -C ../linux apply_patches make[2]: Entering directory '/root/media_build/linux' Syncing with dir ../../media Patches for 5.15.93-rockchip64 already applied. make[2]: Leaving directory '/root/media_build/linux' make -C /lib/modules/5.15.93-rockchip64/build M=/root/media_build/v4l modules make[2]: Entering directory '/usr/src/linux-headers-5.15.93-rockchip64' CC [M] /root/media_build/v4l/adv748x-core.o CC [M] /root/media_build/v4l/ak7375.o CC [M] /root/media_build/v4l/ak881x.o CC [M] /root/media_build/v4l/aptina-pll.o In file included from : /root/media_build/v4l/compat.h:1076: warning: "untagged_addr" redefined 1076 | #define untagged_addr(addr) (addr) | In file included from ./arch/arm64/include/asm/thread_info.h:17, from ./include/linux/thread_info.h:60, from ./arch/arm64/include/asm/preempt.h:5, from ./include/linux/preempt.h:78, from ./include/linux/smp.h:110, from ./arch/arm64/include/asm/arch_timer.h:18, from ./arch/arm64/include/asm/timex.h:8, from ./include/linux/timex.h:67, from ./include/linux/time32.h:13, from ./include/linux/time.h:60, from ./include/linux/input.h:8, from /root/media_build/v4l/compat.h:47: ./arch/arm64/include/asm/memory.h:218: note: this is the location of the previous definition 218 | #define untagged_addr(addr) ({ \ | In file included from : /root/media_build/v4l/compat.h:1076: warning: "untagged_addr" redefined 1076 | #define untagged_addr(addr) (addr) | In file included from ./arch/arm64/include/asm/thread_info.h:17, from ./include/linux/thread_info.h:60, from ./arch/arm64/include/asm/preempt.h:5, from ./include/linux/preempt.h:78, from ./include/linux/smp.h:110, from ./arch/arm64/include/asm/arch_timer.h:18, from ./arch/arm64/include/asm/timex.h:8, from ./include/linux/timex.h:67, from ./include/linux/time32.h:13, from ./include/linux/time.h:60, from ./include/linux/input.h:8, from /root/media_build/v4l/compat.h:47: ./arch/arm64/include/asm/memory.h:218: note: this is the location of the previous definition 218 | #define untagged_addr(addr) ({ \ | In file included from : /root/media_build/v4l/compat.h:1076: warning: "untagged_addr" redefined 1076 | #define untagged_addr(addr) (addr) | In file included from ./arch/arm64/include/asm/thread_info.h:17, from ./include/linux/thread_info.h:60, from ./arch/arm64/include/asm/preempt.h:5, from ./include/linux/preempt.h:78, from ./include/linux/smp.h:110, from ./arch/arm64/include/asm/arch_timer.h:18, from ./arch/arm64/include/asm/timex.h:8, from ./include/linux/timex.h:67, from ./include/linux/time32.h:13, from ./include/linux/time.h:60, from ./include/linux/input.h:8, from /root/media_build/v4l/compat.h:47: ./arch/arm64/include/asm/memory.h:218: note: this is the location of the previous definition 218 | #define untagged_addr(addr) ({ \ | In file included from : /root/media_build/v4l/compat.h:1076: warning: "untagged_addr" redefined 1076 | #define untagged_addr(addr) (addr) | In file included from ./arch/arm64/include/asm/thread_info.h:17, from ./include/linux/thread_info.h:60, from ./arch/arm64/include/asm/preempt.h:5, from ./include/linux/preempt.h:78, from ./include/linux/smp.h:110, from ./arch/arm64/include/asm/arch_timer.h:18, from ./arch/arm64/include/asm/timex.h:8, from ./include/linux/timex.h:67, from ./include/linux/time32.h:13, from ./include/linux/time.h:60, from ./include/linux/input.h:8, from /root/media_build/v4l/compat.h:47: ./arch/arm64/include/asm/memory.h:218: note: this is the location of the previous definition 218 | #define untagged_addr(addr) ({ \ | CC [M] /root/media_build/v4l/bt819.o /root/media_build/v4l/adv748x-core.c:851:19: error: initialization of 'int (*)(struct i2c_client *)' from incompatible pointer type 'void (*)(struct i2c_client *)' [-Werror=incompatible-pointer-types] 851 | .remove = adv748x_remove, | ^~~~~~~~~~~~~~ /root/media_build/v4l/adv748x-core.c:851:19: note: (near initialization for 'adv748x_driver.remove') In file included from : /root/media_build/v4l/compat.h:1076: warning: "untagged_addr" redefined 1076 | #define untagged_addr(addr) (addr) | In file included from ./arch/arm64/include/asm/thread_info.h:17, from ./include/linux/thread_info.h:60, from ./arch/arm64/include/asm/preempt.h:5, from ./include/linux/preempt.h:78, from ./include/linux/smp.h:110, from ./arch/arm64/include/asm/arch_timer.h:18, from ./arch/arm64/include/asm/timex.h:8, from ./include/linux/timex.h:67, from ./include/linux/time32.h:13, from ./include/linux/time.h:60, from ./include/linux/input.h:8, from /root/media_build/v4l/compat.h:47: ./arch/arm64/include/asm/memory.h:218: note: this is the location of the previous definition 218 | #define untagged_addr(addr) ({ \ | CC [M] /root/media_build/v4l/bt856.o cc1: some warnings being treated as errors make[3]: *** [scripts/Makefile.build:289: /root/media_build/v4l/adv748x-core.o] Error 1 make[3]: *** Waiting for unfinished jobs.... In file included from : /root/media_build/v4l/compat.h:1076: warning: "untagged_addr" redefined 1076 | #define untagged_addr(addr) (addr) | In file included from ./arch/arm64/include/asm/thread_info.h:17, from ./include/linux/thread_info.h:60, from ./arch/arm64/include/asm/preempt.h:5, from ./include/linux/preempt.h:78, from ./include/linux/smp.h:110, from ./arch/arm64/include/asm/arch_timer.h:18, from ./arch/arm64/include/asm/timex.h:8, from ./include/linux/timex.h:67, from ./include/linux/time32.h:13, from ./include/linux/time.h:60, from ./include/linux/input.h:8, from /root/media_build/v4l/compat.h:47: ./arch/arm64/include/asm/memory.h:218: note: this is the location of the previous definition 218 | #define untagged_addr(addr) ({ \ | make[2]: *** [Makefile:1903: /root/media_build/v4l] Error 2 make[2]: Leaving directory '/usr/src/linux-headers-5.15.93-rockchip64' make[1]: *** [Makefile:53: default] Error 2 make[1]: Leaving directory '/root/media_build/v4l' make: *** [Makefile:26: all] Error 2 ```
hartontw commented 1 year ago

I've found the problem and the solution. Tomorrow I will do a Pull Request with a better solution.

For now this is a quick fix:

apt install gcc make git patchutils libproc-processtable-perl linux-headers-current-rockchip64
git clone https://github.com/tbsdtv/media_build.git
git clone --depth=1 https://github.com/tbsdtv/linux_media.git -b latest ./media

Edit ./media/drivers/media/platform/verisilicon/rockchip_av1_filmgrain.c commenting lines 195-198:

//static inline s32 clamp(s32 value, s32 low, s32 high)
//{
//  return value < low ? low : (value > high ? high : value);
//}
cd media_build
make dir DIR=../media
make allyesconfig
sed -i -r 's/(^CONFIG.*_RC.*=)./\1n/g' v4l/.config
sed -i -r 's/(^CONFIG.*_IR.*=)./\1n/g' v4l/.config
make -j4
make install
reboot