hexdump0815 / linux-mainline-and-mali-generic-stable-kernel

my kind of generic armv7l 32bit linux mainline stable kernel build - used on bananapi m1, asus tinkerboard, tx1 allwinner h3 tv box, r39 allwinner h3 tv box, orbsmart s92 tv box (same as beelink r89, tronsmart orion r28, very similar to ubox tv box), raspberry pi 3b and 3b plus in 32bit mode
21 stars 12 forks source link

troubles compiling working cbq v6.6.23 kernel #15

Open thenameisluk opened 4 months ago

thenameisluk commented 4 months ago

i did it few times before but now it doesn't seam to work any more for no apparent reason i reseted repos to the original state and tried again

  273  git reset --hard v6.6.23
  274  # fix kernel version number: + instead of -dirty at the end
  275  patch -p1 < /compile/doc/stable/misc.cbq/patches/fix-kernel-version-number-v6.6.patch
  276  # fix for at least the panel on some wormdingler devices (maybe others too)
  277  patch -p1 < /compile/doc/stable/misc.cbq/patches/fix-boe-tv101wum-nl6-panel.patch
  278  export ARCH=arm64
  279  scripts/kconfig/merge_config.sh -m  arch/arm64/configs/defconfig /compile/doc/kernel-config-options/chromebooks-aarch64.cfg /compile/doc/kernel-config-options/mediatek.cfg /compile/doc/kernel-config-options/docker-options.cfg /compile/doc/kernel-config-options/options-to-remove-generic.cfg /compile/doc/stable/misc.cbq/options/options-to-remove-special.cfg /compile/doc/kernel-config-options/additional-options-generic.cfg /compile/doc/kernel-config-options/additional-options-aarch64.cfg /compile/doc/stable/misc.cbq/options/additional-options-special.cfg
  280  ( cd /compile/doc/kernel-config-options ; git rev-parse --verify HEAD ) > /compile/doc/stable/misc.cbq/options/kernel-config-options.version
  281  make olddefconfig
  282  make -j 8 Image dtbs modules
  283  cd tools/perf
  284  export NO_JEVENTS=1
  285  make
  286  cd ../power/cpupower
  287  make
  288  cd ../../..
  289  export kver=`make kernelrelease`
  290  echo ${kver}
  291  make modules_install
  292  mkdir -p /lib/modules/${kver}/tools
  293  cp -v tools/perf/perf /lib/modules/${kver}/tools
  294  cp -v tools/power/cpupower/cpupower /lib/modules/${kver}/tools
  295  cp -v tools/power/cpupower/libcpupower.so.0.0.1 /lib/modules/${kver}/tools/libcpupower.so.0
  296  cp -v .config /boot/config-${kver}
  297  cp -v arch/arm64/boot/Image /boot/Image-${kver}
  298  mkdir -p /boot/dtb-${kver}
  299  cp -v arch/arm64/boot/dts/qcom/sc7180-trogdor*.dtb /boot/dtb-${kver}
  300  cp -v System.map /boot/System.map-${kver}
  301  cp arch/arm64/boot/Image Image
  302  lz4 -f Image Image.lz4
  303  dd if=/dev/zero of=bootloader.bin bs=512 count=1
  304  cp /compile/doc/stable/misc.cbq/misc/cmdline cmdline
  305  ls arch/arm64/boot/dts/qcom/sc7180-trogdor-*.dtb | xargs printf " -b %s" | xargs mkimage -D "-I dts -O dtb -p 2048" -f auto -A arm64 -O linux -T kernel -C lz4 -a 0 -d Image.lz4 kernel.itb
  306  vbutil_kernel --pack vmlinux.kpart --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --version 1 --config cmdline --bootloader bootloader.bin --vmlinuz kernel.itb --arch arm
  307  cp -v vmlinux.kpart /boot/vmlinux.kpart-${kver}
  308  rm -f Image Image.lz4 cmdline bootloader.bin kernel.itb vmlinux.kpart
  309  cd /boot
  310  update-initramfs -c -k ${kver}
  311  dd if=/boot/vmlinux.kpart-6.6.23-stb-cbq+ of=/dev/mmcblk1p1

but after rebooting all i see is a black screen

make olddefconfig throws this warnings

.config:1618:warning: override: DEBUG_INFO_NONE changes choice state
.config:2405:warning: override: reassigning to symbol TYPEC_QCOM_PMIC
.config:2411:warning: override: reassigning to symbol DRM_MSM
.config:2412:warning: override: reassigning to symbol BACKLIGHT_PWM
cd tools/perf
# this is to avoid compile errors
export NO_JEVENTS=1
make

throws a warning

Warning: Kernel ABI header differences:
  diff -u tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
  diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
  diff -u tools/include/uapi/linux/mount.h include/uapi/linux/mount.h
  diff -u tools/arch/x86/include/asm/disabled-features.h arch/x86/include/asm/disabled-features.h
  diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
  diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
  diff -u tools/arch/x86/include/uapi/asm/prctl.h arch/x86/include/uapi/asm/prctl.h
  diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
  diff -u tools/arch/s390/include/uapi/asm/kvm.h arch/s390/include/uapi/asm/kvm.h
  diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S
  diff -u tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S
  diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
  diff -u tools/perf/trace/beauty/include/linux/socket.h include/linux/socket.h

not sure it these matter

all folders are put as the readme.cbq instructs i used install buildtools script and installed additional deps cmdline is "default" (the one that comes with this repo) i even tried building directly using the config from v6.6.23 release on the repo cp /home/luk/6.6.23-stb-cbq+/boot/config-6.6.23-stb-cbq+ .config

it just doesn't seam to work is there anyway to troubleshoot this or sth i could be doing wrong? i don't have a suzyqable yet so no early output thingy could this be a reason? (i do run debian trixi after all) also still being on 6.1.51-stb-cbq kernel could be a reason?

hexdump0815 commented 4 months ago

with the default kernel cmdline options there should be at least something on the screen from the boot of the kernel itself, so i guess its not related to those debian changes (but could still be in some way)

my guess would be /boot being full and the kpart image creation failing resulting in an imcomplete image - have a close look at all log output, maybe there is something not working well around those steps

if you are on trixie (not tried it myself yet) gcc version might be an issue, but i did not read about any problems with newer gcc versions yet ... otherwise i have no further ideas what could be the problem ... v6.1 kernel should not be a problem

thenameisluk commented 4 months ago

my guess would be /boot being full and the kpart image creation failing resulting in an imcomplete image - have a close look at all log output, maybe there is something not working well around those steps

highly unlikely lack of space is an issue

mmcblk1      179:0    0 116,5G  0 disk 
├─mmcblk1p1  179:1    0    64M  0 part 
├─mmcblk1p2  179:2    0    64M  0 part 
├─mmcblk1p3  179:3    0     1G  0 part /boot <- isn't even 50% full
├─mmcblk1p4  179:4    0 107,4G  0 part /
└─mmcblk1p5  179:5    0     8G  0 part [SWAP]

if you are on trixie (not tried it myself yet) gcc version might be an issue, but i did not read about any problems with newer gcc versions yet ... otherwise i have no further ideas what could be the problem ... v6.1 kernel should not be a problem

will try debstraping and chroot after i have a look if there r any other errors

thenameisluk commented 4 months ago

is perf required to make a working kernel? because it doesn't really feel like compiling under chroot

  BUILD:   Doing 'make -j8' parallel build
Warning: Kernel ABI header differences:
  diff -u tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
  diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
  diff -u tools/include/uapi/linux/mount.h include/uapi/linux/mount.h
  diff -u tools/arch/x86/include/asm/disabled-features.h arch/x86/include/asm/disabled-features.h
  diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
  diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
  diff -u tools/arch/x86/include/uapi/asm/prctl.h arch/x86/include/uapi/asm/prctl.h
  diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
  diff -u tools/arch/s390/include/uapi/asm/kvm.h arch/s390/include/uapi/asm/kvm.h
  diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S
  diff -u tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S
  diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
  diff -u tools/perf/trace/beauty/include/linux/socket.h include/linux/socket.h
Makefile.config:464: *** No gnu/libc-version.h found, please install glibc-dev[el].  Stop.
make[1]: *** [Makefile.perf:242: sub-make] Error 2
make: *** [Makefile:70: all] Error 2

that package doesn't even exist and the include header it asks for is literally located here /usr/include/aarch64-linux-gnu/gnu/libc-version.h

hexdump0815 commented 4 months ago

perf is not required for the kernel - it is just an extra tool for profiling the execution of programs ... i build it as part of the kernel as it needs to match the kernel version, i.e. the perf binary which comes by default with debian/ubuntu will most likely not work ... if the perf part makes problems, then you can just skip it

thenameisluk commented 4 months ago

building works perfectly fine under stable debian so yeah weird, i did a bit of testing and narrowed down the problem i think

it turnes out only

make olddefconfig
make -j 8 Image dtbs modules

part has to be done on stable system

the rest of the process so

export kver=`make kernelrelease`
make modules_install

cp -v .config /boot/config-${kver}
cp -v arch/arm64/boot/Image /boot/Image-${kver}
mkdir -p /boot/dtb-${kver}
cp -v arch/arm64/boot/dts/qcom/sc7180-trogdor*.dtb /boot/dtb-${kver}
cp -v System.map /boot/System.map-${kver}

cp arch/arm64/boot/Image Image
lz4 -f Image Image.lz4
dd if=/dev/zero of=bootloader.bin bs=512 count=1
cp /compile/doc/stable/misc.cbq/misc/cmdline cmdline
ls arch/arm64/boot/dts/qcom/sc7180-trogdor-*.dtb | xargs printf " -b %s" | xargs mkimage -D "-I dts -O dtb -p 2048" -f auto -A arm64 -O linux -T kernel -C lz4 -a 0 -d Image.lz4 kernel.itb
vbutil_kernel --pack vmlinux.kpart --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --version 1 --config cmdline --bootloader bootloader.bin --vmlinuz kernel.itb --arch arm
cp -v vmlinux.kpart /boot/vmlinux.kpart-${kver}
rm -f Image Image.lz4 cmdline bootloader.bin kernel.itb vmlinux.kpart

rm /compile/source/linux-stable-cbq/${kver}.tar.gz
tar cvzf /compile/source/linux-stable-cbq/${kver}.tar.gz /boot/Image-${kver} /boot/System.map-${kver} /boot/config-${kver} /boot/dtb-${kver} /boot/vmlinux.kpart-${kver} /lib/modules/${kver}

isn't an issue on any version

what i noticed is that after copying the compile folder from debootstrap(stable) to root(trixie) and running make -j 8 Image dtbs modules on it we get

make -j 8 Image dtbs modules
  SYNC    include/config/auto.conf.cmd
*
* Restart config...
*
*
* General architecture-dependent options
*
Kprobes (KPROBES) [N/y/?] n
Optimize very unlikely/likely branches (JUMP_LABEL) [Y/n/?] y
  Static key selftest (STATIC_KEYS_SELFTEST) [N/y/?] n
Enable seccomp to safely execute untrusted bytecode (SECCOMP) [Y/n/?] y
  Show seccomp filter cache status in /proc/pid/seccomp_cache (SECCOMP_CACHE_DEBUG) [N/y/?] n
Stack Protector buffer overflow detection (STACKPROTECTOR) [Y/n/?] y
  Strong Stack Protector (STACKPROTECTOR_STRONG) [Y/n/?] y
Shadow Call Stack (SHADOW_CALL_STACK) [N/y/?] n
Link Time Optimization (LTO)
> 1. None (LTO_NONE)
choice[1]: 1
Provide system calls for 32-bit time_t (COMPAT_32BIT_TIME) [Y/n/?] y
Use a virtually-mapped stack (VMAP_STACK) [Y/n/?] y
Support for randomizing kernel stack offset on syscall entry (RANDOMIZE_KSTACK_OFFSET) [Y/?] y
  Default state of kernel stack offset randomization (RANDOMIZE_KSTACK_OFFSET_DEFAULT) [N/y/?] n
Locking event counts collection (LOCK_EVENT_COUNTS) [N/y/?] n
Use RELR relocation packing (RELR) [Y/n/?] (NEW)

so for some reason kernel configures diffrently under diffrent debians

the diff between them looks like this

diff /compile/source/linux-stable-cbq/.config /stable-chroot/compile/source/linux-stable-cbq/.config
5c5
< CONFIG_CC_VERSION_TEXT="gcc (Debian 12.4.0-1) 12.4.0"
---
> CONFIG_CC_VERSION_TEXT="gcc (Debian 12.2.0-14) 12.2.0"
7c7
< CONFIG_GCC_VERSION=120400
---
> CONFIG_GCC_VERSION=120200
10c10
< CONFIG_AS_VERSION=24250
---
> CONFIG_AS_VERSION=24000
12c12
< CONFIG_LD_VERSION=24250
---
> CONFIG_LD_VERSION=24000
18c18
< CONFIG_TOOLS_SUPPORT_RELR=y
---
> CONFIG_GCC_ASM_GOTO_OUTPUT_WORKAROUND=y
21c21
< CONFIG_PAHOLE_VERSION=0
---
> CONFIG_PAHOLE_VERSION=124
740d739
< CONFIG_RELR=y

the tooling version diffrence is expected but what caught my attention is missmatch in CONFIG_TOOLS_SUPPORT_RELR, CONFIG_GCC_ASM_GOTO_OUTPUT_WORKAROUND (<--seams to be the reason), CONFIG_RELR and CONFIG_PAHOLE_VERSION i have no idea what these do but they seem to be cause of the issue

this assumes we skip perf and cpupower which don't seam to be related to an issue but still

thenameisluk commented 4 months ago

additional info i managed to setup depthcharge (with build from stable) /etc/depthcharge-tools/config

[depthcharge-tools]

[depthchargectl]
board: homestar
kernel-cmdline: console=tty1 console=ttyMSM0,115200 rootwait ro fsck.fix=yes fsck.repair=yes net.ifnames=0
dtbs: sc7180-trogdor-*.dtb

Note. that's just cmdline i use, default works too

it's as simple as running make install to install or update-initramfs to update cmdline

it's still super bloated (at least now it boots)

-rw-r--r-- 1 root root 53M 07-02 00:28 6.6.23-stb-cbq+.img

but i can't find any option within it to set a compression, will try looking deeper

thenameisluk commented 4 months ago

it seams like it's trixie related issue

when compiling the corsola kernel the same issue building on trixie -> nothing building on stable chroot -> everything works

thenameisluk commented 4 months ago

also kernel for corsola built from this commit seams to be stable Linux cpluk 6.9.0-cos-mt9+ #3 SMP PREEMPT_DYNAMIC Fri Jul 5 22:03:36 UTC 2024 aarch64 GNU/Linux the wayland issue still is a thing, i assume it is a kms starting too late thing but i struggle to find any solution for mali

hexdump0815 commented 3 months ago

it might be that those problems came from a binutils bug which existed for a few days or maybe weeks recently and gave a lot of trouble for people failing to build working kernels - see here for instance: https://libera.irclog.whitequark.org/linux-mediatek/2024-07-25#36737983 ... i think its fixed now and there should be at least chance that after updating your trixie install it might work now

bookworm was not affected as the updated broken binutils package did not yet make it there before the problem was discovered