pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post 449bb94f by Anonymous on Wed 24th Jan 2024 17:25
original post 3b8 by Anonymous on Sat 20th Jan 2024 13:31
Download diff
Show old version | new version | both versions

    
11
#!/bin/ksh93
22
33
#
44
# build_rovema_kernel.ksh
55
#
66
# worse-is-better/simpler rewrite for rovema-088 kernel
77
#
88
# Written by Roland Mainz <roland.mainz@nrubsig.org>
99
#
1010
1111
#
1212
# * install new kernel
1313
#
1414
# $ mount -o remount,rw /
1515
# $ cd /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_10_rt19/dist_files/
1616
# $ dpkg -i *.deb
1717
#
1818
# remove old linux 4.9 kernel:
1919
# $ dpkg -r --force-depends linux-image-4.9.303-rt192
2020
#
2121
2222
#
2323
# * igb_avb.ko installation:
2424
# # igb_avb kernel module must be manually installed on the target system, and the igb.ko kernel module removed
2525
# $ cp dist_files/igb_avb.ko /lib/modules/6.6.10-rt19-rovema088/kernel/drivers/net/ethernet/intel/igb/.
2626
# $ mv /lib/modules/6.6.10-rt19-rovema088/kernel/drivers/net/ethernet/intel/igb/igb.ko /root/igb.ko_disabled
2727
# $ depmod
2828
# $ update-initramfs -k all -u
2929
#
3030
# $ cp /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_10_rt19/dist_files/libigb.so /usr/lib/i386-linux-gnu/libigb_avb.so
3131
#
3232
#
3333
3434
#
3535
#
3636
# * simatic installation:
3737
# $ cp dist_files/simatic-ipc*.ko /lib/modules/6.6.10-rt19-rovema088/kernel/drivers/mfd/.
3838
# $ depmod
3939
# $ update-initramfs -k all -u
4040
#
4141
# * install closed-source firmware data:
4242
# $ cd /
4343
# $ tar -xf /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_10_rt19/dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
4444
# $ update-initramfs -k all -u
4545
#
4646
4747
#
4848
# Installation:
4949
#
5050
5151
#
5252
# Login into target machine:
5353
# $ ksh ~/work/nrubsigsvn/gisburn/scripts/sshnfs/sshnfs.ksh -o NFSURL=ssh+nfs://derfwpc5131/export/home2/rmainz target@fe80::d6f5:27ff:fe2b:4330%enp2s0
5454
#
5555
5656
#
5757
# Install updated Debian Jessie packages:
5858
# $ cd /mnt_nfs/work/jessie_target_packages/
5959
# dpkg -i --force-conflicts console-*.deb # conflicts with "plymouth"
6060
# dpkg -i *.deb
6161
#
6262
6363
#
6464
# Update Linux kernel boot args in grub:
6565
# $ vi /etc/default/grub
6666
# 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"
6767
# $ update-grub
6868
#
6969
7070
#
7171
# fix binfmt (Debian 'Jessie' bug):
7272
# printf 'ksh\nmagic\n0\n\\x0B\\x13\\x08\n\n/bin/ksh\n\n\n\n\n' >'/var/lib/binfmts/ksh'
7373
#
7474
7575
7676
7777
7878
#
7979
# build Linux kernel v6.6.10-rt19
8080
#
8181
8282
function build_kernel
8383
{
8484
	set -o errexit
8585
	set -o nounset
8686
8787
	# subshell so CWD remains unchanged on return
8888
	(
8989
		mkdir builddir_kernel
9090
		cd builddir_kernel/
9191
92-
		# fixme: we should use git:// once the ROVEMA firewall has been fixed
92+
		git clone -b 'v6.6.10-rt19' git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git
9693
9794
		cd linux-rt-devel/
9895
		cp '../../myconfig_linux_v6_6_10_rt19.config' '.config'
9996
10097
		#
10198
		# fixme: add patches here
10299
		# - rt RCU patch
103100
		# - default boot args patch
104101
		# - i915 patches
105102
		# - rt udev dir
106103
		#
107104
108105
		time nice -n 19 chrt --idle 0 ksh -c 'CC="gcc -m32" make -j2 bindeb-pkg 2>&1 | tee buildlog.log'
109106
110107
		cd ..
111108
112109
		cp linux-headers-*_i386.deb	"${c.dist_files_dir}/"
113110
		cp linux-image-*_i386.deb	"${c.dist_files_dir}/"
114111
		cp linux-libc-*_i386.deb	"${c.dist_files_dir}/"
115112
	)
116113
117114
	print '# build_kernel OK'
118115
119116
	return 0
120117
}
121118
122119
123120
#
124121
# build custom igb_avb module
125122
#
126123
function build_igbavb
127124
{
128125
	set -o errexit
129126
	set -o nounset
130127
131128
	# subshell so CWD remains unchanged on return
132129
	(
133130
		mkdir builddir_igbavb
134131
		cd builddir_igbavb/
135132
136133
		git clone https://github.com/Avnu/igb_avb.git
137134
		git clone https://github.com/wheybags/glibc_version_header.git
138135
139136
		cd igb_avb/
140137
141138
		# switch to commit 6c115ee89c88f6284d1407244b4a47586c3332d,
142139
		# which is known to work with Linux 6.6.10-rt19
143140
		git checkout '86c115ee89c88f6284d1407244b4a47586c3332d'
144141
145142
		#
146143
		# apply patches
147144
		#
148145
		# fixme:
149146
		# - pciid patch is missing
150147
		# - igb patches may need backport (bfp ?)
151148
		#
152149
		git am <'../../0001-libigb-Use-PTHREAD_PRIO_INHERIT-for-mutex-to-avoid-r.patch'
153150
		git am <'../../0002-Disable-pci_-_pcie_error_reporting-for-Linux-kernels.patch'
154151
155152
		#
156153
		# build kernel module
157154
		#
158155
		cd kmod/
159156
		CC="gcc -m32" make -j4 -C "$PWD/../../../builddir_kernel/linux-rt-devel/" KSRC="$PWD/../../../builddir_kernel/linux-rt-devel/" M=$PWD
160157
		cp igb_avb.ko	"${c.dist_files_dir}/"
161158
		cd ..
162159
163160
		#cp simatic-ipc*.ko /lib/modules/6.6.10-rt19-rovema088/kernel/drivers/mfd/.
164161
		# build libigb.a
165162
		#
166163
		cd lib
167164
		CC="gcc -m32 -pthread -include $PWD/../../glibc_version_header/version_headers/x86/force_link_glibc_2.18.h" make all
168165
169166
		#
170167
		# build shared library vesion of libigb.a
171168
		#
172169
		gcc -m32 -pthread -shared -fPIC -o libigb_avb.so -Wl,--whole-archive libigb.a -Wl,--no-whole-archive -lpthread -lrt
173170
174171
		# make sure we do not pick up libc symbols beyond glibc 2.19
175172
		glibcversymmatch="$(strings 'libigb_avb.so' | grep -E 'GLIBC_2\.[2-9][0-9]')" || true
176173
		if [[ "${glibcversymmatch}" != '' ]] ; then
177174
			print -u2 -f '# build_igbavb: glibc ELF ref for glibc > 2.19 found: %q\n' "$glibcversymmatch"
178175
			return 1
179176
		fi
180177
181178
		cp libigb_avb.so	"${c.dist_files_dir}/."
182179
	)
183180
184181
	print '# build_igbavb OK'
185182
186183
	return 0
187184
}
188185
189186
function build_simatic
190187
{
191188
	set -o errexit
192189
	set -o nounset
193190
194191
	# subshell so CWD remains unchanged on return
195192
	(
196193
		mkdir builddir_simatic
197194
		cd builddir_simatic/
198195
199196
		svn checkout http://svn.rovema.de/repos/bootimage/branches/dev027_kernel5_15/rovema_simatickernelmodules/simatic-ipc-modules-lsp-v1.2.0RC1/
200197
		cd simatic-ipc-modules-lsp-v1.2.0RC1/
201198
		make -C "$PWD/../../builddir_kernel/linux-rt-devel/" KSRC="$PWD/../../builddir_kernel/linux-rt-devel/" M=$PWD
202199
203200
		cp ./simatic-ipc.ko		"${c.dist_files_dir}/"
204201
		cp ./simatic-ipc-leds.ko	"${c.dist_files_dir}/"
205202
		cp ./simatic-ipc-wdt.ko		"${c.dist_files_dir}/"
206203
		cp ./simatic-ipc-batt.ko	"${c.dist_files_dir}/"
207204
		cp ./simatic-ipc-sensors.ko	"${c.dist_files_dir}/"
208205
		cp ./simatic-ipc-ps.ko		"${c.dist_files_dir}/"
209206
		cp ./simatic-ipc-nvram.ko	"${c.dist_files_dir}/"
210207
	)
211208
212209
	print '# build_simatic OK'
213210
214211
	return 0
215212
}
216213
217214
function build_firmware_tarball
218215
{
219216
	set -o errexit
220217
	set -o nounset
221218
222219
	typeset -r linux_firmware_git_tag='20231211'
223220
	typeset -r tarball_filename="linux_firmware_git_lib_firmware_i915_${linux_firmware_git_tag}.tar.bz2"
224221
225222
	# subshell so CWD remains unchanged on return
226223
	(
227224
		mkdir build_firmware_tarball
228225
		cd build_firmware_tarball/
229226
230227
		git clone -b "${linux_firmware_git_tag}" git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
231228
		mkdir -p 'lib/firmware/i915'
232229
		ln linux-firmware/i915/* 'lib/firmware/i915/.'
233230
		tar -cvf - 'lib' | pbzip2 >"${tarball_filename}"
234231
		cp "${tarball_filename}" "${c.dist_files_dir}/"
235232
	)
236233
}
237234
238235
#
239236
# main
240237
#
241238
242239
# use ksh93 builtins
243240
export PATH="/opt/ast/bin/:/usr/ast/bin:$PATH"
244241
builtin mkdir
245242
246243
# keep all global script data in a compound variable
247244
# so we can use $ print -u2 -v c # for debugging
248245
compound c
249246
250247
typeset c.dist_files_dir="$PWD/dist_files"
251248
mkdir -p "${c.dist_files_dir}"
252249
253250
254251
#
255252
# build packages
256253
#
257254
build_kernel
258255
build_igbavb
259256
build_simatic
260257
build_firmware_tarball
261258
262259
#
263260
# list resulting packages
264261
#
265262
ls -l "${c.dist_files_dir}"
266263
267264
# EOF.
268265

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