快速去掉不用的linux kernel模块

快速去掉不用的linux kernel模块

由于要满足尽量多的客户需求,Xilinx的默认linux kernel的配置,包含了尽可能多的常用模块。实际嵌入式产品中,很多模块用不到。

如果在linux kernel的编译目录,搜索所有目标(.o)文件,就能发现那些模块被编译到linux kernel中。对于不用的模块,可以配置linux kernel,去掉它们。

PetaLinux工程,修改linux kernel的配置后,保存在文件project-spec/meta-user/recipes-kernel/linux/bsp.cfg里。

/zcu106-bsp-kernel-cfg-peta/project-spec/meta-user/recipes-kernel/linux$ tree -L  2
    linux-xlnx
            bsp.cfg
        linux-xlnx_%.bbappend

如果想快速去掉不用的模块,可以在文件project-spec/meta-user/recipes-kernel/linux/bsp.cfg里,添加如下内容,去掉不用的无线网络、虚拟化模块等。注意,请检查下面的项目,确保你的产品不会用到。如果要用到某些项目,请从bsp.cfg里中删除。

# CONFIG_EFI is not set
# CONFIG_BT is not set
# CONFIG_CFG80211 is not set
# CONFIG_RFKILL is not set
# CONFIG_NET_9P is not set
# CONFIG_MTD_RAW_NAND is not set
# CONFIG_MEDIA_ANALOG_TV_SUPPORT is not set
# CONFIG_MEDIA_DIGITAL_TV_SUPPORT is not set
# CONFIG_MEDIA_RADIO_SUPPORT is not set
# CONFIG_MEDIA_SDR_SUPPORT is not set
# CONFIG_MEDIA_PLATFORM_SUPPORT is not set
# CONFIG_MEDIA_TEST_SUPPORT is not set
# CONFIG_IOMMU_SUPPORT is not set
# CONFIG_IIO is not set
# CONFIG_EXT3_FS is not set
# CONFIG_BTRFS_FS is not set
# CONFIG_OVERLAY_FS is not set
# CONFIG_ECRYPT_FS is not set
# CONFIG_JFFS2_FS is not set
# CONFIG_UBIFS_FS is not set
# CONFIG_CRAMFS is not set
# CONFIG_NETWORK_FILESYSTEMS is not set
# CONFIG_PARAVIRT is not set
# CONFIG_NET_IP_TUNNEL is not set
# CONFIG_IPV6 is not set
# CONFIG_NETFILTER is not set
# CONFIG_OPENVSWITCH is not set
# CONFIG_MPLS is not set
# CONFIG_NET_NSH is not set
# CONFIG_CGROUPS is not set
# CONFIG_XEN is not set
# CONFIG_NAMESPACES is not set

如果产品中不使用声音,还可以增加下面两行,去掉声音模块。

# CONFIG_SND is not set
# CONFIG_SOUND is not set

测试版本: 2021.2

posted @ 2021-12-09 18:08  HankFu  阅读(572)  评论(0编辑  收藏  举报