pastebin - collaborative debugging tool
rovema.kpaste.net RSS


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