Compile a Linux kernel module - Page 1
Forum section: electronics / general

author: RoGeorge
author_rank: Super Contributor
timestamp: July 22, 2022, 06:54:31 pm
content: The goal is to make a very small change in a .c file about the driver of a soundcard (CA0132), then to compile and make the current kernel to load the modified module.I've googled already but I don't have a bird-eye view of the whole process, so I can not make sense of the details I found online about how to recompile the kernel (or just a single loadable module). I could try one of the many recipes out there, and eventually one will work, but I would like to also understand what I'm doing.I'm confused about- where from to get the sources+headers, and what versions- what differences are between using dkms-get sources vs. apt install- also about using git vs downloading an archive with the sourcesThe OS is Ubuntu 20.04 LTS, AMD64, and I want to compile the module for the stable kernel version that is already installed, not for the nightly builds or for beta versions of kernels.I would prefer to use git, so to be able to make a pull request in case the changes will be successful.So far my plan is to add a new quirk definition for the ID of my card, which is "1102 0011", and by looking inside the Windows drivers, it's name seems to be "Sound Blaster Recon3Di", the chip is ca0132 Creative Sound Core3D. It's the onboard sound for the motherboard AsRock model "Fatal1ty Z97 Professional". I could see a Quirk in the sources for another Recon3Di card with the ID 1102 0010, and want to try the same quirk (a quirk here = custom settings) for my card ID with the ID 1102 0011. If I could only flip that bitAlso, I don't really know what I'm doing, so any other advice (except buy a new soundcard) is welcome.Code:~$ sudo apt update~$ uname -aLinux zub 5.15.0-41-generic #44~20.04.1-Ubuntu SMP Fri Jun 24 13:27:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux~$ find / -path "*/wd8TB/*" -prune -o -iname "*ca0132*.ko" -print 2>/dev/null/usr/lib/modules/5.13.0-52-generic/kernel/sound/pci/hda/snd-hda-codec-ca0132.ko/usr/lib/modules/5.15.0-41-generic/kernel/sound/pci/hda/snd-hda-codec-ca0132.ko~$ apt list linux-source*Listing... Donelinux-source-5.4.0/focal-updates,focal-updates,focal-security,focal-security,now 5.4.0-122.138 all [installed,automatic]linux-source/focal-updates,focal-updates,focal-security,focal-security,now 5.4.0.122.123 all ~$ uname -r5.15.0-41-genericThe file I want to modify is related with this bug that was fixed by Connor McAdamshttps://bugzilla.kernel.org/show_bug.cgi?id=109191#c66and his fix is already in the kernel, except that my card has a slightly different ID which I need to add.To be more precise, the file I plan to change corresponds to this one (but for my Unbuntu kernel/version):https://github.com/torvalds/linux/blob/master/sound/pci/hda/patch_ca0132.cMy understanding so far is that Ubuntu kernel has particular patches and configs that are specific to Ubuntu, so I can not just use any 5.15.0-41-generic Linux, it has to be from Ubuntu, but I'm not sure.What sources do I need, from where, and with what command(s) do I get them please?

author: ve7xen
author_rank: Super Contributor
timestamp: July 22, 2022, 07:50:53 pm
content: Ubuntu does apply their own patch sets, but these shouldn't change the kernel ABI, so a module built against the official source tree should (I think) still load in the corresponding Ubuntu kernel.The process to build a single in-tree module is pretty straightforward. You will need the kernel source tree (e.g. from apt source) and your running kernel configuration file (in Ubuntu I believe this should be available as /boot/config-<version>). Place the config file as .config in the root of the source tree. Then you can simply do (from the root of the kernel source tree):Code:make preparemake modules_preparemake M=sound/pci/hda/And you will find the .ko files in sound/pci/hda, which you can load or install manually. I believe you can also doCode:make M=sound/pci/hda/ modules_installto install just that module, but I'm not totally sure about that.

author: magic
author_rank: Super Contributor
timestamp: July 22, 2022, 11:03:40 pm
content: Quote from: RoGeorge on July 22, 2022, 06:54:31 pmYou can, with a hex editor, which may be the fastest option. Note that you are on a little-endian machine, so byte order in those numbers may be reversed.Obtaining the source corresponding to your installed package, kernel or otherwise, is a Ubuntu-specific question which you need to solve somehow.Configuration of the running kernel may be available in/proc/config.gz; if not, see if it's included in the Ubuntu kernel source package/tarball/repository; or installlinux-headers(make sure it's same version as your kernel) and then look for/lib/modules/`uname -r`/build/.config.If you have the full kernel source unpacked somewhere, I think it should be as simple as putting the.configthere andCode:make sound/pci/hda/snd-hda-codec-ca0132.koI wouldn't try to install the modified module, just reload. If it refuses to unload, close processes using it.I'm not 100% if the instructions above are corrrect, it seems ve7xen tries to build a module inside the kernel source directory as an out-of-tree module, I have never tried such things. Not sure ifmodules_installwill put it under /extra/ or overwrite the distribution's module in /kernel/ (both are subdirectories of/lib/modules/`uname -r`/). Did I say I would just reload it without installing?

author: langwadt
author_rank: Super Contributor
timestamp: July 23, 2022, 12:57:11 am
content: https://smallbusiness.chron.com/compile-modules-ubuntu-52622.html?

author: RoGeorge
author_rank: Super Contributor
timestamp: July 23, 2022, 12:57:26 am
content: Not sure if poking bits inside binaries would still work. I suspect the modules nowadays are cryptographically signed, but I digress.Back to Ubuntu sources, got them like this:Code:# https://wiki.ubuntu.com/Kernel/Dev/KernelGitGuidemkdir kernelcd kernel# Ubuntu 20.04 LTS is named Focal Fossa, so the /focal at the endgit clone git://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal# !!! git downloaded 1.95 GiB of sourcescd focaluname -r5.15.0-41-generic# each version has a tag, to list all available versionsgit tag -l *5.15.0-41*Ubuntu-hwe-5.15-5.15.0-41.44_20.04.1# make a new branch 'temp' with the desired versiongit checkout -b temp Ubuntu-hwe-5.15-5.15.0-41.44_20.04.1# search for the patch to be modifiedfind ./ -iname *ca0132*./sound/pci/hda/patch_ca0132.c./sound/pci/hda/ca0132_regs.h

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 23, 2022, 05:24:51 am
content: Quick guide for fixing a module in the currently running kernel in Debian derivatives:In a directory where you want to do your kernel stuff, runapt source linux-kernel-`uname -r`apt source linux-modules-`uname -r`to obtain the sources for the current kernel and its modules, andcd linux-[0-9]*/cp /boot/config-`uname -r` .configto enter the kernel tree and copy the configuration used to build the running kernel. Runsudo apt install build-essential fakerootsudo apt build-dep linux-kernel-`uname -r`sudo apt build-dep linux-modules-`uname -r`to install all development packages you might need when building the kernel and/or modules. (There's a lot of stuff, including Java Runtime, probably due to OpenJade used in some documentation generation options.)(Instead of actual package names, you can also just use the name 'linux', but I never remember such details.)Next, use your favourite editor to edit the sources, apply patches, et cetera.Then, in the same kernel root directory as you cd'd to above, runmake sound/pci/hda/make sound/pci/hda/snd-hda-codec-ca0132.koYou can remove its debug symbols via e.g.strip --strip-debug sound/pci/hda/snd-hda-codec-ca0132.koto make it smaller, or leave it be.You can now try the new module:sudo rmmod snd-hda-codec-ca0132sudo insmod sound/pci/hda/snd-hda-codec-ca0132.koIf you are satisfied by it, just replace original with the new modified one,sudo install sound/pci/hda/snd-hda-codec-ca0132.ko /lib/modules/`uname -r`/kernel/sound/pci/hda/At this point, you can just remove the entire kernel tree, about 1.3 GiB as of 5.4.0. I would still keep this guide, and the patch/changes you make to the files, in a text file so you can redo them for every new kernel you switch to, until the changes are included upstream.(I did verify this works in Mint 20.04. Do let me know if there are any typos, or forgot to mention a step, though.)You can also build a complete set of "fixed" packages, but for that, I'd switch to using upstream sources and going by theDebian Linux Kernel Handbook.

author: magic
author_rank: Super Contributor
timestamp: July 23, 2022, 09:55:39 am
content: Quote from: RoGeorge on July 23, 2022, 12:57:26 amIf it's signed, your custom compiled module won't load either.If you have the private key, re-sign the edited version. But I guess, at that point, it may be similar effort to compiling using the official build system. Or, at any rate, I don't know how to do it manually yet.Quote from: Nominal Animal on July 23, 2022, 05:24:51 amNot sure if I want to know the difference between these twoQuote from: Nominal Animal on July 23, 2022, 05:24:51 amLOL.Alternatively, just runmakeand if it fails, install the missing program or two. Realistically, you needmake,gccand maybe a few basic Linux utilities that are likely already installed on your system, or should be anyway if they aren't yet.Quote from: Nominal Animal on July 23, 2022, 05:24:51 amIIRC, the first line will just build everything in the HDA driver directory. I don't think it's necessary or useful.Quote from: Nominal Animal on July 23, 2022, 05:24:51 amIIRC, you can install modules in some special subdirectories other than /kernel/ and in some cases your module may even shadow the one in /kernel/, without deleting it.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 23, 2022, 01:22:01 pm
content: Quote from: magic on July 23, 2022, 09:55:39 amTypo. First one was supposed to belinux-image-`uname -r`, containing the stuff needed (later on) if you want to sign the kernel. The latter obtains the Linux source tree.Note that I was not writing about "how you can fix your ca0132 hda codec kernel module", I'm writing about how to go about it in general.Even if you switch from the kernel to some application or service, there's very little one needs to change.I'm sure you prefer simple recipes that are unique to each package that do nothing extra, but I just don't care to memorize such crap.And yes, I do do Linux kernel development myself. It's just that each Linux distribution varies a bit on exactly how to duplicate already installed kernels; although all Debian variants share the basic procedure.You know, magic, you come across as quite the asshole. No matter how good work you might do (which, well, based on your attitude, is unlikely –– I'm sure you're capable; I just don't think you actually ever really bother), I for sure would not like to work with you, ever. You somehow manage to be very annoying, even when you try to help. Are you a teenager? That would explain a lot.Quote from: magic on July 23, 2022, 09:55:39 amThat depends. If you feel comfortable walking blind in the dark and hope that fixing whatever errors you get will get you there, be my guest. I do not.And in general, I'm not the type that tells people to install packages until something works, I prefer to tell them how to install the set that the distribution maintainers have deemed relevant.Quote from: magic on July 23, 2022, 09:55:39 amIt is intentional, and useful. Although kernel configuration is tested by compile farms in random configurations, it is quite possible for a specific kernel module that depends on other kernel modules to not compile solo cleanly, unless those others are compiled first. (Because the Makefiles are written by humans who often make rather funny assumptions.) In this case, snd-hda-codec-ca0132.ko does compile cleanly alone.Quote from: magicYes, and no. Yes, you can do that by modifying modprobe config (seeman 5 modprobe.d) but it won't affect things like initrd creation (if you happen to do your own configuration and have the driver loaded there, say if you need the machine to make (yuk!) startup noise).You can trivially makermmod snd-hda-codec-ca0132 ; insmod /path/to/snd-hda-codec-ca0132.kointo a systemd init module, so it's run at boot time, too.Just replacing the existing one (assuming a typical unsigned kernel module) is easier. If you want to revert it, all you need to do is runapt reinstall $(dpkg-query -S /lib/modules/`uname -r`/kernel/sound/pci/hda/snd-hda-codec-ca0132.ko | cut -d ':' -f 1)where thedpkg-query -Spath-to-file| cut -d ':' -f 1provides the package name that "owns" the specified file. In this case, it will belinux-modules-extra-`uname -r`. So, it's not like overwriting the existing module file is somehow irreversible.If one wanted to (re)build the entire (unsigned) kernel and modules, there are three options. One is to runfakeroot debian/rules binaryin the kernel directory (that my short guide cd'd into). This can be used to build.debpackages whenever the project does contain the Debian tooling indebian/. The second is to usedebuildfrom the Debian devscripts package,debuild -b -uc -usto build only the binary packages, unsigned, for the package corresponding to the current directory. It basically runs the former as one step, but also does stuff like change the package info to match the build user and so on. This is the command I normally reach for in Debian derivatives. The third is to runmake deb-pkgsince the kernel Makefile contains thedeb-pkgtarget needed.In any case, one should do a small modification when copying over the current configuration:cp /boot/config-`uname -r` .configsed -e 's|^\(CONFIG_MODULE_SIG[_A-Z0-9]*\)=y$|\1=n|' -e 's|^\(CONFIG_MODULE_SIG[_A-Z0-9]*\)=".*$|\1=""|' -i .configto disable module signing, andsed -e '/debian/ s|^\(CONFIG_SYSTEM_[A-Z]*_KEYS\)=.*$|\1=""|' -i .configto remove the canonical certificate list (debian/canonical-certs.pem) and revoked certificates list (debian/canonical-revoked-certs.pem) from being embedded in the kernel, since they are not included in the kernel sources, and the build will fail in one of thecerts/targets otherwise.You can run e.g.diff -U 0 /boot/config-`uname -r` .configto see exactly what changes the above does.The packages will appear in the parent directory. (These commands are always run in the topmost directory belonging to the sources, the topmost one extracted when the sources are downloaded and patches applied; i.e. inlinux-5.4.0/for example.)

author: magic
author_rank: Super Contributor
timestamp: July 23, 2022, 03:35:43 pm
content: Quote from: Nominal Animal on July 23, 2022, 01:22:01 pmYes, I feel comfortable compiling C software withmakeand fixing problems likemake: /usr/bin/perl: no such file or directory, which is about the worst you could encounter while building a stupid kernel moduleQuote from: Nominal Animal on July 23, 2022, 01:22:01 pmOkay, so it's your defense against Makefile bugs that you have encountered at some point in the past. In such case, I would clearly state that it's the second line which does the business and that the first may help in case of particular problems, or it may not, because perhapsmake sound/would be necessary or whatever. You made it look like this is the right process, but it is not.Quote from: Nominal Animal on July 23, 2022, 01:22:01 pmI just happen to know how to build kernel modules. THB, I would grab the C file from relevant repository's web interface and build the module out of tree. It's a job that's distribution-agnostic (save for locating the source and installinglinux-headers) and takes five minutes. Add another five for figuring out signing, if it's in use on given distribution, which should be well documented somewhere because building OoT modules is a common use case.BTW, if your distribution enforces package signatures and doesn't publish its private key, you are screwed anyway without rebuilding the whole kernel and rebooting. I'm not up to date with all that signing drama (I run my own kernel builds) but I know how crypto works.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 23, 2022, 04:34:35 pm
content: Quote from: magic on July 23, 2022, 03:35:43 pmI doubt it. I believe you get paid to compile out of tree kernel modules for someones private fork, but that's it.Quote from: magic on July 23, 2022, 03:35:43 pmExtremely unlikely, based on the content of your posts thus far.

author: magic
author_rank: Super Contributor
timestamp: July 24, 2022, 06:16:27 am
content: I haven't been paid for anything involving Linux in over a decade and you are welcome to keep doubting whatever you want. It's you guys who will spend a week on this project.editBTW, I'm not blaming the OP. You guys are fucked, being Linux beginners in the era of Ubuntu, with layers upon layers of "abstraction" and the all-prevailing culture of "tutorials" (written by people who have just learned something, barely enough to cover their narrow need) and askubuntu.com answers to OPs who don't even know what to ask, and hardly any competent documentation, particularly one detailed enough to described the overall architecture of the system and the rationale (if there was any) for the design decisions. Back in the day at least there was TLDP.This is what I really hate Ubuntu for, basically for a decade of being forced to append -ubuntu to all my Google queries about anything to do with Linux.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 24, 2022, 06:50:26 am
content: Perhaps you should take a minute and consider what might be the reason why most members tend to completely disregard your posts.I'll give you a hint: the "Ignore list" facility this forum provides is most definitely involved.

author: magic
author_rank: Super Contributor
timestamp: July 24, 2022, 06:55:57 am
content: You aren't going to use it because you will want to meticulously read all my posts and ensure I'm not recommending anything wrong or dangerous

author: DiTBho
author_rank: Super Contributor
timestamp: July 24, 2022, 10:33:17 am
content: Life seemseasierto me withVanillasources(most likely not, but today I want to think so)

author: RoGeorge
author_rank: Super Contributor
timestamp: July 27, 2022, 07:42:45 am
content: Thank you all for the replies, having more examples helped a lot to understand what has to be done.However, tried yesterday to modify the module until early hours, and failed.Eventually the module compiled, but the kernel requires signed modules, couldn't load it, so I gave up!The rest is ranting.Most of the frustration was from fighting against Ubuntu, not from the sound module. By the way, PPA repositories for sources are not enabled by default in Ubuntu, that's why apt was showing no kernel sources, but either by using repository sources, or by using manually cloned sources from git, it was not possible to build only the modules, without the whole kernel.Another ugly thing (looks like a bug to me) was because of tex-common (needed by other tools that are required to make/build from sources) Tex was a nightmare and refused to install, only to find some obscure answer that it will install if I change the locale to en utf8. It seemed to me that some perl scripts were failing to install tex when mixed locale settings are in use (I have US English utf8, but I was using some other locales for dates and numbers, so I can see english but with ISO format for datetime and non comma (custom) thousand separators for numbers. Once I set all to En Us Utf8, I could finally install all the build tools:Code:sudo apt-get install libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconfTo enable the repository for sources, either edit the /etc/apt/sources.list, or from GUI (Updates & Software tool) check the "Sources" checkbox. For my Ubuntu, this how the sources.list (filtered) looked like after enabled the sources from GUI:Code:cat /etc/apt/sources.list | grep deb-srcdeb-src http://archive.ubuntu.com/ubuntu focal main restricted #Added by software-propertiesdeb-src http://ubuntu.mirrors.linux.ro/archive/ focal restricted universe multiverse main #Added by software-properties# deb-src http://ro.archive.ubuntu.com/ubuntu/ focal main restricteddeb-src http://ubuntu.mirrors.linux.ro/archive/ focal-updates restricted universe multiverse main #Added by software-properties# deb-src http://ro.archive.ubuntu.com/ubuntu/ focal-updates main restricted# deb-src http://ro.archive.ubuntu.com/ubuntu/ focal universe# deb-src http://ro.archive.ubuntu.com/ubuntu/ focal-updates universe# deb-src http://ro.archive.ubuntu.com/ubuntu/ focal multiverse# deb-src http://ro.archive.ubuntu.com/ubuntu/ focal-updates multiversedeb-src http://ubuntu.mirrors.linux.ro/archive/ focal-backports main restricted universe multiverse #Added by software-properties# deb-src http://ro.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse# deb-src http://archive.canonical.com/ubuntu focal partnerdeb-src http://ubuntu.mirrors.linux.ro/archive/ focal-security restricted universe multiverse main #Added by software-properties# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted# deb-src http://security.ubuntu.com/ubuntu focal-security universe# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse# deb-src http://dl.winehq.org/wine-builds/ubuntu/ focal main# deb-src https://paulcarroty.gitlab.io/vscodium-deb-rpm-repo/debs/ vscodium mainThe rest of the tries were done in two separate Ubuntu kernel sources (not vanilla Linux), one from git, one from Ubuntu repos. First, all the kernel has to build, or else the modules will miss "Module.symvers", which is only build at a full make, which on my hardware and with -j8, a full kernel compile takes about 2 hours first time. Subsequent compilations or only modules takes only minutes. I've read some other distros (e.g. OpenSUSE) have a package that includes "Module.symvers", but couldn't find any such package for Ubuntu, so I had to compile the full kernelUnfortunately, the kernel modules in my Ubuntu are signed. I had to generate my own keys.In the end my "snd-hda-codec-ca0132.ko" didn't load, even when manually copied in "/lib/modules/5.15.0-41-generic/kernel/sound/pci/hda/snd-hda-codec-ca0132.ko" then rebooting. Secure boot is not enabled in the motherboard's BIOS, and by looking at the kernel config, it looks like the kernel should accept self-signed modules.The module "snd-hda-codec-ca0132.ko" built from repository sources does not load at all (according to dmesg).The one built from git has a differrent dmesg message about some missing symbol, and the alsamixer shows the same set of wrong sliders like in the case of no "snd-hda-codec-ca0132.ko" loaded.I didn't experiment with replacing the full kernel because of two things:- my install is with root on ZFS, which is experimental and all the docs I found were not considering this aspect- with either sets of sources, neither of my builds have the exact same version "5.15.0-41-generic"- I've tried installing a newer kernel (ready made debs from Ubuntu), and it didn't bootVery frustrating afternoon, and it all felt like I was fighting against the OS.Maybe I should give up Ubuntu. Ubuntu works great if you don't touch anything, but as soon as you want something different, it's a pain bigger than Arch or Gentoo. It is probably just me not knowing what I'm doing, but if I want to understand more, I guess I should start using something else, less obfuscated.Though, I still have a generic question. When I was building from sources, I didn't get the exact same version "5.15.0-41-generic". I was seeing something like "5.15.0-38+" (from git sources) and something else for apt downloaded sources (I don't recall exactly), but neither was called "5.15.0-41-generic" as "uname -r" was telling for the kernel I was running and wanted to rebuild again from sources.Is this difference in version naming expected to show at a rebuild, or I was building wrong sources the whole time?

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 27, 2022, 09:21:02 am
content: Quote from: RoGeorge on July 27, 2022, 07:42:45 amThat seems very strange to me. I did test the entire chain I suggestedreply #5, but on Linux Mint 20.04.It is more generic than just the kernel that roughly the same flow should work to reproduceanypackage.(If you want, I can distill the recipe down to rebuilding the full set of current kernel packages, on Debian derivatives.But it is so much effort I'd require you to exactly reproduce it on your system, and report any errors/issues/findings on each step.)A core idea of packages is that they should be recompilable, and reproducible excluding timestamps (included in the object files) and compiler version differences. Perhaps you are running a kernel from a PPA that does shenanigans with its source package? I personally would not, I hate that kind of shenanigans. Even running completely custom kernels with an optimised.configis far more preferable. I used to do that for a long time, when I was using a motherboard with AMD integrated graphics with open-source drivers still in heavy development.

author: magic
author_rank: Super Contributor
timestamp: July 27, 2022, 09:38:35 am
content: Quote from: RoGeorge on July 27, 2022, 07:42:45 amThat's what I meant by "just run make and manually install missing programs, if any". Tex isn't needed to compile a few lines of C code, neither is JavaQuote from: RoGeorge on July 27, 2022, 07:42:45 amSo you have compiled your module to work against your own build of the kernel. I am actually not 100% sure if your build is guaranteed to be similar enough for the module to load into the distribution kernel too. If it matches, it's still a waste of time.The right (and fast) solution is to use your distribution'sModule.symversand this should be provided bylinux-headers. Also.configand everything else needed to build modules for the distribution kernel should be in this package, because it's the whole point of this package to enable building of additional modules for the distribution kernel. It might even pull all dependencies required by kernel Makefiles so that you shouldn't need any of thatbuild-depstuff just to build a module.You could steal required files from there to your source tree, or just build the module out-of-tree. The point of building OoT is not because it's the only way I know of or to make Nominal jealous because he doesn't know it, but simply because it works and it works fast and it's easy to set up and doesn't require a gigabyte download.Quote from: RoGeorge on July 27, 2022, 07:42:45 amI would look at how it's done by kernel modules provided by the distribution in source format, such asthis one. As far as I see after unpacking the .DEB, they simply use DKMS, so maybe everything is somehow sorted out by DKMS.Can you install this module and load it, or at least get it to the point where it says that you don't have such hardware and exists?If so, there seems to be an obvious path forward: use DKMS to build your patched code out-of-tree and call it a day.If not, what is even the officially supported way of installing this driver (or NVIDIA, etc) on Ubuntu? There has to be something, and it ought to be simple enough for a monkey to use.editCAUTION, this package seems to blacklist some other Broadcom WiFi drivers. So maybe don't install it or be sure to have instructions how to uninstall it downloaded if you use such hardware

author: RoGeorge
author_rank: Super Contributor
timestamp: July 27, 2022, 03:03:37 pm
content: I said I'll give up, but still itchy to make it work, sorry for not keeping my word.To answer in order, I'll try first the Reply#5, considering what I've learned meanwhile, but I'll ask where I see deviations. To some commands I've pasted the stdout from the terminal, either to check, or to point at unexpected behavior.Quote from: Nominal Animal on July 27, 2022, 09:21:02 amI've looked at Minthttps://linuxmint.com/download_all.php,and my understanding is the current Mint is based on Ubuntu 20.04 LTS Focal Fossa, the exact Ubuntu I am running.About the sources, please note the "Picking 'linux-signed-hwe-5.15'" as source package instead of 'linux-image-5.15.0-41-generic', did Mint does that?Next strange thing is that out of all the .sh scripts in the ./scripts directory, only 3 of them are not executables, the rest are executable. Not sure if this is a bug. I am tempted to chmod them to +x and continue, but I thought I might stop to ask before going on, given that it also picked some other sources than my "uname -r" requested.Is it OK"-ish" so far, or I'm already on a wrong path?Code:mkdir reply5cd reply5apt source linux-image-`uname -r`Reading package lists... DonePicking 'linux-signed-hwe-5.15' as source package instead of 'linux-image-5.15.0-41-generic'Need to get 22,0 kB of source archives.Get:1 http://ubuntu.mirrors.linux.ro/archive focal-updates/main linux-signed-hwe-5.15 5.15.0-41.44~20.04.1 (dsc) [1.949 B]Get:2 http://ubuntu.mirrors.linux.ro/archive focal-updates/main linux-signed-hwe-5.15 5.15.0-41.44~20.04.1 (tar) [20,1 kB]Fetched 22,0 kB in 0s (337 kB/s)dpkg-source: info: extracting linux-signed-hwe-5.15 in linux-signed-hwe-5.15-5.15.0dpkg-source: info: unpacking linux-signed-hwe-5.15_5.15.0-41.44~20.04.1.tar.xzapt source linux-modules-`uname -r`# huge list of source file# cd linux-[0-9]*/lslinux-hwe-5.15-5.15.0linux-hwe-5.15_5.15.0-41.44~20.04.1.diff.gzlinux-hwe-5.15_5.15.0-41.44~20.04.1.dsclinux-hwe-5.15_5.15.0.orig.tar.gzlinux-signed-hwe-5.15-5.15.0linux-signed-hwe-5.15_5.15.0-41.44~20.04.1.dsclinux-signed-hwe-5.15_5.15.0-41.44~20.04.1.tar.xztree linux-signed-hwe-5.15-5.15.0linux-signed-hwe-5.15-5.15.0├── debian│ ├── changelog│ ├── compat│ ├── control│ ├── control.stub│ ├── copyright│ ├── rules│ ├── scripts│ │ └── misc│ │ └── git-ubuntu-log│ ├── source│ │ ├── format│ │ └── options│ ├── templates│ │ ├── image.postinst.in│ │ ├── image.postrm.in│ │ ├── image.preinst.in│ │ └── image.prerm.in│ └── variants├── download-signed├── download-unsigned├── generate-depends└── update-version5 directories, 18 files# seems the other one has the sourcescd linux-hwe-5.15-5.15.0# insert a new line with vendor ID 1102 0011 for the soundchip ca0132 in the ASRock Fatal1ty Z97 Professional motherboard# most probably a Recon3Di Creative Sound Blaster, by the folder names found inside the Windows sound drivers of this motherboardcp sound/pci/hda/patch_ca0132.c ./patch_ca0132.c_from_linux-hwe-5.15-5.15.0_sourcessed -i '/SND_PCI_QUIRK(0x1458, 0xA026, "Gigabyte G1.Sniper Z97", QUIRK_R3DI),/a \\tSND_PCI_QUIRK(0x1102, 0x0011, "ASRock Fatal1ty Z97 Professional", QUIRK_R3DI),' sound/pci/hda/patch_ca0132.cdiff -c ./patch_ca0132.c_from_linux-hwe-5.15-5.15.0_sources sound/pci/hda/patch_ca0132.c*** ./patch_ca0132.c_from_linux-hwe-5.15-5.15.0_sources 2022-07-27 16:10:06.582011362 +0300--- sound/pci/hda/patch_ca0132.c 2022-07-27 16:59:02.162469113 +0300****************** 1304,1309 ****--- 1304,1310 ----SND_PCI_QUIRK(0x1102, 0x0033, "Sound Blaster ZxR", QUIRK_SBZ),SND_PCI_QUIRK(0x1458, 0xA016, "Recon3Di", QUIRK_R3DI),SND_PCI_QUIRK(0x1458, 0xA026, "Gigabyte G1.Sniper Z97", QUIRK_R3DI),+ SND_PCI_QUIRK(0x1102, 0x0011, "ASRock Fatal1ty Z97 Professional", QUIRK_R3DI),SND_PCI_QUIRK(0x1458, 0xA036, "Gigabyte GA-Z170X-Gaming 7", QUIRK_R3DI),SND_PCI_QUIRK(0x3842, 0x1038, "EVGA X99 Classified", QUIRK_R3DI),SND_PCI_QUIRK(0x1102, 0x0013, "Recon3D", QUIRK_R3D),# buildcp /boot/config-`uname -r` .configsudo apt install build-essential fakerootsudo apt build-dep linux-image-`uname -r`Reading package lists... DonePicking 'linux-signed-hwe-5.15' as source package instead of 'linux-image-5.15.0-41-generic'Reading package lists... DoneBuilding dependency treeReading state information... Done0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.sudo apt build-dep linux-modules-`uname -r`Reading package lists... DonePicking 'linux-hwe-5.15' as source package instead of 'linux-modules-5.15.0-41-generic'Reading package lists... DoneBuilding dependency treeReading state information... DoneThe following NEW packages will be installed:dvipng latexmk librsvg2-bin zstd0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.Need to get 813 kB of archives.After this operation, 2.582 kB of additional disk space will be used.Do you want to continue? [Y/n]Get:1 http://ubuntu.mirrors.linux.ro/archive focal/universe amd64 dvipng amd64 1.15-1.1 [78,9 kB]Get:2 http://ubuntu.mirrors.linux.ro/archive focal/universe amd64 latexmk all 1:4.67-0.1 [376 kB]Get:3 http://ubuntu.mirrors.linux.ro/archive focal-updates/universe amd64 librsvg2-bin amd64 2.48.9-1ubuntu0.20.04.1 [14,2 kB]Get:4 http://ubuntu.mirrors.linux.ro/archive focal-updates/universe amd64 zstd amd64 1.4.4+dfsg-3ubuntu0.1 [343 kB]Fetched 813 kB in 0s (6.164 kB/s)Requesting to save current system stateSuccessfully saved as "autozsys_wb5pqa"Selecting previously unselected package dvipng.(Reading database ... 417550 files and directories currently installed.)Preparing to unpack .../dvipng_1.15-1.1_amd64.deb ...Unpacking dvipng (1.15-1.1) ...Selecting previously unselected package latexmk.Preparing to unpack .../latexmk_1%3a4.67-0.1_all.deb ...Unpacking latexmk (1:4.67-0.1) ...Selecting previously unselected package librsvg2-bin.Preparing to unpack .../librsvg2-bin_2.48.9-1ubuntu0.20.04.1_amd64.deb ...Unpacking librsvg2-bin (2.48.9-1ubuntu0.20.04.1) ...Selecting previously unselected package zstd.Preparing to unpack .../zstd_1.4.4+dfsg-3ubuntu0.1_amd64.deb ...Unpacking zstd (1.4.4+dfsg-3ubuntu0.1) ...Setting up librsvg2-bin (2.48.9-1ubuntu0.20.04.1) ...Setting up dvipng (1.15-1.1) ...Setting up latexmk (1:4.67-0.1) ...Setting up zstd (1.4.4+dfsg-3ubuntu0.1) ...Processing triggers for install-info (6.7.0.dfsg.2-5) ...Processing triggers for man-db (2.9.1-1) ...ZSys is adding automatic system snapshot to GRUB menumake sound/pci/hda//bin/sh: 1: ./scripts/pahole-flags.sh: Permission deniedSYNC include/config/auto.conf.cmd/bin/sh: 1: ./scripts/pahole-flags.sh: Permission deniedHOSTCC scripts/basic/fixdep/bin/sh: 1: ./scripts/pahole-flags.sh: Permission deniedHOSTCC scripts/kconfig/conf.oHOSTCC scripts/kconfig/confdata.oHOSTCC scripts/kconfig/expr.oLEX scripts/kconfig/lexer.lex.cYACC scripts/kconfig/parser.tab.HOSTCC scripts/kconfig/lexer.lex.oHOSTCC scripts/kconfig/menu.oHOSTCC scripts/kconfig/parser.tab.oHOSTCC scripts/kconfig/preprocess.oHOSTCC scripts/kconfig/symbol.oHOSTCC scripts/kconfig/util.oHOSTLD scripts/kconfig/confsh: 1: ./scripts/pahole-version.sh: Permission deniedinit/Kconfig:92: syntax errorinit/Kconfig:91: invalid statementmake: *** [scripts/kconfig/Makefile:77: syncconfig] Error 1make: *** [Makefile:622: syncconfig] Error 2Makefile:712: include/config/auto.conf.cmd: No such file or directorymake: *** [Makefile:735: include/config/auto.conf.cmd] Error 2find ./scripts -type f -iname *.sh ! -executable./scripts/pahole-version.sh./scripts/spdxcheck-test.sh./scripts/pahole-flags.shfind ./scripts -type f -iname *.sh -executable./scripts/cc-version.sh./scripts/check_extable.sh./scripts/modules-check.sh./scripts/ld-version.sh./scripts/selinux/install_policy.sh./scripts/find-unused-docs.sh./scripts/cc-can-link.sh./scripts/atomic/gen-atomic-long.sh./scripts/atomic/gen-atomics.sh./scripts/atomic/check-atomics.sh./scripts/atomic/gen-atomic-instrumented.sh./scripts/atomic/atomic-tbl.sh./scripts/atomic/gen-atomic-fallback.sh./scripts/file-size.sh./scripts/checksyscalls.sh./scripts/syscalltbl.sh./scripts/kconfig/merge_config.sh./scripts/kconfig/mconf-cfg.sh./scripts/kconfig/gconf-cfg.sh./scripts/kconfig/qconf-cfg.sh./scripts/kconfig/nconf-cfg.sh./scripts/link-vmlinux.sh./scripts/xz_wrap.sh./scripts/gcc-plugins/gen-random-seed.sh./scripts/syscallhdr.sh./scripts/min-tool-version.sh./scripts/tags.sh./scripts/adjust_autoksyms.sh./scripts/gen_ksymdeps.sh./scripts/tools-support-relr.sh./scripts/syscallnr.sh./scripts/gcc-goto.sh./scripts/tracing/ftrace-bisect.sh./scripts/dtc/update-dtc-source.sh./scripts/dev-needs.sh./scripts/as-version.sh./scripts/gcc-x86_32-has-stack-protector.sh./scripts/depmod.sh./scripts/xen-hypercalls.sh./scripts/mkuboot.sh./scripts/headers_install.sh./scripts/decode_stacktrace.sh./scripts/gcc-x86_64-has-stack-protector.sh./scripts/gen_autoksyms.shPlease ignore the "ZSys is adding automatic system snapshot to GRUB menu". Ubuntu with ZFS on root autosaves a ZFS snapshot after any install/uninstall, and it has to change the Grub menus, too, since Canonical added a feature to boot from a ZFS snapshot at Grub screen, just like normal OSs are able to select, for example, a different version of kernel from the Grub screen at boot.Same for messages like this, it's the Ubuntu's "Zsys" layer, a bunch of scripts on top of normal ZFS:Requesting to save current system stateSuccessfully saved as "autozsys_blabla_ID"

author: DiTBho
author_rank: Super Contributor
timestamp: July 27, 2022, 03:43:38 pm
content: Quote from: RoGeorge on July 27, 2022, 03:03:37 pmInstall a decent Linux rootfs, e.g. Debian, Fedora, ...

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 27, 2022, 04:04:26 pm
content: Quote from: RoGeorge on July 27, 2022, 03:03:37 pmNo, andlinux-signed-*do not exist in the standard repositories. That stuff is Ubuntu/Canonical-specific.Quote from: RoGeorge on July 27, 2022, 03:03:37 pmOn 5.4.0-122-generic,scripts/spdxcheck-test.shandscripts/xen-hypercalls.share not executable, and I do believe this is normal.Quote from: RoGeorge on July 27, 2022, 03:03:37 pmUnless you belong to Canonical Kernel Team, you cannot sign that kernel, and its build machinery will fail.Even if you do succeed, the compiled modules and kernel will not be compatible with the Canonical-signed kernel you're currently running.What I would do, is switch to an unsigned kernel first, by installing an unsigned kernel, and then rebooting and in Grub, picking the new unsigned kernel.Do some testing to verify all the features you need from a kernel are available. (Might be just ZFS support, so if it boots and you can log in and your full filesystem is visible, you're go.)

author: RoGeorge
author_rank: Super Contributor
timestamp: July 27, 2022, 04:05:30 pm
content: Decided to make those 3 scripts executable and continue:Code:# decided to make them executablefind ./scripts -type f -iname *.sh ! -executable -exec chmod +x {} \+make sound/pci/hda/# went all OK, no errors and no .ko yetmake sound/pci/hda/snd-hda-codec-ca0132.koCALL scripts/checksyscalls.shCALL scripts/atomic/check-atomics.shDESCEND objtoolDESCEND bpf/resolve_btfidsLDS scripts/module.ldsWARNING: Symbol version dump "vmlinux.symvers" is missing.Modules may not have dependencies or modversions.You may get many unresolved symbol warnings.MODPOST modules-only.symversWARNING: modpost: "module_layout" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: "snd_hdac_power_up" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: "system_wq" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: "kmalloc_caches" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: "msleep" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: "snd_hda_codec_load_dsp_prepare" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: "snd_hda_multi_out_dig_prepare" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: "snd_hda_mixer_amp_volume_put" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: "snd_hdac_codec_read" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: "strlen" [sound/pci/hda/snd-hda-codec-ca0132.ko] undefined!WARNING: modpost: suppressed 76 unresolved symbol warnings because there were too many)CC  sound/pci/hda/snd-hda-codec-ca0132.mod.omake: *** No rule to make target 'vmlinux', needed by 'sound/pci/hda/snd-hda-codec-ca0132.ko'. Stop.make: *** [scripts/Makefile.modpost:140: __modpost] Error 2make: *** [Makefile:1851: single_modpost] Error 2From last night (other sources than these) I remember a README file telling to either "make pdfdocs" (which didn't work) or go visit the online docs athttps://www.kernel.org/doc/html/latest/and there I read something containing the word "symvers", which I'm not sure is the same thing in the last command error:QuoteFromhttps://www.kernel.org/doc/html/latest/kbuild/modules.htmlI'm temped to build the whole kernel, like I did last night when I was following the steps given byve7xeninReply#2, but then I'll probably fail just like yesterday.Any directions/ideas for how to get rid of the error posted in this reply, please?

author: RoGeorge
author_rank: Super Contributor
timestamp: July 27, 2022, 04:22:11 pm
content: Quote from: Nominal Animal on July 27, 2022, 04:04:26 pmThat's exactly what I was afraid the most. I'm not sure how to manually change the kernel to unsigned, I've tried a couple of days ago to install a newer kernel binaries from Canonical, and it didn't boot in my setup.Another thing is that the Ubuntu I am running now is installed on a ZFS root, and when Canonical added this feature (still experimental even today, after a couple of years already), it added some layers and some wrappers and some hooks anywhere from GRUB to systemd, and it is not documented yet.It would be much easier for me to just take another HDD and install a normal Debian, and boot and experiment there. After all, I don't even need all the bells and whistles from that ca0132 chipset, I only use it as it is now, as a stereo soundcard.Yet another thing would be that even if I make the ca0132 to work properly, I've just read that the HDA standard is only 192kSa/s and 96k rec? (don't recall the exact numbers), but anyway, the HDA standard allows less data rates and less resolution than the ca0132 hardware can do, so the only way to get 384k/24bits is probably to use the chip from Windows.Though the goal to modify the ko driver failed so far, it was a lot of interesting learning for me.

author: DiTBho
author_rank: Super Contributor
timestamp: July 27, 2022, 04:58:08 pm
content: Quote from: RoGeorge on July 27, 2022, 04:22:11 pmYou learnt how depressing and annoying Linux can go.A Linux kernel should be compiled with a simple "make", but you're reporting tons of shit involved in the process because someone at Canonical wanted to make things worse.Holy crap, the whole computer is really falling apart. I'm here with an Allwinner SBC ... and ... well it's even worse than Canonical for the same reason + they also violated the GPL so there are a lot of binary blobs.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 27, 2022, 04:58:35 pm
content: Quote from: RoGeorge on July 27, 2022, 04:22:11 pmAnother option would be to convert the signed running kernel to unsigned one. Make sure you have thepesignpackage installed.Assuming your current kernel is/boot/vmlinuz-5.15.0-41-generic, runsudo pesign -i /boot/vmlinuz-5.15.0-41-generic -o /boot/vmlinuz-5.15.0-41-unsigned -r -u 0sudo update-gruband reboot. You should now have the kernel that does not enforce signing installed as "Ubuntu, with Linux 5.15.0-41-unsigned" as a boot option.(If that boot does work, make sure youruname -rstill reports5.15.0-41-generic.If not, then you need to rename the -generic to -signed, and then -unsigned to -generic, and run update-grub again.)You also forgot to apply the twosedcommands to modify.configto disable signing, as I showed at the end ofreply #7.Here's the log after downloading the kernel sources, and changing to the kernel directory (containing MAINTAINERS, README, COPYING, CREDITS, and so on), for me:Code:$ cp /boot/config-`uname -r` .config$ sed -e 's|^\(CONFIG_MODULE_SIG[_A-Z0-9]*\)=y$|\1=n|' -e 's|^\(CONFIG_MODULE_SIG[_A-Z0-9]*\)=".*$|\1=""|' -i .config$ sed -e '/debian/ s|^\(CONFIG_SYSTEM_[A-Z]*_KEYS\)=.*$|\1=""|' -i .config$ make sound/pci/hda/snd-hda-codec-ca0132.koHOSTCC scripts/basic/fixdepHOSTCC scripts/kconfig/conf.oHOSTCC scripts/kconfig/confdata.oHOSTCC scripts/kconfig/expr.oLEX scripts/kconfig/lexer.lex.cYACC scripts/kconfig/parser.tab.HOSTCC scripts/kconfig/lexer.lex.oHOSTCC scripts/kconfig/parser.tab.oHOSTCC scripts/kconfig/preprocess.oHOSTCC scripts/kconfig/symbol.oHOSTLD scripts/kconfig/confscripts/kconfig/conf --syncconfig KconfigSYSTBL arch/x86/include/generated/asm/syscalls_32.hSYSHDR arch/x86/include/generated/asm/unistd_32_ia32.hSYSHDR arch/x86/include/generated/asm/unistd_64_x32.hSYSTBL arch/x86/include/generated/asm/syscalls_64.hHYPERCALLS arch/x86/include/generated/asm/xen-hypercalls.hSYSHDR arch/x86/include/generated/uapi/asm/unistd_32.hSYSHDR arch/x86/include/generated/uapi/asm/unistd_64.hSYSHDR arch/x86/include/generated/uapi/asm/unistd_x32.hHOSTCC arch/x86/tools/relocs_32.oHOSTCC arch/x86/tools/relocs_64.oHOSTCC arch/x86/tools/relocs_common.oHOSTLD arch/x86/tools/relocsHOSTCC scripts/genksyms/genksyms.oYACC scripts/genksyms/parse.tab.HOSTCC scripts/genksyms/parse.tab.oLEX scripts/genksyms/lex.lex.cHOSTCC scripts/genksyms/lex.lex.oHOSTLD scripts/genksyms/genksymsHOSTCC scripts/selinux/genheaders/genheadersHOSTCC scripts/selinux/mdp/mdpHOSTCC scripts/bin2cHOSTCC scripts/kallsymsHOSTCC scripts/conmakehashHOSTCC scripts/recordmcountHOSTCC scripts/sortextableHOSTCC scripts/asn1_compilerHOSTCC scripts/sign-fileHOSTCC scripts/extract-certHOSTCC scripts/insert-sys-certWRAP arch/x86/include/generated/uapi/asm/bpf_perf_event.hWRAP arch/x86/include/generated/uapi/asm/errno.hWRAP arch/x86/include/generated/uapi/asm/fcntl.hWRAP arch/x86/include/generated/uapi/asm/ioctl.hWRAP arch/x86/include/generated/uapi/asm/ioctls.hWRAP arch/x86/include/generated/uapi/asm/ipcbuf.hWRAP arch/x86/include/generated/uapi/asm/param.hWRAP arch/x86/include/generated/uapi/asm/poll.hWRAP arch/x86/include/generated/uapi/asm/resource.hWRAP arch/x86/include/generated/uapi/asm/socket.hWRAP arch/x86/include/generated/uapi/asm/sockios.hWRAP arch/x86/include/generated/uapi/asm/termbits.hWRAP arch/x86/include/generated/uapi/asm/termios.hWRAP arch/x86/include/generated/uapi/asm/types.hWRAP arch/x86/include/generated/asm/dma-contiguous.hWRAP arch/x86/include/generated/asm/early_ioremap.hWRAP arch/x86/include/generated/asm/export.hWRAP arch/x86/include/generated/asm/mcs_spinlock.hWRAP arch/x86/include/generated/asm/mm-arch-hooks.hWRAP arch/x86/include/generated/asm/mmiowb.hUPD include/config/kernel.releaseUPD include/generated/uapi/linux/version.hUPD include/generated/utsrelease.hCC scripts/mod/empty.oHOSTCC scripts/mod/mk_elfconfigMKELF scripts/mod/elfconfig.hHOSTCC scripts/mod/modpost.oCC scripts/mod/devicetable-offsets.sUPD scripts/mod/devicetable-offsets.hHOSTCC scripts/mod/file2alias.oHOSTCC scripts/mod/sumversion.oHOSTLD scripts/mod/modpostCC kernel/bounds.sUPD include/generated/bounds.hUPD include/generated/timeconst.hCC arch/x86/kernel/asm-offsets.sUPD include/generated/asm-offsets.hCALL scripts/checksyscalls.shCALL scripts/atomic/check-atomics.shDESCEND objtoolHOSTCC /home/.../linux-5.4.0/tools/objtool/fixdep.oHOSTLD /home/.../linux-5.4.0/tools/objtool/fixdep-in.oLINK /home/.../linux-5.4.0/tools/objtool/fixdepCC /home/.../linux-5.4.0/tools/objtool/exec-cmd.oCC /home/.../linux-5.4.0/tools/objtool/help.oCC /home/.../linux-5.4.0/tools/objtool/pager.oCC /home/.../linux-5.4.0/tools/objtool/parse-options.oCC /home/.../linux-5.4.0/tools/objtool/run-command.oCC /home/.../linux-5.4.0/tools/objtool/sigchain.oCC /home/.../linux-5.4.0/tools/objtool/subcmd-config.oLD /home/.../linux-5.4.0/tools/objtool/libsubcmd-in.oAR /home/.../linux-5.4.0/tools/objtool/libsubcmd.aMKDIR /home/.../linux-5.4.0/tools/objtool/arch/x86/lib/GEN /home/.../linux-5.4.0/tools/objtool/arch/x86/lib/inat-tables.cCC /home/.../linux-5.4.0/tools/objtool/arch/x86/decode.oLD /home/.../linux-5.4.0/tools/objtool/arch/x86/objtool-in.oCC /home/.../linux-5.4.0/tools/objtool/builtin-check.oCC /home/.../linux-5.4.0/tools/objtool/builtin-orc.oCC /home/.../linux-5.4.0/tools/objtool/check.oCC /home/.../linux-5.4.0/tools/objtool/orc_gen.oCC /home/.../linux-5.4.0/tools/objtool/orc_dump.oCC /home/.../linux-5.4.0/tools/objtool/elf.oCC /home/.../linux-5.4.0/tools/objtool/special.oCC /home/.../linux-5.4.0/tools/objtool/objtool.oCC /home/.../linux-5.4.0/tools/objtool/libstring.oCC /home/.../linux-5.4.0/tools/objtool/libctype.oCC /home/.../linux-5.4.0/tools/objtool/str_error_r.oLD /home/.../linux-5.4.0/tools/objtool/objtool-in.oLINK /home/.../linux-5.4.0/tools/objtool/objtoolCC  sound/pci/hda/patch_ca0132.oLD  sound/pci/hda/snd-hda-codec-ca0132.oBuilding modules, stage 2.MODPOST 1 modulesCC  sound/pci/hda/snd-hda-codec-ca0132.mod.oLD  sound/pci/hda/snd-hda-codec-ca0132.ko$ strip --strip-debug sound/pci/hda/snd-hda-codec-ca0132.kowhere...is just a path snippet to where I was doing this. Took maybe half a minute.I would definitely run the above once before applying the patch, in case the timestamp changes the patch applies confuse the kernel build machinery. This way, the kernel does the prep work (including symversions) before the patch is applied, and should do the right thing afterwards too (as the files now exist, and just need to be redone depending on the timestamps).

author: RoGeorge
author_rank: Super Contributor
timestamp: July 27, 2022, 05:21:36 pm
content: Quote from: Nominal Animal on July 27, 2022, 04:58:35 pmI have a bad feeling about this (won't boot any more), but I'll try.Posting this before trying, just to be sure.If it were to be that simple to disable the signature checking, than what would stop a malware to do the same? I've read the whole key signature circus is to prevent rootkits and alike malware. So if all I need to disable it is to be root, and no Canonical private keys, then why even bother having cryptographic keys?

author: PKTKS
author_rank: Super Contributor
timestamp: July 27, 2022, 05:25:11 pm
content: Unless you have some very good reasons to use signed stuff...Keep your life simple.Get a clean stock treeCompile it clean and all integrated...DIFFERENT VERSION from current running... (install clean)Add it to the boot list.Avoid grub messPaul

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 27, 2022, 06:27:11 pm
content: Quote from: RoGeorge on July 27, 2022, 05:21:36 pmItaddsa new boot entry. It does not modify the existing kernel, it creates a copy of it, and tells the update mechanism to add it to your grub menus. It will not be auto-booted, I think, but you should be able to deliberately select it.Quote from: RoGeorge on July 27, 2022, 05:21:36 pmThe idea is that the signature checking chain starts at the EFI BIOS. Before it runs your bootloader (Grub), it checks its signature. Then, Grub is supposed to verify the kernel signature before booting it.I don't like the model myself; I do not run signed kernels. And I'm obviously hoping here that Grub will let you choose to boot an unsigned kernel; it is just not supposed to auto-boot an unsigned kernel, or indeed the signing scheme is basically irrelevant. I consider it a MSism, and Canonical marketing, myself.My security model is such that if someone gets unfettered physical access to my computer, or a root access on it, everything on it must be considered compromised. After all, if my processes get infected with malware, they can monitor my keypresses without even gaining root access, and relay that to a remote server. Gaining root access doesn't make my data somehow "even more compromised", it just means the malware is harder to get rid of.

author: RoGeorge
author_rank: Super Contributor
timestamp: July 27, 2022, 06:34:40 pm
content: Quote from: PKTKS on July 27, 2022, 05:25:11 pmI certainly did not ask for signed modules, and I didn't know they were so until yesterday, when I tried to install a modified one. From now on I'll experiment on another clean install, and let this OS as it is for now.Quote from: Nominal Animal on July 27, 2022, 04:58:35 pmIt did reboot, but I didn't see any new grub entry to boot from, same name same version. Not sure if grub-update was successful:Code:sudo apt install pesignman pesignsudo pesign -i /boot/vmlinuz-5.15.0-41-generic -o /boot/vmlinuz-5.15.0-41-unsigned -r -u 0sudo update-grubSourcing file `/etc/default/grub'Sourcing file `/etc/default/grub.d/init-select.cfg'Generating grub configuration file ...Found linux image: vmlinuz-5.15.0-30-generic in rpool/ROOT/ubuntu_eqazcxFound initrd image: initrd.img-5.15.0-30-generic in rpool/ROOT/ubuntu_eqazcxFound linux image: vmlinuz-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcxFound initrd image: initrd.img-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcxFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_wo_AutoKey_for_F12_TimestampFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_wo_AutoKey_for_F12_TimestampFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_wo_AutoKey_for_F12_TimestampFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_wo_AutoKey_for_F12_Timestampdpkg: warning: version 'ed/vmlinuz-5.11.0-41-generic' has bad syntax: version number does not start with digitdpkg: warning: version 'ed/vmlinuz-5.11.0-27-generic' has bad syntax: version number does not start with digitFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_config-edFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_config-edFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_config-edFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_config-eddpkg: warning: version 'ed_and_clean_wine/vmlinuz-5.11.0-41-generic' has bad syntax: version number does not start with digitdpkg: warning: version 'ed_and_clean_wine/vmlinuz-5.11.0-27-generic' has bad syntax: version number does not start with digitFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_and_clean_wineFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_and_clean_wineFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_and_clean_wineFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_and_clean_winedpkg: warning: version 'ed_wine5_installs/vmlinuz-5.11.0-41-generic' has bad syntax: version number does not start with digitdpkg: warning: version 'ed_wine5_installs/vmlinuz-5.11.0-27-generic' has bad syntax: version number does not start with digitFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_wine5_installsFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_wine5_installsFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_wine5_installsFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_wine5_installsdpkg: warning: version 'designer_lxi-tools/vmlinuz-5.11.0-41-generic' has bad syntax: version number does not start with digitdpkg: warning: version 'designer_lxi-tools/vmlinuz-5.11.0-27-generic' has bad syntax: version number does not start with digitFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_added_Qt5-designer_lxi-toolsFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_added_Qt5-designer_lxi-toolsFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_added_Qt5-designer_lxi-toolsFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_added_Qt5-designer_lxi-toolsdpkg: warning: version 'Hot-Pursuit-attempt/vmlinuz-5.11.0-41-generic' has bad syntax: version number does not start with digitdpkg: warning: version 'Hot-Pursuit-attempt/vmlinuz-5.11.0-27-generic' has bad syntax: version number does not start with digitFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_tmp_before_NFS-Hot-Pursuit-attemptFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_tmp_before_NFS-Hot-Pursuit-attemptFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_tmp_before_NFS-Hot-Pursuit-attemptFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_tmp_before_NFS-Hot-Pursuit-attemptFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_with_gamesFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_with_gamesFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_with_gamesFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_with_gamesFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_jc7jseFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_jc7jse......Found initrd image: initrd.img-5.15.0-30-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_8br34kFound linux image: vmlinuz-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_8br34kFound initrd image: initrd.img-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_8br34kFound linux image: vmlinuz-5.15.0-41-unsigned in rpool/ROOT/ubuntu_ifipuuWarning: Couldn't find any valid initrd for dataset rpool/ROOT/ubuntu_ifipuu.Found linux image: vmlinuz-5.15.0-41-generic in rpool/ROOT/ubuntu_ifipuuFound initrd image: initrd.img-5.15.0-41-generic in rpool/ROOT/ubuntu_ifipuuFound linux image: vmlinuz-5.13.0-52-generic in rpool/ROOT/ubuntu_ifipuuFound initrd image: initrd.img-5.13.0-52-generic in rpool/ROOT/ubuntu_ifipuucannot open 'bpool/BOOT/default': dataset does not existWarning: didn't find any valid initrd or kernel.device-mapper: reload ioctl on osprober-linux-sda4 failed: Device or resource busyCommand failed.Adding boot menu entry for UEFI Firmware SettingsdoneNear the end it sais "Command failed."I do see a "/boot/vmlinuz-5.15.0-41-unsigned" file near the "/boot/System.map-5.15.0-41-generic" file, but there was no "unsigned" word anywhere in the grub menus. I guess it booted the same signed kernel, uname is "5.15.0-41-generic".By the cat /proc/cmdline at the end, it seems that it's running the old signed one:Code:sudo pesign -S -i /boot/vmlinuz-5.15.0-41-generic---------------------------------------------certificate address is 0x7f6003a3f368Content was not encrypted.Content is detached; signature cannot be verified.The signer's common name is Canonical Ltd. Secure Boot Signing (2017)No signer email address.Signing time: Wed Jun 29, 2022There were certs or crls included.---------------------------------------------sudo pesign -S -i /boot/vmlinuz-5.15.0-41-unsignedNo signatures found.cat /proc/cmdlineBOOT_IMAGE=/BOOT/ubuntu_ifipuu@/vmlinuz-5.15.0-41-generic root=ZFS=rpool/ROOT/ubuntu_ifipuu ro quiet splash vt.handoff=1

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 27, 2022, 07:50:18 pm
content: Quote from: RoGeorge on July 27, 2022, 06:34:40 pmWhat a wart, when a plainsudo update-grubreports errors...If I were you, I'd test Mint, as a direct replacement for that Ubuntu installation.(If you want snapshots et cetera but a mainline FS, you could use LVM2 (for snapshotting), and on top of it, an ext4 (leaving a gigabyte or so for overprovisioning and snapshot divergence from current).)Quote from: RoGeorge on July 27, 2022, 06:34:40 pmAh, yours wants a matching initrd as well. Copying initrd.img-5.15.0-41-generic to initrd.img-5.15.0-41-unsigned in rpool/ROOT/ubuntu/ifipuu, and then rerunningsudo update-grub, should make the boot option show up.You might also consider removing some of your old kernel images, as you seem to have tons and tons of them.Note that you should be able to boot the modified kernel using kernel command lineCode:BOOT_IMAGE=/BOOT/ubuntu_ifipuu@/vmlinuz-5.15.0-41-unsigned root=ZFS=rpool/ROOT/ubuntu_ifipuu ro quiet splash vt.handoff=1in Grub.

author: RoGeorge
author_rank: Super Contributor
timestamp: July 27, 2022, 09:55:45 pm
content: Quote from: Nominal Animal on July 27, 2022, 07:50:18 pmI didn't meant to not try to finish this exercise, that thought was a way of agreeing with PKTKS about leaving Ubuntu for good at the next install, I would probably not upgrade it from 20.04 LTS to 22.04 LTS, but rather move to something like Devuan, or maybe move to FreeBSD entirely, the most unclutter OS I've seen so far.Back to the unsigned image, "rpool/ROOT/ubuntu_ifipuu" is a ZFS dataset, ROOT a ZFS volume, and the ones like "rpool/ROOT/ubuntu_ifipuu@a_snapshot_name" are ZFS snapshots, and rpool is the ZFS pool (I might be mixing the ZFS terminology).While in a normal ZFS one can handle these manually, Ubuntu added another layer, Zsys, that automates snapshots and restores, and adds a more commands on top of standard ZFS, and integrated Zsys with ZFS, systemd and GRUB. Also, Zsys added a few more proprietary concepts apart from the ZFS ones.Zsys does automated snaphots from time to time, or when it detects am OS change, like e.g. an install. I don't know how often Zsys interferes, or how to disable it. Zsys is made by Canonical, it is still experimental and undocumented. I do not want to manually handle the ZFS in Ubuntu with Zsys.Anyway the only place where I can see "vmlinuz-5.15.0-41-unsigned" (or the -original) is "/boot" (without manually handling datasets or snapshots) so just to be sure, I did a copy for any other "generic" as "unsigned", like this:Code:sudo cp /boot/initrd.img-5.15.0-41-generic /boot/initrd.img-5.15.0-41-unsignedsudo cp /boot/System.map-5.15.0-41-generic /boot/System.map-5.15.0-41-unsignedsudo cp /boot/config-5.15.0-41-generic /boot/config-5.15.0-41-unsignedls -l /boot/*5.15.0-41*-rw-r--r-- 1 root root 262026 Jun 24 16:04 /boot/config-5.15.0-41-generic-rw-r--r-- 1 root root 262026 Jul 27 23:46 /boot/config-5.15.0-41-unsigned-rw-r--r-- 1 root root 170835870 Jul 13 22:37 /boot/initrd.img-5.15.0-41-generic-rw-r--r-- 1 root root 170835870 Jul 27 23:43 /boot/initrd.img-5.15.0-41-unsigned-rw------- 1 root root 6218651 Jun 24 16:04 /boot/System.map-5.15.0-41-generic-rw------- 1 root root 6218651 Jul 27 23:44 /boot/System.map-5.15.0-41-unsigned-rw------- 1 root root 11000544 Jun 24 14:37 /boot/vmlinuz-5.15.0-41-generic-rw------- 1 root root 10998624 Jul 27 20:22 /boot/vmlinuz-5.15.0-41-unsignedCode:sudo update-grubSourcing file `/etc/default/grub'Sourcing file `/etc/default/grub.d/init-select.cfg'Generating grub configuration file ...Found linux image: vmlinuz-5.15.0-30-generic in rpool/ROOT/ubuntu_eqazcxFound initrd image: initrd.img-5.15.0-30-generic in rpool/ROOT/ubuntu_eqazcxFound linux image: vmlinuz-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcxFound initrd image: initrd.img-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcxFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_wo_AutoKey_for_F12_TimestampFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_wo_AutoKey_for_F12_TimestampFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_wo_AutoKey_for_F12_TimestampFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_wo_AutoKey_for_F12_Timestampdpkg: warning: version 'ed/vmlinuz-5.11.0-41-generic' has bad syntax: version number does not start with digitdpkg: warning: version 'ed/vmlinuz-5.11.0-27-generic' has bad syntax: version number does not start with digitFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_config-edFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_config-edFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_config-edFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@full_OS_config-eddpkg: warning: version 'ed_and_clean_wine/vmlinuz-5.11.0-41-generic' has bad syntax: version number does not start with digitdpkg: warning: version 'ed_and_clean_wine/vmlinuz-5.11.0-27-generic' has bad syntax: version number does not start with digitFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_and_clean_wineFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_and_clean_wineFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_and_clean_wineFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_and_clean_winedpkg: warning: version 'ed_wine5_installs/vmlinuz-5.11.0-41-generic' has bad syntax: version number does not start with digitdpkg: warning: version 'ed_wine5_installs/vmlinuz-5.11.0-27-generic' has bad syntax: version number does not start with digitFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_wine5_installsFound initrd image: initrd.img-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_wine5_installsFound linux image: vmlinuz-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_wine5_installsFound initrd image: initrd.img-5.11.0-27-generic in rpool/ROOT/ubuntu_eqazcx@OS_config-ed_wine5_installsdpkg: warning: version 'designer_lxi-tools/vmlinuz-5.11.0-41-generic' has bad syntax: version number does not start with digitdpkg: warning: version 'designer_lxi-tools/vmlinuz-5.11.0-27-generic' has bad syntax: version number does not start with digitFound linux image: vmlinuz-5.11.0-41-generic in rpool/ROOT/ubuntu_eqazcx@OS_added_Qt5-designer_lxi-tools......Found linux image: vmlinuz-5.15.0-30-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_wb5pqaFound initrd image: initrd.img-5.15.0-30-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_wb5pqaFound linux image: vmlinuz-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_wb5pqaFound initrd image: initrd.img-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_wb5pqaFound linux image: vmlinuz-5.15.0-30-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_8br34kFound initrd image: initrd.img-5.15.0-30-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_8br34kFound linux image: vmlinuz-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_8br34kFound initrd image: initrd.img-5.13.0-41-generic in rpool/ROOT/ubuntu_eqazcx@autozsys_8br34kFound linux image: vmlinuz-5.15.0-41-unsigned in rpool/ROOT/ubuntu_ifipuuFound initrd image: initrd.img-5.15.0-41-unsigned in rpool/ROOT/ubuntu_ifipuuFound linux image: vmlinuz-5.15.0-41-generic in rpool/ROOT/ubuntu_ifipuuFound initrd image: initrd.img-5.15.0-41-generic in rpool/ROOT/ubuntu_ifipuuFound linux image: vmlinuz-5.13.0-52-generic in rpool/ROOT/ubuntu_ifipuuFound initrd image: initrd.img-5.13.0-52-generic in rpool/ROOT/ubuntu_ifipuucannot open 'bpool/BOOT/default': dataset does not existWarning: didn't find any valid initrd or kernel.device-mapper: reload ioctl on osprober-linux-sda4 failed: Device or resource busyCommand failed.Adding boot menu entry for UEFI Firmware SettingsdonerebootAnd it worked, it worked!Code:cat /proc/cmdlineBOOT_IMAGE=/BOOT/ubuntu_ifipuu@/vmlinuz-5.15.0-41-unsigned root=ZFS=rpool/ROOT/ubuntu_ifipuu ro quiet splashuname -r5.15.0-41-genericThank you!

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 28, 2022, 07:30:52 am
content: Quote from: RoGeorge on July 27, 2022, 09:55:45 pmOh, no worries either way. By a wart, I was definitely referring to Ubuntu 20.04 LTS. I do not like the direction Canonical is taking it, what with the signing and 'snap' packaging.I much prefer Debian/Devuan. The reason I'm running Mint on this laptop has to do with helping other people, and is not "optimal"; I'm just more lax about these things than say PKTKS.Quote from: RoGeorge on July 27, 2022, 09:55:45 pmYup, that's exactly it.Quote from: RoGeorge on July 27, 2022, 09:55:45 pmWell, it is supposed to. You added a new kernel (albeit the same as an old one, just unsigned), its symbol map and configuration, and most importantly, its initial ramdisk, and then used theupdate-grubhelper to regenerate the grub boot menu for all existing kernels. If you take a look, you'll find/boot/grub/grub.cfg(and/boot/grub/grubenv) got updated. Instead of editing it directly, we use/etc/grub.d/,/etc/default/grub,/etc/default/grub.d/and so on and letupdate-grubpiece a working one together for us.I knew that ZFS stuff adds some wonky stuff to the config, but not exactly what; I haven't used ZFS at all.

author: RoGeorge
author_rank: Super Contributor
timestamp: July 29, 2022, 11:00:46 am
content: Meanwhile, found there is also an unsigned package for the linux kernel:Code:apt list *-5.15.0-41-*Listing... Donelinux-buildinfo-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1 amd64linux-cloud-tools-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1 amd64linux-headers-5.15.0-41-generic/focal-updates,focal-security,now 5.15.0-41.44~20.04.1 amd64 linux-image-5.15.0-41-generic/focal-updates,focal-security,now 5.15.0-41.44~20.04.1 amd64 [installed,automatic]linux-image-unsigned-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1 amd64linux-modules-5.15.0-41-generic/focal-updates,focal-security,now 5.15.0-41.44~20.04.1 amd64 [installed,automatic]linux-modules-extra-5.15.0-41-generic/focal-updates,focal-security,now 5.15.0-41.44~20.04.1 amd64 [installed,automatic]linux-modules-iwlwifi-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1 amd64linux-modules-nvidia-418-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-modules-nvidia-450-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-modules-nvidia-470-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-modules-nvidia-470-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-modules-nvidia-510-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-modules-nvidia-510-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-modules-nvidia-515-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-modules-nvidia-515-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-objects-nvidia-418-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-objects-nvidia-450-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-objects-nvidia-470-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-objects-nvidia-470-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-objects-nvidia-510-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-objects-nvidia-510-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-objects-nvidia-515-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-objects-nvidia-515-server-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-signatures-nvidia-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1+1 amd64linux-tools-5.15.0-41-generic/focal-updates,focal-security 5.15.0-41.44~20.04.1 amd64and "apt source linux-image-unsigned-5.15.0-41-generic" will select by itself "linux-hwe-5.15-5.15.0" instead of "linux-image-unsigned-5.15.0-41-generic". Same thing, a whole kernel build was needed to generate the "Module.symvers" file, without which, modules alone won't compile.I still don't know who keeps busy the .ko I want to remove in order to replace it with the newly compiled, but anyway, the Quirk I was trying to add it's not needed.Seems like only a few CA0132 sound card need those QUIRK customisations, most other CA0132 based cards (CA0132 is in fact a CODEC, the generic name for the chipset is Creative Sound Core3D, and includes the Creative hardware DSP cores (has 4 DSP cores, with an architecture descendants from the emu10k and emu10k2 - aka Creative SB Live and Audigy - Creative bought EMU, the ones that designed the first emu10k chips) and an 8051 core that handles the audio CODEC, the DSP engines and the rest of the hardware found inside of that Creative Sound Core3D chipset).Found some very helpful notes about HDAhttps://android.googlesource.com/kernel/msm.git/+/android-msm-bullhead-3.10-n-preview-1/Documentation/sound/alsa/HD-Audio.txtfrom which I realized I could change the Vendor ID of my soundcard live, if it were to check for the already existing QUIRK definitions in the unmodified CA0132 driver.There is a file tree with most of the properties I was wanting to change, for example (for Card 1 Device 0):/sys/class/sound/hwC1D0/ there is a writable file named "/sys/class/sound/hwC1D0/vendor_id" with the current text "0x11020011", and another write only file called "reconfigure". To activate the QUIRK r3di specific to some "Recon3Di" cards defined insideTo change the vendor ID to make active quirks like these from the driver:Code:diff -c ./patch_ca0132.c sound/pci/hda/patch_ca0132.c*** ./patch_ca0132.c--- sound/pci/hda/patch_ca0132.c 2022-07-27 16:59:02.162469113 +0300****************** 1304,1309 ****--- 1304,1310 ----SND_PCI_QUIRK(0x1102, 0x0033, "Sound Blaster ZxR", QUIRK_SBZ),SND_PCI_QUIRK(0x1458, 0xA016, "Recon3Di", QUIRK_R3DI),SND_PCI_QUIRK(0x1458, 0xA026, "Gigabyte G1.Sniper Z97", QUIRK_R3DI),+ SND_PCI_QUIRK(0x1102, 0x0011, "ASRock Fatal1ty Z97 Professional", QUIRK_R3DI),SND_PCI_QUIRK(0x1458, 0xA036, "Gigabyte GA-Z170X-Gaming 7", QUIRK_R3DI),SND_PCI_QUIRK(0x3842, 0x1038, "EVGA X99 Classified", QUIRK_R3DI),SND_PCI_QUIRK(0x1102, 0x0013, "Recon3D", QUIRK_R3D),it is enough to rewrite the content of the "/sys/class/sound/hwC1D0/vendor_id" file, then trigger a reconfigure, like this:Code:# temporary stop PulseAudio, or else triggering a reconfigure will I/O error as busysystemctl --user stop pulseaudio.{socket,service}# pretend the current onboard soundcard in "ASRock Fatal1ty Z97 Professional" motherbords,# with vendor ID 0x11020011 would be a 0x1458A026, "Gigabyte G1.Sniper Z97", r3dicat /sys/class/sound/hwC1D0/vendor_id# 0x11020011 <-- this vendor ID is for "ASRock Fatal1ty Z97 Professional" motherbordssudo sh': sudo sh -c "echo 0x1458A026 > /sys/class/sound/hwC1D0/vendor_id"sudo sh': sudo sh -c "echo 1 > /sys/class/sound/hwC1D0/reconfig"systemctl --user start pulseaudio.{socket,service}Either with module recompile or with live vendor ID faking, none of the existing quirks worked for my card.However, if I let the vendor ID unchanged, and only trigger a reconfigure without changing any settings at all, the "Line-in" appears as an option in any PulseAudio related GUI. Without manually triggering a reconfigure, there is only "Microphone" and no option to change to "Line-in", as seen in the pics, and it does the same even when booting from a live Ubuntu pendrive.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 29, 2022, 01:57:03 pm
content: Are you aware ofgithub.com/Conmanx360/ca0132-tools(Connor McAdams)?I am more and more convinced that you'd be better off tearing apart a suitable USB audio capture device, or use an USB microcontroller with a suitable ADC input and analog frontend...

author: RoGeorge
author_rank: Super Contributor
timestamp: July 29, 2022, 04:59:28 pm
content: Yes, forgot to mention that resource, thank you for posting it.From yesterday's checks, it looks like all his findings are already upstream in the patch_ca0132.c file. I've diff-ed against the latest kernel from Linus' github repo and nothing has changed in years. Found the tools, too. Those are gold in case I've ever want to sniff the messages between the Windows driver and the Windows OS, but I don't think I'll go there.I don't need to change anything to my soundcard for its daily use, and if it were to really want to record in 24 bits then I'll just install Windows and use the proprietary Creative drivers for Windows.Though recording in 24 bits for this soundcard would be kind of futile, because the card is too noisy, especially at high sampling rates. This is the typical noise floor (the picture is from another topic, please consider only the noise floor and ignore the signal):All this dive into the Linux sound was mostly for learning. So far it was very interesting for me, I've learn about PulseAudio/Jack/PipeWire + ALSA/OSS + Intel HDA + Linux modules/drivers + recompile own changes and/or add custom kernels to GRUB + many other thing.As a matter of fact, it happens that only seconds ago I was playing with an algorithm specific to emu10k family of DSP's, from the exact github repo you just mentioned.The algorithm is bamboozling looking at the C code implementation. It computes logarithms or exponentials.It is suppose to be DSP stile, which in hardware is usually implement with a hardware multiplier and an accumulator, so I'm trying to figure out the hardware that would correspond to the algorithm, or at least a block representation with Z-1steps, like in filters.I compiled the C emulation (since it happened that I'm in FreeBSD now, there is no <linux/types.h> so I've blindly used #include <infiniband/types.h>, not sure if this ruins it, I hope not, but at least it compiles).Made a script to run it for a range of inputs, then pasted the data in a spreadsheet to make a chart. Well, the shape does look like either as an exponential decay or as a logarithmic increase (looks exactly like the response of an RC circuit, if it were to think in terms passive resistors/capacitors filters).If anybody curious for a code puzzle, this is the C code for it:Code:/** This file was taken from the emu10k1 archives. I've cleaned up the code a* bit and fixed some of the bugs, but other than that it's unchanged.*//* By: Daniel BertrandDate: Nov 6th, 2000Description: A software implementation of creatives LOG and EXP instructionsfound in the emu10k1 processor. (Patent: WO 9901814 (A1))I'm not sure if this is even legal, being a software implementation of a patented hardware instruction,so I'm releasing it into the public domain (no license, no copyright).Compiling:exp:gcc explog.c -o expusage:./exp <log_data> <max_exponent_size> <Sign_control>log:gcc explog.c -DLOG -o logusage:./log <lin_data> <max_exponent_size> <Sign_control>--log converts linear to logarithmicexp converts logarithmic to linearLogarithmic representation:| 31 |30 29-25|28-24 0||sign| exponent | Mantissa |exponent size varies between 2 and 5 bits,<max_exp_size> is specified in actual value, thus 3 bits is <max_exp_size>=7max_exp_size can be anyvalue between 2 and 31.*/#include <stdio.h>#include <stdlib.h>/*#include <linux/types.h>search for existing replacements:find /usr/include -iname types.h/usr/include/rpc/types.h/usr/include/sys/types.h/usr/include/infiniband/types.h*/#include <infiniband/types.h>__u32 log1(__u32 lin_data,__u32 max_exp,__u32 sign_ctrl){int exp = (int)max_exp + 1;__u32 result;__u8 sign;//FIX ME: mask inputs (i think this is what it does, haven't checked it yet):sign_ctrl &= 0x03;max_exp &= 0x1f;sign = (lin_data >> 31) & 0x01;/* Smallest exponent value is 2, if we're below that, default to 2. */if (max_exp < 2)max_exp = 2;/* If the value is negative, one's complement the bits. */if (sign)lin_data= ~lin_data;/** Continue to shift left until we either:* - End up with the exponent being 0.* - Or end up with the MSB set.*/while (!(lin_data & 0x80000000)) {lin_data <<= 1;exp--;if (!exp)break;}/** If the exponent is not 0, shift left by 1 to get rid of the* implicit bit.*/if (exp)lin_data <<= 1;if (max_exp & 0x10)result = (exp << 26) | (lin_data >> 6);else if (max_exp & 0x8)result = (exp << 27) | (lin_data >> 5);else if (max_exp & 0x4)result = (exp << 28) | (lin_data >> 4);elseresult = (exp << 29) | (lin_data >> 3);printf("Exponent %d, mantissa 0x%08x, result 0x%08x.\n", exp, ((lin_data >> 1) + 0x80000000) >> 6, result);/*Sign control------------the result is complemented depending on the following conditions|----------------|----------|---------|| Sign Control | sign=0 | sign=1 ||----------------|----------|---------|| 00 | R | ~R ||----------------|----------|---------|| 01 | R | R ||----------------|----------|---------|| 10 | ~R | ~R ||----------------|----------|---------|| 11 | ~R | R ||----------------|----------|---------|*/switch( sign_ctrl){case 0:if (sign)result = ~result;break;case 2:result = ~result;break;case 3:if (!sign)result= ~result;break;default:break;}return result;}__u32 exp1(__u32 log_data,__u32 max_exp,__u32 sign_ctrl){int exp = (int)max_exp + 1;__u32 result;__u8 sign;sign_ctrl &= 0x03;max_exp &= 0x1f;sign = (log_data >> 31) & 0x01;/* Smallest exponent value is 2, if we're below that, default to 2. */if (max_exp < 2)max_exp = 2;/* If the value is negative, one's complement the bits. */if (sign)log_data = ~log_data;//seperate mantissa and exponentif (max_exp & 0x10) {exp = log_data >> 26;log_data <<= 6;} else if (max_exp & 0x8) {exp = log_data >> 27;log_data <<= 5;} else if (max_exp & 0x4) {exp = log_data >> 28;log_data <<= 4;} else {exp = log_data >> 29;log_data <<= 3;}//put back the implicit 1if (exp) {log_data >>= 1;log_data |= 0x80000000;exp--;}//shift mantissa back downresult = log_data >> (max_exp - exp);//handle signswitch( sign_ctrl){case 0:if(sign!=0)result= ~result;return result;case 1:return result;case 2:return ~result;case 3:if(sign==0)result= ~result;return result;}}int main (int argc, char *argv[]){if(argc!=4){printf("usage: log <lin_value> <max exponent size> <sign control>");return -1;}#ifdef LOGprintf("0x%08x\n",log1(strtoul(argv,NULL,16),strtoul(argv,NULL,16),strtoul(argv,NULL,16) ));#elseprintf("0x%08x\n",exp1(strtoul(argv,NULL,16),strtoul(argv,NULL,16),strtoul(argv,NULL,16) ));#endifreturn 0;}Source:https://github.com/Conmanx360/ca0132-tools/tree/master/documentationCompiled it with "gcc emu10k1-explog.c -o explog", and when executed like this:Code:#!/usr/bin/env bash#!/bin/bashfor i in {0..50}do./explog 10 $i 1doneand it produces something like this:Guess I should probably browse the other input parameter.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 29, 2022, 05:49:33 pm
content: Quote from: RoGeorge on July 29, 2022, 04:59:28 pmUse<stdint.h>(or<inttypes.h>), and replace__uNwithuintN_t.What's the puzzle? It's just emulating an instruction Creative used in its emu10k1 DSP. I used to have a Creative Sound Blaster Live! with emu10k1 in it.Quote from: RoGeorge on July 29, 2022, 04:59:28 pmSee the,16? That means the inputs are inhexadecimal. (0 is autodetect from prefix – 0x=hex, 0=octal, default decimal.)

author: RoGeorge
author_rank: Super Contributor
timestamp: July 29, 2022, 06:04:55 pm
content: Quote from: Nominal Animal on July 29, 2022, 05:49:33 pmTo me it was not clear how it calculates. I need to look more carefully and scribble on a piece of paper. In fact, I never had to solve such problems, and I'm not familiar with the most known ways to compute log or exp with integers and in hardware (meaning no complex algorithms or long recursive loops).Even so, since the idea was patented (couldn't find the patent number mention in the C comment) I guess it should contain something different that the usual ways of getting exp/log with integers.

author: RoGeorge
author_rank: Super Contributor
timestamp: July 29, 2022, 06:38:07 pm
content: Doh, is that really calculates enand loge(n), or is it just shifting bits to get 2nor log2(n)? If it's the second, then what's in it to patent, I don't get it.

author: Nominal Animal
author_rank: Super Contributor
timestamp: July 29, 2022, 10:39:05 pm
content: LOG converts to a customizable floating point format, and EXP back from it. SeeLOGatemu10k1 sourceforge project.