- #!/bin/ksh93
- #
- # build_rovema_kernel.ksh
- #
- # worse-is-better/simpler rewrite for rovema-081 kernel
- #
- # Written by Roland Mainz <roland.mainz@nrubsig.org>
- #
- #
- # * igb_avb.ko installation:
- # igb_avb kernel module must be manually installed on the target system, and the igb.ko kernel module removed
- # $ dist_files/igb_avb.ko /lib/modules/6.6.0-rt15-rovema081/kernel/drivers/net/ethernet/intel/igb/.
- # $ mv /lib/modules/6.6.0-rt15-rovema081/kernel/drivers/net/ethernet/intel/igb/igb.ko /root/igb.ko_disabled
- # $ depmod
- # $ update-initramfs -k all -u
- #
- #
- # * simatic installation:
- # $ cp dist_files/simatic-ipc*.ko /lib/modules/6.6.0-rt15-rovema081/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_rt15/dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
- # $ update-initramfs -k all -u
- #
- #
- # build Linux kernel 6.6-RT15
- #
- function build_kernel
- {
- set -o errexit
- set -o nounset
- # subshell so CWD remains unchanged on return
- (
- mkdir build_kernel
- cd build_kernel/
- git clone -b v6.6-rt15 git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git
- cd linux-rt-devel/
- cp ../../myconfig_linux_v6_6_rt15.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 build_igbavb
- cd build_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-RT15
- 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/../../../build_kernel/linux-rt-devel/" KSRC="$PWD/../../../build_kernel/linux-rt-devel/" M=$PWD
- cp igb_avb.ko "${c.dist_files_dir}/"
- cd ..
- #cp simatic-ipc*.ko /lib/modules/6.6.0-rt15-rovema081/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 build_simatic
- cd build_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/../../build_kernel/linux-rt-devel/" KSRC="$PWD/../../build_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_kernel
- #build_igbavb
- #build_simatic
- build_firmware_tarball
- ls -l "${c.dist_files_dir}"
- # EOF.
build_rovema_kernel.ksh
Posted by Anonymous on Wed 13th Dec 2023 11:27
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.