本篇记录 Ampere ARM Server 服务器上,升级内核版本或部分驱动的方法。

安装编译依赖库

sudo  apt-get install build-essential kernel-package libncurses5-dev libncurses-dev
sudo apt-get install gcc make bison flex libssl-dev

升级内核

##<1>. 编译内容

下载内核

选择国内内核镜像网站,下载对应版本内核。

使用运行版本的 config 文件

先清除前面编译残留文件,使用 ARM Server 运行的 config 文件编译内核;

$ make mrproper 
$ cp /boot/config-5.15.0-73-generic ./.config
$ make menuconfig  

修改配置项

make menuconfig 选择

 Kernel hacking —> Compile-time checks and compiler options —>(1024)Warn for stack frames larger than //将1024改为2048
 Kernel hacking —> Compile-time checks and compiler options —> [ ]   Generate BTF typeinfo //选中该选项

去除 system_trusted 内容

vim .config
#
# Certificates for signature checking
#
CONFIG_SYSTEM_TRUSTED_KEYRING=y
CONFIG_SYSTEM_TRUSTED_KEYS=""       ## 清空 keys 内容
CONFIG_SYSTEM_EXTRA_CERTIFICATE=y
CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE=4096
CONFIG_SECONDARY_TRUSTED_KEYRING=y
CONFIG_SYSTEM_BLACKLIST_KEYRING=y
CONFIG_SYSTEM_BLACKLIST_HASH_LIST=""
CONFIG_SYSTEM_REVOCATION_LIST=y
CONFIG_SYSTEM_REVOCATION_KEYS=""   ## 清空 keys 内容 
# end of Certificates for signature checking

安装内核编译支持库libssl-dev

sudo apt-get install libssl-dev

编译内核

make menuconfig 开启 android 相关支持模块, binder ashmem模块支持,
并修改 Makefile 文件中内核版本号。

make -j 64

<2>. 更新内核版本

以下指令在 /usr/src/linux-5.15.23 内核源码根目录.

2.1> 安装内核

将生成的Image镜像文件复制到目录下

cp arch/arm64/boot/Image /boot/vmliuz-5.15.23

将源代码目录下的System.map复制到/boot目录下:

cp System.map /boot/System.map-5.15.23

将源代码目录下的.config复制到/boot/目录下:

cp .config /boot/config-5.15.23

2.2> 安装模块

root@armtest:/usr/src/linux-5.15.23# make modules_install

  INSTALL /lib/modules/5.15.23/kernel/sound/soc/xtensa/snd-soc-xtfpga-i2s.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/soundcore.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/synth/emux/snd-emux-synth.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/synth/snd-util-mem.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/6fire/snd-usb-6fire.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/bcd2000/snd-bcd2000.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/caiaq/snd-usb-caiaq.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/hiface/snd-usb-hiface.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/line6/snd-usb-line6.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/line6/snd-usb-pod.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/line6/snd-usb-podhd.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/line6/snd-usb-toneport.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/line6/snd-usb-variax.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/misc/snd-ua101.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/snd-usb-audio.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/usb/snd-usbmidi-lib.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/virtio/virtio_snd.ko
  INSTALL /lib/modules/5.15.23/kernel/sound/xen/snd_xen_front.ko
  DEPMOD  /lib/modules/5.15.23

2.3> 安装编译内核vmlinuz

root@armtest:/usr/src/linux-5.15.23# make install
sh ./arch/arm64/boot/install.sh 5.15.23 \
arch/arm64/boot/Image System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/dkms 5.15.23 /boot/vmlinuz-5.15.23
 * dkms: running auto installation service for kernel 5.15.23
Kernel preparation unnecessary for this kernel. Skipping...

Building module:
cleaning build area...(bad exit status: 2)
unset ARCH; [ ! -h /usr/bin/cc ] && export CC=/usr/bin/gcc; env NV_VERBOSE=1 'make' -j16 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=5.15.23 IGNORE_XEN_PRESENCE=1 IGNORE_CC_MISMATCH=1 SYSSRC=/lib/modules/5.15.23/build LD=/usr/bin/ld.bfd CONFIG_X86_KERNEL_IBT= modules...(bad exit status: 2)
ERROR (dkms apport): kernel package linux-headers-5.15.23 is not supported
Error! Bad return status for module build on kernel: 5.15.23 (aarch64)
Consult /var/lib/dkms/nvidia/530.41.03/build/make.log for more information.
                                                                                                                                                     [ OK ]
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.15.23 /boot/vmlinuz-5.15.23
update-initramfs: Generating /boot/initrd.img-5.15.23
W: Possible missing firmware /lib/firmware/ast_dp501_fw.bin for module ast
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 5.15.23 /boot/vmlinuz-5.15.23
run-parts: executing /etc/kernel/postinst.d/update-notifier 5.15.23 /boot/vmlinuz-5.15.23
run-parts: executing /etc/kernel/postinst.d/xx-update-initrd-links 5.15.23 /boot/vmlinuz-5.15.23
I: /boot/initrd.img is now a symlink to initrd.img-5.15.23
run-parts: executing /etc/kernel/postinst.d/zz-shim 5.15.23 /boot/vmlinuz-5.15.23
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 5.15.23 /boot/vmlinuz-5.15.23
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.23
Found initrd image: /boot/initrd.img-5.15.23
Found linux image: /boot/vmlinuz-5.15.23.old
Found initrd image: /boot/initrd.img-5.15.23
Found linux image: /boot/vmlinuz-5.15.0-73-generic
Found initrd image: /boot/initrd.img-5.15.0-73-generic
Found linux image: /boot/vmlinuz-5.15.0-72-generic
Found initrd image: /boot/initrd.img-5.15.0-72-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

2.4> 更新 grub 引导

root@armtest:cd /boot/grub
root@armtest:/boot/grub# udate-grub
root@armtest:/usr/src/linux-5.15.23# update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.23
Found initrd image: /boot/initrd.img-5.15.23
Found linux image: /boot/vmlinuz-5.15.23.old
Found initrd image: /boot/initrd.img-5.15.23
Found linux image: /boot/vmlinuz-5.15.0-73-generic
Found initrd image: /boot/initrd.img-5.15.0-73-generic
Found linux image: /boot/vmlinuz-5.15.0-72-generic
Found initrd image: /boot/initrd.img-5.15.0-72-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

更新 grub 后已经把 grub 缺省为当前的系统版本,重启系统后就自动进入 5.15.23 系统。

升级驱动

如果仅更新部分 *.ko 内容,可以指定安装位置,然后把模块更新到系统中。内核编译过程与升级内核部分
描述的方法相同,make menuconfig 中选择相关驱动模块,编译出 *.ko 文件,把此模块拷贝至对应的文件目录下,
记着执行 depmod -a 刷新驱动的依赖关系。通过 modinfo 查看模块是否为更新后的驱动模块。

09-19 07:54