- #!/bin/ksh93
- #
- # build_rovema_schnipo_kernel5_15_163_rt78.ksh
- #
- # worse-is-better/simpler rewrite for Schnitzel-mit-Pommes kernel
- #
- # Written by Roland Mainz <roland.mainz@nrubsig.org>
- #
- #
- # * install new kernel
- #
- # # log into the system with
- # # ksh sshnfs.ksh -o NFSURL=ssh+nfs://derfwpc5131//export/home2/rmainz -Y target@10.49.28.154
- # # su - root
- # # mount forwarnded NFSv4 filesystem as required by sshnfs messages
- #
- # $ mount -o remount,rw /
- # $ cd /mnt_nfs/work/bootimage_schnitzelmitpommes5_15_163_rt78/
- # $ dpkg -i $PWD/dist_files/*.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
- # $ mkdir -p /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/net/ethernet/intel/igb
- # $ cp dist_files/igb_avb.ko /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/net/ethernet/intel/igb/.
- # $ mv /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/net/ethernet/intel/igb/igb.ko /root/igb.ko_disabled
- # $ depmod
- # $ update-initramfs -k all -u
- #
- # $ cp dist_files/libigb_avb.so /usr/lib/i386-linux-gnu/libigb_avb.so
- #
- #
- #
- #
- # * simatic installation:
- # $ cp dist_files/simatic-ipc*.ko /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/mfd/.
- # $ depmod
- # $ update-initramfs -k all -u
- #
- # * install closed-source firmware data:
- # $ cd /
- # $ tar -xf dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
- # $ update-initramfs -k all -u
- #
- #
- # Installation:
- #
- #
- # Login into target machine:
- # $ ksh 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 v5.15.163-rt78-schnipo007
- #
- function build_kernel
- {
- set -o errexit
- set -o nounset
- # subshell so CWD remains unchanged on return
- (
- mkdir builddir_kernel
- cd builddir_kernel/
- git -c 'checkout.workers=16' clone -b 'v5.15.163-rt78' --single-branch git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git
- cd linux-stable-rt/
- cp '../../myconfig_linux_v5_15_163_rt78.config' '.config'
- #
- # fixme: add patches here
- # - rt RCU patch
- # - default boot args patch
- # - i915 patches
- # - rt udev dir
- #
- time nice -n 19 chrt --idle 0 ksh -c 'CC="gcc -m32" make -j4 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
- git clone https://github.com/wheybags/glibc_version_header.git
- cd igb_avb/
- # switch to commit 52ad70906fcb50d167475fe606aeb9631ca2b1fb,
- # which is known to work with Linux v5.15.163-rt78+6.6.32-rt32
- git checkout '52ad70906fcb50d167475fe606aeb9631ca2b1fb'
- #
- # 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 -j2 -C "$PWD/../../../builddir_kernel/linux-stable-rt/" KSRC="$PWD/../../../builddir_kernel/linux-stable-rt/" M=$PWD
- cp igb_avb.ko "${c.dist_files_dir}/"
- cd ..
- #cp simatic-ipc*.ko /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/mfd/.
- # build libigb.a
- #
- cd lib
- CC="gcc -m32 -pthread -include $PWD/../../glibc_version_header/version_headers/x86/force_link_glibc_2.18.h" make all
- #
- # build shared library vesion of libigb.a
- #
- gcc -m32 -pthread -shared -fPIC -o libigb_avb.so -Wl,--whole-archive libigb.a -Wl,--no-whole-archive -lpthread -lrt
- # make sure we do not pick up libc symbols beyond glibc 2.19
- glibcversymmatch="$(strings 'libigb_avb.so' | grep -E 'GLIBC_2\.[2-9][0-9]')" || true
- if [[ "${glibcversymmatch}" != '' ]] ; then
- print -u2 -f '# build_igbavb: glibc ELF ref for glibc > 2.19 found: %q\n' "$glibcversymmatch"
- return 1
- fi
- cp libigb_avb.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-stable-rt/" KSRC="$PWD/../../builddir_kernel/linux-stable-rt/" 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 builddir_firmware_tarball
- cd builddir_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_schnipo_kernel5_15_163_rt78.ksh - worse-is-better/simpler rewrite for Schnitzel-mit-Pommes kernel
Posted by Anonymous on Fri 2nd Aug 2024 11:33
raw | new post
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.