如何在 Odroid C2 上编译以多媒体为模块的 Linux 内核

如何在 Odroid C2 上编译以多媒体为模块的 Linux 内核

我正在尝试在 Odroid C2 上编译 Linux 内核并使用安装 DVB-T 驱动程序媒体构建。我按照官方描述的步骤进行的维基百科论坛。根据论坛,Device Drivers -> Amlogic Device Drivers -> Multimedia Support如果我想使用向后移植的 media_build DVB-T 驱动程序,则需要将其编译为模块。

首先,我获取了Linux源码:

git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y

然后我设置 Odroid C2 的配置:

make odroidc2_defconfig

最后,我按照以下步骤进行内核编译并禁用 V4L 依赖项:

$make menuconfig
Device Drivers
    Amlogic Device Drivers
  ION Support
     ION memory management support = no
  Amlogic ion video support
     videobuf2-ion video device support = no
     Amlogic ion video devic support = no
  V4L2 Video Support
     Amlogic v4l video device support = no
     Amlogic v4l video2 device support = no
  Amlogic Camera Support
     Amlogic Platform Capture Driver = no
  Multimedia support = m

此配置编译没有错误,然后我可以编译并安装 media_build 驱动程序。问题是,在这种配置下,Odroid C2 无法通过硬件解码在 Kodi 中播放视频文件。我的印象是我禁用了 amlogic 硬件解码所需的依赖项。我尝试修改配置并将我之前禁用的所有依赖项标记为模块。不幸的是,使用此配置,无法编译内核,并且编译失败并出现以下错误:

drivers/built-in.o: In function `v4l2_device_release':
odroid-battery.c:(.text+0x1731c0): undefined reference to 
`media_device_unregister_entity'
odroid-battery.c:(.text+0x1731c0): relocation truncated to fit: 
R_AARCH64_CALL26 against undefined symbol `media_device_unregister_entity'
drivers/built-in.o: In function `__video_register_device':
odroid-battery.c:(.text+0x173c4c): undefined reference to 
`media_device_register_entity'
odroid-battery.c:(.text+0x173c4c): relocation truncated to fit: 
R_AARCH64_CALL26 against undefined symbol `media_device_register_entity'
drivers/built-in.o: In function `v4l2_device_register_subdev':
odroid-battery.c:(.text+0x1797b0): undefined reference to 
`media_device_register_entity'
odroid-battery.c:(.text+0x1797b0): relocation truncated to fit: 
R_AARCH64_CALL26 against undefined symbol `media_device_register_entity'
drivers/built-in.o: In function `v4l2_device_unregister_subdev':
odroid-battery.c:(.text+0x179a58): undefined reference to 
`media_entity_remove_links'
odroid-battery.c:(.text+0x179a58): relocation truncated to fit: 
R_AARCH64_CALL26 against undefined symbol `media_entity_remove_links'
odroid-battery.c:(.text+0x179a60): undefined reference to 
`media_device_unregister_entity'
odroid-battery.c:(.text+0x179a60): relocation truncated to fit: 
R_AARCH64_CALL26 against undefined symbol `media_device_unregister_entity'
drivers/built-in.o: In function `subdev_close':
odroid-battery.c:(.text+0x180c10): undefined reference to `media_entity_put'
odroid-battery.c:(.text+0x180c10): relocation truncated to fit: 
R_AARCH64_CALL26 against undefined symbol `media_entity_put'
drivers/built-in.o: In function `subdev_open':
odroid-battery.c:(.text+0x1814f4): undefined reference to `media_entity_get'
odroid-battery.c:(.text+0x1814f4): relocation truncated to fit: 
R_AARCH64_CALL26 against undefined symbol `media_entity_get'
odroid-battery.c:(.text+0x181540): undefined reference to `media_entity_put'
odroid-battery.c:(.text+0x181540): relocation truncated to fit: 
R_AARCH64_CALL26 against undefined symbol `media_entity_put'
Makefile:831: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

如何将多媒体支持作为模块编译内核,并且仍然能够对视频文件使用硬件解码?

答案1

我终于让它发挥作用了。我创建了一个包含脚本、补丁和说明的 git 存储库。如果有人也在处理这个问题,请克隆这个存储库并执行以下步骤(这些也在存储库的自述文件中进行了描述):

Linux

克隆 Hardkernel Linux 存储库

git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidc2-3.14.y
cd linux

应用补丁,允许您将 aml 视频驱动程序编译为模块(我从LibreELEC media_build 版本

patch -p1 < ../odroidC2-kernel/allow_amlvideodri_as_module.patch

应用默认的 Odroid C2 配置

make odroidc2_defconfig

现在修改配置

make menuconfig

并设置以下值(按Y选择,N删除,M选择它作为模块)

Device Drivers
   Amlogic Device Drivers
      ION Support
         ION memory management support = Yes
      Amlogic ion video support
         videobuf2-ion video device support = M
         Amlogic ion video devic support = no
      V4L2 Video Support
         Amlogic v4l video device support = M
         Amlogic v4l video2 device support = no
      Amlogic Camera Support
         Amlogic Platform Capture Driver = no
   Multimedia support = M

编译内核

make -j5 LOCALVERSION=""

LOCALVERSION 参数只是为了避免内核名称中出现“+”号。编译成功后,安装模块、内核并重启系统

sudo make modules_install
sudo cp -f arch/arm64/boot/Image arch/arm64/boot/dts/meson64_odroidc2.dtb /media/boot/
sudo sync
sudo reboot

媒体建设

克隆 media_build 存储库并尝试构建它。

git clone https://git.linuxtv.org/media_build.git
cd media_build
./build

构建命令可能会失败。忽略此错误并继续执行以下步骤。以下脚本的灵感也来自LibreELEC media_build 版本它只是将视频驱动程序包含到媒体模块中。

../odroidC2-kernel/add_video_driver_module.sh

为了避免潜在的编译问题,请尝试禁用远程控制器支持和所有不需要的 USB 适配器。尝试运行:

make menuconfig

它可能会导致类似于以下错误:

./Kconfig:694: syntax error
./Kconfig:693: unknown option "Enable"
./Kconfig:694: unknown option "which"

您需要编辑该文件v4l/Kconfig并将错误中打印的行与空格对齐。这些线需要与之前的线对齐。然后,再次运行make menuconfig。可能您需要多次执行此步骤。

如果您看到菜单而不是错误,则可以按以下方式修改配置:

Remote Controller support = no
Multimedia support
    Media USB Adapters
        ## Disable all driver you don't need ##

应用以下补丁

patch -p1 < ../odroidC2-kernel/warning.patch

进行以下更改以避免错误并编译内核

sed -i 's/#define NEED_PM_RUNTIME_GET 1/\/\/#define NEED_PM_RUNTIME_GET 1/g' v4l/config-compat.h
make -j5

可能,您需要多次运行上一步(sed 和 make)才能成功。

编译完成后,安装模块并重启系统

sudo make install
sudo reboot

最后一步是添加amlvideodri模块/etc/modules以使其在启动时加载。

sudo echo "amlvideodri" >> /etc/modules

就这样。您现在可以在 Kodi 中欣赏 DVB-T TV 和硬件加速视频。

相关内容