pastebin - collaborative debugging tool
rovema.kpaste.net RSS


build_rovema_schnipo_kernel5_10_222_rt114_rc1.ksh - worse-is-better/simpler rewrite for Schnitzel-mit-Pommes kernel
Posted by Anonymous on Tue 23rd Jul 2024 17:46
raw | new post

  1. #!/bin/ksh93
  2.  
  3. #
  4. # build_rovema_schnipo_kernel5_10_222_rt114_rc1.ksh
  5. #
  6. # worse-is-better/simpler rewrite for Schnitzel-mit-Pommes kernel
  7. #
  8. # Written by Roland Mainz <roland.mainz@nrubsig.org>
  9. #
  10.  
  11. #
  12. # * install new kernel
  13. #
  14. # # log into the system with
  15. # # ksh sshnfs.ksh -o NFSURL=ssh+nfs://derfwpc5131//export/home2/rmainz -Y target@10.49.28.154
  16. # # su - root
  17. # # mount forwarnded NFSv4 filesystem as required by sshnfs messages
  18. #
  19. # $ mount -o remount,rw /
  20. # $ cd /mnt_nfs/work/debian_rt_kernel_src/linux_5_10_222_rt114_rc1/dist_files/
  21. # $ dpkg -i *.deb
  22. #
  23. # remove old linux 4.9 kernel:
  24. # $ dpkg -r --force-depends linux-image-4.9.303-rt192
  25. #
  26.  
  27. #
  28. # * igb_avb.ko installation:
  29. # # igb_avb kernel module must be manually installed on the target system, and the igb.ko kernel module removed
  30. # $ cp dist_files/igb_avb.ko /lib/modules/5.10.222-rt114-rc1-schnipo003/kernel/drivers/net/ethernet/intel/igb/.
  31. # $ mv /lib/modules/5.10.222-rt114-rc1-schnipo003/kernel/drivers/net/ethernet/intel/igb/igb.ko /root/igb.ko_disabled
  32. # $ depmod
  33. # $ update-initramfs -k all -u
  34. #
  35. # $ cp /mnt_nfs/work/debian_rt_kernel_src/linux_5_10_222_rt114_rc1/dist_files/libigb_avb.so /usr/lib/i386-linux-gnu/libigb_avb.so
  36. #
  37. #
  38.  
  39. #
  40. #
  41. # * simatic installation:
  42. # $ cp dist_files/simatic-ipc*.ko /lib/modules/5.10.222-rt114-rc1-schnipo003/kernel/drivers/mfd/.
  43. # $ depmod
  44. # $ update-initramfs -k all -u
  45. #
  46. # * install closed-source firmware data:
  47. # $ cd /
  48. # $ tar -xf /mnt_nfs/work/debian_rt_kernel_src/linux_5_10_222_rt114_rc1/dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
  49. # $ update-initramfs -k all -u
  50. #
  51.  
  52. #
  53. # Installation:
  54. #
  55.  
  56. #
  57. # Login into target machine:
  58. # $ ksh sshnfs.ksh -o NFSURL=ssh+nfs://derfwpc5131/export/home2/rmainz target@fe80::d6f5:27ff:fe2b:4330%enp2s0
  59. #
  60.  
  61. #
  62. # Install updated Debian Jessie packages:
  63. # $ cd /mnt_nfs/work/jessie_target_packages/
  64. # dpkg -i --force-conflicts console-*.deb # conflicts with "plymouth"
  65. # dpkg -i *.deb
  66. #
  67.  
  68. #
  69. # Update Linux kernel boot args in grub:
  70. # $ vi /etc/default/grub
  71. # 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"
  72. # $ update-grub
  73. #
  74.  
  75. #
  76. # fix binfmt (Debian 'Jessie' bug):
  77. # $ printf 'ksh\nmagic\n0\n\\x0B\\x13\\x08\n\n/bin/ksh\n\n\n\n\n' >'/var/lib/binfmts/ksh'
  78. #
  79.  
  80.  
  81.  
  82.  
  83. #
  84. # build Linux kernel v5.10.222-rt114-rc1-schnipo003
  85. #
  86.  
  87. function build_kernel
  88. {
  89.         set -o errexit
  90.         set -o nounset
  91.  
  92.         # subshell so CWD remains unchanged on return
  93.         (
  94.                 mkdir builddir_kernel
  95.                 cd builddir_kernel/
  96.  
  97.                 git -c 'checkout.workers=16' clone -b 'v5.10.222-rt114-rc1' --single-branch git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git
  98.  
  99.                 cd linux-stable-rt/
  100.                 cp '../../myconfig_linux_v5_10_222_rt114_rc1.config' '.config'
  101.  
  102.                 #
  103.                 # fixme: add patches here
  104.                 # - rt RCU patch
  105.                 # - default boot args patch
  106.                 # - i915 patches
  107.                 # - rt udev dir
  108.                 #
  109.  
  110.                 time nice -n 19 chrt --idle 0 ksh -c 'CC="gcc -m32" make -j4 bindeb-pkg 2>&1 | tee buildlog.log'
  111.                
  112.                 cd ..
  113.                
  114.                 cp linux-headers-*_i386.deb     "${c.dist_files_dir}/"
  115.                 cp linux-image-*_i386.deb       "${c.dist_files_dir}/"
  116.                 cp linux-libc-*_i386.deb        "${c.dist_files_dir}/"
  117.         )
  118.  
  119.         print '# build_kernel OK'
  120.  
  121.         return 0
  122. }
  123.  
  124.  
  125. #
  126. # build custom igb_avb module
  127. #
  128. function build_igbavb
  129. {
  130.         set -o errexit
  131.         set -o nounset
  132.  
  133.         # subshell so CWD remains unchanged on return
  134.         (
  135.                 mkdir builddir_igbavb
  136.                 cd builddir_igbavb/
  137.  
  138.                 git clone https://github.com/Avnu/igb_avb.git
  139.                 git clone https://github.com/wheybags/glibc_version_header.git
  140.  
  141.                 cd igb_avb/
  142.  
  143.                 # switch to commit 52ad70906fcb50d167475fe606aeb9631ca2b1fb,
  144.                 # which is known to work with Linux v5.10.222-rt114-rc1+6.6.32-rt32
  145.                 git checkout '52ad70906fcb50d167475fe606aeb9631ca2b1fb'
  146.  
  147.                 #
  148.                 # apply patches
  149.                 #
  150.                 # fixme:
  151.                 # - pciid patch is missing
  152.                 # - igb patches may need backport (bfp ?)
  153.                 #
  154.                 git am <'../../0001-libigb-Use-PTHREAD_PRIO_INHERIT-for-mutex-to-avoid-r.patch'
  155.                 git am <'../../0002-Disable-pci_-_pcie_error_reporting-for-Linux-kernels.patch'
  156.  
  157.                 #
  158.                 # build kernel module
  159.                 #
  160.                 cd kmod/
  161.                 CC="gcc -m32" make -j2 -C "$PWD/../../../builddir_kernel/linux-stable-rt/" KSRC="$PWD/../../../builddir_kernel/linux-stable-rt/" M=$PWD
  162.                 cp igb_avb.ko   "${c.dist_files_dir}/"
  163.                 cd ..
  164.  
  165.                 #cp simatic-ipc*.ko /lib/modules/5.10.222-rt114-rc1-schnipo003/kernel/drivers/mfd/.
  166.                 # build libigb.a
  167.                 #
  168.                 cd lib
  169.                 CC="gcc -m32 -pthread -include $PWD/../../glibc_version_header/version_headers/x86/force_link_glibc_2.18.h" make all
  170.  
  171.                 #
  172.                 # build shared library vesion of libigb.a
  173.                 #
  174.                 gcc -m32 -pthread -shared -fPIC -o libigb_avb.so -Wl,--whole-archive libigb.a -Wl,--no-whole-archive -lpthread -lrt
  175.                
  176.                 # make sure we do not pick up libc symbols beyond glibc 2.19
  177.                 glibcversymmatch="$(strings 'libigb_avb.so' | grep -E 'GLIBC_2\.[2-9][0-9]')" || true
  178.                 if [[ "${glibcversymmatch}" != '' ]] ; then
  179.                         print -u2 -f '# build_igbavb: glibc ELF ref for glibc > 2.19 found: %q\n' "$glibcversymmatch"
  180.                         return 1
  181.                 fi
  182.  
  183.                 cp libigb_avb.so        "${c.dist_files_dir}/."
  184.         )
  185.  
  186.         print '# build_igbavb OK'
  187.  
  188.         return 0
  189. }
  190.  
  191. function build_simatic
  192. {
  193.         set -o errexit
  194.         set -o nounset
  195.  
  196.         # subshell so CWD remains unchanged on return
  197.         (
  198.                 mkdir builddir_simatic
  199.                 cd builddir_simatic/
  200.  
  201.                 svn checkout http://svn.rovema.de/repos/bootimage/branches/dev027_kernel5_15/rovema_simatickernelmodules/simatic-ipc-modules-lsp-v1.2.0RC1/
  202.                 cd simatic-ipc-modules-lsp-v1.2.0RC1/
  203.                 make -C "$PWD/../../builddir_kernel/linux-stable-rt/" KSRC="$PWD/../../builddir_kernel/linux-stable-rt/" M=$PWD
  204.                
  205.                 cp ./simatic-ipc.ko             "${c.dist_files_dir}/"
  206.                 cp ./simatic-ipc-leds.ko        "${c.dist_files_dir}/"
  207.                 cp ./simatic-ipc-wdt.ko         "${c.dist_files_dir}/"
  208.                 cp ./simatic-ipc-batt.ko        "${c.dist_files_dir}/"
  209.                 cp ./simatic-ipc-sensors.ko     "${c.dist_files_dir}/"
  210.                 cp ./simatic-ipc-ps.ko          "${c.dist_files_dir}/"
  211.                 cp ./simatic-ipc-nvram.ko       "${c.dist_files_dir}/"
  212.         )
  213.  
  214.         print '# build_simatic OK'
  215.  
  216.         return 0
  217. }
  218.  
  219. function build_firmware_tarball
  220. {
  221.         set -o errexit
  222.         set -o nounset
  223.  
  224.         typeset -r linux_firmware_git_tag='20231211'
  225.         typeset -r tarball_filename="linux_firmware_git_lib_firmware_i915_${linux_firmware_git_tag}.tar.bz2"
  226.  
  227.         # subshell so CWD remains unchanged on return
  228.         (
  229.                 mkdir builddir_firmware_tarball
  230.                 cd builddir_firmware_tarball/
  231.  
  232.                 git clone -b "${linux_firmware_git_tag}" git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
  233.                 mkdir -p 'lib/firmware/i915'
  234.                 ln linux-firmware/i915/* 'lib/firmware/i915/.'
  235.                 tar -cvf - 'lib' | pbzip2 >"${tarball_filename}"
  236.                 cp "${tarball_filename}" "${c.dist_files_dir}/"
  237.         )
  238. }
  239.  
  240. #
  241. # main
  242. #
  243.  
  244. # use ksh93 builtins
  245. export PATH="/opt/ast/bin/:/usr/ast/bin:$PATH"
  246. builtin mkdir
  247.  
  248. # keep all global script data in a compound variable
  249. # so we can use $ print -u2 -v c # for debugging
  250. compound c
  251.  
  252. typeset c.dist_files_dir="$PWD/dist_files"
  253. mkdir -p "${c.dist_files_dir}"
  254.  
  255.  
  256. #
  257. # build packages
  258. #
  259. build_kernel
  260. build_igbavb
  261. build_simatic
  262. build_firmware_tarball
  263.  
  264. #
  265. # list resulting packages
  266. #
  267. ls -l "${c.dist_files_dir}"
  268.  
  269. # EOF.

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at