pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post 46e by Anonymous on Fri 2nd Aug 2024 11:33
original post 332b0 by Anonymous on Tue 30th Jul 2024 10:41
Download diff
Show old version | new version | both versions

    
11
#!/bin/ksh93
22
33
#
44
# build_rovema_schnipo_kernel5_15_163_rt78.ksh
55
#
66
# worse-is-better/simpler rewrite for Schnitzel-mit-Pommes kernel
77
#
88
# Written by Roland Mainz <roland.mainz@nrubsig.org>
99
#
1010
1111
#
1212
# * install new kernel
1313
#
1414
# # log into the system with
1515
# # ksh sshnfs.ksh -o NFSURL=ssh+nfs://derfwpc5131//export/home2/rmainz -Y target@10.49.28.154
1616
# # su - root
1717
# # mount forwarnded NFSv4 filesystem as required by sshnfs messages
1818
#
1919
# $ mount -o remount,rw /
20-
# $ cd /mnt_nfs/work/debian_rt_kernel_src/linux_5_15_163_rt78/dist_files/
20+
# $ cd /mnt_nfs/work/bootimage_schnitzelmitpommes5_15_163_rt78/
21-
# $ dpkg -i *.deb
21+
# $ dpkg -i $PWD/dist_files/*.deb
2222
#
2323
# remove old linux 4.9 kernel:
2424
# $ dpkg -r --force-depends linux-image-4.9.303-rt192
2525
#
2626
2727
#
2828
# * igb_avb.ko installation:
2929
# # igb_avb kernel module must be manually installed on the target system, and the igb.ko kernel module removed
30+
# $ mkdir -p /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/net/ethernet/intel/igb
3031
# $ cp dist_files/igb_avb.ko /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/net/ethernet/intel/igb/.
3132
# $ mv /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/net/ethernet/intel/igb/igb.ko /root/igb.ko_disabled
3233
# $ depmod
3334
# $ update-initramfs -k all -u
3435
#
35-
# $ cp /mnt_nfs/work/debian_rt_kernel_src/linux_5_15_163_rt78/dist_files/libigb_avb.so /usr/lib/i386-linux-gnu/libigb_avb.so
36+
# $ cp dist_files/libigb_avb.so /usr/lib/i386-linux-gnu/libigb_avb.so
3637
#
3738
#
3839
3940
#
4041
#
4142
# * simatic installation:
4243
# $ cp dist_files/simatic-ipc*.ko /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/mfd/.
4344
# $ depmod
4445
# $ update-initramfs -k all -u
4546
#
4647
# * install closed-source firmware data:
4748
# $ cd /
48-
# $ tar -xf /mnt_nfs/work/debian_rt_kernel_src/linux_5_15_163_rt78/dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
49+
# $ tar -xf dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
4950
# $ update-initramfs -k all -u
5051
#
5152
5253
#
5354
# Installation:
5455
#
5556
5657
#
5758
# Login into target machine:
5859
# $ ksh sshnfs.ksh -o NFSURL=ssh+nfs://derfwpc5131/export/home2/rmainz target@fe80::d6f5:27ff:fe2b:4330%enp2s0
5960
#
6061
6162
#
6263
# Install updated Debian Jessie packages:
6364
# $ cd /mnt_nfs/work/jessie_target_packages/
6465
# dpkg -i --force-conflicts console-*.deb # conflicts with "plymouth"
6566
# dpkg -i *.deb
6667
#
6768
6869
#
6970
# Update Linux kernel boot args in grub:
7071
# $ vi /etc/default/grub
7172
# 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"
7273
# $ update-grub
7374
#
7475
7576
#
7677
# fix binfmt (Debian 'Jessie' bug):
7778
# $ printf 'ksh\nmagic\n0\n\\x0B\\x13\\x08\n\n/bin/ksh\n\n\n\n\n' >'/var/lib/binfmts/ksh'
7879
#
7980
8081
8182
8283
8384
#
8485
# build Linux kernel v5.15.163-rt78-schnipo007
8586
#
8687
8788
function build_kernel
8889
{
8990
	set -o errexit
9091
	set -o nounset
9192
9293
	# subshell so CWD remains unchanged on return
9394
	(
9495
		mkdir builddir_kernel
9596
		cd builddir_kernel/
9697
9798
		git -c 'checkout.workers=16' clone -b 'v5.15.163-rt78' --single-branch git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git
9899
99100
		cd linux-stable-rt/
100101
		cp '../../myconfig_linux_v5_15_163_rt78.config' '.config'
101102
102103
		#
103104
		# fixme: add patches here
104105
		# - rt RCU patch
105106
		# - default boot args patch
106107
		# - i915 patches
107108
		# - rt udev dir
108109
		#
109110
110111
		time nice -n 19 chrt --idle 0 ksh -c 'CC="gcc -m32" make -j4 bindeb-pkg 2>&1 | tee buildlog.log'
111112
112113
		cd ..
113114
114115
		cp linux-headers-*_i386.deb	"${c.dist_files_dir}/"
115116
		cp linux-image-*_i386.deb	"${c.dist_files_dir}/"
116117
		cp linux-libc-*_i386.deb	"${c.dist_files_dir}/"
117118
	)
118119
119120
	print '# build_kernel OK'
120121
121122
	return 0
122123
}
123124
124125
125126
#
126127
# build custom igb_avb module
127128
#
128129
function build_igbavb
129130
{
130131
	set -o errexit
131132
	set -o nounset
132133
133134
	# subshell so CWD remains unchanged on return
134135
	(
135136
		mkdir builddir_igbavb
136137
		cd builddir_igbavb/
137138
138139
		git clone https://github.com/Avnu/igb_avb.git
139140
		git clone https://github.com/wheybags/glibc_version_header.git
140141
141142
		cd igb_avb/
142143
143144
		# switch to commit 52ad70906fcb50d167475fe606aeb9631ca2b1fb,
144145
		# which is known to work with Linux v5.15.163-rt78+6.6.32-rt32
145146
		git checkout '52ad70906fcb50d167475fe606aeb9631ca2b1fb'
146147
147148
		#
148149
		# apply patches
149150
		#
150151
		# fixme:
151152
		# - pciid patch is missing
152153
		# - igb patches may need backport (bfp ?)
153154
		#
154155
		git am <'../../0001-libigb-Use-PTHREAD_PRIO_INHERIT-for-mutex-to-avoid-r.patch'
155156
		git am <'../../0002-Disable-pci_-_pcie_error_reporting-for-Linux-kernels.patch'
156157
157158
		#
158159
		# build kernel module
159160
		#
160161
		cd kmod/
161162
		CC="gcc -m32" make -j2 -C "$PWD/../../../builddir_kernel/linux-stable-rt/" KSRC="$PWD/../../../builddir_kernel/linux-stable-rt/" M=$PWD
162163
		cp igb_avb.ko	"${c.dist_files_dir}/"
163164
		cd ..
164165
165166
		#cp simatic-ipc*.ko /lib/modules/5.15.163-rt78-schnipo007/kernel/drivers/mfd/.
166167
		# build libigb.a
167168
		#
168169
		cd lib
169170
		CC="gcc -m32 -pthread -include $PWD/../../glibc_version_header/version_headers/x86/force_link_glibc_2.18.h" make all
170171
171172
		#
172173
		# build shared library vesion of libigb.a
173174
		#
174175
		gcc -m32 -pthread -shared -fPIC -o libigb_avb.so -Wl,--whole-archive libigb.a -Wl,--no-whole-archive -lpthread -lrt
175176
176177
		# make sure we do not pick up libc symbols beyond glibc 2.19
177178
		glibcversymmatch="$(strings 'libigb_avb.so' | grep -E 'GLIBC_2\.[2-9][0-9]')" || true
178179
		if [[ "${glibcversymmatch}" != '' ]] ; then
179180
			print -u2 -f '# build_igbavb: glibc ELF ref for glibc > 2.19 found: %q\n' "$glibcversymmatch"
180181
			return 1
181182
		fi
182183
183184
		cp libigb_avb.so	"${c.dist_files_dir}/."
184185
	)
185186
186187
	print '# build_igbavb OK'
187188
188189
	return 0
189190
}
190191
191192
function build_simatic
192193
{
193194
	set -o errexit
194195
	set -o nounset
195196
196197
	# subshell so CWD remains unchanged on return
197198
	(
198199
		mkdir builddir_simatic
199200
		cd builddir_simatic/
200201
201202
		svn checkout http://svn.rovema.de/repos/bootimage/branches/dev027_kernel5_15/rovema_simatickernelmodules/simatic-ipc-modules-lsp-v1.2.0RC1/
202203
		cd simatic-ipc-modules-lsp-v1.2.0RC1/
203204
		make -C "$PWD/../../builddir_kernel/linux-stable-rt/" KSRC="$PWD/../../builddir_kernel/linux-stable-rt/" M=$PWD
204205
205206
		cp ./simatic-ipc.ko		"${c.dist_files_dir}/"
206207
		cp ./simatic-ipc-leds.ko	"${c.dist_files_dir}/"
207208
		cp ./simatic-ipc-wdt.ko		"${c.dist_files_dir}/"
208209
		cp ./simatic-ipc-batt.ko	"${c.dist_files_dir}/"
209210
		cp ./simatic-ipc-sensors.ko	"${c.dist_files_dir}/"
210211
		cp ./simatic-ipc-ps.ko		"${c.dist_files_dir}/"
211212
		cp ./simatic-ipc-nvram.ko	"${c.dist_files_dir}/"
212213
	)
213214
214215
	print '# build_simatic OK'
215216
216217
	return 0
217218
}
218219
219220
function build_firmware_tarball
220221
{
221222
	set -o errexit
222223
	set -o nounset
223224
224225
	typeset -r linux_firmware_git_tag='20231211'
225226
	typeset -r tarball_filename="linux_firmware_git_lib_firmware_i915_${linux_firmware_git_tag}.tar.bz2"
226227
227228
	# subshell so CWD remains unchanged on return
228229
	(
229230
		mkdir builddir_firmware_tarball
230231
		cd builddir_firmware_tarball/
231232
232233
		git clone -b "${linux_firmware_git_tag}" git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
233234
		mkdir -p 'lib/firmware/i915'
234235
		ln linux-firmware/i915/* 'lib/firmware/i915/.'
235236
		tar -cvf - 'lib' | pbzip2 >"${tarball_filename}"
236237
		cp "${tarball_filename}" "${c.dist_files_dir}/"
237238
	)
238239
}
239240
240241
#
241242
# main
242243
#
243244
244245
# use ksh93 builtins
245246
export PATH="/opt/ast/bin/:/usr/ast/bin:$PATH"
246247
builtin mkdir
247248
248249
# keep all global script data in a compound variable
249250
# so we can use $ print -u2 -v c # for debugging
250251
compound c
251252
252253
typeset c.dist_files_dir="$PWD/dist_files"
253254
mkdir -p "${c.dist_files_dir}"
254255
255256
256257
#
257258
# build packages
258259
#
259260
build_kernel
260261
build_igbavb
261262
build_simatic
262263
build_firmware_tarball
263264
264265
#
265266
# list resulting packages
266267
#
267268
ls -l "${c.dist_files_dir}"
268269
269270
# EOF.
270271

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