pastebin - collaborative debugging tool
rovema.kpaste.net RSS


build_rovema_kernel.ksh
Posted by Anonymous on Mon 15th Jan 2024 11:44
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.                 git clone https://github.com/wheybags/glibc_version_header.git
  135.  
  136.                 cd igb_avb/
  137.  
  138.                 # switch to commit 6c115ee89c88f6284d1407244b4a47586c3332d,
  139.                 # which is known to work with Linux 6.6.5-RT16
  140.                 git checkout '86c115ee89c88f6284d1407244b4a47586c3332d'
  141.  
  142.                 #
  143.                 # apply patches
  144.                 #
  145.                 # fixme:
  146.                 # - pciid patch is missing
  147.                 # - igb patches may need backport (bfp ?)
  148.                 #
  149.                 git am <'../../0001-libigb-Use-PTHREAD_PRIO_INHERIT-for-mutex-to-avoid-r.patch'
  150.                 git am <'../../0002-Disable-pci_-_pcie_error_reporting-for-Linux-kernels.patch'
  151.  
  152.                 #
  153.                 # build kernel module
  154.                 #
  155.                 cd kmod/
  156.                 CC="gcc -m32" make -j4 -C "$PWD/../../../builddir_kernel/linux-rt-devel/" KSRC="$PWD/../../../builddir_kernel/linux-rt-devel/" M=$PWD
  157.                 cp igb_avb.ko   "${c.dist_files_dir}/"
  158.                 cd ..
  159.  
  160.                 #cp simatic-ipc*.ko /lib/modules/6.6.5-rt16-rovema082/kernel/drivers/mfd/.
  161.                 # build libigb.a
  162.                 #
  163.                 cd lib
  164.                 CC="gcc -m32 -pthread -include $PWD/../../glibc_version_header/version_headers/x86/force_link_glibc_2.18.h" make all
  165.  
  166.                 #
  167.                 # build shared library vesion of libigb.a
  168.                 #
  169.                 gcc -m32 -pthread -shared -fPIC -o libigb_avb.so -Wl,--whole-archive libigb.a -Wl,--no-whole-archive -lpthread -lrt
  170.                
  171.                 # make sure we do not pick up libc symbols beyond glibc 2.19
  172.                 glibcversymmatch="$(strings 'libigb_avb.so' | grep -E 'GLIBC_2\.[2-9][0-9]')" || true
  173.                 if [[ "${glibcversymmatch}" != '' ]] ; then
  174.                         print -u2 -f '# build_igbavb: glibc ELF ref for glibc > 2.19 found: %q\n' "$glibcversymmatch"
  175.                         return 1
  176.                 fi
  177.  
  178.                 cp libigb_avb.so        "${c.dist_files_dir}/."
  179.         )
  180.  
  181.         print '# build_igbavb OK'
  182.  
  183.         return 0
  184. }
  185.  
  186. function build_simatic
  187. {
  188.         set -o errexit
  189.         set -o nounset
  190.  
  191.         # subshell so CWD remains unchanged on return
  192.         (
  193.                 mkdir builddir_simatic
  194.                 cd builddir_simatic/
  195.  
  196.                 svn checkout http://svn.rovema.de/repos/bootimage/branches/dev027_kernel5_15/rovema_simatickernelmodules/simatic-ipc-modules-lsp-v1.2.0RC1/
  197.                 cd simatic-ipc-modules-lsp-v1.2.0RC1/
  198.                 make -C "$PWD/../../builddir_kernel/linux-rt-devel/" KSRC="$PWD/../../builddir_kernel/linux-rt-devel/" M=$PWD
  199.                
  200.                 cp ./simatic-ipc.ko             "${c.dist_files_dir}/"
  201.                 cp ./simatic-ipc-leds.ko        "${c.dist_files_dir}/"
  202.                 cp ./simatic-ipc-wdt.ko         "${c.dist_files_dir}/"
  203.                 cp ./simatic-ipc-batt.ko        "${c.dist_files_dir}/"
  204.                 cp ./simatic-ipc-sensors.ko     "${c.dist_files_dir}/"
  205.                 cp ./simatic-ipc-ps.ko          "${c.dist_files_dir}/"
  206.                 cp ./simatic-ipc-nvram.ko       "${c.dist_files_dir}/"
  207.         )
  208.  
  209.         print '# build_simatic OK'
  210.  
  211.         return 0
  212. }
  213.  
  214. function build_firmware_tarball
  215. {
  216.         set -o errexit
  217.         set -o nounset
  218.  
  219.         typeset -r linux_firmware_git_tag='20231211'
  220.         typeset -r tarball_filename="linux_firmware_git_lib_firmware_i915_${linux_firmware_git_tag}.tar.bz2"
  221.  
  222.         # subshell so CWD remains unchanged on return
  223.         (
  224.                 mkdir build_firmware_tarball
  225.                 cd build_firmware_tarball/
  226.  
  227.                 git clone -b "${linux_firmware_git_tag}" git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
  228.                 mkdir -p 'lib/firmware/i915'
  229.                 ln linux-firmware/i915/* 'lib/firmware/i915/.'
  230.                 tar -cvf - 'lib' | pbzip2 >"${tarball_filename}"
  231.                 cp "${tarball_filename}" "${c.dist_files_dir}/"
  232.         )
  233. }
  234.  
  235. #
  236. # main
  237. #
  238.  
  239. # use ksh93 builtins
  240. export PATH="/opt/ast/bin/:/usr/ast/bin:$PATH"
  241. builtin mkdir
  242.  
  243. # keep all global script data in a compound variable
  244. # so we can use $ print -u2 -v c # for debugging
  245. compound c
  246.  
  247. typeset c.dist_files_dir="$PWD/dist_files"
  248. mkdir -p "${c.dist_files_dir}"
  249.  
  250.  
  251. #
  252. # build packages
  253. #
  254. build_kernel
  255. build_igbavb
  256. build_simatic
  257. build_firmware_tarball
  258.  
  259. #
  260. # list resulting packages
  261. #
  262. ls -l "${c.dist_files_dir}"
  263.  
  264. # 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