Sample Header Ad - 728x90

Yocto Linux /lib/modules/<version> directory differs per root filesystem build due to kgit-s2q

1 vote
0 answers
157 views
I am using Yocto Kirkstone to create a Linux image for a i.MX8 device. It successfully builds the Linux kernel version 5.15.71. I have also integrated RAUC (https://github.com/rauc/rauc) for firmware updates. This method creates an A/B partitioning scheme for firmware updates where the root file system is updated on the device. I have created a bbappend in my own custom layer and locked the SRCREV of the kernel. SRCREV = "50ade09d822cbf0f49af4c2cac250edb4003c7ef" The problem I am facing is that after a RAUC update of the root filesystem, the secondary partition is successfully updated and activated, however the /lib/modules/ directory has the incorrect version. This results in error messsages such as the following: Aug 27 13:29:02 device python3: modprobe: FATAL: Module ip_tables not found in directory /lib/modules/5.15.71-1.0+ge1cb7633db6d Aug 27 13:29:02 device python3: iptables v1.8.7 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?) Aug 27 13:29:02 device python3: Perhaps iptables or your kernel needs to be upgraded. Aug 27 13:29:02 device python3: 2024-08-27 13:29:02,425:ERROR:Error: Failed to set firewall commands: None The actual directory that does exist on disk is now: /lib/modules/2018 5.15.71-1.0+g885f034ad83a When I check the Yocto **tmp/work/*/linux-complab** build directory, I can see that the git repository is successfully checked out to my specified version. If I symlink this new directory to the expected directory version, the kernel successfully finds the modules it is looking for. Why is the root filesystem image produced by Yocto containing this directory by a changing name? How can I lock it down to one dependable name? UPDATE: After digging more, I think the issue is that the script in the work directory "recipe-sysroot-native/usr/bin/kgit-s2q" is missing some information. This section adds the 'invalid_git config': # Parse the author information GIT_AUTHOR_NAME=$(sed -ne 's/Author: //p' "$tmp_info") GIT_AUTHOR_EMAIL=$(sed -ne 's/Email: //p' "$tmp_info") export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL while test -z "$GIT_AUTHOR_EMAIL" && test -z "$GIT_AUTHOR_NAME" ; do if [ -n "$quilt_author" ] ; then GIT_AUTHOR_NAME="$quilt_author_name"; GIT_AUTHOR_EMAIL="$quilt_author_email"; else if [ -z "$INTERACTIVE" ]; then GIT_AUTHOR_NAME="invalid_git config" GIT_AUTHOR_EMAIL="" else echo "No author found in $patch_name" >&2; echo "---" cat $tmp_msg printf "Author: "; read patch_author echo "$patch_author" patch_author_name=$(expr "z$patch_author" : 'z\(.*[^ ]\) *]*\)') && test '' != "$patch_author_name" && test '' != "$patch_author_email" && GIT_AUTHOR_NAME="$patch_author_name" && GIT_AUTHOR_EMAIL="$patch_author_email" fi fi done It looks like it sets the invalid git config if "INTERACTIVE" is null: if [ -z "$INTERACTIVE" ]; then GIT_AUTHOR_NAME="invalid_git config" GIT_AUTHOR_EMAIL="" This in turn causes the top of the git log to include this bogus commit that is different each time I use bitbake to clean and build the kernel: commit 84e2651775ca2bdb4fdfbc081f314ec61451b3de (HEAD -> linux-compulab_v5.15.71) Author: invalid_git config Date: Tue Aug 27 22:55:34 2024 +0000 commit 50ade09d822cbf0f49af4c2cac250edb4003c7ef (origin/linux-compulab_v5.15.71, origin/HEAD) Author: vraevsky Date: Fri Feb 16 13:13:45 2024 +0200 Update README.md The temp folder logs show this kgit-s2q script getting called only in these few locations: >>/5.15.71-r0/temp$ grep -R "kgit-s2q" * run.do_patch: kgit-s2q --gen -v $kgit_extra_args --patches .kernel-meta/ run.do_patch.2351048: kgit-s2q --gen -v $kgit_extra_args --patches .kernel-meta/ run.do_validate_branches: # We've checked out HEAD, make sure we cleanup kgit-s2q fence post check run.do_validate_branches: kgit-s2q --clean run.do_validate_branches.2350365: # We've checked out HEAD, make sure we cleanup kgit-s2q fence post check run.do_validate_branches.2350365: kgit-s2q --clean This causes the git checkout to match the built kernel modules: linux-compulab/5.15.71-r0/image/lib/modules$ ls 5.15.71-1.0+g84e2651775ca It looks like the kernel-yocto.bbclass file is what sets the extra args: developer@machine:~/compulab-nxp-bsp/sources$ grep -R "kgit_extra_args" * poky/meta/classes/kernel-yocto.bbclass: kgit_extra_args="" poky/meta/classes/kernel-yocto.bbclass: kgit_extra_args="--commit-sha author" poky/meta/classes/kernel-yocto.bbclass: kgit-s2q --gen -v $kgit_extra_args --patches .kernel-meta/ How do I fix the kgit-s2q script so this bogus checkout is not created? UPDATE: I tried setting the following per the Yocto documentation to force a suffix for the uname command. However, this did not change the **/lib/modules/** value that Yocto creates on the root filesystem: # Force the uname extension LOCALVERSION = "+custom-${LINUX_VERSION_EXTENSION}" LINUX_VERSION_EXTENSION = "1.0" I created a really ugly workaround until this can be figured out. It checks that the **/lib/modules/** directory suffix matches the kernel's expected value on boot: EXPECTED_MODULES_SUFFIX=$(uname -r | cut -d '-' -f 2) EXPECTED_MODULES_NAME="5.15.71-$EXPECTED_MODULES_SUFFIX" FOUND_MODULES_NAME=$(ls /lib/modules) ls /lib/modules | grep $EXPECTED_MODULES_SUFFIX retVal=$? if [ $retVal -ne 0 ]; then echo "Error: Did not find expected modules: $EXPECTED_MODULES_NAME ..." mount -o remount,rw / echo "Repairing correct module directory now ..." mv $FOUND_MODULES_NAME $EXPECTED_MODULES_NAME mount -o remount,ro / else echo "Successfully found expected modules: $EXPECTED_MODULES_NAME ..." fi
Asked by PhilBot (101 rep)
Aug 27, 2024, 01:46 PM
Last activity: Aug 28, 2024, 01:40 PM