pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post c81b10 by Anonymous on Fri 12th Jul 2024 13:37
original post 40c18ee8d by Anonymous on Fri 12th Jul 2024 11:53
Download diff
Show old version | new version | both versions

    
11
#!/bin/ksh93
22
33
#
44
# build_rovema_hanswurst_kernel49rt.ksh
55
#
66
# worse-is-better/simpler rewrite for hanswurst 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 /
2020
# $ cd /mnt_nfs/work/debian_rt_kernel_src/linux_4_9_32_rt32/dist_files/
2121
# $ dpkg -i *.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
3030
# $ cp dist_files/igb_avb.ko /lib/modules/4.9.327-rt197-hawu002/kernel/drivers/net/ethernet/intel/igb/.
3131
# $ mv /lib/modules/4.9.327-rt197-hawu002/kernel/drivers/net/ethernet/intel/igb/igb.ko /root/igb.ko_disabled
3232
# $ depmod
3333
# $ update-initramfs -k all -u
3434
#
3535
# $ cp /mnt_nfs/work/debian_rt_kernel_src/linux_4_9_32_rt32/dist_files/libigb_avb.so /usr/lib/i386-linux-gnu/libigb_avb.so
3636
#
3737
#
3838
3939
#
4040
#
4141
# * simatic installation:
4242
# $ cp dist_files/simatic-ipc*.ko /lib/modules/4.9.327-rt197-hawu002/kernel/drivers/mfd/.
4343
# $ depmod
4444
# $ update-initramfs -k all -u
4545
#
4646
# * install closed-source firmware data:
4747
# $ cd /
4848
# $ tar -xf /mnt_nfs/work/debian_rt_kernel_src/linux_4_9_32_rt32/dist_files/linux_firmware_git_lib_firmware_i915_20231211.tar.bz2
4949
# $ update-initramfs -k all -u
5050
#
5151
5252
#
5353
# Installation:
5454
#
5555
5656
#
5757
# Login into target machine:
5858
# $ ksh sshnfs.ksh -o NFSURL=ssh+nfs://derfwpc5131/export/home2/rmainz target@fe80::d6f5:27ff:fe2b:4330%enp2s0
5959
#
6060
6161
#
6262
# Install updated Debian Jessie packages:
6363
# $ cd /mnt_nfs/work/jessie_target_packages/
6464
# dpkg -i --force-conflicts console-*.deb # conflicts with "plymouth"
6565
# dpkg -i *.deb
6666
#
6767
6868
#
6969
# Update Linux kernel boot args in grub:
7070
# $ vi /etc/default/grub
7171
# 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"
7272
# $ update-grub
7373
#
7474
7575
#
7676
# fix binfmt (Debian 'Jessie' bug):
7777
# $ printf 'ksh\nmagic\n0\n\\x0B\\x13\\x08\n\n/bin/ksh\n\n\n\n\n' >'/var/lib/binfmts/ksh'
7878
#
7979
8080
8181
8282
8383
#
8484
# build Linux kernel v4.9.327-rt197-hawu002
8585
#
8686
8787
function build_kernel
8888
{
8989
	set -o errexit
9090
	set -o nounset
9191
9292
	# subshell so CWD remains unchanged on return
9393
	(
9494
		mkdir builddir_kernel
9595
		cd builddir_kernel/
9696
9797
		git -c 'checkout.workers=16' clone -b 'v4.9.327-rt197' --single-branch git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git
9898
9999
		cd linux-stable-rt/
100100
		cp '../../myconfig_linux_v4_9_327_rt197.config' '.config'
101101
102102
		#
103103
		# fixme: add patches here
104104
		# - rt RCU patch
105105
		# - default boot args patch
106106
		# - i915 patches
107107
		# - rt udev dir
108108
		#
109109
110110
		time nice -n 19 chrt --idle 0 ksh -c 'CC="gcc -m32" make -j4 bindeb-pkg 2>&1 | tee buildlog.log'
111111
112112
		cd ..
113113
114114
		cp linux-headers-*_i386.deb	"${c.dist_files_dir}/"
115115
		cp linux-image-*_i386.deb	"${c.dist_files_dir}/"
116116
		cp linux-libc-*_i386.deb	"${c.dist_files_dir}/"
117117
	)
118118
119119
	print '# build_kernel OK'
120120
121121
	return 0
122122
}
123123
124124
125125
#
126126
# build custom igb_avb module
127127
#
128128
function build_igbavb
129129
{
130130
	set -o errexit
131131
	set -o nounset
132132
133133
	# subshell so CWD remains unchanged on return
134134
	(
135135
		mkdir builddir_igbavb
136136
		cd builddir_igbavb/
137137
138138
		git clone https://github.com/Avnu/igb_avb.git
139139
		git clone https://github.com/wheybags/glibc_version_header.git
140140
141141
		cd igb_avb/
142142
143143
		# switch to commit 52ad70906fcb50d167475fe606aeb9631ca2b1fb,
144144
		# which is known to work with Linux v4.9.327-rt197+6.6.32-rt32
145145
		git checkout '52ad70906fcb50d167475fe606aeb9631ca2b1fb'
146146
147147
		#
148148
		# apply patches
149149
		#
150150
		# fixme:
151151
		# - pciid patch is missing
152152
		# - igb patches may need backport (bfp ?)
153153
		#
154154
		git am <'../../0001-libigb-Use-PTHREAD_PRIO_INHERIT-for-mutex-to-avoid-r.patch'
155155
		git am <'../../0002-Disable-pci_-_pcie_error_reporting-for-Linux-kernels.patch'
156156
157157
		#
158158
		# build kernel module
159159
		#
160160
		cd kmod/
161161
		CC="gcc -m32" make -j2 -C "$PWD/../../../builddir_kernel/linux-stable-rt/" KSRC="$PWD/../../../builddir_kernel/linux-stable-rt/" M=$PWD
162162
		cp igb_avb.ko	"${c.dist_files_dir}/"
163163
		cd ..
164164
165165
		#cp simatic-ipc*.ko /lib/modules/4.9.327-rt197-hawu002/kernel/drivers/mfd/.
166166
		# build libigb.a
167167
		#
168168
		cd lib
169169
		CC="gcc -m32 -pthread -include $PWD/../../glibc_version_header/version_headers/x86/force_link_glibc_2.18.h" make all
170170
171171
		#
172172
		# build shared library vesion of libigb.a
173173
		#
174174
		gcc -m32 -pthread -shared -fPIC -o libigb_avb.so -Wl,--whole-archive libigb.a -Wl,--no-whole-archive -lpthread -lrt
175175
176176
		# make sure we do not pick up libc symbols beyond glibc 2.19
177177
		glibcversymmatch="$(strings 'libigb_avb.so' | grep -E 'GLIBC_2\.[2-9][0-9]')" || true
178178
		if [[ "${glibcversymmatch}" != '' ]] ; then
179179
			print -u2 -f '# build_igbavb: glibc ELF ref for glibc > 2.19 found: %q\n' "$glibcversymmatch"
180180
			return 1
181181
		fi
182182
183183
		cp libigb_avb.so	"${c.dist_files_dir}/."
184184
	)
185185
186186
	print '# build_igbavb OK'
187187
188188
	return 0
189189
}
190190
191191
function build_simatic
192192
{
193193
	set -o errexit
194194
	set -o nounset
195195
196196
	# subshell so CWD remains unchanged on return
197197
	(
198198
		mkdir builddir_simatic
199199
		cd builddir_simatic/
200200
201201
		svn checkout http://svn.rovema.de/repos/bootimage/branches/dev027_kernel5_15/rovema_simatickernelmodules/simatic-ipc-modules-lsp-v1.2.0RC1/
202202
		cd simatic-ipc-modules-lsp-v1.2.0RC1/
203203
		make -C "$PWD/../../builddir_kernel/linux-stable-rt/" KSRC="$PWD/../../builddir_kernel/linux-stable-rt/" M=$PWD
204204
205205
		cp ./simatic-ipc.ko		"${c.dist_files_dir}/"
206206
		cp ./simatic-ipc-leds.ko	"${c.dist_files_dir}/"
207207
		cp ./simatic-ipc-wdt.ko		"${c.dist_files_dir}/"
208208
		cp ./simatic-ipc-batt.ko	"${c.dist_files_dir}/"
209209
		cp ./simatic-ipc-sensors.ko	"${c.dist_files_dir}/"
210210
		cp ./simatic-ipc-ps.ko		"${c.dist_files_dir}/"
211211
		cp ./simatic-ipc-nvram.ko	"${c.dist_files_dir}/"
212212
	)
213213
214214
	print '# build_simatic OK'
215215
216216
	return 0
217217
}
218218
219219
function build_firmware_tarball
220220
{
221221
	set -o errexit
222222
	set -o nounset
223223
224224
	typeset -r linux_firmware_git_tag='20231211'
225225
	typeset -r tarball_filename="linux_firmware_git_lib_firmware_i915_${linux_firmware_git_tag}.tar.bz2"
226226
227227
	# subshell so CWD remains unchanged on return
228228
	(
229229
		mkdir builddir_firmware_tarball
230230
		cd builddir_firmware_tarball/
231231
232232
		git clone -b "${linux_firmware_git_tag}" git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
233233
		mkdir -p 'lib/firmware/i915'
234234
		ln linux-firmware/i915/* 'lib/firmware/i915/.'
235235
		tar -cvf - 'lib' | pbzip2 >"${tarball_filename}"
236236
		cp "${tarball_filename}" "${c.dist_files_dir}/"
237237
	)
238238
}
239239
240240
#
241241
# main
242242
#
243243
244244
# use ksh93 builtins
245245
export PATH="/opt/ast/bin/:/usr/ast/bin:$PATH"
246246
builtin mkdir
247247
248248
# keep all global script data in a compound variable
249249
# so we can use $ print -u2 -v c # for debugging
250250
compound c
251251
252252
typeset c.dist_files_dir="$PWD/dist_files"
253253
mkdir -p "${c.dist_files_dir}"
254254
255255
256256
#
257257
# build packages
258258
#
259259
build_kernel
260260
build_igbavb
261261
build_simatic
262262
build_firmware_tarball
263263
264264
#
265265
# list resulting packages
266266
#
267267
ls -l "${c.dist_files_dir}"
268268
269269
# EOF.
270270

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