pastebin - collaborative debugging tool
rovema.kpaste.net RSS


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)

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