pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post c023acd70 by Anonymous on Wed 19th Jun 2024 15:05
original post c0efbb81b by Anonymous on Wed 5th Jun 2024 09:33
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-149 kernel
77
#
88
# Written by Roland Mainz <roland.mainz@nrubsig.org>
99
#
1010
1111
#
1212
# * install new kernel
1313
#
14+
# # log into the system with
1419
# $ mount -o remount,rw /
1520
# $ cd /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_32_rt32/dist_files/
1621
# $ dpkg -i *.deb
1722
#
1823
# remove old linux 4.9 kernel:
1924
# $ dpkg -r --force-depends linux-image-4.9.303-rt192
2025
#
2126
2227
#
2328
# * igb_avb.ko installation:
2429
# # igb_avb kernel module must be manually installed on the target system, and the igb.ko kernel module removed
2530
# $ cp dist_files/igb_avb.ko /lib/modules/6.6.32-rt32-rovema149/kernel/drivers/net/ethernet/intel/igb/.
2631
# $ mv /lib/modules/6.6.32-rt32-rovema149/kernel/drivers/net/ethernet/intel/igb/igb.ko /root/igb.ko_disabled
2732
# $ depmod
2833
# $ update-initramfs -k all -u
2934
#
30-
# $ cp /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_32_rt32/dist_files/libigb.so /usr/lib/i386-linux-gnu/libigb_avb.so
35+
# $ cp /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_32_rt32/dist_files/libigb_avb.so /usr/lib/i386-linux-gnu/libigb_avb.so
3136
#
3237
#
3338
3439
#
3540
#
3641
# * simatic installation:
3742
# $ cp dist_files/simatic-ipc*.ko /lib/modules/6.6.32-rt32-rovema149/kernel/drivers/mfd/.
3843
# $ depmod
3944
# $ update-initramfs -k all -u
4045
#
4146
# * install closed-source firmware data:
4247
# $ cd /
4348
# $ tar -xf /mnt_nfs/work/debian_rt_kernel_src/linux_6_6_32_rt32/dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
4449
# $ update-initramfs -k all -u
4550
#
4651
4752
#
4853
# Installation:
4954
#
5055
5156
#
5257
# 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
58+
# $ ksh sshnfs.ksh -o NFSURL=ssh+nfs://derfwpc5131/export/home2/rmainz target@fe80::d6f5:27ff:fe2b:4330%enp2s0
5459
#
5560
5661
#
5762
# Install updated Debian Jessie packages:
5863
# $ cd /mnt_nfs/work/jessie_target_packages/
5964
# dpkg -i --force-conflicts console-*.deb # conflicts with "plymouth"
6065
# dpkg -i *.deb
6166
#
6267
6368
#
6469
# Update Linux kernel boot args in grub:
6570
# $ vi /etc/default/grub
6671
# 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"
6772
# $ update-grub
6873
#
6974
7075
#
7176
# fix binfmt (Debian 'Jessie' bug):
7277
# $ printf 'ksh\nmagic\n0\n\\x0B\\x13\\x08\n\n/bin/ksh\n\n\n\n\n' >'/var/lib/binfmts/ksh'
7378
#
7479
7580
7681
7782
7883
#
7984
# build Linux kernel v6.6.32-rt32
8085
#
8186
8287
function build_kernel
8388
{
8489
	set -o errexit
8590
	set -o nounset
8691
8792
	# subshell so CWD remains unchanged on return
8893
	(
8994
		mkdir builddir_kernel
9095
		cd builddir_kernel/
9196
9297
		git -c 'checkout.workers=16' clone -b 'v6.6.32-rt32' --single-branch git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git
9398
9499
		cd linux-stable-rt/
95100
		cp '../../myconfig_linux_v6_6_32_rt32.config' '.config'
96101
97102
		#
98103
		# fixme: add patches here
99104
		# - rt RCU patch
100105
		# - default boot args patch
101106
		# - i915 patches
102107
		# - rt udev dir
103108
		#
104109
105110
		time nice -n 19 chrt --idle 0 ksh -c 'CC="gcc -m32" make -j2 bindeb-pkg 2>&1 | tee buildlog.log'
106111
107112
		cd ..
108113
109114
		cp linux-headers-*_i386.deb	"${c.dist_files_dir}/"
110115
		cp linux-image-*_i386.deb	"${c.dist_files_dir}/"
111116
		cp linux-libc-*_i386.deb	"${c.dist_files_dir}/"
112117
	)
113118
114119
	print '# build_kernel OK'
115120
116121
	return 0
117122
}
118123
119124
120125
#
121126
# build custom igb_avb module
122127
#
123128
function build_igbavb
124129
{
125130
	set -o errexit
126131
	set -o nounset
127132
128133
	# subshell so CWD remains unchanged on return
129134
	(
130135
		mkdir builddir_igbavb
131136
		cd builddir_igbavb/
132137
133138
		git clone https://github.com/Avnu/igb_avb.git
134139
		git clone https://github.com/wheybags/glibc_version_header.git
135140
136141
		cd igb_avb/
137142
138143
		# switch to commit 52ad70906fcb50d167475fe606aeb9631ca2b1fb,
139144
		# which is known to work with Linux 6.6.32-rt32
140145
		git checkout '52ad70906fcb50d167475fe606aeb9631ca2b1fb'
141146
142147
		#
143148
		# apply patches
144149
		#
145150
		# fixme:
146151
		# - pciid patch is missing
147152
		# - igb patches may need backport (bfp ?)
148153
		#
149154
		git am <'../../0001-libigb-Use-PTHREAD_PRIO_INHERIT-for-mutex-to-avoid-r.patch'
150155
		git am <'../../0002-Disable-pci_-_pcie_error_reporting-for-Linux-kernels.patch'
151156
152157
		#
153158
		# build kernel module
154159
		#
155160
		cd kmod/
156161
		CC="gcc -m32" make -j2 -C "$PWD/../../../builddir_kernel/linux-stable-rt/" KSRC="$PWD/../../../builddir_kernel/linux-stable-rt/" M=$PWD
157162
		cp igb_avb.ko	"${c.dist_files_dir}/"
158163
		cd ..
159164
160165
		#cp simatic-ipc*.ko /lib/modules/6.6.32-rt32-rovema149/kernel/drivers/mfd/.
161166
		# build libigb.a
162167
		#
163168
		cd lib
164169
		CC="gcc -m32 -pthread -include $PWD/../../glibc_version_header/version_headers/x86/force_link_glibc_2.18.h" make all
165170
166171
		#
167172
		# build shared library vesion of libigb.a
168173
		#
169174
		gcc -m32 -pthread -shared -fPIC -o libigb_avb.so -Wl,--whole-archive libigb.a -Wl,--no-whole-archive -lpthread -lrt
170175
171176
		# make sure we do not pick up libc symbols beyond glibc 2.19
172177
		glibcversymmatch="$(strings 'libigb_avb.so' | grep -E 'GLIBC_2\.[2-9][0-9]')" || true
173178
		if [[ "${glibcversymmatch}" != '' ]] ; then
174179
			print -u2 -f '# build_igbavb: glibc ELF ref for glibc > 2.19 found: %q\n' "$glibcversymmatch"
175180
			return 1
176181
		fi
177182
178183
		cp libigb_avb.so	"${c.dist_files_dir}/."
179184
	)
180185
181186
	print '# build_igbavb OK'
182187
183188
	return 0
184189
}
185190
186191
function build_simatic
187192
{
188193
	set -o errexit
189194
	set -o nounset
190195
191196
	# subshell so CWD remains unchanged on return
192197
	(
193198
		mkdir builddir_simatic
194199
		cd builddir_simatic/
195200
196201
		svn checkout http://svn.rovema.de/repos/bootimage/branches/dev027_kernel5_15/rovema_simatickernelmodules/simatic-ipc-modules-lsp-v1.2.0RC1/
197202
		cd simatic-ipc-modules-lsp-v1.2.0RC1/
198203
		make -C "$PWD/../../builddir_kernel/linux-stable-rt/" KSRC="$PWD/../../builddir_kernel/linux-stable-rt/" M=$PWD
199204
200205
		cp ./simatic-ipc.ko		"${c.dist_files_dir}/"
201206
		cp ./simatic-ipc-leds.ko	"${c.dist_files_dir}/"
202207
		cp ./simatic-ipc-wdt.ko		"${c.dist_files_dir}/"
203208
		cp ./simatic-ipc-batt.ko	"${c.dist_files_dir}/"
204209
		cp ./simatic-ipc-sensors.ko	"${c.dist_files_dir}/"
205210
		cp ./simatic-ipc-ps.ko		"${c.dist_files_dir}/"
206211
		cp ./simatic-ipc-nvram.ko	"${c.dist_files_dir}/"
207212
	)
208213
209214
	print '# build_simatic OK'
210215
211216
	return 0
212217
}
213218
214219
function build_firmware_tarball
215220
{
216221
	set -o errexit
217222
	set -o nounset
218223
219224
	typeset -r linux_firmware_git_tag='20231211'
220225
	typeset -r tarball_filename="linux_firmware_git_lib_firmware_i915_${linux_firmware_git_tag}.tar.bz2"
221226
222227
	# subshell so CWD remains unchanged on return
223228
	(
224229
		mkdir builddir_firmware_tarball
225230
		cd builddir_firmware_tarball/
226231
227232
		git clone -b "${linux_firmware_git_tag}" git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
228233
		mkdir -p 'lib/firmware/i915'
229234
		ln linux-firmware/i915/* 'lib/firmware/i915/.'
230235
		tar -cvf - 'lib' | pbzip2 >"${tarball_filename}"
231236
		cp "${tarball_filename}" "${c.dist_files_dir}/"
232237
	)
233238
}
234239
235240
#
236241
# main
237242
#
238243
239244
# use ksh93 builtins
240245
export PATH="/opt/ast/bin/:/usr/ast/bin:$PATH"
241246
builtin mkdir
242247
243248
# keep all global script data in a compound variable
244249
# so we can use $ print -u2 -v c # for debugging
245250
compound c
246251
247252
typeset c.dist_files_dir="$PWD/dist_files"
248253
mkdir -p "${c.dist_files_dir}"
249254
250255
251256
#
252257
# build packages
253258
#
254259
build_kernel
255260
build_igbavb
256261
build_simatic
257262
build_firmware_tarball
258263
259264
#
260265
# list resulting packages
261266
#
262267
ls -l "${c.dist_files_dir}"
263268
264269
# EOF.
265270

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