Compiling 4.9 Kernel manually - module mt7663

Hi there,

I’m trying to to compile kernel 4.9 manually from GitHub - CoreELEC/linux-amlogic at amlogic-4.9 for my hobby project.

However, I am getting following error.

MK_FW firmware/video/video_ucode.bin.gen.S
make[1]: *** No rule to make target ‘firmware/video/video_ucode.bin’, needed by ‘firmware/video/video_ucode.bin.gen.o’. Stop.

Is there some dependency needs to be pulled before?

Any help will be appreciated.

Yes, you need the video firmware from the media modules. This is pulled in before compiling the kernel automatically by the build scripts.

1 Like

I’ve copied https://github.com/CoreELEC/media_modules-aml to kernel and appended “drivers/Makefile” as it was only conflicting file.

Now I’m getting following error. Can you tell what it is?

In file included from ./include/uapi/linux/stddef.h:1:0,
                 from ./include/linux/stddef.h:4,
                 from ./include/uapi/linux/posix_types.h:4,
                 from ./include/uapi/linux/types.h:13,
                 from ./include/linux/types.h:5,
                 from drivers/amvdec_ports/aml_vcodec_vfq.h:23,
                 from drivers/amvdec_ports/aml_vcodec_vfm.h:23,
                 from drivers/amvdec_ports/aml_vcodec_vfm.c:20:
drivers/amvdec_ports/aml_vcodec_vfm.c: In function ‘vdec_vf_put’:
drivers/amvdec_ports/aml_vcodec_vfm.c:60:16: error: ‘struct vframe_s’ has no member named ‘use_cnt’
  atomic_set(&vf->use_cnt, 1);
                ^
./include/linux/compiler.h:322:17: note: in definition of macro ‘WRITE_ONCE’
  union { typeof(x) __val; char __c[1]; } __u = \
                 ^
drivers/amvdec_ports/aml_vcodec_vfm.c:60:2: note: in expansion of macro ‘atomic_set’
  atomic_set(&vf->use_cnt, 1);
  ^~~~~~~~~~
drivers/amvdec_ports/aml_vcodec_vfm.c:60:16: error: ‘struct vframe_s’ has no member named ‘use_cnt’
  atomic_set(&vf->use_cnt, 1);
                ^
./include/linux/compiler.h:323:30: note: in definition of macro ‘WRITE_ONCE’
   { .__val = (__force typeof(x)) (val) }; \
                              ^
drivers/amvdec_ports/aml_vcodec_vfm.c:60:2: note: in expansion of macro ‘atomic_set’
  atomic_set(&vf->use_cnt, 1);
  ^~~~~~~~~~
drivers/amvdec_ports/aml_vcodec_vfm.c:60:16: error: ‘struct vframe_s’ has no member named ‘use_cnt’
  atomic_set(&vf->use_cnt, 1);
                ^
./include/linux/compiler.h:324:22: note: in definition of macro ‘WRITE_ONCE’
  __write_once_size(&(x), __u.__c, sizeof(x)); \
                      ^
drivers/amvdec_ports/aml_vcodec_vfm.c:60:2: note: in expansion of macro ‘atomic_set’
  atomic_set(&vf->use_cnt, 1);
  ^~~~~~~~~~
drivers/amvdec_ports/aml_vcodec_vfm.c:60:16: error: ‘struct vframe_s’ has no member named ‘use_cnt’
  atomic_set(&vf->use_cnt, 1);
                ^
./include/linux/compiler.h:324:42: note: in definition of macro ‘WRITE_ONCE’
  __write_once_size(&(x), __u.__c, sizeof(x)); \
                                          ^
drivers/amvdec_ports/aml_vcodec_vfm.c:60:2: note: in expansion of macro ‘atomic_set’
  atomic_set(&vf->use_cnt, 1);
  ^~~~~~~~~~
In file included from ./include/linux/atomic.h:4:0,
                 from ./include/linux/mutex.h:18,
                 from ./include/linux/kernfs.h:13,
                 from ./include/linux/sysfs.h:15,
                 from ./include/linux/kobject.h:21,
                 from ./include/linux/device.h:17,
                 from ./include/linux/platform_device.h:14,
                 from drivers/amvdec_ports/aml_vcodec_drv.h:23,
                 from drivers/amvdec_ports/aml_vcodec_vfm.h:24,
                 from drivers/amvdec_ports/aml_vcodec_vfm.c:20:
drivers/amvdec_ports/aml_vcodec_vfm.c: In function ‘video_vf_put’:
drivers/amvdec_ports/aml_vcodec_vfm.c:98:42: error: ‘struct vframe_s’ has no member named ‘use_cnt’
  if (vfp && vf && atomic_dec_and_test(&vf->use_cnt))
                                          ^
./arch/arm64/include/asm/atomic.h:77:53: note: in definition of macro ‘atomic_dec_return’
 #define atomic_dec_return(v)  atomic_sub_return(1, (v))
                                                     ^
drivers/amvdec_ports/aml_vcodec_vfm.c:98:19: note: in expansion of macro ‘atomic_dec_and_test’
  if (vfp && vf && atomic_dec_and_test(&vf->use_cnt))
                   ^~~~~~~~~~~~~~~~~~~
scripts/Makefile.build:334: recipe for target 'drivers/amvdec_ports/aml_vcodec_vfm.o' failed
make[2]: *** [drivers/amvdec_ports/aml_vcodec_vfm.o] Error 1
scripts/Makefile.build:648: recipe for target 'drivers/amvdec_ports' failed
make[1]: *** [drivers/amvdec_ports] Error 2
Makefile:1085: recipe for target 'drivers' failed
make: *** [drivers] Error 2

You can not do this, the media modules is not designed to be built-in, they are designed to be compiled as external modules, whilst they can be modified to work and be compiled as built-in, it requires many more changes.

1 Like

As an another option, I am trying to use CoreElec’s kernel with my own rootfs.

mmcblk1p1 is my rootfs and mmcblk1p2 has kernel.img and dtb.img

I used following command in u-boot.

ext4load mmc 0:2 $loadaddr /kernel.img
ext4load mmc 0:2 $dtb_mem_addr /dtb.img

setenv bootargs 'console=ttyS0,115200 root=/dev/mmcblk1p1’
bootm $loadaddr - $dtb_mem_addr

[ 4.431699@0] ALSA device list:
[ 4.434345@0] No soundcards found.
[ 4.437944@0] Warning: unable to open an initial console.
[ 4.550446@0] prepare_namespace() wait 79
[ 4.550561@0] Failed to create /dev/root: -2
[ 4.553119@0] VFS: Cannot open root device "mmcblk1p1" or unknown-block(179,129): error -2
[ 4.561294@0] Please append a correct "root=" boot option; here are the available partitions:
[ 4.569737@0] b300 7634944 mmcblk0 driver: mmcblk
[ 4.575159@0] b301 4096 mmcblk0p1
[ 4.579632@0] b302 65536 mmcblk0p2
[ 4.584116@0] b303 524288 mmcblk0p3
[ 4.588602@0] b304 8192 mmcblk0p4
[ 4.593087@0] b305 32768 mmcblk0p5
[ 4.597571@0] b306 32768 mmcblk0p6
[ 4.602057@0] b307 8192 mmcblk0p7
[ 4.606549@0] b308 8192 mmcblk0p8
[ 4.611027@0] b309 32768 mmcblk0p9
[ 4.615511@0] b30a 32768 mmcblk0p10
[ 4.620082@0] b30b 32768 mmcblk0p11
[ 4.624654@0] b30c 2097152 mmcblk0p12
[ 4.629226@0] b30d 4632576 mmcblk0p13
[ 4.633798@0] b380 31260672 mmcblk1 driver: mmcblk
[ 4.639238@0] b381 797437 mmcblk1p1 58c5634e-01
[ 4.644664@0] b382 512000 mmcblk1p2 58c5634e-02
[ 4.650098@0] b360 4096 mmcblk0rpmb (driver?)
[ 4.655463@0] b340 4096 mmcblk0boot1 (driver?)
[ 4.660879@0] b320 4096 mmcblk0boot0 (driver?)
[ 4.666312@0] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,129)
[ 4.675058@0] SMP: stopping secondary CPUs
[ 4.679101@0] Kernel Offset: disabled
[ 4.682697@0] Memory Limit: none
[ 4.693951@0] Rebooting in 5 seconds..
[ 9.694198@0] reboot reason 12

It won’t boot. Do you have any idea why?

Yes, the rootfs spec through a kernel argument would not work, because CoreELEC hard-codes deployment of SYSTEM.img squashfs into the boot sequence via the init sh script operated by busybox, see the code here. Fortunately, there is a workaround: you can add a file called post-sysroot.sh into your /flash partition and tweak the normal logic as needed, for example:

$ cat /flash/post-sysroot.sh 
umount /sysroot               
mount /dev/mmcblk1p2 /sysroot

A bit different problem, but I think this thread is still relevant.

So, I’m trying to compile GitHub - CoreELEC/linux-amlogic (amlogic-4.9-19 branch).
make fails:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu-
  CHK     include/config/kernel.release
  CHK     include/config/kernel.release_full
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  HOSTCC  scripts/basic/fixdep
as: unrecognized option '--64'
make[1]: *** [scripts/Makefile.host:101: scripts/basic/fixdep] Error 1
make: *** [Makefile:449: scripts_basic] Error 2

Steps:
First, I downloaded the toolchain aarch64-none-linux-gnu (GCC 10.2) (also tried 9 and 8, obviously it all failed). Then:

mkdir ~/toolchain
tar -xJvf ~/Downloads/gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu.tar.xz -C ~/toolchain
cd ~/toolchain
for i in $(find . -type d -name bin); do export PATH=$PWD/$i:$PATH; done
cd
git clone https://github.com/coreelec/linux-amlogic
cd linux-amlogic
# ...here goes all that make stuff

What am I doing wrong?

Use whole CoreELEC build environment which builds everything including kernel.

I don’t need everything, I just need kernel.

Moreover, correct me if I’m wrong, but that “build environment” (you’re talking about this, right?) is supposed to run inside a docker container, which is waaaay overkill for kernel compilation.

Any other ideas?

git clone git@github.com:CoreELEC/CoreELEC.git
cd CoreELEC
./scripts/build linux

Which linux config file did you use? From CE? If not maybe you are building with some default (x64 ?) config.

And btw: What are you trying to do? Seems wasting time on a thing which “just works” with CE build environment :slight_smile:

What do you mean?
make ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- defconfig. Then same thing without defconfig to start the build process.

What are you trying to do?

Just want to have the damn onboard wifi working.
It doesn’t work out of the box, neither with recent 5.x.x kernels, nor with amlogic ones, but in the latter case I can at least try to build the drivers:

(tried to compile the second one for a fresh kernel but failed)

Why build kernel? Drivers require kernel sources and some artifacts generated during kernel build. Thus, if I can’t build kernel, then I can’t build drivers either.

I posted here a few days ago, then moderator merged my thread into generic one (link to the resulting post) and since then I didn’t get any attention. No, I’m not blaming anyone here, it’s okay. Just wanted to say that now I’m trying to solve it myself. I have almost no idea what to do lol, but I’m gonna try it all before giving up (at least I’ll try these repos linked above (does it make any sense btw?)). It’d be nice if you could point me to the right direction, but I think it goes out of scope of this thread.

This is not true, we took a look already to compile mt76, mt7663 and mt7603. But it fail till now. So no idea…

We need to find first one driver which is compatible for kernel 4.9. Already looked but little busy atm.

A little off-top, but maybe you know any other kernel that already have mt7663 supported? In theory, mt76 driver, which is provided by linux-firmware in most distros, should support it, but that wasn’t the case for me.

This was “start” to include the driver. But it’s far from be finished.

# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2021-present Team CoreELEC (https://coreelec.tv)
PKG_NAME="mt76"
PKG_VERSION="bddc1db76d0fe37cd42d7a2c0560e47c103e4ecd"
PKG_SHA256=""
PKG_ARCH="arm aarch64"
PKG_LICENSE="GPL"
PKG_SITE="https://github.com/openwrt/mt76"
PKG_URL="https://github.com/openwrt/mt76/archive/$PKG_VERSION.tar.gz"
PKG_DEPENDS_TARGET="toolchain linux"
PKG_NEED_UNPACK="$LINUX_DEPENDS"
PKG_LONGDESC="mt76 Linux driver"
PKG_IS_KERNEL_PKG="yes"
PKG_TOOLCHAIN="manual"
pre_make_target() {
  unset LDFLAGS
}
make_target() {
  make EXTRA_CFLAGS="-w" \
    -C "$(kernel_path)" \
    ARCH=$TARGET_KERNEL_ARCH \
    CROSS_COMPILE=$TARGET_KERNEL_PREFIX \
    SUBDIRS="${PKG_BUILD}" \
    CONFIG_MT7603E=m \
    modules
}
makeinstall_target() {
  mkdir -p $INSTALL/$(get_full_module_dir)/$PKG_NAME
    find $PKG_BUILD/ -name \*.ko -not -path '*/\.*' -exec cp {} $INSTALL/$(get_full_module_dir)/$PKG_NAME \;
  mkdir -p $INSTALL/$(get_full_firmware_dir)
    cp $PKG_BUILD/firmware/* $INSTALL/$(get_full_firmware_dir)
}

You can add this package to Ce-19 clone and call ./scripts/build mt76

I look around and there is no mt7663 driver. Only in v5 kernel releases which has too much changes to backport.
That’s why I don’t see this driver tot be supported soon.

About | FAQ | Terms of Service | Privacy Policy | Legal Notice