pastebin - collaborative debugging tool
rovema.kpaste.net RSS


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