pastebin - collaborative debugging tool
rovema.kpaste.net RSS


build_rovema_kernel.ksh
Posted by Anonymous on Tue 19th Dec 2023 13:25
raw | new post
view followups (newest first): build_rovema_kernel.ksh by Anonymous
modification of post by Anonymous (view diff)

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