- #!/bin/ksh93
- #
- # build_rovema_kernel.ksh
- #
- # worse-is-better/simpler rewrite for rovema-082 kernel
- #
- # Written by Roland Mainz <roland.mainz@nrubsig.org>
- #
- #
- # * install new kernel
- #
- # $ mount -o remount,rw /
- # $ cd /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_5_rt16/dist_files/
- # $ dpkg -i *.deb
- #
- # remove old linux 4.9 kernel:
- # $ dpkg -r --force-depends linux-image-4.9.303-rt192
- #
- #
- # * igb_avb.ko installation:
- # # igb_avb kernel module must be manually installed on the target system, and the igb.ko kernel module removed
- # $ cp dist_files/igb_avb.ko /lib/modules/6.6.5-rt16-rovema082/kernel/drivers/net/ethernet/intel/igb/.
- # $ mv /lib/modules/6.6.5-rt16-rovema082/kernel/drivers/net/ethernet/intel/igb/igb.ko /root/igb.ko_disabled
- # $ depmod
- # $ update-initramfs -k all -u
- #
- # $ cp /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_5_rt16/dist_files/libigb.so /usr/lib/i386-linux-gnu/libigb_avb.so
- #
- #
- #
- #
- # * simatic installation:
- # $ cp dist_files/simatic-ipc*.ko /lib/modules/6.6.5-rt16-rovema082/kernel/drivers/mfd/.
- # $ depmod
- # $ update-initramfs -k all -u
- #
- # * install closed-source firmware data:
- # $ cd /
- # $ tar -xf /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_5_rt16/dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
- # $ update-initramfs -k all -u
- #
- #
- # Installation:
- #
- #
- # Login into target machine:
- # $ ksh ~/work/nrubsigsvn/gisburn/scripts/sshnfs/sshnfs.ksh -o NFSURL=ssh+nfs://derfwpc5131/export/home2/rmainz target@fe80::d6f5:27ff:fe2b:4330%enp2s0
- #
- #
- # Install updated Debian Jessie packages:
- # $ cd /mnt_nfs/work/jessie_target_packages/
- # dpkg -i --force-conflicts console-*.deb # conflicts with "plymouth"
- # dpkg -i *.deb
- #
- #
- # Update Linux kernel boot args in grub:
- # $ vi /etc/default/grub
- # GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_idle.max_cstate=0 processor.max_cstate=1 intel_pstate=disable nosoftlockup nmi_watchdog=0 idle=poll nohz=on i915.disable_power_well=0 i915.enable_rc6=0 i915.enable_dc=0 i915.enable_guc=2"
- # $ update-grub
- #
- #
- # fix binfmt (Debian 'Jessie' bug):
- # printf 'ksh\nmagic\n0\n\\x0B\\x13\\x08\n\n/bin/ksh\n\n\n\n\n' >'/var/lib/binfmts/ksh'
- #
- #
- # build Linux kernel v6.6.5-rt16
- #
- function build_kernel
- {
- set -o errexit
- set -o nounset
- # subshell so CWD remains unchanged on return
- (
- mkdir builddir_kernel
- cd builddir_kernel/
- git clone -b 'v6.6.5-rt16' git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git
- cd linux-rt-devel/
- cp '../../myconfig_linux_v6_6_5_rt16.config' '.config'
- #
- # fixme: add patches here
- # - rt RCU patch
- # - default boot args patch
- # - i915 patches
- # - rt udev dir
- #
- time nice -n 19 ksh -c 'CC="gcc -m32" make -j2 bindeb-pkg 2>&1 | tee buildlog.log'
- cd ..
- cp linux-headers-*_i386.deb "${c.dist_files_dir}/"
- cp linux-image-*_i386.deb "${c.dist_files_dir}/"
- cp linux-libc-*_i386.deb "${c.dist_files_dir}/"
- )
- print '# build_kernel OK'
- return 0
- }
- #
- # build custom igb_avb module
- #
- function build_igbavb
- {
- set -o errexit
- set -o nounset
- # subshell so CWD remains unchanged on return
- (
- mkdir builddir_igbavb
- cd builddir_igbavb/
- git clone https://github.com/Avnu/igb_avb.git
- cd igb_avb/
- # switch to commit 6c115ee89c88f6284d1407244b4a47586c3332d,
- # which is known to work with Linux 6.6.5-RT16
- git checkout '86c115ee89c88f6284d1407244b4a47586c3332d'
- #
- # apply patches
- #
- # fixme:
- # - pciid patch is missing
- # - igb patches may need backport (bfp ?)
- #
- git am <'../../0001-libigb-Use-PTHREAD_PRIO_INHERIT-for-mutex-to-avoid-r.patch'
- git am <'../../0002-Disable-pci_-_pcie_error_reporting-for-Linux-kernels.patch'
- #
- # build kernel module
- #
- cd kmod/
- CC="gcc -m32" make -j4 -C "$PWD/../../../builddir_kernel/linux-rt-devel/" KSRC="$PWD/../../../builddir_kernel/linux-rt-devel/" M=$PWD
- cp igb_avb.ko "${c.dist_files_dir}/"
- cd ..
- #cp simatic-ipc*.ko /lib/modules/6.6.5-rt16-rovema082/kernel/drivers/mfd/.
- # build libigb.a
- #
- cd lib
- CC="gcc -m32" make all
- #
- # build shared library vesion of libigb.a
- #
- gcc -m32 -shared -fPIC -o libigb.so -Wl,--whole-archive libigb.a -Wl,--no-whole-archive -lpthread
- cp libigb.so "${c.dist_files_dir}/"
- )
- print '# build_igbavb OK'
- return 0
- }
- function build_simatic
- {
- set -o errexit
- set -o nounset
- # subshell so CWD remains unchanged on return
- (
- mkdir builddir_simatic
- cd builddir_simatic/
- svn checkout http://svn.rovema.de/repos/bootimage/branches/dev027_kernel5_15/rovema_simatickernelmodules/simatic-ipc-modules-lsp-v1.2.0RC1/
- cd simatic-ipc-modules-lsp-v1.2.0RC1/
- make -C "$PWD/../../builddir_kernel/linux-rt-devel/" KSRC="$PWD/../../builddir_kernel/linux-rt-devel/" M=$PWD
- cp ./simatic-ipc.ko "${c.dist_files_dir}/"
- cp ./simatic-ipc-leds.ko "${c.dist_files_dir}/"
- cp ./simatic-ipc-wdt.ko "${c.dist_files_dir}/"
- cp ./simatic-ipc-batt.ko "${c.dist_files_dir}/"
- cp ./simatic-ipc-sensors.ko "${c.dist_files_dir}/"
- cp ./simatic-ipc-ps.ko "${c.dist_files_dir}/"
- cp ./simatic-ipc-nvram.ko "${c.dist_files_dir}/"
- )
- print '# build_simatic OK'
- return 0
- }
- function build_firmware_tarball
- {
- set -o errexit
- set -o nounset
- typeset -r linux_firmware_git_tag='20231211'
- typeset -r tarball_filename="linux_firmware_git_lib_firmware_i915_${linux_firmware_git_tag}.tar.bz2"
- # subshell so CWD remains unchanged on return
- (
- mkdir build_firmware_tarball
- cd build_firmware_tarball/
- git clone -b "${linux_firmware_git_tag}" git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
- mkdir -p 'lib/firmware/i915'
- ln linux-firmware/i915/* 'lib/firmware/i915/.'
- tar -cvf - 'lib' | pbzip2 >"${tarball_filename}"
- cp "${tarball_filename}" "${c.dist_files_dir}/"
- )
- }
- #
- # main
- #
- # use ksh93 builtins
- export PATH="/opt/ast/bin/:/usr/ast/bin:$PATH"
- builtin mkdir
- # keep all global script data in a compound variable
- # so we can use $ print -u2 -v c # for debugging
- compound c
- typeset c.dist_files_dir="$PWD/dist_files"
- mkdir -p "${c.dist_files_dir}"
- #
- # build packages
- #
- build_kernel
- build_igbavb
- build_simatic
- build_firmware_tarball
- #
- # list resulting packages
- #
- ls -l "${c.dist_files_dir}"
- # EOF.
build_rovema_kernel.ksh
Posted by Anonymous on Wed 20th Dec 2023 14:51
raw | new post
view followups (newest first): build_rovema_kernel.ksh by Anonymous
modification of post by Anonymous (view diff)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.