pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


build_rovema_kernel.ksh
Posted by Anonymous on Wed 13th Dec 2023 11:27
raw | new post
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-081 kernel
  7. #
  8. # Written by Roland Mainz <roland.mainz@nrubsig.org>
  9. #
  10.  
  11.  
  12. #
  13. # * igb_avb.ko installation:
  14. # igb_avb kernel module must be manually installed on the target system, and the igb.ko kernel module removed
  15. # $ dist_files/igb_avb.ko /lib/modules/6.6.0-rt15-rovema081/kernel/drivers/net/ethernet/intel/igb/.
  16. # $ mv /lib/modules/6.6.0-rt15-rovema081/kernel/drivers/net/ethernet/intel/igb/igb.ko /root/igb.ko_disabled
  17. # $ depmod
  18. # $ update-initramfs -k all -u
  19. #
  20. #
  21. # * simatic installation:
  22. # $ cp dist_files/simatic-ipc*.ko /lib/modules/6.6.0-rt15-rovema081/kernel/drivers/mfd/.
  23. # $ depmod
  24. # $ update-initramfs -k all -u
  25. #
  26. # * install closed-source firmware data:
  27. # $ cd /
  28. # $ tar -xf /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_rt15/dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
  29. # $ update-initramfs -k all -u
  30. #
  31.  
  32.  
  33. #
  34. # build Linux kernel 6.6-RT15
  35. #
  36.  
  37. function build_kernel
  38. {
  39.         set -o errexit
  40.         set -o nounset
  41.  
  42.         # subshell so CWD remains unchanged on return
  43.         (
  44.                 mkdir build_kernel
  45.  
  46.                 cd build_kernel/
  47.                 git clone -b v6.6-rt15 git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git
  48.  
  49.                 cd linux-rt-devel/
  50.                 cp ../../myconfig_linux_v6_6_rt15.config .config
  51.  
  52.                 #
  53.                 # fixme: add patches here
  54.                 # - rt RCU patch
  55.                 # - default boot args patch
  56.                 # - i915 patches
  57.                 # - rt udev dir
  58.                 #
  59.  
  60.                 time nice -n 19 ksh -c 'CC="gcc -m32" make -j2 bindeb-pkg 2>&1 | tee buildlog.log'
  61.                
  62.                 cd ..
  63.                
  64.                 cp linux-headers-*_i386.deb     "${c.dist_files_dir}/"
  65.                 cp linux-image-*_i386.deb       "${c.dist_files_dir}/"
  66.                 cp linux-libc-*_i386.deb        "${c.dist_files_dir}/"
  67.         )
  68.  
  69.         print '# build_kernel OK'
  70.  
  71.         return 0
  72. }
  73.  
  74.  
  75. #
  76. # build custom igb_avb module
  77. #
  78. function build_igbavb
  79. {
  80.         set -o errexit
  81.         set -o nounset
  82.  
  83.         # subshell so CWD remains unchanged on return
  84.         (
  85.                 mkdir build_igbavb
  86.                 cd build_igbavb/
  87.  
  88.                 git clone https://github.com/Avnu/igb_avb.git
  89.  
  90.                 cd igb_avb/
  91.  
  92.                 # switch to commit 6c115ee89c88f6284d1407244b4a47586c3332d,
  93.                 # which is known to work with Linux 6.6-RT15
  94.                 git checkout '86c115ee89c88f6284d1407244b4a47586c3332d'
  95.  
  96.                 #
  97.                 # apply patches
  98.                 #
  99.                 # fixme:
  100.                 # - pciid patch is missing
  101.                 # - igb patches may need backport (bfp ?)
  102.                 #
  103.                 git am <'../../0001-libigb-Use-PTHREAD_PRIO_INHERIT-for-mutex-to-avoid-r.patch'
  104.                 git am <'../../0002-Disable-pci_-_pcie_error_reporting-for-Linux-kernels.patch'
  105.  
  106.                 #
  107.                 # build kernel module
  108.                 #
  109.                 cd kmod/
  110.                 CC="gcc -m32" make -j4 -C "$PWD/../../../build_kernel/linux-rt-devel/" KSRC="$PWD/../../../build_kernel/linux-rt-devel/" M=$PWD
  111.                 cp igb_avb.ko   "${c.dist_files_dir}/"
  112.                 cd ..
  113.  
  114.                 #cp simatic-ipc*.ko /lib/modules/6.6.0-rt15-rovema081/kernel/drivers/mfd/.
  115.                 # build libigb.a
  116.                 #
  117.                 cd lib
  118.                 CC="gcc -m32" make all
  119.  
  120.                 #
  121.                 # build shared library vesion of libigb.a
  122.                 #
  123.                 gcc -m32 -shared -fPIC -o libigb.so -Wl,--whole-archive libigb.a -Wl,--no-whole-archive -lpthread
  124.                 cp libigb.so    "${c.dist_files_dir}/"
  125.         )
  126.  
  127.         print '# build_igbavb OK'
  128.  
  129.         return 0
  130. }
  131.  
  132. function build_simatic
  133. {
  134.         set -o errexit
  135.         set -o nounset
  136.  
  137.         # subshell so CWD remains unchanged on return
  138.         (
  139.                 mkdir build_simatic
  140.                 cd build_simatic/
  141.  
  142.                 svn checkout http://svn.rovema.de/repos/bootimage/branches/dev027_kernel5_15/rovema_simatickernelmodules/simatic-ipc-modules-lsp-v1.2.0RC1/
  143.                 cd simatic-ipc-modules-lsp-v1.2.0RC1/
  144.                 make -C "$PWD/../../build_kernel/linux-rt-devel/" KSRC="$PWD/../../build_kernel/linux-rt-devel/" M=$PWD
  145.                
  146.                 cp ./simatic-ipc.ko             "${c.dist_files_dir}/"
  147.                 cp ./simatic-ipc-leds.ko        "${c.dist_files_dir}/"
  148.                 cp ./simatic-ipc-wdt.ko         "${c.dist_files_dir}/"
  149.                 cp ./simatic-ipc-batt.ko        "${c.dist_files_dir}/"
  150.                 cp ./simatic-ipc-sensors.ko     "${c.dist_files_dir}/"
  151.                 cp ./simatic-ipc-ps.ko          "${c.dist_files_dir}/"
  152.                 cp ./simatic-ipc-nvram.ko       "${c.dist_files_dir}/"
  153.         )
  154.  
  155.         print '# build_simatic OK'
  156.  
  157.         return 0
  158. }
  159.  
  160. function build_firmware_tarball
  161. {
  162.         set -o errexit
  163.         set -o nounset
  164.  
  165.         typeset -r linux_firmware_git_tag='20231211'
  166.         typeset -r tarball_filename="linux_firmware_git_lib_firmware_i915_${linux_firmware_git_tag}.tar.bz2"
  167.  
  168.         # subshell so CWD remains unchanged on return
  169.         (
  170.                 mkdir build_firmware_tarball
  171.                 cd build_firmware_tarball/
  172.  
  173.                 git clone -b "${linux_firmware_git_tag}" git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
  174.                 mkdir -p 'lib/firmware/i915'
  175.                 ln linux-firmware/i915/* 'lib/firmware/i915/.'
  176.                 tar -cvf - 'lib' | pbzip2 >"${tarball_filename}"
  177.                 cp "${tarball_filename}" "${c.dist_files_dir}/"
  178.         )
  179. }
  180.  
  181. #
  182. # main
  183. #
  184.  
  185. # use ksh93 builtins
  186. export PATH="/opt/ast/bin/:/usr/ast/bin:$PATH"
  187. builtin mkdir
  188.  
  189. # keep all global script data in a compound variable
  190. # so we can use $ print -u2 -v c # for debugging
  191. compound c
  192.  
  193. typeset c.dist_files_dir="$PWD/dist_files"
  194. mkdir -p "${c.dist_files_dir}"
  195.  
  196.  
  197. #build_kernel
  198. #build_igbavb
  199. #build_simatic
  200. build_firmware_tarball
  201.  
  202. ls -l "${c.dist_files_dir}"
  203.  
  204. # 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